示例#1
0
        public void processObjectVariable(SQLElement objectVariable)
        {
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(objectVariable, Main.MoflonExportTreeTaggedValueName);

            ObjectVariable ov = new ObjectVariable(objectVariable, repository);

            ov.loadTreeFromTaggedValue();

            SQLElement classifier = EAUtil.getClassifierElement(repository, objectVariable.ClassifierID);

            if (classifier != null)
            {
                Export.computeAndAddToDependencies(repository, classifier);
            }

            MocaNode ovMocaNode = new MocaNode();

            ovMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement);

            ov.addAttributesDuringExport(ovMocaNode);

            this.currentNode.appendChildNode(ovMocaNode);

            foreach (SQLConnector linkVariable in objectVariable.Connectors)
            {
                if ((linkVariable.Stereotype == SDMModelingMain.LinkVariableStereotype || linkVariable.Stereotype == "SDM_Association") && linkVariable.ClientID == objectVariable.ElementID)
                {
                    this.currentNode = ovMocaNode.getChildNodeWithName(ObjectVariable.OutgoingLinksNodeName);
                    processLinkVariable(linkVariable);
                }
            }
        }
示例#2
0
        private void btnOKClick(object sender, EventArgs e)
        {
            DialogClosed = true;
            Boolean valid = false;

            valid  = ovPropertiesControl.btnOK_Click();
            valid &= ovConstraintControl.handleCloseAction();
            if (valid)
            {
                forceClose = true;
                if (objectVariable.BindingState == BindingState.BOUND)
                {
                    objectVariable.BindingExpression = ovBindingProvider.getExpression();
                }
                else
                {
                    objectVariable.BindingExpression = null;
                }
                objectVariable.saveTreeToEATaggedValue(true);
                Close();

                objectVariable.loadTreeFromTaggedValue();
                objectVariable.saveTreeToEATaggedValue(true);
            }
        }
示例#3
0
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
            {
                ObjectVariable ov = new ObjectVariable(eaElement, repository);
                ov.loadTreeFromTaggedValue();
                if (ov.BindingExpression != null)
                {
                    if (!ConsistencyUtil.checkExpression(eaElement, ov.BindingExpression, repository))
                    {
                        results.Add("BindingExpression is Invalid: (" + ov.BindingExpression.ToString() + ")");
                    }
                }
            }
            return(results);
        }
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
            {
                ObjectVariable ov    = new ObjectVariable(eaElement, repository);
                Boolean        valid = ov.loadTreeFromTaggedValue();

                valid = ov.Guid == eaElement.ElementGUID && valid;

                if (!valid)
                {
                    results.Add("ObjectVariable is invalid and has to be updated manually");
                }
            }
            return(results);
        }
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype || eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
            {
                ObjectVariable tggOv = ObjectVariable.createCorrectOvType(eaElement, repository);
                tggOv.loadTreeFromTaggedValue();
                if (tggOv.BindingOperator == Modeling.SDMModeling.SDMExportWrapper.patterns.BindingOperator.CREATE && tggOv.Constraints.Count > 0)
                {
                    results.Add("Constraints and BindingOperator create is not allowed");
                }
                else if (tggOv.BindingOperator == Modeling.SDMModeling.SDMExportWrapper.patterns.BindingOperator.CHECK_ONLY && tggOv.AttributeAssignments.Count > 0)
                {
                    results.Add("AttributeAssigmnments and BindingOperator check_only is not allowed");
                }

                else if (tggOv.BindingState == Modeling.SDMModeling.SDMExportWrapper.patterns.BindingState.BOUND)
                {
                    Boolean valid = false;
                    foreach (SQLConnector con in eaElement.Connectors)
                    {
                        if (con.SupplierID == eaElement.ElementID && con.Type == Main.EADependencyType)
                        {
                            valid = true;
                        }
                    }
                    if (!valid)
                    {
                        SQLTaggedValue refinedtag = EAUtil.findTaggedValue(eaElement, TGGObjectVariable.RefinedTaggedValueName);
                        if (refinedtag == null || refinedtag.Value == "false")
                        {
                            results.Add("Bound TGG ObjectVariables must be the target of a TGG BindingExpression");
                        }
                    }
                }
            }
            return(results);
        }
