コード例 #1
0
ファイル: NotInOperator.cs プロジェクト: Vadi/sones
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var result = myIndex.Contains(lookup, currentType, dbContext);
            if (result.Value)
            {
                var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);

                foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        if (!interestingUUIDs.Contains(aUUID))
                        {
                            yield return aUUID;
                        }
                    }
                }
            }
            else
            {
                foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
コード例 #2
0
ファイル: TypeAttribute.cs プロジェクト: TheByte/sones
 public TypeAttribute(AttributeUUID myAttributeUUID)
 {
     UUID                    = myAttributeUUID;
     RelatedGraphDBTypeUUID  = null;
     TypeCharacteristics     = new TypeCharacteristics();
     _Settings               = new Dictionary<String, ADBSettingsBase>();
 }
コード例 #3
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
 /// <summary>
 /// Adds a single ADBBaseObject to the IndexKex
 /// </summary>
 /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
 /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
 /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
 public IndexKey(AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
 {
     if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
     {
         throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
     }
     else
     {
         AddAAKey(myAttributeUUID, myIndexKeyPayload);
     }
 }
コード例 #4
0
ファイル: EqualsOperator.cs プロジェクト: TheByte/sones
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            var myIndeyKey = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            if (myIndex.Contains(myIndeyKey, currentType, dbContext))
            {
                foreach (var aUUID in myIndex.GetValues(myIndeyKey, currentType, dbContext))
                {
                    yield return aUUID;
                }
            }

            yield break;
        }
コード例 #5
0
ファイル: ABinaryCompareOperator.cs プロジェクト: Vadi/sones
        public virtual IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            foreach (var keyValPair in myIndex.GetKeyValues(dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID), dbContext))
            {
                var res = Compare(keyValPair.Key.IndexKeyValues[0], myOperationValue);

                if (res.Failed())
                {
                    throw new GraphDBException(res.PushIError(new Error_InvalidIndexOperation(myIndex.IndexName, keyValPair.Key.IndexKeyValues[0].Value, myOperationValue.Value)).IErrors);
                }

                if (res.Value)
                {
                    foreach (var aUUID in keyValPair.Value)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
コード例 #6
0
ファイル: DBSessionSettings.cs プロジェクト: TheByte/sones
 /// <summary>
 /// Returns a setting that was set for an attribute. If there isn't a direct hit the type, session and db are checked.
 /// </summary>
 /// <param name="settingName">The name of the setting</param>
 /// <param name="typeUUID">The name of the type</param>
 /// <param name="attributeUUID">The attribute name</param>
 /// <returns>A setting.</returns>
 public ADBSettingsBase GetAttributeSetting(string settingName, TypeUUID typeUUID, AttributeUUID attributeUUID)
 {
     if (_SessionSettingsTypeAttribute.ContainsKey(typeUUID))
     {
         if (_SessionSettingsTypeAttribute[typeUUID].ContainsKey(attributeUUID))
         {
             if (_SessionSettingsTypeAttribute[typeUUID][attributeUUID].ContainsKey(settingName))
             {
                 return _SessionSettingsTypeAttribute[typeUUID][attributeUUID][settingName];
             }
             else
             {
                 return GetTypeSetting(settingName, typeUUID);
             }
         }
         else
         {
             return GetTypeSetting(settingName, typeUUID);
         }
     }
     else
     {
         return GetTypeSetting(settingName, typeUUID);
     }
 }
コード例 #7
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
 /// <summary>
 /// return the attribute which relates to type and not his superclass
 /// </summary>
 /// <param name="myAttributeUUID">uuid of the attribute</param>
 /// <returns></returns>
 public TypeAttribute GetTypeSpecificAttributeByUUID(AttributeUUID myAttributeUUID)
 {
     return _Attributes.FirstOrDefault(item => item.Value.UUID == myAttributeUUID).Value;
 }
コード例 #8
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
        /// <summary>
        /// Instantiates a new IndexKey on the base of another one. Additionally a AADBBaseObject is added.
        /// </summary>
        /// <param name="myStartingIndexKey">The base of the new IndexKey</param>
        /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
        /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
        /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
        public IndexKey(IndexKey myStartingIndexKey, AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
        {
            _hashCode = myStartingIndexKey.GetHashCode();

            _indexKeyValues.AddRange(myStartingIndexKey.IndexKeyValues);

            if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
            {
                throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
            }
            else
            {
                AddAAKey(myAttributeUUID, myIndexKeyPayload);
            }
        }
コード例 #9
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
 public Boolean HasAttributeIndices(AttributeUUID myAttributeUUID)
 {
     return _AttributeIndices.ContainsKey(new IndexKeyDefinition(new List<AttributeUUID>() { myAttributeUUID }));
 }
コード例 #10
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
 public void RemoveAttributeFromLookupTable(AttributeUUID attributeUUID)
 {
     _TypeAttributeLookupTable.Remove(attributeUUID);
 }
コード例 #11
0
        /// <summary>
        /// Removes index entries corresponding to a DBObject
        /// </summary>
        /// <param name="dBObjectStream"></param>
        /// <param name="attributeUUID"></param>
        /// <param name="myDBContext"></param>
        /// <returns></returns>
        private Exceptional RemoveDBObjectFromIndex(DBObjectStream dBObjectStream, AttributeUUID attributeUUID, DBContext myDBContext)
        {
            foreach (var aType in myDBContext.DBTypeManager.GetAllParentTypes(myDBContext.DBTypeManager.GetTypeByUUID(dBObjectStream.TypeUUID), true, false))
            {
                foreach (var aAttributeIdx in aType.GetAttributeIndices(attributeUUID))
                {
                    var result = aAttributeIdx.Remove(dBObjectStream, aType, myDBContext);

                    if (result.Failed())
                    {
                        return new Exceptional(result);
                    }
                }
            }

            return new Exceptional();
        }
コード例 #12
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        public Exceptional CreateUUIDIndex(DBContext myDBContext, AttributeUUID myUUID)
        {
            var _NewUUIDIndex = new UUIDIndex(SpecialTypeAttribute_UUID.AttributeName, new IndexKeyDefinition(myUUID), this, ObjectDirectoryShards);

            return new Exceptional(AddAttributeIndex(_NewUUIDIndex, myDBContext));
        }
コード例 #13
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            if (mySerializationReader != null)
            {
                try
                {
                    _UUID = new TypeUUID(this.ObjectUUID.GetByteArray());
                    ParentTypeUUID = new TypeUUID();
                    ParentTypeUUID.Deserialize(ref mySerializationReader);
                    _IsUserDefined = mySerializationReader.ReadBoolean();
                    _IsAbstract = mySerializationReader.ReadBoolean();
                    _Comment = mySerializationReader.ReadString();

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Attributes = new Dictionary<AttributeUUID, TypeAttribute>();

                    _TypeAttributeLookupTable = new Dictionary<AttributeUUID, TypeAttribute>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        var _AttrAtrib = new AttributeUUID();
                        _AttrAtrib.Deserialize(ref mySerializationReader);
                        var _TypeObj = new TypeAttribute();
                        _TypeObj.Deserialize(ref mySerializationReader);
                        _Attributes.Add(_AttrAtrib, _TypeObj);
                        _TypeAttributeLookupTable.Add(_AttrAtrib, _TypeObj);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _TypeSettings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {
                        ADBSettingsBase _ADBSettingsBase = (ADBSettingsBase) mySerializationReader.ReadObject();
                        if(_ADBSettingsBase != null)
                            _TypeSettings.Add(_ADBSettingsBase.Name, _ADBSettingsBase);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _UniqueAttributes = new List<AttributeUUID>();
                    AttributeUUID AttribID = null;

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _UniqueAttributes.Add(AttribID);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _MandatoryAttributes = new HashSet<AttributeUUID>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _MandatoryAttributes.Add(AttribID);
                    }

                    ObjectDirectoryShards = mySerializationReader.ReadUInt16();

                    #region Indices

                    _AttributeIndices = new Dictionary<IndexKeyDefinition, Dictionary<String, AAttributeIndex>>();
                    _AttributeIndicesNameLookup = new Dictionary<String, IndexKeyDefinition>();

                    var idxCount = mySerializationReader.ReadUInt32();
                    for (var i = 0; i < idxCount; i++)
                    {

                        var idxKey = new IndexKeyDefinition();
                        idxKey.Deserialize(ref mySerializationReader);

                        //_AttributeIndices.Add(idxKey, new Dictionary<String, AttributeIndex>());

                        var idxVersionCount = mySerializationReader.ReadUInt32();

                        for (var j = 0; j < idxVersionCount; j++)
                        {

                            var key                 = mySerializationReader.ReadString();
                            var fileSystemLocation  = new ObjectLocation(mySerializationReader.ReadString());
                            var indexEdition        = mySerializationReader.ReadString();
                            var indexName           = mySerializationReader.ReadString();
                            var indexType           = mySerializationReader.ReadString();
                            var isUUIDIdx           = mySerializationReader.ReadBoolean();
                            var keyCount            = mySerializationReader.ReadUInt64();
                            var valueCount          = mySerializationReader.ReadUInt64();
                            var attributeIdxShards = mySerializationReader.ReadUInt16();

                            //var CreateIdxExcept = CreateAttributeIndex(indexName, idxKey.IndexKeyAttributeUUIDs, indexEdition, indexObjectType, fileSystemLocation);

                            if (isUUIDIdx)
                            {
                                AddAttributeIndex(new UUIDIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount));
                            }
                            else
                            {
                                AddAttributeIndex(new AttributeIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount, valueCount));
                            }

                            //if (CreateIdxExcept.Failed())
                            //    throw new GraphDBException(CreateIdxExcept.Errors);
                        }

                    }

                    #endregion

                }

                catch (Exception e)
                {
                    throw new SerializationException("The GraphDBType could not be deserialized!\n\n" + e);
                }

            }
        }
