示例#1
0
        /// <summary>
        /// Writes all paths included in the HashSet. Every object is represented via a given attribute.
        /// 
        /// example path between fry and morbo (attribute is "Name") 
        /// 
        /// output:
        /// Fry -> Leela -> Lrrr -> Morbo
        /// </summary>
        /// <param name="myPaths">An HashSet which contains Lists of UUIDs</param>
        /// <param name="myTypeManager">The type manager to load the DBObjects</param>
        /// <param name="myTypeAttribute">The Type Attribute</param>
        /// <param name="myAttribute">The Attribute which shall be used for output.</param>
        public static void ShowDBObjects(HashSet<List<ObjectUUID>> myPaths, DBTypeManager myTypeManager, TypeAttribute myTypeAttribute, String myAttribute, DBObjectCache myObjectCache)
        {
            var attributeUUID = myTypeAttribute.GetRelatedType(myTypeManager).GetTypeSpecificAttributeByName(myAttribute).UUID;

            foreach (var path in myPaths)
            {

                var pathString = new StringBuilder();
                Exceptional<DBObjectStream> currentDBObject;

                foreach (var _ObjectUUID in path)
                {
                    //load from DB
                    currentDBObject = myObjectCache.LoadDBObjectStream(myTypeAttribute.GetRelatedType(myTypeManager), _ObjectUUID);
                    if (currentDBObject.Failed())
                    {
                        throw new NotImplementedException();
                    }

                    pathString.Append(currentDBObject.Value.GetAttribute(attributeUUID) + " -> ");
                }

                ////_Logger.Info(pathString.ToString());
                pathString.Remove(0, pathString.Length);

            }
        }
示例#2
0
        public override Exceptional<FuncParameter> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var aggregateResult = new DBDouble(0d);
            var total = 0UL;

            foreach (var dbo in myDBObjects)
            {
                var attr = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attr.Failed())
                {
                    return new Exceptional<FuncParameter>(attr);
                }
                if (attr.Value != null && attr.Value is ADBBaseObject && aggregateResult.IsValidValue((attr.Value as ADBBaseObject).Value))
                {
                    aggregateResult.Add((attr.Value as ADBBaseObject));
                    total++;
                }
                else
                {
                    return new Exceptional<FuncParameter>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            aggregateResult.Div(new DBUInt64(total));

            return new Exceptional<FuncParameter>(new FuncParameter(aggregateResult));
        }
示例#3
0
        /// <summary>
        /// Writes an DBObject into log
        /// </summary>
        /// <param name="myObjectUUID">The UUID of the Object</param>
        /// <param name="myTypeManager">The corresponding type manager</param>
        /// <param name="myTypeAttribute">The type attribute</param>
        public static void ShowDBObject(ObjectUUID myObjectUUID, DBTypeManager myTypeManager, TypeAttribute myTypeAttribute, DBObjectCache myObjectCache)
        {
            var currentDBObject = myObjectCache.LoadDBObjectStream(myTypeAttribute.GetRelatedType(myTypeManager), myObjectUUID);

            if (currentDBObject.Failed())
                throw new NotImplementedException();
        }
 public Error_CouldNotRemoveSetting(ADBSettingsBase mySetting, TypesSettingScope myScope, GraphDBType myType = null, TypeAttribute myAttribute = null)
 {
     Setting = mySetting;
     Scope = myScope;
     Type = myType;
     Attribute = myAttribute;
 }
 public Warning_EdgeToNonExistingNode(DBObjectStream myStartingNode, GraphDBType myTypeOfDBO, TypeAttribute myEdge, IEnumerable<IError> myErrors)
 {
     StartingNode = myStartingNode;
     Errors = myErrors;
     Edge = myEdge;
     TypeOfDBO = myTypeOfDBO;
 }
示例#6
0
 public SelectionElement(string myAlias, Select.EdgeList myEdgeList, bool myIsGroupedOrAggregated, IDChainDefinition myRelatedIDChainDefinition, TypeAttribute myElement = null)
     : this(myAlias, myRelatedIDChainDefinition)
 {
     EdgeList = myEdgeList;
     IsGroupedOrAggregated = myIsGroupedOrAggregated;
     Element = myElement;
 }
示例#7
0
        public override Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var foundFirstMax = false;
            var aggregateResult = myTypeAttribute.GetADBBaseObjectType(myDBContext.DBTypeManager);
            foreach (var dbo in myDBObjects)
            {
                var attrResult = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attrResult.Failed())
                {
                    return attrResult;
                }
                var attr = attrResult.Value;

                if (attr != null && attr is ADBBaseObject && aggregateResult.IsValidValue((attr as ADBBaseObject).Value))
                {
                    if (foundFirstMax == false)
                    {
                        aggregateResult.Value = (attr as ADBBaseObject).Value;
                        foundFirstMax = true;
                    }
                    else
                    {
                        if (aggregateResult.CompareTo((attr as ADBBaseObject).Value) < 0)
                        {
                            aggregateResult.Value = (attr as ADBBaseObject).Value;
                        }
                    }
                }
                else
                {
                    return new Exceptional<IObject>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            return new Exceptional<IObject>(aggregateResult);
        }
