Ejemplo n.º 1
0
        internal void fillSchemaDiagram(EA.Diagram diagram)
        {
            EA.Package tggPackage = repository.GetPackageByID(diagram.PackageID);

            if (tggPackage != null)
            {
                TGGModelingUtil.fillTGGSchemaDiagram(repository, tggPackage, diagram);
            }
        }
Ejemplo n.º 2
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            this.domain = TGGModelingUtil.getDomainOfLinkVariable(Repository, this.LinkVariableEA);
            MocaNode lvNode = base.serializeToMocaTree();

            lvNode.appendChildAttribute("domain", this.domain.ToString().ToLower());
            lvNode.Name = TGGModelingMain.TggLinkVariableStereotype;
            return(lvNode);
        }
Ejemplo n.º 3
0
        public override Serialization.MocaTree.MocaNode serializeToMocaTree()
        {
            this.domain = TGGModelingUtil.getDomainOfObjectVariable(Repository, this);

            MocaNode ovNode = base.serializeToMocaTree();

            ovNode.appendChildAttribute("metamodelGuid", this.metamodelGuid);
            ovNode.appendChildAttribute("domain", this.domain.ToString().ToLower());
            ovNode.Name = "TGGObjectVariable";
            return(ovNode);
        }
Ejemplo n.º 4
0
        public SelectCorrespondenceObject(Dictionary <int, List <SQLConnector> > possibleCorrespondencesLinkWithConnectors, SQLElement corrObject, SQLRepository repository, BindingOperator bO, SQLElement clientClassifier, SQLElement supplierClassifier, SQLElement clientOv, SQLElement supplierOv)
        {
            InitializeComponent();
            this.sqlRepository = repository;
            this.repository    = sqlRepository.GetOriginalRepository();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.possibleCorrespondencesLinkWithConnectors = possibleCorrespondencesLinkWithConnectors;
            this.corrObject = corrObject;
            this.clientOv   = clientOv;
            this.supplierOv = supplierOv;

            DomainType clientDomain   = TGGModelingUtil.getDomainOfEClass(sqlRepository, clientClassifier);
            DomainType supplierDomain = TGGModelingUtil.getDomainOfEClass(sqlRepository, supplierClassifier);

            if (clientDomain == DomainType.SOURCE && supplierDomain == DomainType.TARGET)
            {
                this.clientClassifier   = clientClassifier;
                this.supplierClassifier = supplierClassifier;
            }
            else if (clientDomain == DomainType.TARGET && supplierDomain == DomainType.SOURCE)
            {
                this.clientClassifier   = supplierClassifier;
                this.supplierClassifier = clientClassifier;
            }

            else
            {
                this.clientClassifier   = clientClassifier;
                this.supplierClassifier = supplierClassifier;
            }

            this.bo = bO;
            foreach (int possibleCorrClassID in this.possibleCorrespondencesLinkWithConnectors.Keys)
            {
                SQLElement possibleCorrClass = sqlRepository.GetElementByID(possibleCorrClassID);
                this.comboBoxCorrClasses.Items.Add(possibleCorrClass.Name);
            }

            checkBoxCreateNew.Checked = false;
            if (this.clientClassifier != null && this.supplierClassifier != null)
            {
                textBoxObjectName.Text = this.clientOv.Name + "To" + this.supplierOv.Name.Substring(0, 1).ToUpper() + this.supplierOv.Name.Substring(1, this.supplierOv.Name.Length - 1);
            }
            textBoxLinkName.Text = this.clientClassifier.Name + "To" + this.supplierClassifier.Name;


            if (this.comboBoxCorrClasses.Items.Count > 0)
            {
                this.comboBoxCorrClasses.SelectedIndex = 0;
            }

            ShowDialog();
        }