コード例 #14
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        /// <summary>
        /// add an mandatory attribute to type
        /// </summary>
        /// <param name="myAttrib"></param>        
        public void AddMandatoryAttribute(AttributeUUID myAttribID, DBTypeManager myTypeManager)
        {
            List<GraphDBType> SubTypes = myTypeManager.GetAllSubtypes(this, false);

            foreach (var Types in SubTypes)
            {
                Types.AddMandatoryAttribute(myAttribID, myTypeManager);
            }

            _MandatoryAttributes.Add(myAttribID);
        }
コード例 #15
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
 /// <summary>
 /// Creates an index for the given myAttribute by filling the given the index with the objects
 /// of this type that are already stored.</summary>
 /// <param name="myAttributeNames">The names of the myAttributes, over which the index was created.</param>
 public Exceptional<AttributeIndex> CreateUniqueAttributeIndex(DBContext myDBContext, String myIndexName, AttributeUUID myAttributeName, String myIndexEdition)
 {
     return CreateUniqueAttributeIndex(myDBContext, myIndexName, new List<AttributeUUID> { myAttributeName }, myIndexEdition);
 }
コード例 #16
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        private TypeAttribute FindAttributeInLookup(String myTypeName, ref AttributeUUID myAttributeUUID)
        {
            foreach (var attr in _TypeAttributeLookupTable)
            {
                if (attr.Value.Name == myTypeName)
                {
                    myAttributeUUID = attr.Key;
                    return attr.Value;
                }
            }

            return null;
        }