示例#8
0
        public ADBBaseObject GetValue(GraphDBType myTypeID, TypeAttribute myAttrID, UUID mySettingUUID, DBContext context)
        {
            if (_TypeAttrSetting.ContainsKey(myTypeID.UUID))
            {
                if (_TypeAttrSetting[myTypeID.UUID].ContainsKey(myAttrID.UUID))
                {
                    if (_TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].ContainsKey(mySettingUUID))
                    {
                        return _TypeAttrSetting[myTypeID.UUID][myAttrID.UUID][mySettingUUID];
                    }
                }
                else
                {
                    _TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
                }
            }
            else
            {
                _TypeAttrSetting.Add(myTypeID.UUID, new Dictionary<AttributeUUID, Dictionary<UUID, ADBBaseObject>>());
                _TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
            }

            //we are here, so we have to add the setting and return it

            var settingValue = context.DBSettingsManager.GetSettingValue(mySettingUUID, context, TypesSettingScope.ATTRIBUTE, myTypeID, myAttrID).Value.Clone();

            _TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].Add(mySettingUUID, settingValue);

            return settingValue;
        }
示例#9
0
        public static BasicType ConvertGraph2CSharp(TypeAttribute attributeDefinition, GraphDBType typeOfAttribute)
        {
            if (typeOfAttribute.IsUserDefined)
            {
                if (attributeDefinition.KindOfType != KindsOfType.SetOfReferences && attributeDefinition.KindOfType != KindsOfType.SingleReference)
                    throw new GraphDBException(new Error_ListAttributeNotAllowed(typeOfAttribute.Name));

                return BasicType.Reference;
            }

            else
            {

                if (attributeDefinition.KindOfType == KindsOfType.ListOfNoneReferences || attributeDefinition.KindOfType == KindsOfType.SetOfNoneReferences)
                    return BasicType.SetOfDBObjects;

                switch (typeOfAttribute.Name)
                {

                    case DBConstants.DBInteger:
                        return GraphInteger;

                    case DBConstants.DBInt32:
                        return GraphInt32;

                    case DBConstants.DBUnsignedInteger:
                        return GraphUnsignedInteger;

                    case DBConstants.DBString:
                        return GraphString;

                    case DBConstants.DBDouble:
                        return GraphDouble;

                    case DBConstants.DBDateTime:
                        return GraphDateTime;

                    case DBConstants.DBBoolean:
                        return GraphBoolean;

                    case "NumberLiteral":
                        return BasicType.Unknown;

                    case "StringLiteral":
                        return BasicType.Unknown;

                    case DBConstants.DBObject:
                        return BasicType.Reference;

                    default:
                        throw new GraphDBException(new Error_TypeDoesNotExist(typeOfAttribute.Name));

                }

            }
        }
示例#10
0
        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()));
            }
        }
示例#11
0
        /// <summary>
        /// Get the content of the CollectionDefinition as an edge
        /// </summary>
        /// <param name="myTypeAttribute"></param>
        /// <param name="myGraphDBType"></param>
        /// <param name="myDBContext"></param>
        /// <returns></returns>
        public Exceptional<ASetOfReferencesEdgeType> GetEdge(TypeAttribute myTypeAttribute, GraphDBType myGraphDBType, DBContext myDBContext)
        {
            if (CollectionType == CollectionType.List || !(myTypeAttribute.EdgeType is ASetOfReferencesEdgeType))
            {
                return new Exceptional<ASetOfReferencesEdgeType>(new Error_InvalidAssignOfSet(myTypeAttribute.Name));
            }

            #region The Edge is empty

            if (TupleDefinition == null)
            {
                return new Exceptional<ASetOfReferencesEdgeType>(myTypeAttribute.EdgeType.GetNewInstance() as ASetOfReferencesEdgeType);
            }

            #endregion

            Exceptional<ASetOfReferencesEdgeType> uuids = null;
            if (CollectionType == CollectionType.SetOfUUIDs)
            {
                uuids = TupleDefinition.GetAsUUIDEdge(myDBContext, myTypeAttribute);
                if (uuids.Failed())
                {
                    return new Exceptional<ASetOfReferencesEdgeType>(uuids);
                }
            }
            else
            {
                uuids = TupleDefinition.GetCorrespondigDBObjectUUIDAsList(myGraphDBType, myDBContext, (ASetOfReferencesEdgeType)myTypeAttribute.EdgeType, myGraphDBType);
                if (CollectionType == CollectionType.Set)
                {
                    if (uuids.Success())
                    {
                        uuids.Value.Distinction();
                    }
                }
            }
            return uuids;
        }
示例#12
0
        public override Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var aggregateResult = myTypeAttribute.GetADBBaseObjectType(myDBContext.DBTypeManager);
            foreach (var dbo in myDBObjects)
            {
                var attrResult = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attrResult.Failed())
                {
                    return attrResult;
                }
                var attr = attrResult.Value;

                if (attr != null && attr is ADBBaseObject && aggregateResult.IsValidValue((attr as ADBBaseObject).Value))
                {
                    aggregateResult.Add((attr as ADBBaseObject));
                }
                else if (attr != null) // if null, this value will be skipped
                {
                    return new Exceptional<IObject>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            return new Exceptional<IObject>(aggregateResult);
        }
