public override Dictionary <SQLElement, string> doGlobalRule(SQLRepository repository)
        {
            Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>();
            String sql    = "select * from t_object a where Object_ID not in ( select Object_ID from t_diagramobjects where Object_ID = a.Object_ID)";
            String result = repository.SQLQuery(sql);

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row"))
            {
                if (row != "")
                {
                    SQLElement eaElement = new SQLElement(repository, row);
                    if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
                        eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
                        eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype ||
                        eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype ||
                        eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype ||
                        eaElement.Stereotype == SDMModelingMain.StartNodeStereotype ||
                        eaElement.Stereotype == SDMModelingMain.StopNodeStereotype ||
                        eaElement.Stereotype == ECOREModelingMain.EClassStereotype ||
                        eaElement.Stereotype == ECOREModelingMain.EEnumStereotype ||
                        eaElement.Stereotype == ECOREModelingMain.EDatatypeStereotype ||
                        eaElement.Stereotype == TGGModelingMain.TggRuleStereotype)
                    {
                        results.Add(eaElement, "Element is not on any diagram");
                    }
                }
            }
            return(results);
        }
        /// informed that the deletion of the Method will delete the SDM Diagram as well.
        /// </summary>
        /// <param name="Repository"></param>
        /// <param name="Info"></param>
        /// <returns></returns>
        public Boolean EA_OnPreDeleteMethod(EA.Repository Repository, EA.Method method)
        {
            EA.Method      meth       = method;
            EA.Element     methParent = Repository.GetElementByID(meth.ParentID);
            EA.TaggedValue aTag       = null;

            SQLRepository sqlRep = new SQLRepository(Repository, false);

            foreach (EA.Element actEle in methParent.Elements)
            {
                aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(actEle, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName);
                if (aTag != null)
                {
                    if (aTag.Value.ToString() == meth.MethodGUID.ToString())
                    {
                        Boolean      delete       = false;
                        DeleteMethod deleteMethod = new DeleteMethod(delete);
                        deleteMethod.StartPosition = FormStartPosition.CenterScreen;
                        deleteMethod.ShowDialog();
                        delete = deleteMethod.setVal();
                        if (delete)
                        {
                            EAUtil.deleteElement(actEle, sqlRep);
                            return(true);
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #3
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);
                }
            }
        }
        public override void doEaGuiStuff()
        {
            EA.Connector realconnector = LinkVariableEA.getRealConnector();

            if (linkDialogueEntry != null)
            {
                if (linkDialogueEntry.direction == LinkDialogueEntryDirection.LEFT && !Persistency.Export.ExportRunning)
                {
                    int clientID = LinkVariableEA.ClientID;
                    realconnector.ClientID   = LinkVariableEA.SupplierID;
                    realconnector.SupplierID = clientID;
                }
            }

            realconnector.Direction        = "Unspecified";
            realconnector.StereotypeEx     = SDMModelingMain.LinkVariableStereotype;
            realconnector.ClientEnd.Role   = this.linkDialogueEntry.clientRoleName;
            realconnector.SupplierEnd.Role = this.linkDialogueEntry.supplierRoleName;
            this.Name = realconnector.SupplierEnd.Role;

            EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realconnector, Main.MoflonVerboseTaggedValueName, Main.FalseValue);
            EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realconnector, ObjectVariable.BindingSemanticsTaggedValueName, this.BindingSemantics.ToString().ToLower());
            EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realconnector, ObjectVariable.BindingOperatorTaggedValueName, this.BindingOperator.ToString().ToLower());

            if (NacIndex == -1)
            {
                EAUtil.deleteTaggedValue(realconnector, ObjectVariable.NacIndexTaggedValueName);
            }
            else
            {
                EAUtil.setTaggedValue(Repository, realconnector, ObjectVariable.NacIndexTaggedValueName, NacIndex.ToString());
            }

            this.LinkVariableEA.getRealConnector().Update();
        }
