Ejemplo n.º 1
0
        private HashSet<AttributeUUID> GetParentMandatoryAttr(DBTypeManager myDBTypeManager)
        {
            Debug.Assert(myDBTypeManager != null);

            var _ParentGraphDBTypes = myDBTypeManager.GetAllParentTypes(this, false, false);

            if (_MandatoryParentAttributes == null)
                _MandatoryParentAttributes = new HashSet<AttributeUUID>();

            _MandatoryParentAttributes.Clear();

            foreach (var Type in _ParentGraphDBTypes)
            {
                foreach (var attribID in Type.GetMandatoryAttributesUUIDs(myDBTypeManager))
                {
                    _MandatoryParentAttributes.Add(attribID);
                }
            }

            return _MandatoryParentAttributes;
        }
Ejemplo n.º 2
0
        public List<AttributeUUID> GetAllUniqueAttributes(Boolean includeCurrentType, DBTypeManager myTypeManager)
        {
            List<AttributeUUID> result = new List<AttributeUUID>();

            foreach (var aParentType in myTypeManager.GetAllParentTypes(this, includeCurrentType, false))
            {
                result.AddRange(aParentType._UniqueAttributes);
            }

            return result;
        }
Ejemplo n.º 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;
        }