示例#6
0
 internal static void setAllMceVisTags(bool p, SQLRepository repository, EA.Diagram currentDiagram)
 {
     EA.Diagram diagram = currentDiagram;
     if (diagram == null)
     {
         diagram = repository.GetTreeSelectedObject() as EA.Diagram;
     }
     repository.SaveDiagram(diagram.DiagramID);
     foreach (EA.DiagramObject diagObj in diagram.DiagramObjects)
     {
         EA.Element correspondingElement = repository.GetOriginalRepository().GetElementByID(diagObj.ElementID);
         if (correspondingElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
             correspondingElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
             correspondingElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
         {
             setSingleOvMceVisualizationTag(p, correspondingElement, repository);
             ObjectVariable ov = new ObjectVariable(repository.GetElementByID(correspondingElement.ElementID), repository);
             ov.loadTreeFromTaggedValue();
             setOvMethodCallExpressionGui(ov);
         }
     }
 }
示例#7
0
        public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
                eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
            {
                ObjectVariable ov = new ObjectVariable(eaElement, repository);
                ov.loadTreeFromTaggedValue();

                String output = "";

                foreach (Constraint constraint in ov.Constraints)
                {
                    if (!ConsistencyUtil.checkConstraint(eaElement, constraint, repository))
                    {
                        output += " - (" + constraint.ToString() + ")";
                    }
                }

                foreach (AttributeAssignment attrAssignment in ov.AttributeAssignments)
                {
                    if (!ConsistencyUtil.checkAttributeAssignment(eaElement, attrAssignment, repository))
                    {
                        output += " - (" + attrAssignment.ToString() + ")";
                    }
                }

                if (output != "")
                {
                    output = "ObjectVariable contains invalid Constraints / Assignments: " + output;
                    results.Add(output);
                }
            }

            return(results);
        }
示例#8
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BindingSemantics bindingSemantics = BindingSemantics.MANDATORY;
            BindingOperator  bindingOperator  = BindingOperator.CHECK_ONLY;

            if (radioButtonMandatory.Checked)
            {
                bindingSemantics = BindingSemantics.MANDATORY;
            }
            else if (radioButtonNegative.Checked)
            {
                bindingSemantics = BindingSemantics.NEGATIVE;
            }
            if (radioButtonDestroy.Checked)
            {
                bindingOperator = BindingOperator.DESTROY;
            }
            else if (radioButtonCreate.Checked)
            {
                bindingOperator = BindingOperator.CREATE;
            }
            else if (radioButtonCheckOnly.Checked)
            {
                bindingOperator = BindingOperator.CHECK_ONLY;
            }


            foreach (EA.Element selectedOv in this.selectedObjectVariables)
            {
                ObjectVariable currentOV = ObjectVariable.createCorrectOvType(repository.GetElementByID(selectedOv.ElementID), repository);
                currentOV.loadTreeFromTaggedValue();

                currentOV.BindingSemantics = bindingSemantics;
                currentOV.BindingOperator  = bindingOperator;

                if (bindingOperator == BindingOperator.CHECK_ONLY)
                {
                    TGGModelingUtil.assignmentsToConstraints(currentOV, repository);
                }
                else if (bindingOperator == BindingOperator.CREATE)
                {
                    TGGModelingUtil.constraintsToAssignments(currentOV, repository);
                }

                currentOV.saveTreeToEATaggedValue(true);
            }

            if (checkBoxLinksToo.Checked)
            {
                foreach (EA.Connector selectedLink in this.selectedLinkVariables)
                {
                    LinkVariable lv = null;
                    if (selectedLink.Stereotype == SDMModelingMain.LinkVariableStereotype)
                    {
                        lv = new LinkVariable(repository.GetConnectorByID(selectedLink.ConnectorID), repository);
                    }
                    else if (selectedLink.Stereotype == TGGModelingMain.TggLinkVariableStereotype)
                    {
                        lv = new TGGLinkVariable(repository.GetConnectorByID(selectedLink.ConnectorID), repository);
                    }

                    lv.loadTreeFromTaggedValue();
                    lv.BindingOperator  = bindingOperator;
                    lv.BindingSemantics = bindingSemantics;

                    lv.saveTreeToEATaggedValue(true);
                }
            }
            repository.ReloadDiagram(repository.GetCurrentDiagram().DiagramID);
            Close();
        }
