/// <summary> /// return the uuid, revision id and the editition for a new created type /// </summary> /// <param name="myGraphDBType">the created type</param> /// <returns></returns> private Exceptional<Vertex> GetVertexForType(GraphDBType myGraphDBType) { if (myGraphDBType == null) return new Exceptional<Vertex>(new Error_ArgumentNullOrEmpty("The type should not be null.")); var _Vertex = new Vertex(); _Vertex.AddAttribute(DBConstants.DbGraphType, myGraphDBType.Name); _Vertex.AddAttribute(SpecialTypeAttribute_UUID.AttributeName, myGraphDBType.ObjectUUID); _Vertex.AddAttribute(SpecialTypeAttribute_REVISION.AttributeName, myGraphDBType.ObjectRevisionID); _Vertex.AddAttribute(SpecialTypeAttribute_EDITION.AttributeName, myGraphDBType.ObjectEdition); return new Exceptional<Vertex>(_Vertex); }
/// <summary> /// Generate an output for an type with the attributes of the types and all parent types /// </summary> /// <param name="myGraphDBType">The db type</param> /// <param name="myDBContext">The db context</param> /// <param name="myDepth">If depth == 0 only the type basic attributes will be returned</param> private Vertex GenerateOutput(DBContext myDBContext, GraphDBType myGraphDBType, Int32 myDepth = 0) { var retVal = new Vertex(); if (myGraphDBType.ParentTypeUUID != null) retVal.AddAttribute("UUID", myGraphDBType.UUID); retVal.AddAttribute("TYPE", myGraphDBType.GetType().Name); retVal.AddAttribute("Name", myGraphDBType.Name); retVal.AddAttribute("Comment", myGraphDBType.Comment); if (myDepth > 0) { retVal.AddAttribute("Properties", new Edge(retVal, GeneratePropertiesOutput(myGraphDBType, myDBContext, myGraphDBType.Attributes.Where(a => !(a.Value.EdgeType is IReferenceEdge)).Select(kv => kv.Value))) { EdgeTypeName = "Property" }); retVal.AddAttribute("Edges", new Edge(retVal, GenerateEdgesOutput(myGraphDBType, myDBContext, myGraphDBType.Attributes.Where(a => (a.Value.EdgeType is IReferenceEdge) && !a.Value.IsBackwardEdge).Select(kv => kv.Value))) { EdgeTypeName = "Edge" }); retVal.AddAttribute("BackwardEdges", new Edge(retVal, GenerateEdgesOutput(myGraphDBType, myDBContext, myGraphDBType.Attributes.Where(a => (a.Value.EdgeType is IReferenceEdge) && a.Value.IsBackwardEdge).Select(kv => kv.Value))) { EdgeTypeName = "Edge" }); retVal.AddAttribute("UniqueAttributes", new Edge(retVal, GeneratePropertiesOutput(myGraphDBType, myDBContext, myGraphDBType.GetUniqueAttributes().Select(a => myGraphDBType.GetTypeAttributeByUUID(a)))) { EdgeTypeName = "Unique" }); retVal.AddAttribute("MandatoryAttributes", new Edge(retVal, GeneratePropertiesOutput(myGraphDBType, myDBContext, myGraphDBType.GetMandatoryAttributes().Select(a => myGraphDBType.GetTypeAttributeByUUID(a)))) { EdgeTypeName = "Mandatory" }); retVal.AddAttribute("Indices", new Edge(retVal, GenerateIndicesOutput(myGraphDBType, myDBContext)) { EdgeTypeName = "Index" }); if (myGraphDBType.ParentTypeUUID != null) { var _ParentType = myDBContext.DBTypeManager.GetTypeByUUID(myGraphDBType.ParentTypeUUID); retVal.AddAttribute("Extends", new Edge(retVal, GenerateOutput(myDBContext, _ParentType, myDepth - 1)) { EdgeTypeName = "VertexType" }); } } return retVal; }