コード例 #17
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        public Exceptional<Boolean> RenameAttribute(AttributeUUID attributeUUID, string newName)
        {
            if (GetTypeSpecificAttributeByName(newName) != null)
                return new Exceptional<Boolean>(new Error_AttributeAlreadyExists(newName));

            _Attributes[attributeUUID].Name = newName;

            return new Exceptional<Boolean>(true);
        }
コード例 #18
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        /// <summary>
        /// remove an unique attribute
        /// </summary>
        /// <param name="myAttribID"></param>
        public Exceptional<Boolean> RemoveUniqueAttribute(AttributeUUID myAttribID, DBTypeManager myTypeManager)
        {
            List<GraphDBType> SubTypes = myTypeManager.GetAllSubtypes(this, false);
            List<AttributeUUID> AttrList = new List<AttributeUUID>();
            AttrList.Add(myAttribID);

            foreach (var Types in SubTypes)
            {
                Types._UniqueAttributes.Remove(myAttribID);
                var removeIdxExcept = Types.RemoveIndex(Types.GetAttributeIndex(AttrList, DBConstants.UNIQUEATTRIBUTESINDEX).IndexName, DBConstants.UNIQUEATTRIBUTESINDEX, myTypeManager);

                if (removeIdxExcept.Failed())
                    return new Exceptional<Boolean>(removeIdxExcept);
            }

            _UniqueAttributes.Remove(myAttribID);

            return new Exceptional<Boolean>(true);
        }
