public static bool openSelectedMethodSDM(EA.Diagram actDiag, SQLMethod meth, SQLRepository sqlRepository, out SQLElement methParent, out SQLElement container) { SQLTaggedValue aTag = null; methParent = sqlRepository.GetElementByID(meth.ParentID); container = null; foreach (SQLElement sdmContainer in methParent.Elements) { aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName); if (aTag != null) { if (aTag.Value == meth.MethodGUID.ToString()) { container = sdmContainer; break; } } } SQLDiagram sdmDiagg = null; if (container != null) { foreach (SQLDiagram sdmDiag in container.Diagrams) { sdmDiagg = sdmDiag; Navigator.addAnchorEntry(sdmDiag.DiagramID, actDiag.DiagramID); sqlRepository.OpenDiagram(sdmDiag.DiagramID); setAnchorElementTags(sqlRepository, actDiag, container); return(true); } } return(false); }
public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository) { Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>(); String ruleElements = repository.SQLQuery("select * from t_object where Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(ruleElements, "Row")) { if (row != "") { SQLElement ruleElement = new SQLElement(repository, row); SQLDiagram ruleDiagram = ruleElement.Diagrams.GetAt(0) as SQLDiagram; EA.Diagram rruleDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, ruleDiagram) as EA.Diagram; foreach (EA.DiagramObject diagObject in rruleDiagram.DiagramObjects) { SQLElement diagElement = repository.GetElementByID(diagObject.ElementID); if (diagElement.ParentID != ruleElement.ElementID && (diagElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype || diagElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)) { results.Add(diagElement, "Element is no child of Rule: " + ruleElement.Name + " but is contained on its Rule Diagram"); } } } } return(results); }
private void startValidation(EA.ObjectType ot, Object eaObject, SQLRepository repository, Boolean singleRulecheck, Boolean validateAll) { this.fullValidation = validateAll; this.singleRuleCheck = singleRulecheck; switch (ot) { //do rules for elements and their attributes/methods case EA.ObjectType.otElement: validateEAElement(eaObject, repository, singleRulecheck); break; //do rules for connectors case EA.ObjectType.otConnector: SQLConnector connector = eaObject as SQLConnector; RuleControl.deleteRuleResults(EA.ObjectType.otConnector, connector.ConnectorID); RuleControl.doRules(connector, repository); break; //do rules for attributes case EA.ObjectType.otAttribute: SQLAttribute attribute = eaObject as SQLAttribute; RuleControl.deleteRuleResults(EA.ObjectType.otAttribute, attribute.AttributeID); RuleControl.doRules(attribute, repository); break; //do rules for methods case EA.ObjectType.otMethod: SQLMethod method = eaObject as SQLMethod; RuleControl.deleteRuleResults(EA.ObjectType.otMethod, method.MethodID); RuleControl.doRules(method, repository); break; //do rules for packages case EA.ObjectType.otPackage: validatePackage(eaObject, repository, singleRulecheck, validateAll); break; case EA.ObjectType.otDiagram: SQLDiagram diagram = eaObject as SQLDiagram; RuleControl.deleteRuleResults(EA.ObjectType.otDiagram, diagram.DiagramID); RuleControl.doRules(diagram, repository); break; } if (DoGlobalRules) { RuleControl.doGlobalRules(repository); } endValidation(repository); }
public void doSingleDiagramRule(SQLDiagram diagram, SQLRepository repository, Rule rule) { if (rule is DiagramRule && (ruleExecutionPoint == rule.getRuleExecutionPoint() || ruleExecutionPoint == RuleExecutionPoint.OnRequest)) { foreach (RuleResult result in rule.getRuleResult(diagram, repository)) { if (!result.Passed) { handleRuleResult(result, repository); } } } }
public static RuleResult computeRuleResult(Rule rule, SQLDiagram diag, String ruleOutput) { Boolean passed = ruleOutput == ""; RuleResult ruleResult = new RuleResult(); ruleResult.Passed = passed; ruleResult.Rule = rule; ruleResult.RuleID = rule.getRuleID(); ruleResult.EaObject = diag; ruleResult.ObjectType = EA.ObjectType.otDiagram; ruleResult.ObjectID = diag.DiagramID; ruleResult.NameOfObject = diag.Name; ruleResult.ErrorOutput = ruleOutput; ruleResult.ErrorLevel = rule.getErrorLevel(diag, ruleOutput); return(ruleResult); }
public override List <String> doRule(SQLElement eaElement, SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { if (eaElement.Diagrams.Count == 1) { SQLDiagram evacDiagram = eaElement.Diagrams.GetAt(0); if (evacDiagram.Name != eaElement.Name) { results.Add("Diagram of evacuated storypattern must have the same name as the storypattern itself"); } } } return(results); }
private void buttonVerboseGlobal_Click(object sender, EventArgs e) { String sqlQuery = "select * from t_diagram"; foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(repository.SQLQuery(sqlQuery), "Row")) { if (row != "") { SQLDiagram diagram = new SQLDiagram(repository, row); if (SDMModelingMain.SdmDiagramMetatype.Contains(diagram.MetaType)) { EA.Diagram rdiagram = repository.GetOriginalRepository().GetDiagramByID(diagram.DiagramID); toggleDiagramVerboseStatus(rdiagram); } } } }
private void updateDiagramMetaType(String oldMetaType, String newMetaType, EA.Repository repository) { SQLRepository sqlRep = new SQLRepository(repository, false); String sqlString = "select Diagram_ID from t_diagram where StyleEx LIKE '*" + oldMetaType + "*'"; String result = repository.SQLQuery(sqlString); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLDiagram diag = new SQLDiagram(sqlRep, row); EA.Diagram rdiag = EAUtil.sqlEAObjectToOriginalObject(sqlRep, diag) as EA.Diagram; String StyleEx = rdiag.StyleEx.Replace(oldMetaType, newMetaType); sqlString = "UPDATE t_diagram SET StyleEx = '" + StyleEx + "' WHERE Diagram_ID = " + rdiag.DiagramID; repository.Execute(sqlString); } } }
public static SQLElement getContainingElement(Object eaObject, SQLRepository repo) { try { if (eaObject is SQLElement) { return(eaObject as SQLElement); } else if (eaObject is SQLAttribute) { SQLElement parent = repo.GetElementByID((eaObject as SQLAttribute).ParentID); return(parent); } else if (eaObject is SQLMethod) { SQLElement parent = repo.GetElementByID((eaObject as SQLMethod).ParentID); return(parent); } else if (eaObject is SQLConnector) { SQLElement parent = repo.GetElementByID((eaObject as SQLConnector).ClientID); return(parent); } else if (eaObject is SQLDiagram) { SQLDiagram dia = eaObject as SQLDiagram; if (dia.ParentID != 0) { return(repo.GetElementByID((eaObject as SQLDiagram).ParentID)); } else if (dia.getRealDiagram().PackageID != 0) { return(repo.GetPackageByID(dia.getRealDiagram().PackageID).Element); } } } catch { return(null); } return(null); }
public override void dataReveiced(List <string> receivedLines) { for (int i = 0; i < receivedLines.Count; i++) { String line = receivedLines[i]; if (line == "SETUP_HIGHLIGHT_OBJECT") { setIsActive(true); } else if (line == "TEARDOWN_HIGHLIGHT_OBJECT") { setIsActive(false); } else if (isActive()) { try { PropertyObject propertyObject = ValidationPropertyUtil.computeObjectFromPath(sqlRep, line); EAUtil.markObjectInProjectBrowser(propertyObject.EAObject, sqlRep); if (propertyObject.EAObject is SQLDiagram) { SQLDiagram sqlDiagram = propertyObject.EAObject as SQLDiagram; sqlRep.OpenDiagram(sqlDiagram.DiagramID); Main.tcpServerFunctions.addStatusMessage("Displayed TGG Rule diagram: " + line); } else { int onDiagrams = EAUtil.markObjectOnDiagram(propertyObject.EAObject, sqlRep); Main.tcpServerFunctions.addStatusMessage("Displayed object on diagram: " + line); } } catch (NullReferenceException) { //something went wrong while computing the path Main.tcpServerFunctions.addStatusMessage("An error occured while parsing the highlight object path from Eclipse: " + line); } } } stream.WriteByte((byte)10); }
/// <summary> /// Defines what happens if the user doubleclicks on SDM related Elements. /// </summary> /// <param name="repository"></param> /// <param name="GUID"></param> /// <param name="ot"></param> /// <returns>True if the EA Dialogs should not be openend. False if the standard EA Dialogs should be opened. /// </returns> public bool EA_OnContextItemDoubleClicked(EA.Repository repository, String GUID, EA.ObjectType ot) { SQLRepository sqlRepository = new SQLRepository(repository, false); EA.Diagram actDiag = repository.GetCurrentDiagram(); SQLMethod meth = sqlRepository.GetMethodByGuid(GUID); SQLElement elem = sqlRepository.GetElementByGuid(GUID); SQLConnector con = sqlRepository.GetConnectorByGuid(GUID); if (actDiag != null) { if (ECOREModelingMain.EcoreDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod) { SQLElement methParent; SQLElement container; if (!openSelectedMethodSDM(actDiag, meth, sqlRepository, out methParent, out container)) { if (methParent.Stereotype == ECOREModelingMain.EClassStereotype) { CreateSDMDialog createSdmDialog = new CreateSDMDialog(); if (createSdmDialog.ShowDialog() == DialogResult.OK) { createStoryDiagram(meth, repository, actDiag); } return(true); } } else { return(true); } } else if (SdmDiagramMetatype.Contains(actDiag.MetaType)) { repository.SaveDiagram(actDiag.DiagramID); if (elem != null) { if (elem.Stereotype == SDMModelingMain.ObjectVariableStereotype) { ObjectVariable ov = new ObjectVariable(elem, sqlRepository); OvDialog objectVariableDialogue = new OvDialog(sqlRepository, ov); objectVariableDialogue.ShowDialog(); return(true); } else if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype || elem.Stereotype == SDMModelingMain.StatementNodeStereotype) { SQLTaggedValue extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName); if (extractedTag == null) { SQLTaggedValue oldExtractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, "evacuated"); if (oldExtractedTag != null) { EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, oldExtractedTag.Value); } else { EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "false"); } extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName); } if (extractedTag != null && extractedTag.Value == Main.TrueValue) { SQLDiagram diagram = (SQLDiagram)elem.Diagrams.GetAt(0); Navigator.addAnchorEntry(diagram.DiagramID, actDiag.DiagramID); repository.OpenDiagram(diagram.DiagramID); } else { if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype) { ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StoryNode(sqlRepository, elem), sqlRepository); } else if (elem.Stereotype == SDMModelingMain.StatementNodeStereotype) { ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StatementNode(sqlRepository, elem), sqlRepository); } } return(true); } else if (elem.Stereotype == SDMModelingMain.StopNodeStereotype) { StopNode stopNode = new StopNode(sqlRepository, elem); StopNodeForm sNodeForm = new StopNodeForm(stopNode, sqlRepository); return(true); } else if (elem.Stereotype == TGGModelingMain.CSPConstraintStereotype) { SDMCSPDialog sdmCspDialog = new SDMCSPDialog(elem, sqlRepository); sdmCspDialog.ShowDialog(); return(true); } } if (con != null) { if (con.Stereotype == SDMModelingMain.LinkVariableStereotype) { LinkVariablePropertiesForm linkVariableDialogue = new LinkVariablePropertiesForm(new LinkVariable(con, sqlRepository), sqlRepository, true); return(true); } else if (con.Type == Main.EAControlFlowType) { ActivityEdge activityEdge = new ActivityEdge(sqlRepository, con); ActivityEdgePropertiesForm activityEdgeDialog = new ActivityEdgePropertiesForm(activityEdge, repository); return(true); } else if (con.Stereotype == SDMModelingMain.BindingExpressionLinkStereotype) { SQLElement targetElement = sqlRepository.GetElementByID(con.SupplierID); ObjectVariable ov = new ObjectVariable(targetElement, sqlRepository); OvDialog ovDialog = new OvDialog(sqlRepository, ov); ovDialog.showTab(2); ovDialog.ShowDialog(); return(true); } } if (ot == EA.ObjectType.otDiagram) { EA.Diagram diag = (EA.Diagram)repository.GetDiagramByGuid(GUID); EA.Element activity = null; SQLTaggedValue evacuatedTag = null; if (diag.ParentID != 0) { activity = repository.GetElementByID(diag.ParentID); evacuatedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sqlRepository.GetElementByID(activity.ElementID), Main.MoflonExtractedStoryPatternTaggedValueName); } if (evacuatedTag != null && evacuatedTag.Value == Main.TrueValue) { StoryNode activityNode = new StoryNode(sqlRepository, sqlRepository.GetElementByID(activity.ElementID)); ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(activityNode, sqlRepository); return(true); } } //sqlRepository.ReloadDiagram(actDiag.DiagramID); } else if (TGGModelingMain.TggRulesDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod) { EA.TaggedValue aTag = null; EA.Element methParent = repository.GetElementByID(meth.ParentID); EA.Element container = null; foreach (EA.Element sdmContainer in methParent.Elements) { if (sdmContainer.Stereotype == SDMModelingMain.SdmContainerStereotype) { aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName); if (aTag.Value == meth.MethodGUID.ToString()) { container = sdmContainer; break; } } } EA.Diagram sdmDiagg = null; if (container != null) { foreach (EA.Diagram sdmDiag in container.Diagrams) { sdmDiagg = sdmDiag; repository.OpenDiagram(sdmDiag.DiagramID); return(true); } } if (sdmDiagg == null && container == null) // no SDM Diagram exists { if (methParent.Stereotype == TGGModelingMain.TggRuleStereotype) { createStoryDiagram(meth, repository, actDiag); return(true); } } } } return(false); }
public abstract void doRuleQuickFix(SQLDiagram eaDiagram, EA.Repository repository, int i, String errorMessage);
public abstract List <String> doRule(SQLDiagram eaDiagram, SQLRepository repository);
public override List <String> doRule(object eaObject, SQLRepository repository) { SQLDiagram diagram = eaObject as SQLDiagram; return(doRule(diagram, repository)); }