示例#9
0
        private void buttonJump_Click(object sender, EventArgs e)
        {
            EA.Diagram currentDiagram = repository.GetCurrentDiagram();

            Boolean handled = false;

            if (currentDiagram != null && currentDiagram.SelectedObjects.Count == 1)
            {
                EA.DiagramObject selectedDiagramObject = currentDiagram.SelectedObjects.GetAt(0) as EA.DiagramObject;
                SQLElement       selectedElement       = repository.GetElementByID(selectedDiagramObject.ElementID);

                EA.Diagram calledDiagram = null;

                Expression callExpression = null;

                if (selectedElement.Stereotype == SDMModelingMain.StatementNodeStereotype)
                {
                    StatementNode statementNode = new StatementNode(repository, selectedElement);
                    statementNode.loadTreeFromTaggedValue();
                    callExpression = statementNode.StatementExpression;
                }
                else if (selectedElement.Stereotype == SDMModelingMain.ObjectVariableStereotype)
                {
                    ObjectVariable ov = new ObjectVariable(selectedElement, repository);
                    ov.loadTreeFromTaggedValue();
                    callExpression = ov.BindingExpression;
                }
                else if (selectedElement.Stereotype == SDMModelingMain.StopNodeStereotype)
                {
                    StopNode stopNode = new StopNode(repository, selectedElement);
                    stopNode.loadTreeFromTaggedValue();
                    callExpression = stopNode.ReturnValue;
                }

                if (callExpression is MethodCallExpression)
                {
                    MethodCallExpression mcE          = callExpression as MethodCallExpression;
                    SQLMethod            calledMethod = repository.GetMethodByGuid(mcE.MethodGuid);
                    if (calledMethod != null)
                    {
                        int sdmDiagramId = SDMUtil.getSDMDiagramID(repository, calledMethod);
                        if (sdmDiagramId != SDMUtil.UNKNOWN_SDM_DIAGRAM_ID)
                        {
                            calledDiagram = repository.GetOriginalRepository().GetDiagramByID(sdmDiagramId);
                        }
                    }
                }

                if (calledDiagram != null)
                {
                    Navigator.addAnchorEntry(calledDiagram.DiagramID, currentDiagram.DiagramID);
                    repository.OpenDiagram(calledDiagram.DiagramID);
                    handled = true;
                }
            }

            if (!handled)
            {
                if (currentDiagram != null)
                {
                    Navigator.jumpToAnchorSuccessor(repository.GetOriginalRepository(), currentDiagram.DiagramID);
                }
            }
        }
        public Boolean EA_OnPostNewConnector(SQLRepository sqlRep, EA.Connector actCon, EA.Diagram currentDiagram)
        {
            if (SdmDiagramMetatype.Contains(currentDiagram.MetaType))
            {
                sqlRep.SaveDiagram(currentDiagram.DiagramID);
                if (actCon.Stereotype == SDMModelingMain.LinkVariableStereotype)
                {
                    //save initial data for linkVariable
                    LinkVariable   linkVariable = new LinkVariable(sqlRep.GetConnectorByID(actCon.ConnectorID), sqlRep);
                    ObjectVariable newClient    = new ObjectVariable(sqlRep.GetElementByID(actCon.ClientID), sqlRep);
                    ObjectVariable newSupplier  = new ObjectVariable(sqlRep.GetElementByID(actCon.SupplierID), sqlRep);
                    newClient.loadTreeFromTaggedValue();
                    newSupplier.loadTreeFromTaggedValue();
                    String           clientBindingOperator   = newClient.BindingOperator.ToString().ToLower();
                    String           supplierBindingOperator = newSupplier.BindingOperator.ToString().ToLower();
                    BindingSemantics bindingSemantics        = BindingSemantics.MANDATORY;
                    BindingOperator  bindingOperator         = BindingOperator.CHECK_ONLY;

                    if (supplierBindingOperator == BindingOperator.CREATE.ToString().ToLower() || clientBindingOperator == BindingOperator.CREATE.ToString().ToLower())
                    {
                        bindingSemantics = BindingSemantics.MANDATORY;
                        bindingOperator  = BindingOperator.CREATE;
                    }
                    else if (supplierBindingOperator == BindingOperator.DESTROY.ToString().ToLower() || clientBindingOperator == BindingOperator.DESTROY.ToString().ToLower())
                    {
                        bindingSemantics = BindingSemantics.MANDATORY;
                        bindingOperator  = BindingOperator.DESTROY;
                    }
                    else if (supplierBindingOperator == BindingOperator.CHECK_ONLY.ToString().ToLower() && clientBindingOperator == BindingOperator.CHECK_ONLY.ToString().ToLower())
                    {
                        bindingSemantics = BindingSemantics.MANDATORY;
                        bindingOperator  = BindingOperator.CHECK_ONLY;
                    }
                    else if (supplierBindingOperator == BindingOperator.CHECK_ONLY.ToString().ToLower() && clientBindingOperator == BindingOperator.DESTROY.ToString().ToLower() || supplierBindingOperator == BindingOperator.DESTROY.ToString().ToLower() && clientBindingOperator == BindingOperator.CREATE.ToString().ToLower())
                    {
                        bindingSemantics = BindingSemantics.MANDATORY;
                        bindingOperator  = BindingOperator.CHECK_ONLY;
                    }
                    linkVariable.BindingOperator  = bindingOperator;
                    linkVariable.BindingSemantics = bindingSemantics;
                    LinkVariablePropertiesForm linkVariableDialogue = new LinkVariablePropertiesForm(linkVariable, sqlRep, false);
                }
                else if (actCon.Type.Equals(Main.EAControlFlowType))
                {
                    ActivityEdge activityEdge = new ActivityEdge(sqlRep, sqlRep.GetConnectorByID(actCon.ConnectorID));

                    //if there is already Success / Failure / ForEach / End guarded edge set new Edge respectively
                    foreach (SQLConnector outgoingEdge in activityEdge.Source.Connectors)
                    {
                        if (outgoingEdge.ClientID == activityEdge.Source.ElementID && outgoingEdge.ConnectorID != activityEdge.EaConnector.ConnectorID)
                        {
                            if (outgoingEdge.TransitionGuard == ActivityEdge.EdgeGuardFailureGui)
                            {
                                activityEdge.GuardType = EdgeGuard.SUCCESS;
                                break;
                            }
                            else if (outgoingEdge.TransitionGuard == ActivityEdge.EdgeGuardSuccessGui)
                            {
                                activityEdge.GuardType = EdgeGuard.FAILURE;
                                break;
                            }
                            else if (outgoingEdge.TransitionGuard == ActivityEdge.EdgeGuardEachTimeGui)
                            {
                                activityEdge.GuardType = EdgeGuard.END;
                                break;
                            }
                            else if (outgoingEdge.TransitionGuard == ActivityEdge.EdgeGuardEndGui)
                            {
                                activityEdge.GuardType = EdgeGuard.EACH_TIME;
                                break;
                            }
                        }
                    }

                    if (activityEdge.GuardType == EdgeGuard.NONE)
                    {
                        SQLElement sourceNode = sqlRep.GetElementByID(actCon.ClientID);
                        if (sourceNode.Stereotype == SDMModelingMain.StoryNodeStereotype)
                        {
                            StoryNode storyNode = new StoryNode(sqlRep, sourceNode);
                            storyNode.loadTreeFromTaggedValue();
                            if (storyNode.ForEach)
                            {
                                activityEdge.GuardType = EdgeGuard.END;
                            }
                        }
                    }

                    activityEdge.saveTreeToEATaggedValue(true);
                }
            }
            return(true);
        }