Example #5
0
        private void cmbFirstObjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            setInformationLossBoolean();

            object previouslySelectedSecondItem = this.cmbSecondObjects.SelectedItem;

            this.cmbSecondObjects.Items.Clear();
            this.cmbSecondObjects.Items.AddRange(expressionProvider.getSecondStringList(cmbFirstObjects.SelectedIndex).ToArray());

            if (this.cmbSecondObjects.Items.Count > 0)
            {
                if (previouslySelectedSecondItem != null && this.cmbSecondObjects.Items.Contains(previouslySelectedSecondItem))
                {
                    this.cmbSecondObjects.SelectedItem = previouslySelectedSecondItem;
                }
                else
                {
                    this.cmbSecondObjects.SelectedIndex = 0;
                }
            }

            this.cmbSecondObjects.DropDownWidth = EAUtil.computeDropDownWidth(this.cmbSecondObjects);

            updateTreeView();
        }
        public override void doEaGuiStuff()
        {
            base.doEaGuiStuff();
            EA.Element realElement = ActivityNodeEAElement.getRealElement();
            if (StatementExpression == null)
            {
                realElement.Notes = "";
                realElement.Update();
            }
            else
            {
                realElement.Notes = StatementExpression.ToString();
                //diagramObject.right = diagramObject.left + 20 + longestConstraint * 5;

                foreach (String id in EAUtil.getDiagramIDsOfObject(ActivityNodeEAElement, Repository))
                {
                    if (id != "")
                    {
                        EA.Diagram currentDiagram = Repository.GetOriginalRepository().GetDiagramByID(int.Parse(id));
                        if (currentDiagram != null)
                        {
                            EA.DiagramObject diagramObject = EAEcoreAddin.Util.EAUtil.findDiagramObject(Repository, realElement, currentDiagram);
                            if (diagramObject != null)
                            {
                                diagramObject.right  = diagramObject.left + 20 + StatementExpression.ToString().Length * 5;
                                diagramObject.bottom = diagramObject.top - 80;
                                diagramObject.Update();
                            }
                        }
                    }
                }
            }
            realElement.Stereotype = SDMModelingMain.StatementNodeStereotype;
            realElement.Update();
        }
Example #7
0
        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);
        }
Example #8
0
        /// <summary>
        /// create Inheritance connectors
        /// </summary>
        public void setInheritances()
        {
            foreach (EA.Element element in MainImport.getInstance().ElementToBaseClassGuids.Keys)
            {
                if (MainImport.hasGui)
                {
                    MainImport.getInstance().ImportWorker.ReportProgress(3, new ProgressObject(ProgressBarType.Current, "Create Inheritance", MainImport.getInstance().ElementToBaseClassGuids.Count));
                }

                String[] guids = MainImport.getInstance().ElementToBaseClassGuids[element].Split(" ".ToCharArray());
                foreach (String baseClassGuid in guids)
                {
                    if (baseClassGuid != "")
                    {
                        EA.Element baseClass = MainImport.getInstance().ElementGuidToElement[MainImport.getInstance().OldGuidToNewGuid[baseClassGuid]];

                        String result = repository.SQLQuery("select Connector_ID from t_connector where Connector_Type ='Generalization' AND Start_Object_ID = " + element.ElementID + " AND End_Object_ID = " + baseClass.ElementID);

                        if (EAUtil.getXMLNodeContentFromSQLQueryString(result, "Connector_ID")[0] == "")
                        {
                            EA.Connector inhCon = element.Connectors.AddNew("", "Generalization") as EA.Connector;
                            inhCon.SupplierID = baseClass.ElementID;
                            inhCon.Update();
                        }
                    }
                }
            }
        }
Example #9
0
        public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository)
        {
            Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>();

            string sqlString = @"SELECT x.* from t_diagram d, t_diagramobjects a, t_diagramobjects b, t_object o,t_object x 
                                                              WHERE d.Diagram_ID = a.Diagram_ID 
                                                              AND o.Object_ID = a.Object_ID 
                                                              AND b.Diagram_ID = a.Diagram_ID 
                                                              AND b.RectTop <= a.RectTop 
                                                              AND b.RectBottom >= a.RectBottom 
                                                              AND b.RectLeft >= a.RectLeft 
                                                              AND b.RectRight <= a.RectRight 
                                                              AND b.Object_ID <> a.Object_ID 
                                                              AND x.Object_ID = b.Object_ID 
                                                              AND x.ParentID  <> o.Object_ID
                                                              AND o.Stereotype = '" + TGGModelingMain.TggRuleSetStereotype + @"' 
                                                              AND x.Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'";

            String result = repository.SQLQuery(sqlString);

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row"))
            {
                if (row != "")
                {
                    SQLElement element = new SQLElement(repository, row);
                    results.Add(element, "The Rule should be a children of the containing Rule-Set");
                }
            }
            return(results);
        }