コード例 #19
0
ファイル: DBSessionSettings.cs プロジェクト: TheByte/sones
 /// <summary>
 /// Removes an attribute setting from this session
 /// </summary>
 /// <param name="settingName">The name of the setting that should be removed</param>
 /// <param name="typeUUID">The name of the type</param>
 /// <param name="attributeUUID">The name of the attribute</param>
 /// <returns>True if there was something removed. Otherwise false.</returns>
 public bool RemoveAttributeSetting(string settingName, TypeUUID typeUUID, AttributeUUID attributeUUID)
 {
     lock (_SessionSettingsTypeAttribute)
     {
         if (_SessionSettingsTypeAttribute.ContainsKey(typeUUID))
         {
             if (_SessionSettingsTypeAttribute[typeUUID].ContainsKey(attributeUUID))
             {
                 return _SessionSettingsTypeAttribute[typeUUID][attributeUUID].Remove(settingName);
             }
             else
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
 }
コード例 #20
0
ファイル: DBTypeManager.cs プロジェクト: TheByte/sones
        /// <summary>
        /// Removes an attribute of the given type.
        /// </summary>
        /// <param name="aUserType">The target type.</param>
        /// <param name="attributeUUID">The attribute uuid, referencing the deprecated attribute.</param>
        /// <returns></returns>
        private Exceptional<ResultType> RemoveAttributeOfType(GraphDBType aUserType, AttributeUUID attributeUUID)
        {
            #region INPUT EXCEPTIONS

            if (aUserType == null)
            {
                return new Exceptional<ResultType>(new Error_ArgumentNullOrEmpty("aUserType"));
            }

            #endregion

            #region remove attribute from type

            TypeAttribute typeAttribute = aUserType.Attributes[attributeUUID];

            if (typeAttribute != null)
            {

                aUserType.RemoveAttribute(typeAttribute.UUID);

                var FlushExcept = FlushType(aUserType);

                if (FlushExcept.Failed())
                {
                    aUserType.AddAttribute(typeAttribute, this, false);

                    return new Exceptional<ResultType>(FlushExcept);
                }

                #region update lookup tables ob sub-classes

                foreach (var aSubType in GetAllSubtypes(aUserType).Where(aType => aType != aUserType))
                {
                    //delete from lookuptable
                    aSubType.RemoveAttributeFromLookupTable(typeAttribute.UUID);
                }

                #endregion

            }
            else
            {
                return new Exceptional<ResultType>(new Error_AttributeIsNotDefined(aUserType.Name, typeAttribute.Name));
            }

            #endregion

            return new Exceptional<ResultType>(ResultType.Successful);
        }
コード例 #21
0
ファイル: DBSessionSettings.cs プロジェクト: TheByte/sones
        /// <summary>
        /// Sets the given setting for a given type/typeattribute within this session
        /// </summary>
        /// <param name="setting">The setting to be set</param>
        /// <param name="typeUUID">The name of the type</param>
        /// <param name="attributeName">The name of the attribute</param>
        /// <returns>True for success</returns>
        public Exceptional SetAttributeSetting(ADBSettingsBase setting, TypeUUID typeUUID, AttributeUUID attributeUUID)
        {
            lock (_SessionSettingsTypeAttribute)
            {
                if (_SessionSettingsTypeAttribute.ContainsKey(typeUUID))
                {
                    if (_SessionSettingsTypeAttribute[typeUUID].ContainsKey(attributeUUID))
                    {
                        if (_SessionSettingsTypeAttribute[typeUUID][attributeUUID].ContainsKey(setting.Name))
                        {
                            _SessionSettingsTypeAttribute[typeUUID][attributeUUID][setting.Name] = setting;
                        }
                        else
                        {
                            _SessionSettingsTypeAttribute[typeUUID][attributeUUID].Add(setting.Name, setting);
                        }
                    }
                    else
                    {
                        _SessionSettingsTypeAttribute[typeUUID].Add(attributeUUID, new Dictionary<string, ADBSettingsBase>());
                        _SessionSettingsTypeAttribute[typeUUID][attributeUUID].Add(setting.Name, setting);
                    }
                }
                else
                {
                    _SessionSettingsTypeAttribute.Add(typeUUID, new Dictionary<AttributeUUID, Dictionary<string, ADBSettingsBase>>());
                    _SessionSettingsTypeAttribute[typeUUID].Add(attributeUUID, new Dictionary<string, ADBSettingsBase>());
                    _SessionSettingsTypeAttribute[typeUUID][attributeUUID].Add(setting.Name, setting);
                }
            }

            return Exceptional.OK;
        }
コード例 #22
0
 public Error_IndexKeyCreationError(AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
 {
     AttributeUUID = myAttributeUUID;
     IndexKeyPayload = myIndexKeyPayload;
     IndexDefinition = myIndexDefinition;
 }
コード例 #23
0
ファイル: ABinaryCompareOperator.cs プロジェクト: Vadi/sones
 private IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, AOperationDefinition myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
 {
     if (myOperationValue is ValueDefinition)
     {
         return IndexSingleOperation(myIndex, ((ValueDefinition)myOperationValue).Value, myAttributeUUID, typeOfBinExpr, dbContext);
     }
     else
     {
         if (myOperationValue is TupleDefinition)
         {
             return IndexOperation(myIndex, (myOperationValue as TupleDefinition), typeOfBinExpr, dbContext);
         }
         else
         {
             throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true), "Currently, it is not implemented to execute an IndexOperation on anything else but AtomValue or TupleValue."));
         }
     }
 }