示例#13
0
        private ValueDefinition GetCorrectValueDefinition(TypeAttribute typeAttribute, GraphDBType graphDBType, ValueDefinition myValueDefinition, DBContext dbContext, SessionSettings mySessionsInfos)
        {
            if (typeAttribute.IsBackwardEdge)
            {
                return GetCorrectValueDefinition(dbContext.DBTypeManager.GetTypeByUUID(typeAttribute.BackwardEdgeDefinition.TypeUUID).GetTypeAttributeByUUID(typeAttribute.BackwardEdgeDefinition.AttrUUID), graphDBType, myValueDefinition, dbContext, mySessionsInfos);
            }
            else
            {
                if (typeAttribute is ASpecialTypeAttribute && typeAttribute.UUID == SpecialTypeAttribute_UUID.AttributeUUID)
                {
                    //var uuid = SpecialTypeAttribute_UUID.ConvertToUUID(atomValue.Value.Value.ToString(), graphDBType, mySessionsInfos, dbContext.DBTypeManager);

                    //if (uuid.Failed())
                    //{
                    //    throw new GraphDBException(uuid.Errors);
                    //}
                    //return new AtomValue(new DBReference(uuid.Value));
                    return new ValueDefinition(new DBReference(ObjectUUID.FromString(myValueDefinition.Value.Value.ToString())));
                }
                else if (!typeAttribute.GetDBType(dbContext.DBTypeManager).IsUserDefined)
                {
                    return new ValueDefinition(GraphDBTypeMapper.GetADBBaseObjectFromUUID(typeAttribute.DBTypeUUID, myValueDefinition.Value));
                }
                else
                {
                    throw new GraphDBException(new Error_InvalidAttributeValue(typeAttribute.Name, myValueDefinition.Value));
                }
            }
        }
示例#14
0
        private Edge GetNotResolvedBackwardEdgeReferenceAttributeValue(DBObjectStream myDBObject, TypeAttribute myTypeAttribute, EdgeKey edgeKey, EdgeList currentEdgeList, Boolean myUsingGraph, DBContext _DBContext)
        {

            IObject attrValue = null;

            if (myUsingGraph)
            {
                var interestingLevelKey = new LevelKey((currentEdgeList + new EdgeKey(myTypeAttribute.RelatedGraphDBTypeUUID, myTypeAttribute.UUID)).Edges, _DBContext.DBTypeManager);

                attrValue = new EdgeTypeSetOfReferences(_ExpressionGraph.SelectUUIDs(interestingLevelKey, myDBObject), myTypeAttribute.DBTypeUUID);
            }

            else
            {
                var attrValueException = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, myTypeAttribute.GetDBType(_DBContext.DBTypeManager));
                if (attrValueException.Failed())
                {
                    throw new GraphDBException(attrValueException.IErrors);
                }

                attrValue = attrValueException.Value;
            }

            if (attrValue == null)
            {
                return null;
            }

            else if (!(attrValue is IReferenceEdge))
            {
                throw new GraphDBException(new Error_InvalidEdgeType(attrValue.GetType(), typeof(IReferenceEdge)));
            }

            var readouts = new List<Vertex>();
            var typeName = _DBContext.DBTypeManager.GetTypeByUUID(edgeKey.TypeUUID).Name;

            foreach (var reference in (attrValue as IReferenceEdge).GetAllReferenceIDs())
            {
                var specialAttributes = new Dictionary<string, object>();
                specialAttributes.Add(SpecialTypeAttribute_UUID.AttributeName, reference);
                specialAttributes.Add(SpecialTypeAttribute_TYPE.AttributeName, typeName);

                readouts.Add(new Vertex(specialAttributes));
            }

            return new Edge(null, readouts, _DBContext.DBTypeManager.GetTypeAttributeByEdge(edgeKey).GetDBType(_DBContext.DBTypeManager).Name);

        }
示例#15
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);
示例#16
0
        public Exceptional<TypeAttribute> CreateBackwardEdgeAttribute(BackwardEdgeDefinition myBackwardEdgeNode, GraphDBType myDBTypeStream, UInt16 beAttrCounter = 0)
        {
            var edgeType      = GetTypeByName(myBackwardEdgeNode.TypeName);

            if (edgeType == null)
                return new Exceptional<TypeAttribute>(new Error_TypeDoesNotExist(myBackwardEdgeNode.TypeName));

            var edgeAttribute = edgeType.GetTypeAttributeByName(myBackwardEdgeNode.TypeAttributeName);

            //error if the attribute does not exist
            #region
            if (edgeAttribute == null)
            {
                return new Exceptional<TypeAttribute>(new Error_AttributeIsNotDefined(edgeType.Name, myBackwardEdgeNode.TypeAttributeName));
            }
            #endregion

            //error if the attribute does not represent non userdefined content
            #region
            if (!edgeAttribute.GetDBType(this).IsUserDefined)
            {
                return new Exceptional<TypeAttribute>(new Error_BackwardEdgesForNotReferenceAttributeTypesAreNotAllowed(myBackwardEdgeNode.TypeAttributeName));
            }
            #endregion

            //invalid backwardEdge destination
            #region
            if (edgeAttribute.GetDBType(this) != myDBTypeStream)
                return new Exceptional<TypeAttribute>(new Error_BackwardEdgeDestinationIsInvalid(myDBTypeStream.Name, myBackwardEdgeNode.TypeAttributeName));
            #endregion

            //error if there is already an be attribute on the to be changed type that points to the same destination
            #region

            var edgeKey = new EdgeKey(edgeType.UUID, edgeAttribute.UUID);
            if (myDBTypeStream.Attributes.Exists(aKV => aKV.Value.IsBackwardEdge && (aKV.Value.BackwardEdgeDefinition == edgeKey)))
            {
                return new Exceptional<TypeAttribute>(new Error_BackwardEdgeAlreadyExist(myDBTypeStream, edgeType.Name, edgeAttribute.Name));
            }

            #endregion

            //error if the backwardEdge points to a backward edge
            #region
            var beDestinationAttribute = edgeKey.GetTypeAndAttributeInformation(this).Item2;

            if (beDestinationAttribute.IsBackwardEdge)
                return new Exceptional<TypeAttribute>(new Error_BackwardEdgeAlreadyExist(myDBTypeStream, edgeType.Name, edgeAttribute.Name));
            #endregion

            var ta = new TypeAttribute(Convert.ToUInt16(beAttrCounter + DBConstants.DefaultBackwardEdgeIDStart));
            ta.DBTypeUUID = DBBackwardEdgeType.UUID;
            ta.BackwardEdgeDefinition = edgeKey;
            ta.KindOfType = KindsOfType.SetOfReferences;
            ta.Name = myBackwardEdgeNode.AttributeName;
            ta.EdgeType = myBackwardEdgeNode.EdgeType.GetNewInstance();
            ta.TypeCharacteristics.IsBackwardEdge = true;
            ta.RelatedGraphDBTypeUUID = myDBTypeStream.UUID;

            return new Exceptional<TypeAttribute>(ta);
        }