Example #10
0
        public override void doRuleQuickFix(SQLElement eaObject, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage)
        {
            string sqlString = @"SELECT o.Object_ID from t_diagram d, t_diagramobjects a, t_diagramobjects b, t_object o,t_object x 
                                                              WHERE d.Diagram_ID = a.Diagram_ID 
                                                              AND o.Object_ID = a.Object_ID 
                                                              AND b.Diagram_ID = a.Diagram_ID 
                                                              AND b.RectTop <= a.RectTop 
                                                              AND b.RectBottom >= a.RectBottom 
                                                              AND b.RectLeft >= a.RectLeft 
                                                              AND b.RectRight <= a.RectRight 
                                                              AND b.Object_ID <> a.Object_ID 
                                                              AND x.Object_ID = b.Object_ID 
                                                              AND x.ParentID  <> o.Object_ID
                                                              AND o.Stereotype = '" + TGGModelingMain.TggRuleSetStereotype + @"' 
                                                              AND x.Stereotype = '" + TGGModelingMain.TggRuleStereotype + @"' 
                                                              AND x.Object_ID = " + eaObject.ElementID;
            String result    = repository.SQLQuery(sqlString);
            String id        = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Object_ID")[0];

            if (id != "")
            {
                int parentId = int.Parse(id);
                eaObject.getRealElement().ParentID = parentId;
                eaObject.getRealElement().Update();
            }
        }
Example #11
0
        public void doExport()
        {
            ExportRunning = true;

            ExportProgressBar exportProgressBar = new ExportProgressBar();

            try
            {
                exportProgressBar.startExport(this);

                if (AutoUpdatePackages.Count > 0)
                {
                    String pkgStrings = String.Join("\n", AutoUpdatePackages.ToArray());
                    MessageBox.Show("Due to changes in the eMoflon plugin some projects have to be updated. Please retrieve the SCM locks for the following projects (and all subpackages) and retry the export: \n\n" + pkgStrings);
                }
            }
            catch (Exception e)
            {
                if (showStatusBar)
                {
                    MessageBox.Show(EAUtil.formatErrorMessage(e));
                }
                else
                {
                    Console.Out.WriteLine("EXCEPTION:" + e.StackTrace + "#");
                    Console.Out.WriteLine("ERROR:Something went wrong. Please check the validation messages and contact the eMoflon team if necessary ([email protected])#");
                }
                ExportRunning = false;
            }
        }
Example #12
0
        private void deleteTGGRuleMainMethods()
        {
            String result = repository.SQLQuery(@"SELECT a.ea_guid FROM t_object a WHERE a.Stereotype = 'Rule' OR a.Stereotype = 'Multi-Rule' ");

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "ea_guid"))
            {
                if (row != "")
                {
                    EA.Element ruleElement = repository.GetElementByGuid(row);
                    if (ruleElement != null)
                    {
                        short i = 0;
                        foreach (EA.Method method in ruleElement.Methods)
                        {
                            if (method.Name == ruleElement.Name)
                            {
                                ruleElement.Methods.Delete(i);
                            }
                            i++;
                        }
                        EAUtil.deleteTaggedValue(ruleElement, "MainMethodGuid");
                    }
                }
            }
        }
        public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository)
        {
            Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>();

            String sqlString = "select o.* FROM t_object o, t_diagramobjects a, t_diagramobjects b " +
                               "WHERE a.Object_ID = o.Object_ID " +
                               "AND b.Object_ID <> a.Object_ID " +
                               "AND b.RectRight > a.RectRight " +
                               "AND b.RectLeft < a.RectLeft " +
                               "AND b.RectTop > a.RectTop " +
                               "AND b.RectBottom < a.RectBottom " +
                               "AND a.Diagram_ID = b.Diagram_ID " +
                               "AND o.ParentID <> b.Object_ID";

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(repository.SQLQuery(sqlString), "Row"))
            {
                if (row != "")
                {
                    SQLElement element = new SQLElement(repository, row);
                    if (element.Stereotype == SDMModelingMain.ObjectVariableStereotype || element.Stereotype == TGGModelingMain.TggObjectVariableStereotype)
                    {
                        results.Add(element, "Elements diagram bounds are contained by another diagram element which is not its parent");
                    }
                }
            }

            return(results);
        }
