예제 #1
0
        /// <summary>
        /// Get all parent type (the type from which the <paramref name="myType"/> derives)
        /// </summary>
        /// <param name="myType"></param>
        /// <param name="myThisTypeIncluding">If true, the <paramref name="myType"/> is added to the result.</param>
        /// <returns></returns>
        public IEnumerable<GraphDBType> GetAllParentTypes(GraphDBType myType, Boolean myThisTypeIncluding, Boolean includeSystemTypes)
        {
            #region INPUT EXCEPTIONS

            if (myType == null)
            {
                throw new GraphDBException(new Error_ArgumentNullOrEmpty("DBType should not be null."));
            }

            #endregion

            List<GraphDBType> result = new List<GraphDBType>();

            if (myThisTypeIncluding)
                result.Add(myType);

            if (myType.ParentTypeUUID != null)
            {
                if (myType.GetParentType(this).IsUserDefined)
                {
                    result.AddRange(GetAllParentTypes(myType.GetParentType(this), true, includeSystemTypes));
                }
                else
                {
                    if (includeSystemTypes)
                    {
                        result.AddRange(GetAllParentTypes(myType.GetParentType(this), true, includeSystemTypes));
                    }
                }
            }

            return result;
        }
예제 #2
0
        private String CreateGraphDDL(DumpFormats myDumpFormat, GraphDBType myGraphDBType, DBContext myDBContext)
        {
            var stringBuilder = new StringBuilder();
            stringBuilder.AppendFormat("{0} ", myGraphDBType.Name);

            if (myGraphDBType.ParentTypeUUID != null)
            {

                stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myGraphDBType.GetParentType(myDBContext.DBTypeManager).Name);//builder.AppendLine();

                #region Not backwardEdge attributes

                if (myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge).CountIsGreater(0))
                {
                    stringBuilder.Append(S_ATTRIBUTES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfAttributes(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " ");
                }

                #endregion

                #region BackwardEdge attributes

                if (myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge).CountIsGreater(0))
                {
                    stringBuilder.Append(S_BACKWARDEDGES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfBackwardEdges(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " ");
                }

                #endregion

                #region Uniques

                if (myGraphDBType.GetUniqueAttributes().CountIsGreater(0))
                {
                    stringBuilder.Append(S_UNIQUE.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetUniqueAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
                }

                #endregion

                #region Mandatory attributes

                if (myGraphDBType.GetMandatoryAttributes().CountIsGreater(0))
                {
                    stringBuilder.Append(S_MANDATORY.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetMandatoryAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
                }

                #endregion

                #region Indices

                if (myGraphDBType.GetAllAttributeIndices(false).CountIsGreater(0))
                {
                    stringBuilder.Append(S_INDICES.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfIndices(myDumpFormat, myGraphDBType.GetAllAttributeIndices(false), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " ");
                }

                #endregion

            }

            return stringBuilder.ToString();
        }