public static void ProcessManagerUseCase(EA.Package package, XisEntity master, EA.Element useCase, EA.Element be, bool isStartingUC, List<EA.Element> useCases = null, String patternType = null) { // Create IS Diagram EA.Diagram listDiagram = XisWebHelper.CreateDiagram(package, master.Element.Name + "ListIS Diagram", "XIS-Web_Diagrams::InteractionSpaceViewModel"); XisInteractionSpace listIS = null; if (isStartingUC && patternType != null) { listIS = new XisInteractionSpace(repository, package, listDiagram, master.Element.Name + "ListIS", "Manage " + master.Element.Name + "s", InteractionSpaceType.MasterEntityList); } else { listIS = new XisInteractionSpace(repository, package, listDiagram, master.Element.Name + "ListIS", "Manage " + master.Element.Name + "s", InteractionSpaceType.MasterEntityList, isStartingUC, !isStartingUC); if (isStartingUC && patternType == null) { homeIS = listIS; } } //Image & Sitemap Creation - Define a proper source path! XisImage img = new XisImage(repository, listIS, listDiagram, "../images/default.png"); XisSiteMap siteMap = new XisSiteMap(repository, listIS, listDiagram); // List Creation XisList list = new XisList(repository, listDiagram, listIS, master.Element.Name + "List"); list.SetEntityName(master.Element.Name); //if (ContainsSearch(operations)) //{ // string searchBy = ""; // string tv = null; // foreach (EA.Attribute attr in master.Element.Attributes) // { // tv = GetAttributeTag(attr.TaggedValues, "isKey").Value; // if (!string.IsNullOrEmpty(tv) && tv.ToLower() == "true") // { // searchBy += master.Element.Name + "." + attr.Name + ";"; // } // } // if (string.IsNullOrEmpty(searchBy)) // { // list.SetSearchBy(master.Element.Name + ".Id"); // } // else // { // list.SetSearchBy(searchBy.Substring(0, searchBy.Length - 1)); // } //} XisListItem item = new XisListItem(repository, listDiagram, list, list.Element.Name + "Item"); if (ContainsUpdateMaster(useCase)) { string actionName = "edit" + master.Element.Name; item.SetOnTapAction(actionName); } else if (ContainsReadMaster(useCase)) { string actionName = "view" + master.Element.Name; item.SetOnTapAction(actionName); } if (master.Element.Attributes.Count > 1) { EA.Attribute first = master.Element.Attributes.GetAt(0); EA.Attribute second = master.Element.Attributes.GetAt(1); XisLabel lbl1 = new XisLabel(repository, item, listDiagram, first.Name + "Lbl"); lbl1.SetEntityAttributeName(master.Element.Name + "." + first.Name); XisLabel lbl2 = new XisLabel(repository, item, listDiagram, second.Name + "Lbl"); lbl2.SetEntityAttributeName(master.Element.Name + "." + second.Name); } else if (master.Element.Attributes.Count == 1) { EA.Attribute attr = master.Element.Attributes.GetAt(0); item.SetValueFromExpression(master.Element.Name + "." + attr.Name); } // Read, Update, Create //Menu Creation #region Create Options Menu Dictionary<ActionType, XisMenuItem> detailModes = new Dictionary<ActionType, XisMenuItem>(3); if (ContainsCreateMaster(useCase) || ContainsDeleteMaster(useCase)) { XisMenu menu = new XisMenu(repository, listDiagram, listIS, listIS.Element.Name + "Menu", MenuType.OptionsMenu); if (ContainsCreateMaster(useCase)) { menu.SetEntityName(master.Element.Name); string actionName = "create" + master.Element.Name; XisMenuItem menuItem = new XisMenuItem(repository, listDiagram, menu, "Create" + master.Element.Name + "Item", actionName); menuItem.SetValue("Create " + master.Element.Name); detailModes.Add(ActionType.Create, menuItem); } if (ContainsDeleteMaster(useCase)) { menu.SetEntityName(master.Element.Name); string actionName = "deleteAll" + master.Element.Name + "s"; XisMenuItem menuItem = new XisMenuItem(repository, listDiagram, menu, "DeleteAll" + master.Element.Name + "Item", actionName); menuItem.SetValue("Delete all " + master.Element.Name + "s"); XisWebHelper.CreateXisAction(repository, menuItem.Element, actionName, ActionType.DeleteAll); } listIS.Menu = menu; } #endregion #region Create Context Menu if (ContainsReadMaster(useCase) || ContainsUpdateMaster(useCase) || ContainsDeleteMaster(useCase)) { XisMenu context = new XisMenu(repository, listDiagram, package, list.Element.Name + "ContextMenu", MenuType.ContextMenu); if (ContainsReadMaster(useCase)) { context.SetEntityName(master.Element.Name); string actionName = "view" + master.Element.Name; XisMenuItem contextItem = new XisMenuItem(repository, listDiagram, context, "View" + master.Element.Name + "Item", actionName); contextItem.SetValue("View " + master.Element.Name); detailModes.Add(ActionType.Read, contextItem); } if (ContainsUpdateMaster(useCase)) { context.SetEntityName(master.Element.Name); string actionName = "edit" + master.Element.Name; XisMenuItem contextItem = new XisMenuItem(repository, listDiagram, context, "Edit" + master.Element.Name + "Item", actionName); contextItem.SetValue("Edit " + master.Element.Name); detailModes.Add(ActionType.Update, contextItem); } //This action is passing to the Editor page /*if (ContainsDeleteMaster(useCase)) { context.SetEntityName(master.Element.Name); string actionName = "delete" + master.Element.Name; XisMenuItem contextItem = new XisMenuItem(repository, listDiagram, context, "Delete" + master.Element.Name + "Item", actionName); contextItem.SetValue("Delete " + master.Element.Name); XisWebHelper.CreateXisAction(repository, contextItem.Element, actionName, ActionType.Delete); }*/ listIS.ContextMenu = context; } #endregion // Navigation between home UC and the others if (patternType != null) { AddToHomeISByPattern(useCase, listIS, patternType); } else if (isStartingUC) { if (useCases != null) { AssociateFirstSubSpaces(listDiagram, useCases, listIS, be.ElementID, master.Element.Name); } } #region Check ServiceUC Extensions Dictionary<List<EA.Element>, bool> services = new Dictionary<List<EA.Element>, bool>(); if (useCase.Connectors.Count > 0) { List<EA.Element> extends = new List<EA.Element>(); Dictionary<EA.Element, bool> providers = new Dictionary<EA.Element, bool>(); foreach (EA.Connector conn in useCase.Connectors) { if (conn.Stereotype == "extend") { EA.Element el = repository.GetElementByID(conn.ClientID); extends.Add(el); } } foreach (EA.Element e in extends) { bool hasBE = false; EA.Element provider = null; foreach (EA.Connector conn in e.Connectors) { if (conn.Stereotype == "XisServiceUC-BEAssociation") { hasBE = true; } else if (conn.Stereotype == "XisServiceUC-ProviderAssociation") { provider = repository.GetElementByID(conn.SupplierID); providers.Add(provider, false); } } if (provider != null && hasBE) { providers[provider] = true; } } foreach (EA.Element p in providers.Keys) { List<EA.Element> lst = new List<EA.Element>(); foreach (EA.Connector c in p.Connectors) { if (c.Stereotype == "XisProvider-ServiceRealization") { EA.Element el = repository.GetElementByID(c.SupplierID); lst.Add(el); } } if (lst.Count > 0) { services.Add(lst, providers[p]); } } if (services.Count > 0) { if (services.Values.Contains(true)) { if (listIS.ContextMenu == null) { listIS.ContextMenu = new XisMenu(repository, listDiagram, package, list.Element.Name + "ContextMenu", MenuType.ContextMenu); } foreach (List<EA.Element> lst in services.Keys) { if (services[lst]) { foreach (EA.Element serv in lst) { foreach (EA.Method method in serv.Methods) { if (method.Stereotype == "XisServiceMethod") { XisMenuItem menuItem = new XisMenuItem(repository, listDiagram, listIS.ContextMenu, method.Name, serv.Name + "." + method.Name); menuItem.SetValue(method.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, menuItem.GetOnTapAction(), ActionType.WebService); } } } } } } if (services.Values.Contains(false)) { if (listIS.Menu == null) { listIS.Menu = new XisMenu(repository, listDiagram, listIS, listIS.Element.Name + "Menu", MenuType.OptionsMenu); } foreach (List<EA.Element> lst in services.Keys) { if (!services[lst]) { foreach (EA.Element serv in lst) { foreach (EA.Method method in serv.Methods) { if (method.Stereotype == "XisServiceMethod") { XisMenuItem menuItem = new XisMenuItem(repository, listDiagram, listIS.Menu, method.Name, serv.Name + "." + method.Name); menuItem.SetValue(method.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, menuItem.GetOnTapAction(), ActionType.WebService); } } } } } } } } #endregion if (detailModes.Count > 0 || !string.IsNullOrEmpty(item.GetOnTapAction())) { XisInteractionSpace detailIS = CreateMasterEditorIS(package, master, listIS, useCase, be, services); foreach (ActionType key in detailModes.Keys) { XisMenuItem mItem = detailModes[key]; XisWebHelper.CreateXisAction(repository, mItem.Element, mItem.GetOnTapAction(), key, detailIS.Element.Name); CreateXisInteractionSpaceAssociation(mItem.GetOnTapAction(), listIS, detailIS); } if (!string.IsNullOrEmpty(item.GetOnTapAction())) { XisWebHelper.CreateXisAction(repository, item.Element, item.GetOnTapAction(), ActionType.Update, detailIS.Element.Name); CreateXisInteractionSpaceAssociation(item.GetOnTapAction(), listIS, detailIS); } } if (homeIS != listIS) { if (listIS.Menu == null) { listIS.Menu = new XisMenu(repository, listDiagram, listIS, listIS.Element.Name + "Menu", MenuType.OptionsMenu); } string actionBack = "backTo" + homeIS.Element.Name; XisMenuItem backMenuItem = new XisMenuItem(repository, listDiagram, listIS.Menu, "BackTo" + homeIS.Element.Name + "Item", actionBack); backMenuItem.SetValue("Go Back"); XisWebHelper.CreateXisAction(repository, backMenuItem.Element, actionBack, ActionType.Cancel); CreateXisInteractionSpaceAssociation(actionBack, listIS, homeIS); } ComputePositions(listIS, listDiagram); if (listIS.ContextMenu != null) { EA.DiagramObject obj = listIS.GetDiagramObject(listDiagram); int center = (obj.top + obj.bottom) / -2; listIS.ContextMenu.SetPosition(listDiagram, obj.right + 50, obj.right + 330, -obj.top, -obj.top + 70); ComputePositions(listIS.ContextMenu, listDiagram); // Create XisIS-MenuAssociation EA.DiagramObject sourceObj = item.GetDiagramObject(listDiagram); EA.Connector c = item.Element.Connectors.AddNew("", "Association"); c.ClientID = item.Element.ElementID; c.SupplierID = listIS.ContextMenu.Element.ElementID; c.Direction = "Source -> Destination"; c.Stereotype = "XisIS-MenuAssociation"; c.Update(); item.Element.Update(); item.Element.Connectors.Refresh(); } // Associate BE AssociateBEtoIS(listDiagram, listIS, be); if (!isStartingUC) { // TODO: Link subspaces //CreateXisInteractionSpaceAssociation(repository, "goTo" + listIS.Element.Name, homeIS, listIS); } }
private static XisInteractionSpace CreateMasterEditorIS(EA.Package package, XisEntity master, XisInteractionSpace previousIS, EA.Element useCase, EA.Element be, Dictionary<List<EA.Element>, bool> services) { EA.Diagram diagram = XisWebHelper.CreateDiagram(package, master.Element.Name + "EditorIS Diagram", "XIS-Web_Diagrams::InteractionSpaceViewModel"); XisInteractionSpace detailIS = new XisInteractionSpace(repository, package, diagram, master.Element.Name + "EditorIS", master.Element.Name + " Editor", InteractionSpaceType.MasterEntityEditor, false, true); //Image & Sitemap Creation - Define a proper source path! XisImage img = new XisImage(repository, detailIS, diagram, "../images/default.png"); XisSiteMap siteMap = new XisSiteMap(repository, detailIS, diagram); #region Process Master attributes if (!string.IsNullOrEmpty(master.Filter)) { XisForm form = new XisForm(repository, diagram, detailIS, master.Element.Name + "Form", master.Element.Name); List<EA.Attribute> filtered = GetFilteredAttributeList(master); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, master.Element.Name); } } else { XisForm form = new XisForm(repository, diagram, detailIS, master.Element.Name + "Form", master.Element.Name); foreach (EA.Attribute attr in master.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, master.Element.Name); } } #endregion #region Write Details info foreach (XisEntity d in master.Details) { if (d.Cardinality.Contains("*")) { // Needs Manager screen //string actionName = "goTo" + d.Element.Name + "ManagerIS"; //XisButton btn = new XisButton(repository, detailIS, diagram, d.Element.Name + "ManagerButton", actionName); //btn.SetValue("Manage " + d.Element.Name); //XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, managerIS.Element.Name); //CreateXisInteractionSpaceAssociation(actionName, detailIS, managerIS); XisCollapsible collapsible = CreateDetailOrRefManagerCollapsible(package, diagram, d, detailIS, useCase, true, be, d.Element.Name + "Collapsible"); } else { List<EA.Attribute> filtered = new List<EA.Attribute>(); if (!string.IsNullOrEmpty(d.Filter)) { filtered = GetFilteredAttributeList(d); } if (filtered.Count > 0) { if (filtered.Count > 3) { string actionName = "goTo" + d.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, diagram, d.Element.Name + "EditorButton", actionName); btn.SetValue(d.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, d, detailIS, useCase, true, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, diagram, detailIS, d.Element.Name + "Form", d.Element.Name); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, d.Element.Name); } if (ContainsReadDetail(useCase)) { if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, diagram, form, "Save" + d.Element.Name + "Boundary", ContainsCreateDetail(useCase), false, ContainsUpdateDetail(useCase)); b.SetEntityName(d.Element.Name); string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, b, diagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, form, diagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } else if (d.Element.Attributes.Count > 3) { string actionName = "goTo" + d.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, diagram, d.Element.Name + "EditorButton", actionName); btn.SetValue(d.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, d, detailIS, useCase, true, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, diagram, detailIS, d.Element.Name + "Form", d.Element.Name); foreach (EA.Attribute attr in d.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, d.Element.Name); } if (ContainsReadDetail(useCase)) { if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, diagram, form, "Save" + d.Element.Name + "Boundary", ContainsCreateDetail(useCase), false, ContainsUpdateDetail(useCase)); b.SetEntityName(d.Element.Name); string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, b, diagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, form, diagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } } #endregion #region Write References info foreach (XisEntity r in master.References) { if (r.Cardinality.Contains("*")) { //// Needs Manager screen //string actionName = "goTo" + r.Element.Name + "ManagerIS"; //XisButton btn = new XisButton(repository, detailIS, diagram, r.Element.Name + "ManagerButton", actionName); //btn.SetValue("Manage " + r.Element.Name); //XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, viewIS.Element.Name); //CreateXisInteractionSpaceAssociation(actionName, detailIS, viewIS); XisCollapsible collapsible = CreateDetailOrRefManagerCollapsible(package, diagram, r, detailIS, useCase, false, be, r.Element.Name); } else { List<EA.Attribute> filtered = new List<EA.Attribute>(); if (!string.IsNullOrEmpty(r.Filter)) { filtered = GetFilteredAttributeList(r); } if (filtered.Count > 0) { if (filtered.Count > 3) { string actionName = "goTo" + r.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, diagram, r.Element.Name + "EditorButton", actionName); btn.SetValue(r.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, r, detailIS, useCase, false, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, diagram, detailIS, r.Element.Name + "Form", r.Element.Name); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, r.Element.Name); } if (ContainsReadReference(useCase)) { if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, diagram, form, "Save" + r.Element.Name + "Boundary", ContainsCreateReference(useCase), false, ContainsUpdateReference(useCase)); b.SetEntityName(r.Element.Name); string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, b, diagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, form, diagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } else if (r.Element.Attributes.Count > 3) { string actionName = "goTo" + r.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, diagram, r.Element.Name + "EditorButton", actionName); btn.SetValue(r.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, r, detailIS, useCase, false, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, diagram, detailIS, r.Element.Name + "Form", r.Element.Name); foreach (EA.Attribute attr in r.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, diagram, form, attr, r.Element.Name); } if (ContainsReadReference(useCase)) { if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, diagram, form, "Save" + r.Element.Name + "Boundary", ContainsCreateReference(useCase), false, ContainsUpdateReference(useCase)); b.SetEntityName(r.Element.Name); string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, b, diagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, form, diagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } } #endregion XisMenu menu = new XisMenu(repository, diagram, detailIS, detailIS.Element.Name + "Menu", MenuType.OptionsMenu); if (ContainsCreateMaster(useCase) || ContainsUpdateMaster(useCase)) { menu.SetEntityName(master.Element.Name); string actionName = "save" + master.Element.Name; XisWidget parent = menu; if (ContainsReadMaster(useCase)) { parent = new XisVisibilityBoundary(repository, diagram, menu, "Save" + master.Element.Name + "Boundary", ContainsCreateMaster(useCase), false, ContainsUpdateMaster(useCase)); ((XisVisibilityBoundary)parent).SetEntityName(master.Element.Name); } XisMenuItem menuItem = new XisMenuItem(repository, diagram, parent, "Save" + master.Element.Name, actionName); menuItem.SetValue("Save " + master.Element.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, actionName, ActionType.OK, previousIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, previousIS); } if (ContainsDeleteMaster(useCase)) { XisWidget parent = menu; menu.SetEntityName(master.Element.Name); string actionName = "delete" + master.Element.Name; XisMenuItem contextItem = new XisMenuItem(repository, diagram, parent, "Delete" + master.Element.Name + "Item", actionName); contextItem.SetValue("Delete " + master.Element.Name); XisWebHelper.CreateXisAction(repository, contextItem.Element, actionName, ActionType.Delete); } #region Check ServiceUC Extensions if (services.Count > 0) { if (services.Values.Contains(true)) { foreach (List<EA.Element> lst in services.Keys) { if (services[lst]) { foreach (EA.Element serv in lst) { foreach (EA.Method method in serv.Methods) { if (method.Stereotype == "XisServiceMethod") { XisMenuItem menuItem = new XisMenuItem(repository, diagram, menu, method.Name, serv.Name + "." + method.Name); menuItem.SetValue(method.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, menuItem.GetOnTapAction(), ActionType.WebService); } } } } } } } #endregion string cancelAction = "cancel" + master.Element.Name; XisMenuItem cancelItem = new XisMenuItem(repository, diagram, menu, "Cancel" + master.Element.Name, cancelAction); cancelItem.SetValue("Go Back"/*+ master.Element.Name*/); XisWebHelper.CreateXisAction(repository, cancelItem.Element, cancelAction, ActionType.Cancel, previousIS.Element.Name); CreateXisInteractionSpaceAssociation(cancelAction, detailIS, previousIS); ComputePositions(detailIS, diagram); // Associate BE AssociateBEtoIS(diagram, detailIS, be); return detailIS; }
public static void ProcessDetailUseCase(EA.Package package, XisEntity master, EA.Element useCase, EA.Element be, bool isStartingUC, List<EA.Element> useCases = null, String patternType = null) { EA.Diagram detailDiagram = XisWebHelper.CreateDiagram(package, master.Element.Name + "EditorIS Diagram", "XIS-Web_Diagrams::InteractionSpaceViewModel"); XisInteractionSpace detailIS = null; if (isStartingUC && patternType != null) { detailIS = new XisInteractionSpace(repository, package, detailDiagram, master.Element.Name + "EditorIS", master.Element.Name + " Editor", InteractionSpaceType.MasterEntityEditor); } else { detailIS = new XisInteractionSpace(repository, package, detailDiagram, master.Element.Name + "EditorIS", master.Element.Name + " Editor", InteractionSpaceType.MasterEntityEditor, isStartingUC, !isStartingUC); if (isStartingUC && patternType == null) { homeIS = detailIS; } } #region Process Master attributes if (!string.IsNullOrEmpty(master.Filter)) { XisForm form = new XisForm(repository, detailDiagram, detailIS, master.Element.Name + "Form", master.Element.Name); List<EA.Attribute> filtered = GetFilteredAttributeList(master); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, master.Element.Name); } } else { XisForm form = new XisForm(repository, detailDiagram, detailIS, master.Element.Name + "Form", master.Element.Name); foreach (EA.Attribute attr in master.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, master.Element.Name); } } #endregion #region Process Details info foreach (XisEntity d in master.Details) { if (d.Cardinality.Contains("*")) { // Needs Manager screen //string actionName = "goTo" + d.Element.Name + "ManagerIS"; //XisButton btn = new XisButton(repository, detailIS, detailDiagram, d.Element.Name + "ManagerButton", actionName); //btn.SetValue("Manage " + d.Element.Name); //XisInteractionSpace managerIS = //XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, managerIS.Element.Name); //CreateXisInteractionSpaceAssociation(actionName, detailIS, managerIS); XisCollapsible collapsible = CreateDetailOrRefManagerCollapsible(package, detailDiagram, d, detailIS, useCase, true, be, d.Element.Name + "Collapsible"); } else { List<EA.Attribute> filtered = new List<EA.Attribute>(); if (!string.IsNullOrEmpty(d.Filter)) { filtered = GetFilteredAttributeList(d); } if (filtered.Count > 0) { if (filtered.Count > 3) { string actionName = "goTo" + d.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, detailDiagram, d.Element.Name + "EditorButton", actionName); btn.SetValue(d.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, d, detailIS, useCase, true, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, detailDiagram, detailIS, d.Element.Name + "Form", d.Element.Name); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, d.Element.Name); } if (ContainsReadDetail(useCase)) { if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, detailDiagram, form, "Save" + d.Element.Name + "Boundary", ContainsCreateDetail(useCase), false, ContainsUpdateDetail(useCase)); b.SetEntityName(d.Element.Name); string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, b, detailDiagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, detailIS, detailDiagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } else if (d.Element.Attributes.Count > 3) { string actionName = "goTo" + d.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, detailDiagram, d.Element.Name + "EditorButton", actionName); btn.SetValue(d.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, d, detailIS, useCase, true, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, detailDiagram, detailIS, d.Element.Name + "Form", d.Element.Name); foreach (EA.Attribute attr in d.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, d.Element.Name); } if (ContainsReadDetail(useCase)) { if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, detailDiagram, form, "Save" + d.Element.Name + "Boundary", ContainsCreateDetail(useCase), false, ContainsUpdateDetail(useCase)); b.SetEntityName(d.Element.Name); string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, b, detailDiagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateDetail(useCase) || ContainsUpdateDetail(useCase)) { string actionName = "save" + d.Element.Name; XisButton btn = new XisButton(repository, detailIS, detailDiagram, d.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + d.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } } #endregion #region Process References info foreach (XisEntity r in master.References) { if (r.Cardinality.Contains("*")) { // Needs Manager screen //string actionName = "goTo" + r.Element.Name + "ManagerIS"; //XisButton btn = new XisButton(repository, detailIS, detailDiagram, r.Element.Name + "ManagerButton", actionName); //btn.SetValue("Manage " + r.Element.Name); //XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, viewIS.Element.Name); //CreateXisInteractionSpaceAssociation(actionName, detailIS, viewIS); XisCollapsible collapsible = CreateDetailOrRefManagerCollapsible(package, detailDiagram, r, detailIS, useCase, false, be, r.Element.Name + "Collapsible"); } else { List<EA.Attribute> filtered = new List<EA.Attribute>(); if (!string.IsNullOrEmpty(r.Filter)) { filtered = GetFilteredAttributeList(r); } if (filtered.Count > 0) { if (filtered.Count > 3) { string actionName = "goTo" + r.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, detailDiagram, r.Element.Name + "EditorButton", actionName); btn.SetValue(r.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, r, detailIS, useCase, false, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, detailDiagram, detailIS, r.Element.Name + "Form", r.Element.Name); foreach (EA.Attribute attr in filtered) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, r.Element.Name); } if (ContainsReadReference(useCase)) { if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, detailDiagram, form, "Save" + r.Element.Name + "Boundary", ContainsCreateReference(useCase), false, ContainsUpdateReference(useCase)); b.SetEntityName(r.Element.Name); string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, b, detailDiagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, detailIS, detailDiagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } else if (r.Element.Attributes.Count > 3) { string actionName = "goTo" + r.Element.Name + "EditorIS"; XisButton btn = new XisButton(repository, detailIS, detailDiagram, r.Element.Name + "EditorButton", actionName); btn.SetValue(r.Element.Name); XisInteractionSpace editorIS = CreateDetailOrRefEditorIS(package, r, detailIS, useCase, false, be); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.Navigate, editorIS.Element.Name); CreateXisInteractionSpaceAssociation(actionName, detailIS, editorIS); } else { XisForm form = new XisForm(repository, detailDiagram, detailIS, r.Element.Name + "Form", r.Element.Name); foreach (EA.Attribute attr in r.Element.Attributes) { XisWebHelper.ProcessXisAttribute(repository, detailDiagram, form, attr, r.Element.Name); } if (ContainsReadReference(useCase)) { if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { XisVisibilityBoundary b = new XisVisibilityBoundary(repository, detailDiagram, form, "Save" + r.Element.Name + "Boundary", ContainsCreateReference(useCase), false, ContainsUpdateReference(useCase)); b.SetEntityName(r.Element.Name); string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, b, detailDiagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } else if (ContainsCreateReference(useCase) || ContainsUpdateReference(useCase)) { string actionName = "save" + r.Element.Name; XisButton btn = new XisButton(repository, detailIS, detailDiagram, r.Element.Name + "SaveButton", actionName); btn.SetValue("Save " + r.Element.Name); XisWebHelper.CreateXisAction(repository, btn.Element, actionName, ActionType.OK); } } } } #endregion // Navigation between main UC and the others if (patternType != null) { AddToHomeISByPattern(useCase, detailIS, patternType); } else if (isStartingUC) { if (useCases != null) { AssociateFirstSubSpaces(detailDiagram, useCases, detailIS, be.ElementID, master.Element.Name); } } if (ContainsCreateMaster(useCase) || ContainsUpdateMaster(useCase)) { XisWidget parent = detailIS; if (ContainsReadMaster(useCase)) { parent = new XisVisibilityBoundary(repository, detailDiagram, detailIS, "Save" + master.Element.Name + "Boundary", ContainsCreateMaster(useCase), false, ContainsUpdateMaster(useCase)); ((XisVisibilityBoundary)parent).SetEntityName(master.Element.Name); } XisMenu menu = new XisMenu(repository, detailDiagram, parent, detailIS.Element.Name + "Menu", MenuType.OptionsMenu); menu.SetEntityName(master.Element.Name); string actionName = "save" + master.Element.Name; XisMenuItem menuItem = new XisMenuItem(repository, detailDiagram, menu, "Save" + master.Element.Name, actionName); menuItem.SetValue("Save " + master.Element.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, actionName, ActionType.OK); detailIS.Menu = menu; } #region Check ServiceUC Extensions Dictionary<List<EA.Element>, bool> services = new Dictionary<List<EA.Element>, bool>(); if (useCase.Connectors.Count > 0) { List<EA.Element> extends = new List<EA.Element>(); Dictionary<EA.Element, bool> providers = new Dictionary<EA.Element, bool>(); foreach (EA.Connector conn in useCase.Connectors) { if (conn.Stereotype == "extend") { EA.Element el = repository.GetElementByID(conn.ClientID); extends.Add(el); } } foreach (EA.Element e in extends) { bool hasBE = false; EA.Element provider = null; foreach (EA.Connector conn in e.Connectors) { if (conn.Stereotype == "XisServiceUC-BEAssociation") { hasBE = true; } else if (conn.Stereotype == "XisServiceUC-ProviderAssociation") { provider = repository.GetElementByID(conn.SupplierID); providers.Add(provider, false); } } if (provider != null && hasBE) { providers[provider] = true; } } foreach (EA.Element p in providers.Keys) { List<EA.Element> lst = new List<EA.Element>(); foreach (EA.Connector c in p.Connectors) { if (c.Stereotype == "XisProvider-ServiceRealization") { EA.Element el = repository.GetElementByID(c.SupplierID); lst.Add(el); } } if (lst.Count > 0) { services.Add(lst, providers[p]); } } if (services.Count > 0) { if (detailIS.Menu == null) { detailIS.Menu = new XisMenu(repository, detailDiagram, detailIS, detailIS.Element.Name + "Menu", MenuType.OptionsMenu); } foreach (List<EA.Element> lst in services.Keys) { foreach (EA.Element serv in lst) { foreach (EA.Method method in serv.Methods) { if (method.Stereotype == "XisServiceMethod") { XisMenuItem menuItem = new XisMenuItem(repository, detailDiagram, detailIS.Menu, method.Name, serv.Name + "." + method.Name); menuItem.SetValue(method.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, menuItem.GetOnTapAction(), ActionType.WebService); } } } } } } #endregion if (homeIS != detailIS) { if (detailIS.Menu == null) { detailIS.Menu = new XisMenu(repository, detailDiagram, detailIS, detailIS.Element.Name + "Menu", MenuType.OptionsMenu); } string actionBack = "backTo" + homeIS.Element.Name; XisMenuItem backMenuItem = new XisMenuItem(repository, detailDiagram, detailIS.Menu, "BackTo" + homeIS.Element.Name + "Item", actionBack); backMenuItem.SetValue("Go Back"); XisWebHelper.CreateXisAction(repository, backMenuItem.Element, actionBack, ActionType.Cancel); CreateXisInteractionSpaceAssociation(actionBack, detailIS, homeIS); } ComputePositions(detailIS, detailDiagram); // Associate BE AssociateBEtoIS(detailDiagram, detailIS, be); if (detailIS.GetDiagramObject(nsDiagram) == null && isStartingUC) { detailIS.SetPosition(nsDiagram, 355, 445, 10, 80); } if (!isStartingUC) { // TODO: Link subspaces //CreateXisInteractionSpaceAssociation("goTo" + detailIS.Element.Name, homeIS, detailIS); } }
public static void ProcessServiceUseCase(EA.Package package, XisEntity master, EA.Element useCase, EA.Element be, bool isStartingUC, List<EA.Element> useCases = null, String patternType = null) { // Create IS Diagram string serviceISName = useCase.Name.Replace(" ", "") + "IS"; EA.Diagram serviceDiagram = XisWebHelper.CreateDiagram(package, serviceISName + " Diagram", "XIS-Web_Diagrams::InteractionSpaceViewModel"); XisInteractionSpace serviceIS = null; if (isStartingUC && patternType != null) { serviceIS = new XisInteractionSpace(repository, package, serviceDiagram, serviceISName, useCase.Name, InteractionSpaceType.ServiceInteractionSpace); } else { serviceIS = new XisInteractionSpace(repository, package, serviceDiagram, serviceISName, useCase.Name, InteractionSpaceType.ServiceInteractionSpace,isStartingUC, !isStartingUC); if (isStartingUC && patternType == null) { homeIS = serviceIS; } } // List Creation XisList list = new XisList(repository, serviceDiagram, serviceIS, master.Element.Name + "List"); list.SetEntityName(master.Element.Name); XisListItem item = new XisListItem(repository, serviceDiagram, list, list.Element.Name + "Item"); if (master.Element.Attributes.Count > 1) { EA.Attribute first = master.Element.Attributes.GetAt(0); EA.Attribute second = master.Element.Attributes.GetAt(1); XisLabel lbl1 = new XisLabel(repository, item, serviceDiagram, first.Name + "Lbl"); lbl1.SetEntityAttributeName(master.Element.Name + "." + first.Name); XisLabel lbl2 = new XisLabel(repository, item, serviceDiagram, second.Name + "Lbl"); lbl2.SetEntityAttributeName(master.Element.Name + "." + second.Name); } else if (master.Element.Attributes.Count == 1) { EA.Attribute attr = master.Element.Attributes.GetAt(0); item.SetValueFromExpression(master.Element.Name + "." + attr.Name); } // Navigation between home UC and the others if (patternType != null) { AddToHomeISByPattern(useCase, serviceIS, patternType); } else if (isStartingUC) { if (useCases != null) { AssociateFirstSubSpaces(serviceDiagram, useCases, serviceIS, be.ElementID, master.Element.Name); } } XisMenu menu = new XisMenu(repository, serviceDiagram, serviceIS, serviceIS.Element.Name + "Menu", MenuType.OptionsMenu); List<EA.Element> providers = new List<EA.Element>(); EA.Element provider = null; foreach (EA.Connector conn in useCase.Connectors) { if (conn.Stereotype == "XisServiceUC-ProviderAssociation") { provider = repository.GetElementByID(conn.SupplierID); providers.Add(provider); } } List<EA.Element> services = new List<EA.Element>(); foreach (EA.Element p in providers) { foreach (EA.Connector c in p.Connectors) { if (c.Stereotype == "XisProvider-ServiceRealization") { EA.Element el = repository.GetElementByID(c.SupplierID); services.Add(el); } } } foreach (EA.Element serv in services) { foreach (EA.Method method in serv.Methods) { if (method.Stereotype == "XisServiceMethod") { XisMenuItem menuItem = new XisMenuItem(repository, serviceDiagram, menu, method.Name, serv.Name + "." + method.Name); menuItem.SetValue(method.Name); XisWebHelper.CreateXisAction(repository, menuItem.Element, menuItem.GetOnTapAction(), ActionType.WebService); } } } serviceIS.Menu = menu; if (homeIS != serviceIS) { string actionBack = "backTo" + homeIS.Element.Name; XisMenuItem backMenuItem = new XisMenuItem(repository, serviceDiagram, serviceIS.Menu, "BackTo" + homeIS.Element.Name + "Item", actionBack); backMenuItem.SetValue("Go Back"); XisWebHelper.CreateXisAction(repository, backMenuItem.Element, actionBack, ActionType.Cancel); CreateXisInteractionSpaceAssociation(actionBack, serviceIS, homeIS); } ComputePositions(serviceIS, serviceDiagram); // Associate BE AssociateBEtoIS(serviceDiagram, serviceIS, be); }