/// <summary> /// Creates IR representation for given IUMLAttribute attribute /// </summary> /// <param name="attr">original IUMLAttribute attribute</param> /// <returns>Created IR attribute representation</returns> private IR.TableAttribute BuildIRTableAttribute(IUMLAttribute attr) { IR.TableAttribute irAttr = new IR.TableAttribute(); irAttr.Name = attr.Name; irAttr.Type = attr.TypeExpression; irAttr.PrimaryKey = attr.GetTaggedValueAsBoolean(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_PRIMARY_KEY); string nullOption = attr.GetTaggedValueAsEnum(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_NULL_OPTION); irAttr.NotNull = (nullOption == Symbols.ERD_STEREOTYPE_NOT_NULL); irAttr.Identity = (nullOption == Symbols.ERD_STEREOTYPE_IDENTITY); irAttr.ForeignKey = attr.GetTaggedValueAsBoolean(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_FOREIGN_KEY); if (irAttr.ForeignKey) { IExtensibleModel refModel = attr.GetTaggedValueAsReference(Symbols.ERD_PROFILE_NAME, Symbols.ERD_STEREOTYPE_COLUMN, Symbols.ERD_STEREOTYPE_FOREIGN_KEY_REF); if (refModel != null) { irAttr.ForeignKeyRef = refModel.Name; string[] splittedPathName = refModel.Pathname.Split(new string[] { "::" }, System.StringSplitOptions.None); irAttr.ForeignTableRef = splittedPathName[splittedPathName.Length - 2]; } } return(irAttr); }
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); } } }