Example #14
0
        public override void dataReveicedEvent()
        {
            List <String> receivedLines = EMoflonTCPServer.getReadLines(buffer);

            if (receivedLines.Count > 0)
            {
                if (receivedLines[0].StartsWith("TEARDOWN_DEBUG_SESSION"))
                {
                    byte[] sendBuffer = EMoflonTCPServer.StringToByteArray(receivedLines[0] + EMoflonTCPServer.NEW_LINE);
                    stream.Write(sendBuffer, 0, sendBuffer.Length);
                    resetBuffer();
                    server.setReceiveDataStrategy(new StrategyChooseStrategy(server, repository));
                }
                else
                {
                    shouldTrace = trDialog.Accepted;
                    foreach (String line in receivedLines)
                    {
                        objects.Add(ValidationPropertyUtil.computeObjectFromPath(repository, line));
                    }
                    if (shouldTrace)
                    {
                        EAUtil.markObjectOnDiagram(objects[objects.Count - 1].EAObject, repository);
                        EAUtil.markObjectInProjectBrowser(objects[objects.Count - 1].EAObject, repository);
                        resetBuffer();
                        server.setReceiveDataStrategy(this);
                    }
                    else
                    {
                        server.setReceiveDataStrategy(new StrategyChooseStrategy(server, repository));
                    }
                }
            }
        }
        private void embedStoryPattern()
        {
            EA.Diagram evacuateDiagram = currentSdmDiagram;
            EA.Diagram embedDiagram    = null;
            activityTabsForm.ActivityNode.ActivityNodeEAElement.Diagrams.Refresh();
            SQLElement sdmContainer = repository.GetElementByID(activityTabsForm.ActivityNode.ActivityNodeEAElement.ParentID);

            repository.SaveDiagram(currentSdmDiagram.DiagramID);
            EA.DiagramObject activityDiagObj = null;
            foreach (SQLDiagram diagrams in sdmContainer.Diagrams)
            {
                if (activityDiagObj == null)
                {
                    activityDiagObj = EAUtil.findDiagramObject(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), diagrams.getRealDiagram());

                    embedDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, diagrams) as EA.Diagram;
                }
            }
            try
            {
                int i = 30;
                foreach (SQLElement element in activityTabsForm.ActivityNode.ActivityNodeEAElement.Elements)
                {
                    if (element.Stereotype == SDMModelingMain.ObjectVariableStereotype)
                    {
                        EAUtil.deleteDiagramObject(repository.GetOriginalRepository(), evacuateDiagram, element.getRealElement());
                        int l = activityDiagObj.left + i;
                        int r = l + 90;
                        int t = activityDiagObj.top - i;
                        int b = t - 50;
                        EA.DiagramObject elementDiagObj = (EA.DiagramObject)embedDiagram.DiagramObjects.AddNew(

                            "l=" + l +
                            ";r=" + r +
                            ";t=" + t +
                            ";b=" + b, element.Type);

                        i += 60;
                        elementDiagObj.ElementID = element.ElementID;
                        elementDiagObj.Sequence  = activityDiagObj.Sequence + 1;
                        elementDiagObj.Update();
                    }
                }

                activityDiagObj.Sequence = int.MaxValue;
                activityDiagObj.Update();

                repository.ReloadDiagram(embedDiagram.DiagramID);

                EAEcoreAddin.Util.EAUtil.setTaggedValue(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "false");
                buttonEvacuate.Text = "Extract Story Pattern";
                repository.OpenDiagram(embedDiagram.DiagramID);
                this.ParentForm.Close();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("The associated Activity is not on any diagrams");
            }
        }
        private bool validateFirstObject(String selectedExpressionString, int firtObjectClassifierId)
        {
            bool valid = false;

            if (methodParameterClassifierIdFilter != -1 && methodParameterClassifierIdFilter != 0)
            {
                if (selectedExpressionString == "ObjectVariableExpression" || selectedExpressionString == "ParameterExpression")
                {
                    try
                    {
                        //is object classifier == method parameter classifier, we can skip the base class detection
                        if (firtObjectClassifierId == methodParameterClassifierIdFilter)
                        {
                            valid = true;
                        }
                        //is the object classifier contained in the method parameter classifier type hierarchy?
                        else
                        {
                            SQLElement methodClassifier = EAUtil.getClassifierElement(repository, methodParameterClassifierIdFilter);
                            if (methodClassifier != null)
                            {
                                //all targets are valid for EObject parameters
                                if (methodClassifier.Name == "EObject")
                                {
                                    valid = true;
                                }
                            }

                            if (!valid)
                            {
                                SQLElement classifierFilter = repository.GetElementByID(firtObjectClassifierId);

                                List <SQLElement> baseClasses = EAUtil.getBaseClasses(classifierFilter);
                                foreach (SQLElement baseClass in baseClasses)
                                {
                                    if (baseClass.ElementID == methodParameterClassifierIdFilter)
                                    {
                                        valid = true;
                                    }
                                }
                            }
                        }
                    }
                    catch (COMException)
                    {
                    }
                }
                //other expression is used. do not filter it
                else
                {
                    valid = true;
                }
            }
            else
            {
                valid = true;
            }
            return(valid);
        }
