public DescribeSettingDefinition(TypesSettingScope? mySettingType, String mySettingName = null, String myTypeName = null, IDChainDefinition myIDChain = null)
 {
     _SettingType = mySettingType;
     _SettingName = mySettingName;
     _SettingTypeName = myTypeName;
     _SettingAttribute = myIDChain;
 }
 public Error_CouldNotRemoveSetting(ADBSettingsBase mySetting, TypesSettingScope myScope, GraphDBType myType = null, TypeAttribute myAttribute = null)
 {
     Setting = mySetting;
     Scope = myScope;
     Type = myType;
     Attribute = myAttribute;
 }
Exemple #3
0
        protected Vertex CreateNewSettingReadoutOnSet(TypesSettingScope typesSettingScope, Dictionary<String, String> _Settings)
        {
            var payload = new Dictionary<String, Object>();

            payload.Add(DBConstants.SettingScopeAttribute, typesSettingScope.ToString());

            foreach (var aSetting in _Settings)
            {
                payload.Add(aSetting.Key, aSetting.Value);
            }

            return new Vertex(payload);
        }
        public override Exceptional<ADBSettingsBase> Get(DBContext context, TypesSettingScope scope, GraphDBType type = null, TypeAttribute attribute = null)
        {
            switch (scope)
            {
                case TypesSettingScope.DB:
                    #region db

                    return new Exceptional<ADBSettingsBase>(context.SessionSettings.GetDBSetting(this.Name));

                    #endregion

                case TypesSettingScope.SESSION:
                    #region session

                    return new Exceptional<ADBSettingsBase>(context.SessionSettings.GetSessionSetting(this.Name));

                    #endregion

                case TypesSettingScope.TYPE:
                    #region type

                    if (type != null)
                    {
                        return new Exceptional<ADBSettingsBase>(context.SessionSettings.GetTypeSetting(this.Name, type.UUID));
                    }

                    return new Exceptional<ADBSettingsBase>(new Error_CouldNotGetSetting(this, scope));
                    #endregion

                case TypesSettingScope.ATTRIBUTE:
                    #region attribute

                    if ((type != null) && (attribute != null))
                    {
                        return new Exceptional<ADBSettingsBase>(context.SessionSettings.GetAttributeSetting(this.Name, type.UUID, attribute.UUID));
                    }

                    return new Exceptional<ADBSettingsBase>(new Error_CouldNotGetSetting(this, scope, type, attribute));
                    #endregion

                default:

                    return new Exceptional<ADBSettingsBase>(new Error_NotImplemented(new System.Diagnostics.StackTrace()));
            }
        }
Exemple #5
0
 /// <summary>
 /// Sets a setting
 /// </summary>
 /// <param name="context">The database context</param>
 /// <param name="scope">The scope of the setting</param>
 /// <param name="type">The type where the setting should be set</param>
 /// <param name="attribute">The attribute where the setting should be set</param>
 /// <returns>True for success. Otherwise false.</returns>
 public abstract Exceptional Set(DBContext context, TypesSettingScope scope, GraphDBType type = null, TypeAttribute attribute = null);
Exemple #6
0
        public override Exceptional<bool> Remove(DBContext context, TypesSettingScope scope, GraphDBType type = null, TypeAttribute attribute = null)
        {
            switch (scope)
            {
                case TypesSettingScope.DB:
                    #region db

                    return new Exceptional<bool>(context.DBSettingsManager.RemovePersistentDBSetting(context, this.Name));

                    #endregion

                case TypesSettingScope.SESSION:
                    #region session

                    return new Exceptional<bool>(context.SessionSettings.RemoveSessionSettingReloaded(this.Name));

                    #endregion

                case TypesSettingScope.TYPE:
                    #region type

                    if (type != null)
                    {
                        return new Exceptional<bool>(type.RemovePersistentSetting(this.Name, context.DBTypeManager));
                    }

                    return new Exceptional<bool>(new Error_CouldNotRemoveSetting(this, scope));
                    #endregion

                case TypesSettingScope.ATTRIBUTE:
                    #region attribute

                    if ((type != null) && (attribute != null))
                    {
                        return new Exceptional<bool>(attribute.RemovePersistentSetting(this.Name, context.DBTypeManager));
                    }

                    return new Exceptional<bool>(new Error_CouldNotRemoveSetting(this, scope, type, attribute));
                    #endregion

                default:

                    return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace()));
            }
        }