示例#11
0
        private void createExtractedSDMStatementNode()
        {
            Boolean thisPatternCreated = false;

            int leftMax = 0;
            int topMax  = -100000;

            computeLeftAndTopMax(ref leftMax, ref topMax);


            EA.Element thisObject = searchThisObject();
            //only create a statementNode if there exists a this object on the sdm
            //otherwise create new story node with an this variable

            if (thisObject == null)
            {
                thisOvPattern = createStoryPattern("this Activity");

                thisObject = createThisOv(thisOvPattern);

                createDiagramObject(leftMax + 50, topMax - 20, 50, 100, thisObject);

                createDiagramObject(leftMax, topMax, 100, 200, thisOvPattern);

                thisPatternCreated = true;

                leftMax += 300;
            }

            //create new story node with objectvariable bound to new sdm.
            if (checkBoxBoundOv.Checked)
            {
                EA.Element boundOvPattern = createStoryPattern("Bound new SDM");
                EA.Element boundObject2   = createThisOv(boundOvPattern);
                SQLElement boundObject    = sqlRepository.GetElementByID(boundObject2.ElementID);


                createDiagramObject(leftMax + 20, topMax - 20, 50, 100, boundObject2);
                createDiagramObject(leftMax, topMax, 100, 200, boundOvPattern);

                ObjectVariable ov = new ObjectVariable(boundObject, sqlRepository);
                ov.loadTreeFromTaggedValue();

                ov.BindingState = BindingState.BOUND;

                MethodCallExpression mcExp = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository);

                ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository);
                mcExp.Target         = ovExp;
                ov.BindingExpression = mcExp;
                ov.Classifier        = ovClassifiersComboBox1.Classifiers[ovClassifiersComboBox1.SelectedIndex];

                ov.saveTreeToEATaggedValue(true);

                sdmCallPattern = boundOvPattern;

                EA.Method sdmMethod = repository.GetMethodByGuid(EAUtil.findTaggedValue(sqlRepository.GetElementByID(newSdmContainer.ElementID), SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value);
                sdmMethod.ClassifierID = "" + ov.Classifier.EaElement.ElementID;
                sdmMethod.ReturnType   = ov.Classifier.EaElement.Name;
                sdmMethod.Update();
            }
            //instead create statement node construct
            else
            {
                EA.Element           statementActivity = createStoryPattern("Call extracted method");
                StatementNode        statementNode     = new StatementNode(sqlRepository, sqlRepository.GetElementByID(statementActivity.ElementID));
                MethodCallExpression mcExp             = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository);

                ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository);
                mcExp.Target = ovExp;
                statementNode.StatementExpression = mcExp;
                statementActivity.Notes           = thisObject.Name + "." + newMethod.Name + "()";
                EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "activityType", "call");
                EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "evacuated", "false");
                statementActivity.Update();

                createDiagramObject(leftMax, topMax, 200, 200, statementActivity);
                statementNode.saveTreeToEATaggedValue(true);

                sdmCallPattern = statementActivity;
            }

            if (thisPatternCreated)
            {
                //create edge between this pattern and statement pattern
                EA.Connector acEdge = thisOvPattern.Connectors.AddNew("", Main.EAControlFlowType) as EA.Connector;
                acEdge.SupplierID = sdmCallPattern.ElementID;
                acEdge.Update();
                ActivityEdge edge = new ActivityEdge(sqlRepository, sqlRepository.GetConnectorByID(acEdge.ConnectorID));
                edge.saveTreeToEATaggedValue(true);
            }
        }