Example #17
0
        public Boolean EA_OnPostNewConnector(SQLRepository sqlRepository, EA.Connector actCon, EA.Diagram currentDiagram)
        {
            if (ECOREModelingMain.EcoreDiagramMetatype.Contains(currentDiagram.MetaType) || TGGModelingMain.TggSchemaDiagramMetatype.Contains(currentDiagram.MetaType))
            {
                if (actCon.Type.Equals(ECOREModelingMain.EReferenceConnectorType))
                {
                    if (actCon.Stereotype == "bi")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.ClientEnd, actCon.ClientID, "0..1");
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..1");

                        configureBx(actCon);
                    }
                    if (actCon.Stereotype == "biComposite")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.ClientEnd, actCon.ClientID, "0..1");
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..*");

                        configureBx(actCon);
                        toComposite(actCon);
                    }
                    else if (actCon.Stereotype == "biCompositeSingle")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.ClientEnd, actCon.ClientID, "0..1");
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..1");

                        configureBx(actCon);
                        toComposite(actCon);
                    }
                    else if (actCon.Stereotype == "uniSingle")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..1");

                        configureUni(actCon);
                    }
                    else if (actCon.Stereotype == "uniMultiple")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..*");

                        configureUni(actCon);
                    }
                    else if (actCon.Stereotype == "uniComposite")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..*");

                        configureUni(actCon);
                        toComposite(actCon);
                    }
                    else if (actCon.Stereotype == "uniCompositeSingle")
                    {
                        EAUtil.configureConnectorEnd(sqlRepository, actCon.SupplierEnd, actCon.SupplierID, "0..1");

                        configureUni(actCon);
                        toComposite(actCon);
                    }
                }
            }
            return(true);
        }
Example #18
0
 private static void deleteElementsInQueue(EA.Repository Repository)
 {
     while (DeleteQueue.Count > 0)
     {
         EAUtil.deleteElement(Repository.GetElementByGuid(DeleteQueue[0]), new SQLRepository(Repository, false));
         DeleteQueue.RemoveAt(0);
     }
 }
Example #19
0
 public EA.Element getRealElement()
 {
     if (realElem == null)
     {
         realElem = EAUtil.sqlEAObjectToOriginalObject(repository, this) as EA.Element;
     }
     return(realElem);
 }