示例#17
0
        public DBTypeManager(DBTypeManager dBTypeManager)
        {
            _DBContext                                      = dBTypeManager._DBContext;
            _UserID                                         = dBTypeManager._UserID;
            _DatabaseRootPath                               = dBTypeManager._DatabaseRootPath;
            _IGraphFSSession                                = dBTypeManager._IGraphFSSession;
            _ObjectLocationsOfAllUserDefinedDatabaseTypes   = dBTypeManager._ObjectLocationsOfAllUserDefinedDatabaseTypes;

            _SystemTypes                                    = dBTypeManager._SystemTypes;
            _BasicTypes                                     = dBTypeManager._BasicTypes;
            _GUIDTypeAttribute                              = dBTypeManager._GUIDTypeAttribute;

            //TODO: As soon as we have serialized Indices we can recomment these sections
            #region As soon as we have serialized Indices we can recomment these sections

            //_UserDefinedTypes                               = dBTypeManager._UserDefinedTypes;
            //_TypesNameLookUpTable                           = dBTypeManager._TypesNameLookUpTable;

            foreach (GraphDBType ptype in _SystemTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            foreach (GraphDBType ptype in _BasicTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            LoadUserDefinedDatabaseTypes(false);

            #endregion
        }
示例#18
0
        /// <summary>
        /// Adds an attribute with given name and type to the class with the given name
        /// </summary>
        /// <param name="targetClass">The class, we want to add the new attribute to.</param>
        /// <param name="myAttributeName">The name of the attribute.</param>
        /// <param name="attributeType">The type of the attribute.</param>
        /// <returns>Ture, if the attribute could be added to the target class. Else, false. (attribute contained in superclass)</returns>
        public Exceptional<ResultType> AddAttributeToType(GraphDBType mytype, TypeAttribute myTypeAttribute)
        {
            #region check if already initialized

            if (GetTypeByUUID(myTypeAttribute.DBTypeUUID) == null)
            {
                return new Exceptional<ResultType>(new Error_TypeDoesNotExist(myTypeAttribute.DBTypeUUID.ToString()));
            }

            #endregion

            #region Check if any ParentType already have an attribute with this name

            foreach (var aType in GetAllParentTypes(mytype, true, true))
            {
                if (aType.GetTypeAttributeByName(myTypeAttribute.Name) != null)
                {
                    return new Exceptional<ResultType>(new Error_AttributeExistsInSupertype(myTypeAttribute.Name, aType.Name));
                }
            }

            #endregion

            #region adapt type

            //if we reach this code, no other superclass contains an attribute with this name, so add it!
            myTypeAttribute.RelatedGraphDBTypeUUID = mytype.UUID;

            if (myTypeAttribute.DefaultValue != null)
            {
                mytype.AddMandatoryAttribute(myTypeAttribute.UUID, this);
            }

            mytype.AddAttribute(myTypeAttribute, this, true);

            var FlushExcept = FlushType(mytype);

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

            #endregion

            #region update lookup tables ob sub-classes

            foreach (var aSubType in GetAllSubtypes(mytype, false))
            {
                aSubType.AttributeLookupTable.Add(myTypeAttribute.UUID, myTypeAttribute);
            }

            #endregion

            return new Exceptional<ResultType>(ResultType.Successful);
        }
示例#19
0
        private List<TypeAttribute> GetBackwardReferencesForAttribute(TypeAttribute myAttribute)
        {
            List<TypeAttribute> result = new List<TypeAttribute>();

            foreach (var aType in _UserDefinedTypes)
            {
                foreach (var aAttribute in aType.Value.GetAllAttributes(_DBContext))
                {
                    if (aAttribute.IsBackwardEdge)
                    {
                        if (aAttribute.BackwardEdgeDefinition.AttrUUID == myAttribute.UUID)
                        {
                            result.Add(aAttribute);
                        }
                    }
                }
            }

            return result;
        }
示例#20
0
        private IEnumerable<Exceptional<DBObjectStream>> GetReferenceObjects(DBObjectStream myStartingDBObject, TypeAttribute interestingAttributeEdge, GraphDBType myStartingDBObjectType, DBTypeManager myDBTypeManager)
        {
            if (interestingAttributeEdge.GetDBType(myDBTypeManager).IsUserDefined || interestingAttributeEdge.IsBackwardEdge)
            {
                switch (interestingAttributeEdge.KindOfType)
                {
                    case KindsOfType.SingleReference:

                        yield return LoadDBObjectStream(interestingAttributeEdge.GetDBType(myDBTypeManager), ((ASingleReferenceEdgeType)myStartingDBObject.GetAttribute(interestingAttributeEdge.UUID)).GetUUID());

                        break;

                    case KindsOfType.SetOfReferences:

                        if (interestingAttributeEdge.IsBackwardEdge)
                        {
                            //get backwardEdge
                            var beStream = LoadDBBackwardEdgeStream(myStartingDBObjectType, myStartingDBObject.ObjectUUID);

                            if (beStream.Failed())
                            {
                                throw new GraphDBException(new Error_ExpressionGraphInternal(null, String.Format("Error while trying to get BackwardEdge of the DBObject: \"{0}\"", myStartingDBObject.ToString())));
                            }

                            if (beStream.Value.ContainsBackwardEdge(interestingAttributeEdge.BackwardEdgeDefinition))
                            {
                                foreach (var aBackwardEdgeObject in LoadListOfDBObjectStreams(interestingAttributeEdge.BackwardEdgeDefinition.TypeUUID, beStream.Value.GetBackwardEdgeUUIDs(interestingAttributeEdge.BackwardEdgeDefinition)))
                                {
                                    yield return aBackwardEdgeObject;
                                }
                            }
                        }
                        else
                        {
                            foreach (var aDBOStream in LoadListOfDBObjectStreams(interestingAttributeEdge.GetDBType(myDBTypeManager), ((ASetOfReferencesEdgeType)myStartingDBObject.GetAttribute(interestingAttributeEdge.UUID)).GetAllReferenceIDs()))
                            {
                                yield return aDBOStream;
                            }
                        }

                        break;

                    case KindsOfType.SetOfNoneReferences:
                    case KindsOfType.ListOfNoneReferences:
                    default:
                        throw new GraphDBException(new Error_ExpressionGraphInternal(new System.Diagnostics.StackTrace(true), String.Format("The attribute \"{0}\" has an invalid KindOfType \"{1}\"!", interestingAttributeEdge.Name, interestingAttributeEdge.KindOfType.ToString())));
                }
            }
            else
            {
                throw new GraphDBException(new Error_ExpressionGraphInternal(new System.Diagnostics.StackTrace(true), String.Format("The attribute \"{0}\" is no reference attribute.", interestingAttributeEdge.Name)));
            }

            yield break;
        }
示例#21
0
        /// <summary>
        /// Initializes the type manager. This method may only be called once, else it throws an TypeInitializationException.
        /// </summary>
        /// <param name="myIGraphFSSession">The myIGraphFS, on which the database is stored.</param>
        /// <param name="myDatabaseLocation">The databases root path in the myIGraphFS.</param>
        public Exceptional Init(IGraphFSSession myIGraphFSSession, ObjectLocation myDatabaseLocation, Boolean myRebuildIndices)
        {
            #region Input validation

            if (myIGraphFSSession == null)
                return new Exceptional<bool>(new Error_ArgumentNullOrEmpty("The parameter myIGraphFS must not be null!"));

            if (myDatabaseLocation == null)
                return new Exceptional<bool>(new Error_ArgumentNullOrEmpty("The parameter myDatabaseLocation must not be null!"));

            //ToDo: Find a better way to check this!
            if (_BasicTypes.ContainsKey(DBBaseObject.UUID))
                return new Exceptional<bool>(new Error_UnknownDBError("The TypeManager had already been initialized!"));

            #endregion

            var objectDirectoryShards = UInt16.Parse(_DBContext.GraphAppSettings.Get<ObjectsDirectoryShardsSetting>());

            #region DBObject - The base of all database types
            // DBObject is a child of DBBaseObject

            var typeDBBaseObject = new GraphDBType(DBBaseObject.UUID, myDatabaseLocation, DBBaseObject.Name, null, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "The base of all database types", DBConstants.ObjectDirectoryShards);
            _SystemTypes.Add(typeDBBaseObject.UUID, typeDBBaseObject);

            #endregion

            #region DBReference - The base of all user defined database types
            // DBObject is a child of DBBaseObject

            // == DBObject!
            var typeDBReference = new GraphDBType(DBReference.UUID, myDatabaseLocation, DBReference.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "The base of all user defined database types", DBConstants.ObjectDirectoryShards);

            #region DBVertex

            var typeDBVertex = new GraphDBType(DBVertex.UUID, myDatabaseLocation, DBVertex.Name, DBReference.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "The base of all user defined database vertices", DBConstants.ObjectDirectoryShards);
            _SystemTypes.Add(typeDBVertex.UUID, typeDBVertex);

            #endregion

            #region UUID special Attribute

            var specialTypeAttribute_UUID = new SpecialTypeAttribute_UUID() { DBTypeUUID = DBReference.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_UUID, this, false);
            _GUIDTypeAttribute = specialTypeAttribute_UUID;

            #endregion

            #region CreationTime special attribute

            var specialTypeAttribute_CrTime = new SpecialTypeAttribute_CREATIONTIME() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_CrTime, this, false);

            #endregion

            #region DeletionTime special attribute

            var specialTypeAttribute_DelTime = new SpecialTypeAttribute_DELETIONTIME() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_DelTime, this, false);

            #endregion

            #region Edition special attribute

            var specialTypeAttribute_Edition = new SpecialTypeAttribute_EDITION() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_Edition, this, false);

            #endregion

            #region Editions special attribute

            var specialTypeAttribute_Editions = new SpecialTypeAttribute_EDITIONS() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_Editions, this, false);

            #endregion

            #region LastAccessTime special attribute

            var specialTypeAttribute_AcTime = new SpecialTypeAttribute_LASTACCESSTIME() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_AcTime, this, false);

            #endregion

            #region LastModificationTime special attribute

            var specialTypeAttribute_LastModTime = new SpecialTypeAttribute_LASTMODIFICATIONTIME() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_LastModTime, this, false);

            #endregion

            #region TypeName special Attribute

            var specialTypeAttribute_TYPE = new SpecialTypeAttribute_TYPE() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_TYPE, this, false);

            #endregion

            #region REVISION special Attribute

            var specialTypeAttribute_REVISION = new SpecialTypeAttribute_REVISION() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_REVISION, this, false);

            #endregion

            #region REVISIONS special Attribute

            var specialTypeAttribute_REVISIONS = new SpecialTypeAttribute_REVISIONS() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_REVISIONS, this, false);

            #endregion

            #region STREAMS special Attribute

            var specialTypeAttribute_STREAMS = new SpecialTypeAttribute_STREAMS() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_STREAMS, this, false);

            #endregion

            #region NUMBER OF REVISIONS Attribute

            var specialTypeAttribute_NUMBEROFREVISIONS = new SpecialTypeAttribute_NUMBEROFREVISIONS() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_NUMBEROFREVISIONS, this, false);

            #endregion

            #region NUMBER OF COPIES

            var specialTypeAttribute_NUMBEROFCOPIES = new SpecialTypeAttribute_NUMBEROFCOPIES() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_NUMBEROFCOPIES, this, false);

            #endregion

            #region PARENT REVISION IDs

            var specialTypeAttribute_PARENTREVISIONIDs = new SpecialTypeAttribute_PARENTREVISIONS() { DBTypeUUID = DBString.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_PARENTREVISIONIDs, this, false);

            #endregion

            #region MAX REVISION AGE

            var specialTypeAttribute_MAXREVISIONAGE = new SpecialTypeAttribute_MAXREVISIONAGE() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_MAXREVISIONAGE, this, false);

            #endregion

            #region MIN NUMBER OF REVISIONS

            var specialTypeAttribute_MINNUMBEROFREVISIONS = new SpecialTypeAttribute_MINNUMBEROFREVISIONS() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_MINNUMBEROFREVISIONS, this, false);

            #endregion

            #region MAX NUMBER OF REVISIONS

            var specialTypeAttribute_MAXNUMBEROFREVISIONS = new SpecialTypeAttribute_MAXNUMBEROFREVISIONS() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_MAXNUMBEROFREVISIONS, this, false);

            #endregion

            #region MAX NUMBER OF COPIES

            var specialTypeAttribute_MAXNUMBEROFCOPIES = new SpecialTypeAttribute_MAXNUMBEROFCOPIES() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_MAXNUMBEROFCOPIES, this, false);

            #endregion

            #region MIN NUMBER OF COPIES

            var specialTypeAttribute_MINNUMBEROFCOPIES = new SpecialTypeAttribute_MINNUMBEROFCOPIES() { DBTypeUUID = DBUInt64.UUID, RelatedGraphDBTypeUUID = typeDBReference.UUID, KindOfType = KindsOfType.SpecialAttribute };
            typeDBReference.AddAttribute(specialTypeAttribute_MINNUMBEROFCOPIES, this, false);

            #endregion

            foreach (var attr in typeDBReference.Attributes)
            {
                typeDBVertex.AddAttribute(attr.Value, this, false);
            }

            _SystemTypes.Add(typeDBReference.UUID, typeDBReference);

            #endregion

            #region DBEdge

            var typeDBEdge = new GraphDBType(new TypeUUID(DBConstants.DBEdgeID), myDatabaseLocation, DBConstants.DBEdgeName, DBReference.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "The base of all user defined database edges", DBConstants.ObjectDirectoryShards);

            _SystemTypes.Add(typeDBEdge.UUID, typeDBEdge);

            #endregion

            #region Build-in basic database types
            // These are children of DBBaseObject

            _BasicTypes.Add(DBBoolean.UUID, new GraphDBType(DBBoolean.UUID, new ObjectLocation(myDatabaseLocation), DBBoolean.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBDateTime.UUID, new GraphDBType(DBDateTime.UUID, new ObjectLocation(myDatabaseLocation), DBDateTime.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBDouble.UUID, new GraphDBType(DBDouble.UUID, new ObjectLocation(myDatabaseLocation), DBDouble.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBInt64.UUID, new GraphDBType(DBInt64.UUID, new ObjectLocation(myDatabaseLocation), DBInt64.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBInt32.UUID, new GraphDBType(DBInt32.UUID, new ObjectLocation(myDatabaseLocation), DBInt32.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBUInt64.UUID, new GraphDBType(DBUInt64.UUID, new ObjectLocation(myDatabaseLocation), DBUInt64.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));
            _BasicTypes.Add(DBString.UUID, new GraphDBType(DBString.UUID, new ObjectLocation(myDatabaseLocation), DBString.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));

            _BasicTypes.Add(DBBackwardEdgeType.UUID, new GraphDBType(DBBackwardEdgeType.UUID, new ObjectLocation(myDatabaseLocation), DBBackwardEdgeType.Name, DBBaseObject.UUID, new Dictionary<AttributeUUID, TypeAttribute>(), false, false, "", DBConstants.ObjectDirectoryShards));

            #endregion

            foreach (var _GraphDBType in _SystemTypes.Values)
                _TypesNameLookUpTable.Add(_GraphDBType.Name, _GraphDBType);

            foreach (var _GraphDBType in _BasicTypes.Values)
                _TypesNameLookUpTable.Add(_GraphDBType.Name, _GraphDBType);

            return LoadUserDefinedDatabaseTypes(myRebuildIndices);
        }
示例#22
0
        /// <summary>
        /// Extracts the attribute from <paramref name="myDBObject"/>.
        /// </summary>
        /// <param name="myType"></param>
        /// <param name="myTypeAttribute"></param>
        /// <param name="myDBObject"></param>
        /// <param name="myLevelKey"></param>
        /// <returns></returns>
        private Object GetAttributeValue(GraphDBType myType, TypeAttribute myTypeAttribute, DBObjectStream myDBObject, EdgeList myLevelKey)
        {
            if (myTypeAttribute.TypeCharacteristics.IsBackwardEdge)
            {

                #region IsBackwardEdge

                EdgeKey edgeKey = myTypeAttribute.BackwardEdgeDefinition;
                var contBackwardExcept = myDBObject.ContainsBackwardEdge(edgeKey, _DBContext, _DBContext.DBObjectCache, myType);

                if (contBackwardExcept.Failed())
                    throw new GraphDBException(contBackwardExcept.IErrors);

                if (contBackwardExcept.Value)
                {
                    var getBackwardExcept = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, myTypeAttribute.GetDBType(_DBContext.DBTypeManager));

                    if (getBackwardExcept.Failed())
                        throw new GraphDBException(getBackwardExcept.IErrors);

                    return getBackwardExcept.Value;
                }

                #endregion

            }
            else if (myDBObject.HasAttribute(myTypeAttribute.UUID, myType))
            {

                #region ELSE (!IsBackwardEdge)

                return myDBObject.GetAttribute(myTypeAttribute.UUID, myType, _DBContext);

                #endregion

            }

            return null;
        }
示例#23
0
        /// <summary>
        /// Resolves an attribute 
        /// </summary>
        /// <param name="attrDefinition">The TypeAttribute</param>
        /// <param name="attributeValue">The attribute value, either a AListReferenceEdgeType or ASingleEdgeType or a basic object (Int, String, ...)</param>
        /// <param name="myDepth">The current depth defined by a setting or in the select</param>
        /// <param name="currentLvl">The current level (for recursive resolve)</param>
        /// <returns>List&lt;Vertex&gt; for user defined list attributes; Vertex for reference attributes, Object for basic type values </returns>
        private object ResolveAttributeValue(TypeAttribute attrDefinition, object attributeValue, Int64 myDepth, EdgeList myEdgeList, DBObjectStream mySourceDBObject, String reference, Boolean myUsingGraph)
        {

            #region attributeValue is not a reference type just return the value

            if (!((attributeValue is ASetOfReferencesEdgeType) || (attributeValue is ASingleReferenceEdgeType)))
            {
                return attributeValue;
            }

            #endregion

            #region get typeOfAttribute

            var typeOfAttribute = attrDefinition.GetDBType(_DBContext.DBTypeManager);

            // For backwardEdges, the baseType is the type of the DBObjects!
            if (attrDefinition.TypeCharacteristics.IsBackwardEdge)
                typeOfAttribute = _DBContext.DBTypeManager.GetTypeAttributeByEdge(attrDefinition.BackwardEdgeDefinition).GetRelatedType(_DBContext.DBTypeManager);

            #endregion

            #region Get levelKey and UsingGraph

            if (!(attrDefinition is ASpecialTypeAttribute))
            {
                if (myEdgeList.Level == 0)
                {
                    myEdgeList = new EdgeList(new EdgeKey(attrDefinition.RelatedGraphDBTypeUUID, attrDefinition.UUID));
                }
                else
                {
                    myEdgeList += new EdgeKey(attrDefinition.RelatedGraphDBTypeUUID, attrDefinition.UUID);
                }
            }

            // at some deeper level we could get into graph independend results. From this time, we can use the GUID index rather than asking the graph all the time
            if (myUsingGraph)
            {
                myUsingGraph = _ExpressionGraph.IsGraphRelevant(new LevelKey(myEdgeList.Edges, _DBContext.DBTypeManager), mySourceDBObject);
            }

            #endregion

            if (attributeValue is ASetOfReferencesEdgeType)
            {

                #region SetReference attribute -> return new Edge

                IEnumerable<Vertex> resultList = null;

                var edge = ((ASetOfReferencesEdgeType)attributeValue);

                if (myUsingGraph)
                {
                    var dbos = _ExpressionGraph.Select(new LevelKey(myEdgeList.Edges, _DBContext.DBTypeManager), mySourceDBObject, true);

                    resultList = GetVertices(typeOfAttribute, edge, dbos, myDepth, myEdgeList, reference, myUsingGraph);
                }
                else
                {
                    resultList = GetVertices(typeOfAttribute, edge, myDepth, myEdgeList, reference, myUsingGraph);
                }

                return new Edge(null, resultList, typeOfAttribute.Name);

                #endregion

            }
            else if (attributeValue is ASingleReferenceEdgeType)
            {

                #region Single reference

                attributeValue = new Edge(null, (attributeValue as ASingleReferenceEdgeType).GetVertex(a => LoadAndResolveVertex(a, typeOfAttribute, myDepth, myEdgeList, reference, myUsingGraph))
                    , typeOfAttribute.Name);

                return attributeValue;

                #endregion

            }
            else
            {
                throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
            }
        }
示例#24
0
 public abstract Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters);
示例#25
0
        /// <summary>
        /// This will check the exceptional for errors. Depending on the SettingInvalidReferenceHandling an expcetion will be thrown or false will be return on any load error.
        /// </summary>
        /// <param name="dbStream"></param>
        /// <param name="myLevelKey"></param>
        /// <returns></returns>
        private Boolean CheckLoadedDBObjectStream(Exceptional<DBObjectStream> dbStream, GraphDBType myDBType, TypeAttribute myTypeAttribute = null)
        {

            SettingInvalidReferenceHandling invalidReferenceSetting = null;
            GraphDBType currentType = myDBType;

            if (dbStream.Failed())
            {
                #region error

                #region get setting

                if (invalidReferenceSetting == null)
                {
                    //currentType = _DBContext.DBTypeManager.GetTypeByUUID(myLevelKey.LastEdge.TypeUUID);

                    //if (myLevelKey.LastEdge.AttrUUID != null)
                    if (myTypeAttribute != null)
                    {
                        invalidReferenceSetting = (SettingInvalidReferenceHandling)_DBContext.DBSettingsManager.GetSetting(SettingInvalidReferenceHandling.UUID, _DBContext, TypesSettingScope.ATTRIBUTE, currentType, myTypeAttribute).Value; // currentType.GetTypeAttributeByUUID(myLevelKey.LastEdge.AttrUUID)).Value;
                    }
                    else
                    {
                        invalidReferenceSetting = (SettingInvalidReferenceHandling)_DBContext.DBSettingsManager.GetSetting(SettingInvalidReferenceHandling.UUID, _DBContext, TypesSettingScope.TYPE, currentType).Value;
                    }
                }

                #endregion

                switch (invalidReferenceSetting.Behaviour)
                {
                    case BehaviourOnInvalidReference.ignore:
                        #region ignore

                        return false;

                        #endregion
                    case BehaviourOnInvalidReference.log:

                    default:

                        throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace()));
                }

                #endregion
            }

            return true;

        }