Exemple #7
0
        /// <summary>
        /// Sets a setting
        /// </summary>
        /// <param name="settingName">The name of the setting</param>
        /// <param name="aDBBaseObject">The value of the setting</param>
        /// <param name="context">The current database context</param>
        /// <param name="_ActScope">The actual scope</param>
        /// <param name="type">A database type</param>
        /// <param name="attribute">A type attribute</param>
        public Exceptional SetSetting(string settingName, ADBBaseObject aDBBaseObject, DBContext context, TypesSettingScope _ActScope, GraphDBType type = null, TypeAttribute attribute = null)
        {
            if (AllSettingsByName.ContainsKey(settingName))
            {
                var currentSetting = (ADBSettingsBase)AllSettingsByName[settingName].Clone();

                currentSetting.Value = aDBBaseObject;
                return currentSetting.Set(context, _ActScope, type, attribute);
            }
            else
            {
                return new Exceptional(new Error_SettingDoesNotExist(settingName));
            }
        }
        private Vertex CreateNewATTRIBUTESettingReadoutOnSet(TypesSettingScope myTypesSettingScope, GraphDBType myDBType, List<IDChainDefinition> myAttributes, Dictionary<String, String> mySettings)
        {
            var payload = new Dictionary<String, Object>();

            payload.Add(DBConstants.SettingScopeAttribute, myTypesSettingScope.ToString());
            payload.Add(TypesSettingScope.TYPE.ToString(), myDBType.Name);

            var attributes = new List<Vertex>();

            foreach (var _Attribute in myAttributes)
            {

                var innerPayload = new Dictionary<String, Object>();

                innerPayload.Add(TypesSettingScope.ATTRIBUTE.ToString(), _Attribute.LastAttribute.Name);

                foreach (var aSetting in mySettings)
                {
                    innerPayload.Add(aSetting.Key, aSetting.Value);
                }

                attributes.Add(new Vertex(innerPayload));
            }

            payload.Add(DBConstants.SettingAttributesAttribute, new Edge(null, attributes) { EdgeTypeName = DBConstants.SettingAttributesAttributeTYPE });

            return new Vertex(payload);
        }
Exemple #9
0
 /// <summary>
 /// Removes a single setting
 /// </summary>
 /// <param name="context">The current context</param>
 /// <param name="settingName">The name of the setting</param>
 /// <param name="scope">The scope of the request</param>
 /// <param name="type">A database type</param>
 /// <param name="attribute">A type attribute</param>
 /// <returns></returns>
 public Exceptional<bool> RemoveSetting(DBContext context, string settingName, TypesSettingScope scope, GraphDBType type = null, TypeAttribute attribute = null)
 {
     if (AllSettingsByName.ContainsKey(settingName))
     {
         return AllSettingsByName[settingName].Remove(context, scope, type, attribute);
     }
     else
     {
         throw new GraphDBException(new Error_SettingDoesNotExist(settingName));
     }
 }
Exemple #10
0
        /// <summary>
        /// Returns the value of a setting
        /// </summary>
        /// <param name="settingUUID">The id of the setting</param>
        /// <param name="dbContext">The current database context</param>
        /// <param name="typesOfSettingScope">The actual scope</param>
        /// <param name="type">A database type</param>
        /// <param name="attribute">A type attribute</param>
        /// <param name="includingDefaults">Include the default values or take only the settings that has been set</param>
        /// <returns>The value of the setting</returns>
        public Exceptional<ADBBaseObject> GetSettingValue(UUID settingUUID, DBContext dbContext, TypesSettingScope typesOfSettingScope, GraphDBType type = null, TypeAttribute attribute = null, bool includingDefaults = true)
        {
            if (AllSettingsByUUID.ContainsKey(settingUUID))
            {
                var interestingSetting = AllSettingsByUUID[settingUUID].Get(dbContext, typesOfSettingScope, type, attribute);

                if (!interestingSetting.Success())
                {
                    return new Exceptional<ADBBaseObject>(interestingSetting);
                }

                if (interestingSetting.Value == null)
                {
                    if (includingDefaults)
                    {
                        //get default value of setting
                        return new Exceptional<ADBBaseObject>(AllSettingsByUUID[settingUUID].Default.Clone());
                    }
                    else
                    {
                        return new Exceptional<ADBBaseObject>();
                    }
                }
                else
                {
                    return new Exceptional<ADBBaseObject>(interestingSetting.Value.Value.Clone());
                }
            }
            else
            {
                return new Exceptional<ADBBaseObject>();
            }
        }
