/// <summary> /// Gets a list of IR nodes representing ERD table attributes /// </summary> /// <param name="parentTable"> parent IUMLClass table</param> /// <returns>list of created IR table attributes</returns> private List <IR.TableAttribute> BuildIRTableAttributes(IUMLClass parentTable) { List <IR.TableAttribute> irAttrs = new List <IR.TableAttribute>(); for (int i = 0; i < parentTable.GetAttributeCount(); i++) { IR.TableAttribute irAttr = BuildIRTableAttribute(parentTable.GetAttributeAt(i)); irAttrs.Add(irAttr); } return(irAttrs); }
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); } } }
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> /// Gets a list of IR nodes representing ERD tables /// </summary> /// <param name="diagram">ERD Diagram to get data from</param> /// <returns>List of created IR nodes</returns> internal List <IR.Table> GetErdTables(IUMLClassDiagram diagram) { List <IR.Table> result = new List <IR.Table>(); IDiagramView diagramView = diagram.DiagramView; if (diagramView != null) { int nbOfElems = diagramView.GetOwnedViewCount(); for (int i = 0; i < nbOfElems; i++) { try { IUMLClass umlClass = null; IView view = diagramView.GetOwnedViewAt(i); if (view != null) { umlClass = view.Model as IUMLClass; } if (umlClass != null) { // Collect only ERD tables if ( (umlClass.StereotypeProfile == Symbols.ERD_PROFILE_NAME) && (umlClass.StereotypeName == Symbols.ERD_STEREOTYPE_TABLE) ) { IR.Table irTable = new IR.Table(); irTable.TableName = umlClass.Name; irTable.Attribues = BuildIRTableAttributes(umlClass); result.Add(irTable); } } } catch (System.Exception) { } // Ignore offending model elements } } return(result); }