示例#26
0
 public Error_InvalidFunctionBase(TypeAttribute myTypeAttribute, String myFunctionName)
 {
     TypeAttribute = myTypeAttribute;
     FunctionName = myFunctionName;
 }
示例#27
0
        /// <summary>
        /// setting the default value for the attribute
        /// </summary>
        /// <param name="myAttr">the attribute</param>
        /// <param name="myDBObjectCache">the object cache</param>
        /// <returns>true if the value was changed</returns>
        private Exceptional<Boolean> SetDefaultValue(TypeAttribute myAttr, Exceptional<DBObjectStream> myDBO, DBContext dbContext)
        {
            if (myDBO.Success())
            {
                IObject defaultValue = myAttr.DefaultValue;

                if (defaultValue == null)
                    defaultValue = myAttr.GetDefaultValue(dbContext);

                var alterExcept = myDBO.Value.AlterAttribute(myAttr.UUID, defaultValue);

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

                if (!alterExcept.Value)
                {
                    return new Exceptional<bool>(false);
                }
            }
            else
            {
                return new Exceptional<bool>(false);
            }

            return new Exceptional<bool>(true);
        }
 public Error_CouldNotLoadBackwardEdge(DBObjectStream myDBObject, TypeAttribute myTypeAttribute, IEnumerable<IError> myErrors)
 {
     DBObject = myDBObject;
     Attribute = myTypeAttribute;
     Errors = myErrors;
 }