Ejemplo n.º 5
0
        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)
            {
                TGGObjectVariable tggOV  = new TGGObjectVariable(eaElement, repository);
                DomainType        domain = TGGModelingUtil.getDomainOfObjectVariable(repository, tggOV);
                if (domain == DomainType.UNDEFINED)
                {
                    results.Add("Domain of the Object Variable (source or target) cannot be defined. Prefix the name of this object variable with \"src__\" or \"trg__\".");
                }
            }
            return(results);
        }
 public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
 {
     if (errorMessage == "AttributeAssignments and BindingOperator check_only is not allowed")
     {
         if (i == 0)
         {
             TGGObjectVariable tggOv = new TGGObjectVariable(eaElement, repository);
             tggOv.loadTreeFromTaggedValue();
             TGGModelingUtil.assignmentsToConstraints(tggOv, repository);
             tggOv.saveTreeToEATaggedValue(true);
         }
         else if (i == 1)
         {
             TGGObjectVariable tggOv = new TGGObjectVariable(eaElement, repository);
             tggOv.loadTreeFromTaggedValue();
             tggOv.BindingOperator = BindingOperator.CREATE;
             tggOv.saveTreeToEATaggedValue(true);
         }
     }
 }
Ejemplo n.º 7
0
 public override void addAttributesDuringExport(MocaNode linkVariableMocaNode)
 {
     base.addAttributesDuringExport(linkVariableMocaNode);
     linkVariableMocaNode.appendChildAttribute("domain", TGGModelingUtil.getDomainOfLinkVariable(Repository, this.LinkVariableEA).ToString().ToLower());
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 9
0
 public override void addAttributesDuringExport(MocaNode actNode)
 {
     base.addAttributesDuringExport(actNode);
     actNode.appendChildAttribute("domain", TGGModelingUtil.getDomainOfObjectVariable(Repository, this).ToString().ToLower());
 }
Ejemplo n.º 10
0
 public override void deserializeFromMocaTree(MocaNode actNode)
 {
     base.deserializeFromMocaTree(actNode);
     this.domain        = TGGModelingUtil.stringToDomainType(actNode.getAttributeOrCreate("domain").Value);
     this.metamodelGuid = actNode.getAttributeOrCreate("metamodelGuid").Value;
 }
Ejemplo n.º 11
0
        private static Boolean createTGGLink(EA.Repository Repository, EA.EventProperties Info, TGGModelingMain modelingMain)
        {
            SQLRepository sqlRep = new SQLRepository(Repository, false);

            int clientID   = int.Parse(Info.Get("ClientID").Value.ToString());
            int supplierID = int.Parse(Info.Get("SupplierID").Value.ToString());

            SQLElement client   = sqlRep.GetElementByID(clientID);
            SQLElement supplier = sqlRep.GetElementByID(supplierID);

            DomainType clientDomain   = TGGModelingUtil.getDomainOfEClass(sqlRep, client);
            DomainType supplierDomain = TGGModelingUtil.getDomainOfEClass(sqlRep, supplier);

            SQLElement source = null;
            SQLElement target = null;

            if (clientDomain == DomainType.SOURCE || supplierDomain == DomainType.TARGET)
            {
                source = client;
                target = supplier;
            }
            else if (clientDomain == DomainType.TARGET || supplierDomain == DomainType.SOURCE)
            {
                source = supplier;
                target = client;
            }
            else
            {
                //could not define the domains, this is an arbitrary choice
                source = client;
                target = supplier;
            }


            EA.Diagram curDiagram = Repository.GetCurrentDiagram();
            EA.Package tggPackage = Repository.GetPackageByID(curDiagram.PackageID);

            EA.Element tggLink = tggPackage.Elements.AddNew(source.Name + "To" + target.Name, Main.EAClassType) as EA.Element;
            tggLink.StereotypeEx = TGGModelingMain.TggCorrespondenceTypeStereotype;
            tggLink.Update();
            modelingMain.EA_OnNotifyContextItemModified(Repository, tggLink.ElementGUID, EA.ObjectType.otElement);

            EA.Connector connectorToSource = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToSource.SupplierID              = source.ElementID;
            connectorToSource.Direction               = Main.EASourceTargetDirection;
            connectorToSource.SupplierEnd.Role        = "source";
            connectorToSource.SupplierEnd.Navigable   = "Navigable";
            connectorToSource.SupplierEnd.Cardinality = "1";
            connectorToSource.SupplierEnd.IsNavigable = true;

            connectorToSource.Update();
            tggLink.Connectors.Refresh();
            modelingMain.EA_OnNotifyContextItemModified(Repository, connectorToSource.ConnectorGUID, EA.ObjectType.otConnector);

            EA.Connector connectorToTarget = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToTarget.SupplierID              = target.ElementID;
            connectorToTarget.Direction               = Main.EASourceTargetDirection;
            connectorToTarget.SupplierEnd.Role        = "target";
            connectorToTarget.SupplierEnd.Cardinality = "1";
            connectorToTarget.SupplierEnd.Navigable   = "Navigable";
            connectorToTarget.SupplierEnd.IsNavigable = true;

            connectorToTarget.Update();
            tggLink.Connectors.Refresh();
            modelingMain.EA_OnNotifyContextItemModified(Repository, connectorToTarget.ConnectorGUID, EA.ObjectType.otConnector);

            //create a new diagram object
            Repository.SaveDiagram(curDiagram.DiagramID);
            EA.DiagramObject sourceDiagObj = null;
            EA.DiagramObject targetDiagObj = null;

            curDiagram.DiagramObjects.Refresh();
            foreach (EA.DiagramObject diagObj in curDiagram.DiagramObjects)
            {
                if (diagObj.ElementID == source.ElementID)
                {
                    sourceDiagObj = diagObj;
                }
                else if (diagObj.ElementID == target.ElementID)
                {
                    targetDiagObj = diagObj;
                }

                if (sourceDiagObj != null && targetDiagObj != null)
                {
                    continue;
                }
            }

            int sourceLeft   = (sourceDiagObj == null) ? 0 : sourceDiagObj.left;
            int sourceRight  = (sourceDiagObj == null) ? 0 : sourceDiagObj.right;
            int sourceBottom = (sourceDiagObj == null) ? 0 : sourceDiagObj.bottom;
            int sourceTop    = (sourceDiagObj == null) ? 0 : sourceDiagObj.top;

            int targetLeft   = (targetDiagObj == null) ? 0 : targetDiagObj.left;
            int targetRight  = (targetDiagObj == null) ? 0 : targetDiagObj.right;
            int targetBottom = (targetDiagObj == null) ? 0 : targetDiagObj.bottom;
            int targetTop    = (targetDiagObj == null) ? 0 : targetDiagObj.top;

            EA.DiagramObject tggLinkDiagObj = curDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject;
            tggLinkDiagObj.ElementID = tggLink.ElementID;
            tggLinkDiagObj.Update();
            tggLinkDiagObj.left   = (sourceLeft + targetLeft) / 2;
            tggLinkDiagObj.right  = (sourceRight + targetRight) / 2;
            tggLinkDiagObj.bottom = (sourceBottom + targetBottom) / 2;
            tggLinkDiagObj.top    = (sourceTop + targetTop) / 2;
            tggLinkDiagObj.Update();
            curDiagram.DiagramObjects.Refresh();

            Repository.ReloadDiagram(curDiagram.DiagramID);

            tggPackage.Elements.Refresh();


            return(true);
        }
Ejemplo n.º 12
0
        private Boolean createCorrespondenceObjectWithLinks(EA.Repository Repositorya, EA.EventProperties Info)
        {
            DateTime      t1         = DateTime.Now;
            SQLRepository Repository = new SQLRepository(Repositorya, false);

            EA.Diagram curDiagram = Repository.GetCurrentDiagram();

            int tggPackageId = EAUtil.getOutermostPackage(curDiagram, Repository).PackageID;

            BindingOperator newBindingOperator = BindingOperator.CHECK_ONLY;

            SQLElement clientOv   = Repository.GetElementByID(int.Parse(Info.Get("ClientID").Value.ToString()));
            SQLElement supplierOv = Repository.GetElementByID(int.Parse(Info.Get("SupplierID").Value.ToString()));

            EA.Element ruleClass = Repository.GetOriginalRepository().GetElementByID(clientOv.ParentID);

            SQLElement clientClassifier   = Repository.GetElementByID(clientOv.ClassifierID);
            SQLElement supplierClassifier = Repository.GetElementByID(supplierOv.ClassifierID);

            //compute domains of source and target classifiers
            DomainType clientDomain   = TGGModelingUtil.getDomainOfObjectVariable(Repository, new TGGObjectVariable(clientOv, Repository));
            DomainType supplierDomain = TGGModelingUtil.getDomainOfObjectVariable(Repository, new TGGObjectVariable(supplierOv, Repository));

            //get possible correspondence classes with connectors
            Dictionary <int, List <SQLConnector> > possibleCorrespondencesLinkWithConnectors = computeCorrespondencesWithLinks(clientClassifier, supplierClassifier, Repository, tggPackageId);

            //check for existing bindingOperator
            SQLTaggedValue bindingOperatorTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(clientOv, ObjectVariable.BindingOperatorTaggedValueName);

            if (bindingOperatorTag != null)
            {
                newBindingOperator = (BindingOperator)Enum.Parse(typeof(BindingOperator), bindingOperatorTag.Value.ToUpper());
            }

            //create new correspondence ov
            EA.Element tggCorrespondenceObject = ruleClass.Elements.AddNew("", Main.EAObjectType) as EA.Element;
            tggCorrespondenceObject.Update();

            //dont know what this line does :)
            EA_OnNotifyContextItemModified(Repository.GetOriginalRepository(), tggCorrespondenceObject.ElementGUID, EA.ObjectType.otElement);

            //create connector from correspondence object to client ov
            EA.Connector connectorToClient = tggCorrespondenceObject.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToClient.SupplierID = clientOv.ElementID;

            connectorToClient.Direction = "Unspecified";
            connectorToClient.Update();
            tggCorrespondenceObject.Connectors.Refresh();

            //create connector from correspondence object to supplier ov
            EA.Connector connectorToTarget = tggCorrespondenceObject.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToTarget.SupplierID = supplierOv.ElementID;
            connectorToTarget.Direction  = "Unspecified";
            connectorToTarget.Update();
            tggCorrespondenceObject.Connectors.Refresh();

            createCorrespondenceDiagramObject(curDiagram, Repository.GetOriginalRepository(), clientOv.getRealElement(), supplierOv.getRealElement(), tggCorrespondenceObject);

            SelectCorrespondenceObject selectCorr = new SelectCorrespondenceObject(possibleCorrespondencesLinkWithConnectors, Repository.GetElementByID(tggCorrespondenceObject.ElementID), Repository, newBindingOperator, clientClassifier, supplierClassifier, clientOv, supplierOv);

            if (selectCorr.DialogResult == DialogResult.Cancel)
            {
                return(true);
            }

            //compute correct linkDialogueEntries so the rolenames can be set correctly

            LinkDialogueEntry sourceEntry = computeLinkDialogEntry("source", possibleCorrespondencesLinkWithConnectors[selectCorr.selectedCorrespondenceLinkId]);
            LinkDialogueEntry targetEntry = computeLinkDialogEntry("target", possibleCorrespondencesLinkWithConnectors[selectCorr.selectedCorrespondenceLinkId]);

            TGGLinkVariable sourceLv = new TGGLinkVariable(Repository.GetConnectorByID(connectorToClient.ConnectorID), Repository);

            sourceLv.BindingOperator = newBindingOperator;

            TGGLinkVariable targetLv = new TGGLinkVariable(Repository.GetConnectorByID(connectorToTarget.ConnectorID), Repository);

            targetLv.BindingOperator = newBindingOperator;

            if (clientDomain == DomainType.SOURCE && supplierDomain == DomainType.TARGET)
            {
                sourceLv.linkDialogueEntry = sourceEntry;
                targetLv.linkDialogueEntry = targetEntry;
            }
            else if (clientDomain == DomainType.TARGET && supplierDomain == DomainType.SOURCE)
            {
                sourceLv.linkDialogueEntry = targetEntry;
                targetLv.linkDialogueEntry = sourceEntry;
            }
            else
            {
                sourceLv.linkDialogueEntry = sourceEntry;
                targetLv.linkDialogueEntry = targetEntry;
            }
            sourceLv.saveTreeToEATaggedValue(true);
            targetLv.saveTreeToEATaggedValue(true);


            Repository.ReloadDiagram(curDiagram.DiagramID);



            return(true);
        }
Ejemplo n.º 13
0
        internal void fillRuleDiagram(EA.Diagram diagram)
        {
            EA.Element ruleElement = repository.GetElementByID(diagram.ParentID);

            TGGModelingUtil.fillTGGRuleDiagram(repository, diagram, ruleElement);
        }