If I would make it work, I could generate UML Class diagrams by importing a XMI file into Enterprise Architect!
As show below, this is very easy. What I did:
- create a simple class diagram (containing only 2 classes, 2 properties and inheritance)
- Exported the class diagram to a simple XMI file
- Pasted This XMI into a Layout
- Created some logic that supplies repeaters with template information
- added repeaters to the aspx, that made the XMI file dynamic
- visit a page that 'has' the layout bound to it
- voila! a valid XMI file that I can import into Enterprise Architect
step 1: create a simple class diagram |
- <packagedElement xmi:type="uml:Class" xmi:id="EAID_B16F5263_B589_479e_8588_CD3EA2BCF8A7" name="Class1" visibility="public">
- <ownedAttribute xmi:type="uml:Property" xmi:id="EAID_49CFB4AF_DF06_48b1_824C_7025907761B1" name="name1" visibility="private" isDerived="false" isOrdered="false"></ownedAttribute>
- </packagedElement>
- <packagedElement xmi:type="uml:Class" xmi:id="EAID_AD064C48_D2D0_4d00_B739_6E3E8A78005A" name="subclass2" visibility="public">
- <ownedAttribute xmi:type="uml:Property" xmi:id="EAID_AF11B4D8_CD8D_45a0_BC48_9D5E53F06FFB" name="Description2" visibility="private" isDerived="false" isOrdered="false"></ownedAttribute>
- <generalization xmi:type="uml:Generalization" xmi:id="EAID_A05EA125_D602_4d01_B338_31C793A08B12" general="EAID_B16F5263_B589_479e_8588_CD3EA2BCF8A7"/>
- </packagedElement>
- public List<TemplateItem> Templates
- {
- get
- {
- var lSelected = (from Item lItem in Sitecore.Context.Item.GetSelectedItems("IncludedRoots") select lItem);
- foreach (Item lItem in lSelected)
- {
- if(lItem.TemplateName == "Template")
- {
- lTemplates.Add(Factory.GetDatabase("master").GetTemplate(lItem.ID));
- }
- else
- {
- lTemplates.AddRange(from lTemplateItem
- in lItem.GetChildrenDescendantOfTemplate("Template", 10)
- where lTemplateItem.TemplateName == "Template"
- select Factory.GetDatabase("master").GetTemplate(lTemplateItem.ID));
- }
- }
- return lTemplates.OrderBy(a => a.Name).ToList();
- }
- }
- <asp:Repeater ID="Repeater1" runat="server" DataSource="<%#Templates%>">
- <ItemTemplate>
- <packagedElement xmi:type="uml:Class" xmi:id="<%#((CustomItemBase)Container.DataItem).ID.ToShortID()%>" name="<%#((CustomItemBase)Container.DataItem).Name%>" visibility="public">
- <asp:Repeater ID="rptSections" runat="server" DataSource='<%#GetFields(((TemplateItem)Container.DataItem))%>'>
- <ItemTemplate><asp:PlaceHolder runat="server" visible="<%#((TemplateFieldItem)Container.DataItem).Section.Template.Name==((CustomItemBase)Container.GetParentContainerDataItem().DataItem).Name%>">
- <ownedAttribute xmi:type="uml:Property" xmi:id="<%#((TemplateFieldItem)Container.DataItem).ID.ToShortID()%>" name="<%#((TemplateFieldItem)Container.DataItem).Name%>" visibility="private" isDerived="<%#((TemplateFieldItem)Container.DataItem).Section.Template.Name!=((CustomItemBase)Container.GetParentContainerDataItem().DataItem).Name%>" isOrdered="false">
- <type xmi:idref="<%#((TemplateFieldItem)Container.DataItem).Type%>"/>
- <asp:PlaceHolder runat="server" visible="<%#!string.IsNullOrEmpty(((TemplateFieldItem)Container.DataItem).GetStandardValue())%>"><defaultValue xmi:id="<%#((TemplateFieldItem)Container.DataItem).ID.ToShortID()%>" value="<%#((TemplateFieldItem)Container.DataItem).GetStandardValue()%>"/></asp:PlaceHolder>
- </ownedAttribute>
- </asp:PlaceHolder></ItemTemplate>
- </asp:Repeater>
- <asp:Repeater ID="rptBaseTemplates" runat="server" DataSource="<%#((TemplateItem)Container.DataItem).BaseTemplates%>">
- <ItemTemplate><!-- <%#((CustomItemBase)Container.DataItem).Name%> -->
- <generalization xmi:type="uml:Generalization" xmi:id="<%=Sitecore.Data.ID.NewID.ToShortID() %>" general="<%#((CustomItemBase)Container.DataItem).ID.ToShortID()%>"/> </ItemTemplate>
- </asp:Repeater>
- </packagedElement>
- </ItemTemplate>
Final: A class diagram, created from am imported XMI file! |
Really nice, don't you think?
2 things I want do do next:
- make the XMI generation work in the Compiled Domain Model shared source module
- generate the rest of the documentation, with more info per template/field
All links in this article are available here.
This comment has been removed by the author.
ReplyDeleteSounds very good and useful. We would like to use and test this software for our current project, to create and keep our technical documentation up-to-date. I sent you an e-mail with my contact information.
ReplyDeleteCould you please post all the code? I cannot find implementation for GetParentContainerDataItem(). Thanks.
ReplyDelete