Пример #1
0
        /// <summary>
        /// generate a output result
        /// </summary>
        /// <param name="mySetting">the setting</param>
        /// <param name="myReadOutList">list of dbreadouts</param>
        private Vertex GenerateResult(ADBSettingsBase mySetting, DBTypeManager typeManager)
        {
            var Setting = new Dictionary<String, Object>();
            Setting.Add("Name", mySetting.Name);
            Setting.Add("ID", mySetting.ID);
            Setting.Add("Type", typeManager.GetTypeByUUID(mySetting.Type).Name);
            Setting.Add("Desc", mySetting.Description);
            Setting.Add("Default", mySetting.Default);
            Setting.Add("Value", mySetting.Value);

            return new Vertex(Setting);
        }
Пример #2
0
        public void AddAttribute(TypeAttribute myTypeAttribute, DBTypeManager myDBTypeManager, Boolean validate)
        {
            if (validate)
            {

                HashSet<UInt16> occupiedIDs = new HashSet<UInt16>();

                #region validate attributes

                CheckAttributeAgainstOthers(_Attributes, ref myTypeAttribute, ref occupiedIDs);

                #endregion

                #region validate superType

                var parentLookUpAttributes = myDBTypeManager.GetTypeByUUID(this.ParentTypeUUID).AttributeLookupTable;

                CheckAttributeAgainstOthers(parentLookUpAttributes, ref myTypeAttribute, ref occupiedIDs);
                CheckAttributeAgainstOthers(_Attributes, ref myTypeAttribute, ref occupiedIDs);

                #endregion

                #region validate subtypes

                var attributesOfSubtypes = GetAttributesOfSubtypes(myDBTypeManager);

                CheckAttributeAgainstOthers(attributesOfSubtypes, ref myTypeAttribute, ref occupiedIDs);
                CheckAttributeAgainstOthers(parentLookUpAttributes, ref myTypeAttribute, ref occupiedIDs);
                CheckAttributeAgainstOthers(_Attributes, ref myTypeAttribute, ref occupiedIDs);

                #endregion

                //now we can be shure to add the attribute
                _Attributes.Add(myTypeAttribute.UUID, myTypeAttribute);
                _TypeAttributeLookupTable.Add(myTypeAttribute.UUID, myTypeAttribute);

            }

            else
            {
                _Attributes.Add(myTypeAttribute.UUID, myTypeAttribute);
                _TypeAttributeLookupTable.Add(myTypeAttribute.UUID, myTypeAttribute);
            }
        }
Пример #3
0
        /// <summary>
        /// Initialize the type: verify it and set all lookuptables threadsafe
        /// </summary>
        /// <param name="myDBTypeManager"></param>
        /// <returns></returns>
        internal Exceptional Initialize(DBTypeManager myDBTypeManager)
        {
            lock (this)
            {

                if (!isNew)
                {
                    return Exceptional.OK;
                }

                #region check if the parent type exists

                GraphDBType parentType = myDBTypeManager.GetTypeByUUID(ParentTypeUUID);

                if (parentType == null)
                {
                    return new Exceptional(new Error_TypeDoesNotExist(ParentTypeUUID.ToString()));
                }
                else
                {

                    #region update lookup tables ob sub-classes

                    // in case, the type was still in the cache (usually happens if you invoke the RemoveAllUserDefinedTypes method)
                    // just refill the lookup table

                    _TypeAttributeLookupTable.Clear();

                    foreach (var aParentType in myDBTypeManager.GetAllParentTypes(this, false, true).Where(type => type != this))
                    {
                        foreach (var aParentAttribute in aParentType.Attributes)
                        {
                            if (!_TypeAttributeLookupTable.ContainsKey(aParentAttribute.Key))
                            {
                                _TypeAttributeLookupTable.Add(aParentAttribute.Key, aParentAttribute.Value);
                            }
                        }
                    }

                    foreach (var aAttribute in Attributes)
                    {
                        _TypeAttributeLookupTable.Add(aAttribute.Key, aAttribute.Value);
                    }

                    #endregion

                }

                var parentTypeExcept = myDBTypeManager.HasParentType(ParentTypeUUID, DBBaseObject.UUID);

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

                if (!parentTypeExcept.Value)
                {
                    return new Exceptional(new Error_Logic("The type " + Name + " can not be added, because all user defined types must be subtypes of GraphObject."));
                }

                #endregion

                #region check type of attribute

                foreach (TypeAttribute attribute in _Attributes.Values)
                {
                    if (attribute.GetDBType(myDBTypeManager) == null)
                    {
                        //The typemanager is able to add myAttributes that are of its type
                        if (!myDBTypeManager.GetTypeByUUID(attribute.DBTypeUUID).Name.Equals(Name))
                        {
                            return new Exceptional(new Error_TypeDoesNotExist(attribute.DBTypeUUID.ToString()));
                        }
                    }
                }

                #endregion

                isNew = false;
            }

            return Exceptional.OK;
        }
Пример #4
0
        public GraphDBType GetParentType(DBTypeManager myTypeManager)
        {
            if (_ParentType == null)
            {
                if (ParentTypeUUID == null)
                {
                    return null;
                }
                else
                {
                    _ParentType = myTypeManager.GetTypeByUUID(ParentTypeUUID);

                    return _ParentType;
                }
            }
            else
            {
                return _ParentType;
            }
        }
Пример #5
0
        public GraphDBType GetRelatedType(DBTypeManager myDBTypeManager)
        {
            if (_RelatedGraphType == null)
            {
                //if (!IsBackwardEdge)
                    _RelatedGraphType = myDBTypeManager.GetTypeByUUID(RelatedGraphDBTypeUUID);

                //else
                //    _RelatedGraphType = myDBTypeManager.GetTypeByUUID(BackwardEdgeDefinition.TypeUUID);
            }

            return _RelatedGraphType;
        }
Пример #6
0
        public GraphDBType GetDBType(DBTypeManager myDBTypeManager)
        {
            if (_GraphDBType == null)
                _GraphDBType = myDBTypeManager.GetTypeByUUID(DBTypeUUID);

            return _GraphDBType;
        }