Exemple #11
0
 /// <summary>
 /// Returns the value of a setting
 /// </summary>
 /// <param name="settingName">The name of the setting</param>
 /// <param name="dbContext">The current database context</param>
 /// <param name="typesOfSettingScope">The actual scope</param>
 /// <param name="type">A database type</param>
 /// <param name="attribute">A type attribute</param>
 /// <param name="includingDefaults">Include the default values or take only the settings that has been set</param>
 /// <returns>The value of the setting</returns>
 public Exceptional<ADBBaseObject> GetSettingValue(String settingName, DBContext dbContext, TypesSettingScope typesOfSettingScope, GraphDBType type = null, TypeAttribute attribute = null, bool includingDefaults = true)
 {
     if (AllSettingsByName.ContainsKey(settingName))
     {
         return GetSettingValue(AllSettingsByName[settingName].ID, dbContext, typesOfSettingScope, type, attribute, includingDefaults);
     }
     else
     {
         return new Exceptional<ADBBaseObject>();
     }
 }
Exemple #12
0
        /// <summary>
        /// Returns a single setting
        /// </summary>
        /// <param name="settingUUID">The uuid of the setting</param>
        /// <param name="context">The current context</param>
        /// <param name="scope">The scope of the request</param>
        /// <param name="type">A database type</param>
        /// <param name="attribute">A type attribute</param>
        /// <param name="includingDefaults">Include the default values or take only the settings that has been set</param>
        /// <returns>A setting</returns>
        public Exceptional<ADBSettingsBase> GetSetting(UUID settingUUID, DBContext context, TypesSettingScope scope, GraphDBType type = null, TypeAttribute attribute = null, bool includingDefaults = true)
        {
            if (AllSettingsByUUID.ContainsKey(settingUUID))
            {
                var interestingSetting = AllSettingsByUUID[settingUUID].Get(context, scope, type, attribute);

                if (!interestingSetting.Success())
                {
                    return new Exceptional<ADBSettingsBase>(interestingSetting);
                }

                if (interestingSetting.Value == null)
                {
                    if (includingDefaults)
                    {
                        return new Exceptional<ADBSettingsBase>((ADBSettingsBase)AllSettingsByUUID[settingUUID].Clone());
                    }
                    else
                    {
                        return new Exceptional<ADBSettingsBase>();
                    }
                }
                else
                {
                    return new Exceptional<ADBSettingsBase>((ADBSettingsBase)interestingSetting.Value.Clone());
                }
            }
            else
            {
                return new Exceptional<ADBSettingsBase>(new Error_SettingDoesNotExist(settingUUID.ToString()));
            }
        }
Exemple #13
0
        /// <summary>
        /// Returns all settings
        /// </summary>
        /// <param name="_DBContext">The current context</param>
        /// <param name="typesSettingScope">The scope of the request</param>
        /// <param name="type">A database type</param>
        /// <param name="attribute">A type attribute</param>
        /// <param name="includingDefaults">Include the default values or take only the settings that has been set</param>
        /// <returns>Settings as a dictionary name - setting</returns>
        public Dictionary<string, ADBSettingsBase> GetAllSettings(DBContext _DBContext, TypesSettingScope typesSettingScope, GraphDBType type = null, TypeAttribute attribute = null, bool includingDefaults = true)
        {
            Dictionary<String, ADBSettingsBase> result = new Dictionary<string, ADBSettingsBase>();

            foreach (var aSetting in AllSettingsByName)
            {
                var aExtractedSetting = GetSetting(aSetting.Key, _DBContext, typesSettingScope, type, attribute, includingDefaults);
                if (!aExtractedSetting.Success())
                {
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace()));
                }

                if (aExtractedSetting.Value != null)
                {
                    /*
                    var currentDBSetting = aExtractedSetting.Value.Get(_DBContext, TypesSettingScope.DB);
                    if (currentDBSetting.Failed())
                    {
                        throw new GraphDBException(currentDBSetting.Errors);
                    }
                    if (currentDBSetting.Value != null)
                    {
                        result.Add(aSetting.Key, aExtractedSetting.Value);
                    }
                    */
                    result.Add(aSetting.Key, aExtractedSetting.Value);
                }

            }

            return result;
        }