Пример #1
0
        public Exceptional<ResultType> DropUniqueAttributes(DBTypeManager myTypeManager)
        {
            #region Remove old unique index and attributes

            var mayBeUniqueIdx = FindUniqueIndex();

            if (mayBeUniqueIdx != null)
            {
                var RemoveIdxExcept = RemoveIndex(mayBeUniqueIdx.IndexName, mayBeUniqueIdx.IndexEdition, myTypeManager);

                if (RemoveIdxExcept.Failed())
                {
                    return new Exceptional<ResultType>(RemoveIdxExcept);
                }

                foreach (var attrUUID in mayBeUniqueIdx.IndexKeyDefinition.IndexKeyAttributeUUIDs)
                {
                    foreach (var type in myTypeManager.GetAllSubtypes(this, false))
                    {
                        var RemoveUniqueExcept = type.RemoveUniqueAttribute(attrUUID, myTypeManager);

                        if (RemoveUniqueExcept.Failed())
                            return new Exceptional<ResultType>(RemoveUniqueExcept);
                    }
                }
                _UniqueAttributes.Clear();
            }

            #endregion

            var FlushExcept = myTypeManager.FlushType(this);

            if (FlushExcept.Failed())
                return new Exceptional<ResultType>(FlushExcept);

            return new Exceptional<ResultType>(ResultType.Successful);
        }
Пример #2
0
        public Exceptional<Boolean> DropMandatoryAttributes(DBTypeManager myTypeManager)
        {
            List<GraphDBType> SubTypes = myTypeManager.GetAllSubtypes(this, false);

            if (GetMandatoryAttributesUUIDs(myTypeManager) != null)
            {
                foreach (var type in SubTypes)
                {
                    foreach (var attrib in _MandatoryAttributes)
                    {
                        if (type._MandatoryAttributes.Contains(attrib))
                            type._MandatoryAttributes.Remove(attrib);
                    }
                }

                _MandatoryAttributes.Clear();

                var FlushExcept = myTypeManager.FlushType(this);

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

            return new Exceptional<Boolean>(true);
        }
Пример #3
0
        private Dictionary<AttributeUUID, TypeAttribute> GetAttributesOfSubtypes(DBTypeManager myDBTypeManager)
        {
            var result = new Dictionary<AttributeUUID, TypeAttribute>();

            foreach (var aSubType in myDBTypeManager.GetAllSubtypes(this, false))
            {
                foreach (var aSubTypeAttribute in aSubType.Attributes)
                {
                    if (!result.ContainsKey(aSubTypeAttribute.Key))
                    {
                        result.Add(aSubTypeAttribute.Key, aSubTypeAttribute.Value);
                    }
                }
            }

            return result;
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        /// <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);
        }