private void AddErdTableAttribute(IUMLPackage parentPackage, IUMLClass parentTable, string diagramName, IR.TableAttribute irAttr) { // Attribute creation + basic properties IUMLAttribute attr = m_UMLFactory.CreateAttribute(parentTable); attr.Name = irAttr.Name; attr.TypeExpression = irAttr.Type; attr.SetStereotype2(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN); // Setting optional properties if (irAttr.PrimaryKey) { attr.SetTaggedValueAsBoolean(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_PRIMARY_KEY, true); } string nullStatus; if (irAttr.Identity) { nullStatus = Symbols.ERD_STEREOTYPE_IDENTITY; } else if (irAttr.NotNull || irAttr.PrimaryKey) { nullStatus = Symbols.ERD_STEREOTYPE_NOT_NULL; } else { nullStatus = Symbols.ERD_STEREOTYPE_NULL; } attr.SetTaggedValueAsEnum(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_NULL_OPTION, nullStatus); if (irAttr.ForeignKey) { attr.SetTaggedValueAsBoolean(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_FOREIGN_KEY, true); string relativePath = irAttr.ForeignTableRef + "::" + irAttr.ForeignKeyRef; IExtensibleModel refModel = parentPackage.FindByRelativePathname(relativePath) as IExtensibleModel; if (refModel != null) { attr.SetTaggedValueAsReference(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_FOREIGN_KEY_REF, refModel); } } }
/// <summary> /// Return diagrams owned by given package /// </summary> /// <param name="parent">Parent package</param> /// <returns>List of diagrams</returns> internal List <IUMLClassDiagram> GetOwnedErdDiagrams(IUMLPackage parent) { List <IUMLClassDiagram> result = new List <IUMLClassDiagram>(); for (int i = 0; i < parent.GetOwnedDiagramCount(); i++) { // Collect only IUMLPackage elements IDiagram diagram = parent.GetOwnedDiagramAt(i); IUMLClassDiagram classDiagram = diagram as IUMLClassDiagram; if (classDiagram != null) { result.Add(classDiagram); } } return(result); }
internal void AddErdDiagram(IUMLPackage parentPackage, string diagramName, List <IR.Table> tables) { // For perfomance reasons informs the main program that a sequence of models is created ErdAddIn.StarUMLApp.BeginGroupAction(); IUMLClassDiagram erdDiagram = m_UMLFactory.CreateExtendedClassDiagram(parentPackage, Symbols.ERD_PROFILE_NAME, Symbols.ERD_DIAGRAM_TYPE); erdDiagram.Name = diagramName; ResetLocationFactors(); foreach (var table in tables) { AddErdTable(parentPackage, erdDiagram, table); } // End of creation of a sequence of models ErdAddIn.StarUMLApp.EndGroupAction(); }
internal void AddErdTable(IUMLPackage parentPackage, IUMLClassDiagram parentDiagram, IR.Table tableData) { IUMLClass newTable = m_UMLFactory.CreateClass(parentPackage); newTable.Name = tableData.TableName; newTable.SetStereotype2(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_TABLE); UpdateLocationFactors(); IUMLClassDiagramView diagramView = parentDiagram.DiagramView as IUMLClassDiagramView; IUMLClassView newView = diagramView.CreateViewOf(newTable, m_xPos, m_yPos) as IUMLClassView; newView.Update(); UpdateYGrow(newView.Height); foreach (var irAttr in tableData.Attribues) { AddErdTableAttribute(parentPackage, newTable, parentDiagram.Name, irAttr); } }
/// <summary> /// Collect child packages of given package /// Uses top project node if no parent is given (is null) /// </summary> /// <param name="parent">Parent package or top project package if null</param> /// <returns>List of owned packages</returns> internal List <IUMLPackage> GetOwnedPackages(IUMLPackage parent = null) { List <IUMLPackage> result = new List <IUMLPackage>(); if (parent == null) // If no parent given start from the top project node { parent = TopProject; } for (int i = 0; i < parent.GetOwnedElementCount(); i++) { // Collect only IUMLPackage elements IUMLPackage package = parent.GetOwnedElementAt(i) as IUMLPackage; if (package != null) { result.Add(package); } } return(result); }