コード例 #24
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
        //public void AddAttributeToLookupTable(AttributeUUID myUUID, TypeAttribute myTypeAttribute)
        //{
        //    _TypeAttributeLookupTable.Add(myUUID, myTypeAttribute);
        //}
        //public void AddAttributeToLookupTable(Dictionary<AttributeUUID, TypeAttribute> moreAttributes)
        //{
        //    foreach (var aMoreAttribute in moreAttributes)
        //    {
        //        AddAttributeToLookupTable(aMoreAttribute.Key, aMoreAttribute.Value);
        //    }
        //}
        /// <summary>
        /// This method gets a TypeAttribute by its UUID
        /// </summary>
        /// <param name="myAttributeUUID">The refered AttributeUUID of the attribute.</param>
        /// <returns>The TypeAttribute, else null.</returns>
        public TypeAttribute GetTypeAttributeByUUID(AttributeUUID myAttributeUUID)
        {
            TypeAttribute result = null;

            _TypeAttributeLookupTable.TryGetValue(myAttributeUUID, out result);

            return result;
        }
コード例 #25
0
ファイル: DBTypeManager.cs プロジェクト: TheByte/sones
        private Exceptional<ResultType> AddAttributeToDBObject(GraphDBType myTypeOfDBObject, ObjectUUID myUUID, AttributeUUID myAttributeUUID, IObject myAttributeValue)
        {
            //myGraphType is needed due to correctness concerning the attribute name

            #region Input exceptions

            if ((myTypeOfDBObject == null) || (myUUID == null) || (myAttributeUUID == null) || (myAttributeValue == null))
            {
                throw new ArgumentNullException();
            }

            #endregion

            #region Check GraphType for new Attribute

            TypeAttribute typeAttribute = myTypeOfDBObject.GetTypeAttributeByUUID(myAttributeUUID);

            if (typeAttribute == null)
            {
                //Todo: add notification here (the user has to be informed about the detailed circumstances)

                GraphDBError aError = new Error_AttributeIsNotDefined(myTypeOfDBObject.Name, myAttributeUUID.ToString());

                return new Exceptional<ResultType>(aError);
            }

            #endregion

            #region Data

            var objectLocation = new ObjectLocation(myTypeOfDBObject.ObjectLocation, DBConstants.DBObjectsLocation, myUUID.ToString());
            Exceptional<DBObjectStream> aNewDBObject;
            Exceptional<ResultType> result = new Exceptional<ResultType>();

            #endregion

            #region add attribute

            aNewDBObject = _DBContext.DBObjectManager.LoadDBObject(myTypeOfDBObject, myUUID);

            if (aNewDBObject.Failed())
            {
                result.PushIError(new Error_LoadObject(aNewDBObject.Value.ObjectLocation));
                return result;
            }

            result = aNewDBObject.Value.AddAttribute(typeAttribute.UUID, myAttributeValue);

            if (result.Failed())
                return result;

            try
            {
                _DBContext.DBObjectManager.FlushDBObject(aNewDBObject.Value);
            }
            catch (Exception ex)
            {
                result.PushIError(new Error_FlushObject(aNewDBObject.Value.ObjectLocation, ex));
                aNewDBObject.Value.RemoveAttribute(typeAttribute.UUID);
            }

            #endregion

            return result;
        }
