Beispiel #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);
        }
Beispiel #2
0
        public Exceptional<Boolean> ChangeMandatoryAttributes(List<string> myAttribs, DBTypeManager myTypeManager)
        {
            TypeAttribute TypeAttr = null;

            DropMandatoryAttributes(myTypeManager);
            foreach (var attribs in myAttribs)
            {
                TypeAttr = GetTypeAttributeByName(attribs);
                if (TypeAttr == null)
                {
                    return new Exceptional<bool>(new Error_AttributeIsNotDefined(this.Name, attribs));
                }
                else
                {
                    AddMandatoryAttribute(TypeAttr.UUID, myTypeManager);
                    foreach (var attribID in GetParentMandatoryAttr(myTypeManager))
                    {
                        AddMandatoryAttribute(TypeAttr.UUID, myTypeManager);
                    }
                }
            }

            var FlushExcept = myTypeManager.FlushType(this);

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

            return new Exceptional<Boolean>(true);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        /// Adds a setting to this type
        /// </summary>
        /// <param name="myName">The name of the setting</param>
        /// <param name="mySetting">The setting itself</param>
        /// <param name="myTypeManager">The DB type manager</param>
        /// <returns>A Result type</returns>
        public Exceptional SetPersistentSetting(string myName, ADBSettingsBase mySetting, DBTypeManager myTypeManager)
        {
            if (!_TypeSettings.ContainsKey(myName))
            {
                _TypeSettings.Add(myName, (ADBSettingsBase)mySetting.Clone());
            }
            else
            {
                _TypeSettings[myName] = (ADBSettingsBase)mySetting.Clone();
            }

            var FlushExcept = myTypeManager.FlushType(this);

            if (FlushExcept.Failed())
                return new Exceptional(FlushExcept);

            return Exceptional.OK;
        }
Beispiel #5
0
        /// <summary>
        /// Remove a setting from this type
        /// </summary>
        /// <param name="mySettingName">The name of the setting</param>
        /// <param name="myTypeManager">The DB type manager</param>
        /// <returns>A ResultType</returns>
        public Exceptional<bool> RemovePersistentSetting(string mySettingName, DBTypeManager myTypeManager)
        {
            _TypeSettings.Remove(mySettingName);

            var FlushExcept = myTypeManager.FlushType(this);

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

            return new Exceptional<bool>(true);
        }
Beispiel #6
0
        /// <summary>
        /// Removes the given index from this type.
        /// </summary>
        /// <param name="myIndexName">The name of index.</param>
        public Exceptional<Boolean> RemoveIndex(String myIndexName, String myIndexEdition, DBTypeManager myTypeManager)
        {
            myIndexEdition = myIndexEdition ?? DBConstants.DEFAULTINDEX;

            foreach (var aidx in GetAllAttributeIndices())
            {
                if (aidx.IndexName.ToLower() == myIndexName.ToLower() && _AttributeIndices[aidx.IndexKeyDefinition].ContainsKey(myIndexEdition))
                {
                    _AttributeIndices[aidx.IndexKeyDefinition].Remove(aidx.IndexEdition);
                    _AttributeIndicesNameLookup.Remove(aidx.IndexName);

                    if (_AttributeIndices[aidx.IndexKeyDefinition].Count == 0)
                        _AttributeIndices.Remove(aidx.IndexKeyDefinition);

                    var FlushExcept = myTypeManager.FlushType(this);

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

                    return new Exceptional<Boolean>(true);
                }
            }

            return new Exceptional<Boolean>(new Error_IndexDoesNotExist(myIndexName, myIndexEdition));
        }
Beispiel #7
0
        public Exceptional SetPersistentSetting(String mySettingName, ADBSettingsBase myADBSettingsBase, DBTypeManager myDBTypeManager)
        {
            if (!_Settings.ContainsKey(mySettingName))
            {
                _Settings.Add(mySettingName, (ADBSettingsBase)myADBSettingsBase.Clone());
            }
            else
            {
                _Settings[mySettingName] = (ADBSettingsBase)myADBSettingsBase.Clone();
            }

            var FlushExcept = myDBTypeManager.FlushType(GetRelatedType(myDBTypeManager));

            if (FlushExcept.Failed())
                return new Exceptional(FlushExcept);

            return Exceptional.OK;
        }
Beispiel #8
0
        public Exceptional<Boolean> RemovePersistentSetting(String mySettingName, DBTypeManager myDBTypeManager)
        {
            _Settings.Remove(mySettingName);

            var FlushExcept = myDBTypeManager.FlushType(GetRelatedType(myDBTypeManager));

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

            return new Exceptional<Boolean>(true);
        }