public void MakeGraphTopic(CogsModel model, string header) { foreach (var topic in model.TopicIndices) { var output = new StringBuilder(header); Stack <DataType> stack = new Stack <DataType>(); List <string> seen = new List <string>(); foreach (var item in topic.ItemTypes) { stack.Push(item); } while (stack.Count > 0) { var item = stack.Pop(); seen.Add(item.Name); if (Inheritance && !String.IsNullOrWhiteSpace(item.ExtendsTypeName)) { output.Append($"{item.Name} -> {item.ExtendsTypeName} [ arrowhead = \"empty\"]"); } foreach (var property in item.Properties) { if (ClassList.Contains(property.DataType) && !seen.Contains(property.DataTypeName)) { output.Append(item.Name + " -> " + property.DataTypeName + " "); stack.Push(property.DataType); } } } output.Append("}"); GenerateOutput(topic.Name, output.ToString()); } }
private string MakeNode(DataType item, string classText) { StringBuilder outputText = new StringBuilder(); foreach (var property in item.Properties) { classText += property.Name + " : " + property.DataTypeName; if (!string.IsNullOrWhiteSpace(property.MinCardinality) && !string.IsNullOrWhiteSpace(property.MaxCardinality)) { classText += "[" + property.MinCardinality + "..." + property.MaxCardinality + "] "; } classText += "\\l"; if (ClassList.Contains(property.DataType)) { outputText.Append("edge[ arrowhead = \"none\" headlabel = \"0...*\" taillabel = \"0...*\"] "); outputText.Append(item.Name + " -> " + property.DataTypeName + "[ label = \"" + property.Name + "\"] "); } if (ReusableList.Contains(property.DataType) && ShowReusables) { return(MakeCluster(item, property.DataType)); } } if (!string.IsNullOrWhiteSpace(item.ExtendsTypeName) && Inheritance) { outputText.Append("edge [arrowhead = \"empty\" headlabel = \"\" taillabel = \"\"] "); outputText.Append(item.Name + "->" + item.ExtendsTypeName + " "); } outputText.Append(classText + "}\"] "); return(outputText.ToString()); }
public void MakeGraphAll(CogsModel model, string header) { var output = new StringBuilder(header); foreach (var item in model.ItemTypes) { if (Inheritance && !String.IsNullOrWhiteSpace(item.ExtendsTypeName)) { output.Append(item.Name + " -> " + item.ExtendsTypeName + " [arrowhead=\"empty\"]"); } foreach (var property in item.Properties) { if (ClassList.Contains(property.DataType)) { output.Append(item.Name + " -> " + property.DataTypeName + " "); } } } output.Append("}"); GenerateOutput("output", output.ToString()); }
private string MakeCluster(DataType item, DataType reusable) { StringBuilder output = new StringBuilder(); StringBuilder outerClass = new StringBuilder($"subgraph cluster{item.Name} {{ style = \"filled\" " + $"fillcolor = \"#4abdac\" label = \"{item.Name}\" "); List <DataType> reusablesPresent = new List <DataType>(); outerClass.Append(item.Name + "Properties [ shape = \"record\" label=\"{Properties |"); foreach (var property in item.Properties) { outerClass.Append(property.Name + " : " + property.DataTypeName); if (!string.IsNullOrWhiteSpace(property.MinCardinality) && !string.IsNullOrWhiteSpace(property.MaxCardinality)) { outerClass.Append("[" + property.MinCardinality + "..." + property.MaxCardinality + "] "); } outerClass.Append("\\l"); if (ClassList.Contains(property.DataType)) { output.Append("edge[ arrowhead = \"none\" headlabel = \"0...*\" taillabel = \"0...*\"] "); output.Append(item.Name + "Properties -> " + property.DataTypeName + "[ arrowhead = \"none\" label = \"" + property.Name + "\"] "); } else if (ReusableList.Contains(property.DataType)) { // add reusableTypes within that type to reusable list as well Stack <DataType> stack = new Stack <DataType>(); if (!property.DataTypeName.Equals(item.Name) && !reusablesPresent.Contains(property.DataType)) { stack.Push(property.DataType); reusablesPresent.Add(property.DataType); while (stack.Count > 0) { var type = stack.Pop(); foreach (var prop in type.Properties) { // checks: item is a reusable type, item is not already seen, item isn't current item, item isn't primitive if (ReusableList.Contains(prop.DataType) && !reusablesPresent.Contains(type) && !type.Name.Equals(prop.DataTypeName) && !prop.DataTypeName.Equals(item.Name)) { stack.Push(prop.DataType); reusablesPresent.Add(prop.DataType); } } } output.Append(item.Name + "Properties -> " + item.Name + property.DataTypeName + "[ arrowhead = \"none\" label = \"" + property.Name + "\"] "); } } } if (!string.IsNullOrWhiteSpace(item.ExtendsTypeName) && Inheritance) { output.Append("edge [arrowhead = \"empty\"] "); output.Append(item.Name + "Properties ->" + item.ExtendsTypeName + "[ltail=cluster" + item.Name + "] "); } outerClass.Append("}\"] "); foreach (var reused in reusablesPresent) { outerClass.Append(item.Name + reused.Name + " [ shape = \"record\" fillcolor = \"#fc4a1a\" label=\"{ " + reused.Name + " | "); foreach (var property in reused.Properties) { outerClass.Append(property.Name + " : " + property.DataTypeName); if (!string.IsNullOrWhiteSpace(property.MinCardinality) && !string.IsNullOrWhiteSpace(property.MaxCardinality)) { outerClass.Append("[" + property.MinCardinality + "..." + property.MaxCardinality + "] "); } outerClass.Append("\\l"); if (ClassList.Contains(property.DataType) && !property.IsPrimitive) { output.Append("edge[ arrowhead = \"none\" headlabel = \"0...*\" taillabel = \"0...*\"] "); output.Append(item.Name + reused.Name + " -> " + property.DataTypeName + "[ label = \"" + property.Name + "\"] "); } else if (reusablesPresent.Contains(property.DataType)) { output.Append(item.Name + reused.Name + " -> " + item.Name + property.DataTypeName + "[ arrowhead = \"none\" label = \"" + property.Name + "\"] "); } } if (!string.IsNullOrWhiteSpace(reused.ExtendsTypeName) && Inheritance) { output.Append("edge [arrowhead = \"empty\"] "); output.Append(item.Name + reused.Name + "->" + reused.ExtendsTypeName + " "); } outerClass.Append("}\"] "); } outerClass.Append("}"); output.Append(outerClass); return(output.ToString()); }
public bool GetClassTrue(string classStr) { return(ClassList.Contains(classStr)); }