コード例 #26
0
ファイル: GraphDBType.cs プロジェクト: TheByte/sones
 public void RemoveAttribute(AttributeUUID myUUID)
 {
     _TypeAttributeLookupTable.Remove(myUUID);
     _Attributes.Remove(myUUID);
 }
コード例 #27
0
ファイル: DBTypeManager.cs プロジェクト: TheByte/sones
        /// <summary>
        /// Do not use this method if you have to care about performance!!!
        /// It will return a TypeAttribute of the AttributeUUID
        /// </summary>
        /// <param name="myAttributeUUID"></param>
        /// <returns>TypeAttribute or null if it was not found</returns>
        public TypeAttribute GetTypeAttributeByAttributeUUID(AttributeUUID myAttributeUUID)
        {
            var found = from table in _TypesNameLookUpTable
                        where table.Value.Attributes.ContainsKey(myAttributeUUID)
                        select table.Value.Attributes[myAttributeUUID];

            if (found.Count() == 0)
                return null;

            return found.First();
        }
コード例 #28
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
 /// <summary>
 /// Adds a ADBBaseObject to the IndexKey
 /// </summary>
 /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
 /// <param name="myADBBaseObject">The ADBBaseObject that is going to be added</param>
 public void AddAADBBAseObject(AttributeUUID myAttributeUUID, ADBBaseObject myADBBaseObject)
 {
     AddAAKey(myAttributeUUID, myADBBaseObject);
 }
コード例 #29
0
ファイル: DBObjectManager.cs プロジェクト: ipbi/sones
 public Exceptional<Boolean> AddBackwardEdge(DBObjectStream aDBObject, TypeUUID uUIDofType, AttributeUUID uUIDofAttribute, ObjectUUID reference)
 {
     return aDBObject.AddBackwardEdge(uUIDofType, uUIDofAttribute, reference, _DBContext.DBObjectManager);
 }
コード例 #30
0
ファイル: IndexKey.cs プロジェクト: ipbi/sones
        /// <summary>
        /// Adds a ADBBaseObject to the IndexKey
        /// </summary>
        /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
        /// <param name="myADBBaseObject">The ADBBaseObject that is going to be added</param>
        private void AddAAKey(AttributeUUID myAttributeUUID, ADBBaseObject myADBBaseObject)
        {
            _indexKeyValues.Add(myADBBaseObject);

            CalcNewHashCode(myADBBaseObject, ref _hashCode);
        }