Example #20
0
 public override void doEaGuiStuff()
 {
     base.doEaGuiStuff();
     EA.Package newTGGProject = EAUtil.sqlEAObjectToOriginalObject(Repository, this.EaPackage) as EA.Package;
     newTGGProject.Element.StereotypeEx = TGGModelingMain.TggSchemaPackageStereotype;
     newTGGProject.Update();
     newTGGProject.Element.Update();
 }
        /// <summary>
        /// Deserializes the TaggedValue from the tagged Object
        /// </summary>
        /// <returns></returns>
        public Boolean loadTreeFromTaggedValue()
        {
            String tagNotes = "";

            Object mocaTag          = null;
            Object objectToBeTagged = getObjectToBeTagged();

            if (objectToBeTagged is SQLElement)
            {
                mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLElement, Main.MoflonExportTreeTaggedValueName);
            }
            else if (objectToBeTagged is SQLConnector)
            {
                mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLConnector, Main.MoflonExportTreeTaggedValueName);
            }
            else if (objectToBeTagged is SQLPackage)
            {
                mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLPackage, Main.MoflonExportTreeTaggedValueName);
            }
            else if (objectToBeTagged is SQLMethod)
            {
                mocaTag = EAUtil.findTaggedValue(Repository.GetOriginalRepository().GetMethodByID((objectToBeTagged as SQLMethod).MethodID), Main.MoflonExportTreeTaggedValueName);
            }
            if (mocaTag is SQLTaggedValue)
            {
                tagNotes = (mocaTag as SQLTaggedValue).Notes;
            }
            else if (mocaTag is SQLConnectorTag)
            {
                tagNotes = (mocaTag as SQLConnectorTag).Notes;
            }
            else if (mocaTag is EA.MethodTag)
            {
                tagNotes = (mocaTag as EA.MethodTag).Notes;
            }

            if (tagNotes != "")
            {
                XmlDocument xmlDocument   = MocaTreeUtil.stringToXmlDocument(tagNotes);
                MocaNode    emptyMocaNode = new MocaNode();

                //fill mocanode from xmlElement
                emptyMocaNode.deserializeFromXmlTree(xmlDocument.FirstChild.FirstChild as XmlElement);

                //fill this from mocanode

                try
                {
                    deserializeFromMocaTree(emptyMocaNode);
                }
                catch
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }
        private static void onCSPConstraintDoubleClicked(SQLRepository sqlRepository, EA.Element doubleClickedElement)
        {
            TGG tggPackage = new TGG(sqlRepository, EAUtil.getOutermostPackage(doubleClickedElement, sqlRepository));

            tggPackage.loadTreeFromTaggedValue();
            CSPInstanceDialog CSPConstraintDialog = new CSPInstanceDialog(sqlRepository, sqlRepository.GetElementByID(doubleClickedElement.ElementID), new TGGCSPController(tggPackage));

            CSPConstraintDialog.ShowDialog();
        }
Example #23
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            String nacIndexReal = complexNAC1.getNacIndexValue();

            EAUtil.setTaggedValue(sqlRepository, elem, "nacIndex", nacIndexReal != "" ? nacIndexReal : "-1");
            elem.Notes = textBoxCspDefinition.Text;
            elem.Update();
            Close();
        }
Example #24
0
        protected void setDefaultValueIfNecessary(String tagName)
        {
            SQLTaggedValue tag = EAUtil.findTaggedValue(package.EaPackage, tagName);

            if (tag == null)
            {
                EAUtil.setTaggedValue(package.Repository, package.EaPackage.getRealPackage(), tagName, DEFAULT_VALUE_PLACEHOLDER);
            }
        }
