/// <summary> /// Creates the ddl of a type. /// </summary> /// <param name="myVertexType">The vertex type.</param> private String CreateGraphDDL_VertexType(IVertexType myVertexType) { var stringBuilder = new StringBuilder(); String delimiter = ", "; stringBuilder.AppendFormat("{0} ", myVertexType.Name); #region parent type //EXTENDS ... if (myVertexType.HasParentType) { stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myVertexType.ParentVertexType.Name); } #endregion #region attributes //are there attributes if (myVertexType.HasAttributes(false)) { #region !incomingEdges if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind != AttributeType.IncomingEdge)) { //so, there are attributes that are no incoming edges stringBuilder.Append(String.Concat(S_ATTRIBUTES.ToUpperString(), " ", S_BRACKET_LEFT)); #region properties if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.Property)) { stringBuilder.Append(String.Concat(CreateGraphDDLOfProperties(myVertexType.GetPropertyDefinitions(false)))); } #endregion #region outgoing edges if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.OutgoingEdge)) { stringBuilder.Append(String.Concat(CreateGraphDDLOfOutgoingEdges(myVertexType.GetOutgoingEdgeDefinitions(false), myVertexType))); } #endregion if (stringBuilder.ToString().EndsWith(delimiter)) stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(String.Concat(S_BRACKET_RIGHT, " ")); } #endregion #region incomingEdges if (myVertexType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.IncomingEdge)) { stringBuilder.Append( String.Concat(S_INCOMINGEDGES.ToUpperString(), " ", S_BRACKET_LEFT.ToUpperString(), CreateGraphDDLOfIncomingEdges( myVertexType.GetIncomingEdgeDefinitions(false)), S_BRACKET_RIGHT.ToUpperString(), " ")); } #endregion } #endregion #region Uniques if (myVertexType.HasUniqueDefinitions(false)) { if (myVertexType.GetUniqueDefinitions(false).Count() > 0) { stringBuilder.Append(S_UNIQUE.ToUpperString() + " " + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfUniqueAttributes( myVertexType .GetUniqueDefinitions(false)) + S_BRACKET_RIGHT.Symbol + " "); } } #endregion #region Mandatory attributes if (myVertexType.HasProperties(false)) { if (myVertexType.GetPropertyDefinitions(false).Any(aProperty => aProperty.IsMandatory)) { stringBuilder.Append(S_MANDATORY.ToUpperString() + " " + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfMandatoryAttributes( myVertexType .GetPropertyDefinitions(false) .Where(aProperty => aProperty.IsMandatory)) + S_BRACKET_RIGHT.Symbol + " "); } } #endregion #region Indices var indices = myVertexType.GetIndexDefinitions(false).Except( myVertexType.GetUniqueDefinitions(false).Select(_ => _.CorrespondingIndex)); if (indices.Count() > 0) { stringBuilder.Append(S_INDICES.ToUpperString() + " " + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfIndices(indices, myVertexType) + S_BRACKET_RIGHT.Symbol); } #endregion return stringBuilder.ToString(); }