示例#29
0
 private bool IsValidDBObjectStreamForBinExpr(DBObjectStream DBObjectStream, TypeAttribute myTypeAttribute, DBTypeManager myDBTypeManager)
 {
     if (DBObjectStream.HasAttribute(myTypeAttribute.UUID, myTypeAttribute.GetRelatedType(myDBTypeManager)) || myTypeAttribute.IsBackwardEdge)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#30
0
        /// <summary>
        /// Loads an index from a corresponding type.
        /// </summary>
        /// <param name="myAttribute">The interesting attribute.</param>
        /// <param name="dbContext">The TypeManager of the database.</param>
        /// <param name="myType">The type of the interesing attribute.</param>
        /// <returns></returns>
        protected IEnumerable<Tuple<GraphDBType, AAttributeIndex>> GetIndex(TypeAttribute myAttribute, DBContext dbContext, GraphDBType myType, Object myExtraordinary)
        {
            #region INPUT EXCEPTIONS

            if (myType == null || myAttribute == null || dbContext == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            if (myExtraordinary == null)
            {
                #region eventual speedup

                //direct match of idx
                if (myType.HasAttributeIndices(myAttribute.UUID))
                {
                    yield return new Tuple<GraphDBType, AAttributeIndex>(myType, myType.GetAttributeIndex(dbContext, new IndexKeyDefinition(myAttribute.UUID), null).Value);
                }
                else
                {
                    //no direct match... lets try the subtypes
                    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(myType, true))
                    {
                        if (aSubType.HasAttributeIndices(myAttribute.UUID))
                        {
                            yield return new Tuple<GraphDBType, AAttributeIndex>(aSubType, aSubType.GetAttributeIndex(dbContext, new IndexKeyDefinition(myAttribute.UUID), null).Value);
                        }
                        else
                        {
                            yield return new Tuple<GraphDBType, AAttributeIndex>(aSubType, aSubType.GetUUIDIndex(dbContext));
                        }
                    }
                }

                #endregion
            }
            else
            {
                var checkResult = myType.HasAttributeIndices(myExtraordinary as IDChainDefinition);
                if (checkResult.Failed())
                {
                    throw new GraphDBException(checkResult.IErrors);
                }
                if (checkResult.Value)
                {
                    yield return new Tuple<GraphDBType, AAttributeIndex>(myType, myType.GetAttributeIndex(dbContext, myExtraordinary as IDChainDefinition).Value);
                }
                else
                {
                    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(myType, true))
                    {
                        yield return new Tuple<GraphDBType, AAttributeIndex>(aSubType, aSubType.GetUUIDIndex(dbContext));
                    }
                }
            }

            yield break;
        }