Example #25
0
        public override List <string> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> result = new List <string>();

            if (eaElement.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
            {
                List <SQLElement> baseClasses = EAUtil.getBaseClasses(eaElement);
                if (baseClasses.Count > 1)
                {
                    foreach (SQLConnector con in eaElement.Connectors)
                    {
                        if (con.Type != Main.EAGeneralizationConType)
                        {
                            result.Add("Only the top level correspondence type in inheritance hierarchy should have connectors besides inheritance ");
                            break;
                        }
                    }
                }
                else
                {
                    int  count = 0;
                    bool valid = true;
                    foreach (SQLConnector con in eaElement.Connectors)
                    {
                        if (con.Type == Main.EAAssociationType)
                        {
                            count++;
                            SQLConnectorEnd rightEnd = null;
                            SQLConnectorEnd wrongEnd = null;
                            if (con.ClientID == eaElement.ElementID)
                            {
                                wrongEnd = con.ClientEnd;
                                rightEnd = con.SupplierEnd;
                            }
                            else if (con.SupplierID == eaElement.ElementID)
                            {
                                wrongEnd = con.SupplierEnd;
                                rightEnd = con.ClientEnd;
                            }

                            valid &= wrongEnd.Role == "";
                            valid &= !wrongEnd.IsNavigable;

                            valid &= (rightEnd.Role == "source" || rightEnd.Role == "target");
                            valid &= rightEnd.IsNavigable;
                            valid &= rightEnd.Cardinality == "1";
                        }
                    }

                    if (count != 2 || !valid)
                    {
                        result.Add("Correspondence type should only have source and target EReference with multiplicity 1");
                    }
                }
            }
            return(result);
        }
        public List <string> getSecondStringList(int selectedFirstObjectIndex)
        {
            this.secondObjects             = new List <SecondObject>();
            this.selectedFirstObjectIndex  = selectedFirstObjectIndex;
            this.selectedSecondObjectIndex = -1;

            List <String> sourceStringList = new List <string>();

            Object              targetElement    = this.firstObjects[selectedFirstObjectIndex].EaObject;
            EditorExpression    editorExpression = EditorExpression.createEditorExpression(selectedExpressionString);
            List <SecondObject> sourceList       = editorExpression.getSecondObjects(targetElement, repository);

            foreach (SecondObject actSecondObject in sourceList)
            {
                String name         = actSecondObject.Name;
                int    classifierId = actSecondObject.ClassifierId;

                if (actSecondObject.EaObject is SQLMethod)
                {
                    SQLMethod method = actSecondObject.EaObject as SQLMethod;
                    if (methodParameterClassifierIdFilter != 0)
                    {
                        if (classifierId != 0)
                        {
                            SQLElement methodReturnTypeClass     = repository.GetElementByID(classifierId);
                            SQLElement wantedParameterTypeClasss = repository.GetElementByID(methodParameterClassifierIdFilter);

                            foreach (SQLElement baseClass in EAUtil.getBaseClasses(methodReturnTypeClass))
                            {
                                if (baseClass.ElementID == methodParameterClassifierIdFilter)
                                {
                                    name = EAUtil.getMethodSignature(method);
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        name = EAUtil.getMethodSignature(method);
                    }
                }

                if (name != "" && !sourceStringList.Contains(name))
                {
                    sourceStringList.Add(name);
                    this.secondObjects.Add(actSecondObject);
                }
            }

            this.expression = computeExpression();

            //sourceStringList.Sort();
            sourceStringList = sourceStringList.Distinct().ToList();

            return(sourceStringList);
        }
        private static void handleObsoleteTaggedValue(SQLPackage eaPackage, List <String> results, String tag)
        {
            SQLTaggedValue validationFilter = EAUtil.findTaggedValue(eaPackage, tag);

            if (validationFilter != null)
            {
                results.Add("The tagged value " + tag + " is obsolete and should be deleted or renamed appropriately.");
            }
        }
Example #28
0
        public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage)
        {
            if (i == 0)
            {
                List <SQLConnector> toDelte     = new List <SQLConnector>();
                List <SQLElement>   baseClasses = EAUtil.getBaseClasses(eaElement);
                if (baseClasses.Count > 1)
                {
                    foreach (SQLConnector con in eaElement.Connectors)
                    {
                        if (con.Type != Main.EAGeneralizationConType)
                        {
                            toDelte.Add(con);
                        }
                    }
                }

                else
                {
                    foreach (SQLConnector con in eaElement.Connectors)
                    {
                        if (con.Type == Main.EAAssociationType)
                        {
                            bool            valid    = true;
                            SQLConnectorEnd rightEnd = null;
                            SQLConnectorEnd wrongEnd = null;
                            if (con.ClientID == eaElement.ElementID)
                            {
                                wrongEnd = con.ClientEnd;
                                rightEnd = con.SupplierEnd;
                            }
                            else if (con.SupplierID == eaElement.ElementID)
                            {
                                wrongEnd = con.SupplierEnd;
                                rightEnd = con.ClientEnd;
                            }

                            valid &= wrongEnd.Role == "";
                            valid &= !wrongEnd.IsNavigable;

                            valid &= (rightEnd.Role == "source" || rightEnd.Role == "target");
                            valid &= rightEnd.IsNavigable;
                            valid &= rightEnd.Cardinality == "1";
                            if (!valid)
                            {
                                toDelte.Add(con);
                            }
                        }
                    }
                }
                foreach (EA.Connector toDeleteCon in toDelte)
                {
                    EAUtil.deleteConnector(toDeleteCon, repository.GetOriginalRepository());
                }
            }
        }
Example #29
0
        public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository)
        {
            NameValueCollection             parentIdToName = new NameValueCollection();
            Dictionary <SQLElement, String> results        = new Dictionary <SQLElement, string>();

            //SDM ObjectVariables
            string result = repository.SQLQuery(@"select a.* from t_object a, t_object b, t_object c 
                                WHERE a.Name = b.Name 
                                AND a.ea_guid <> b.ea_guid 
                                AND a.ParentID = c.Object_ID
                                AND b.parentID = c.Object_ID
                                AND a.Stereotype = '" + SDMModelingMain.ObjectVariableStereotype + @"'
                                AND b.Stereotype = '" + SDMModelingMain.ObjectVariableStereotype + @"'
                                AND c.Stereotype = '" + SDMModelingMain.StoryNodeStereotype + "'");

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row"))
            {
                if (row != "")
                {
                    SQLElement element = new SQLElement(repository, row);
                    String[]   names   = parentIdToName.GetValues(element.ParentID + "");
                    if (names == null || !names.Contains(element.Name))
                    {
                        results.Add(element, "ObjectVariable name in a single StoryPattern must be explicit");
                        parentIdToName.Add(element.ParentID + "", element.Name);
                    }
                }
            }

            //TGGObjectVariables
            result = repository.SQLQuery(@"select a.* from t_object a, t_object b, t_object c 
                                WHERE a.Name = b.Name 
                                AND a.ea_guid <> b.ea_guid 
                                AND a.ParentID = c.Object_ID
                                AND b.parentID = c.Object_ID
                                AND (a.Stereotype = '" + TGGModelingMain.TggObjectVariableStereotype + @"' OR a.Stereotype = '" + TGGModelingMain.TggCorrespondenceStereotype + @"')
                                AND (b.Stereotype = '" + TGGModelingMain.TggObjectVariableStereotype + @"' OR b.Stereotype = '" + TGGModelingMain.TggCorrespondenceStereotype + @"')
                                AND c.Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'");

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row"))
            {
                if (row != "")
                {
                    SQLElement element = new SQLElement(repository, row);
                    String[]   names   = parentIdToName.GetValues(element.ParentID + "");
                    if (names == null || !names.Contains(element.Name))
                    {
                        results.Add(element, "ObjectVariable name in a single Rule must be explicit");
                        parentIdToName.Add(element.ParentID + "", element.Name);
                    }
                }
            }


            return(results);
        }
Example #30
0
        private static void transformConstraintToCSPElement(SQLElement eaElement2, SQLWrapperClasses.SQLRepository sqlRep, EA.Repository repository)
        {
            EA.Element eaElement = EAUtil.sqlEAObjectToOriginalObject(sqlRep, eaElement2) as EA.Element;
            String     result    = repository.SQLQuery("select Diagram_ID from t_diagramobjects where Object_ID = " + eaElement.ElementID);
            string     diagramId = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Diagram_ID")[0];

            if (diagramId != "")
            {
                EA.Diagram       diagram       = repository.GetDiagramByID(int.Parse(diagramId));
                EA.DiagramObject oldDiagObject = EAUtil.findDiagramObject(sqlRep, eaElement, diagram);
                EA.Element       ruleElement   = repository.GetElementByID(diagram.ParentID);
                if (ruleElement.Stereotype == TGGModelingMain.TggRuleStereotype)
                {
                    List <EA.Connector> outgoingCons = new List <EA.Connector>();

                    foreach (EA.Connector con in eaElement.Connectors)
                    {
                        if (con.Stereotype == "ConstraintLink" && con.ClientID == eaElement.ElementID)
                        {
                            outgoingCons.Add(con);
                        }
                    }

                    EA.Element newCsp = ruleElement.Elements.AddNew("", Main.EAClassType) as EA.Element;
                    newCsp.Notes      = eaElement.Notes;
                    newCsp.Stereotype = TGGModelingMain.CSPConstraintStereotype;
                    newCsp.Update();

                    EA.TaggedValue oldTag = EAUtil.findTaggedValue(eaElement, Main.MoflonExportTreeTaggedValueName);
                    if (oldTag != null)
                    {
                        EAUtil.setTaggedValueNotes(sqlRep, newCsp, oldTag.Name, oldTag.Notes);
                    }


                    EA.DiagramObject newDiagObject = diagram.DiagramObjects.AddNew("", Main.EAClassType) as EA.DiagramObject;
                    newDiagObject.ElementID = newCsp.ElementID;
                    newDiagObject.left      = oldDiagObject.left;
                    newDiagObject.right     = oldDiagObject.right;
                    newDiagObject.bottom    = oldDiagObject.bottom;
                    newDiagObject.top       = oldDiagObject.top;
                    newDiagObject.Update();

                    foreach (EA.Connector con in outgoingCons)
                    {
                        con.ClientID = newCsp.ElementID;
                        con.Update();
                    }



                    EAUtil.deleteDiagramObject(repository, diagram, eaElement);
                    EAUtil.deleteElement(eaElement, sqlRep);
                }
            }
        }