Ejemplo n.º 1
0
        public void processEReference(SQLConnector eaReference, String clientOrSupplier)
        {
            SQLConnectorTag mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaReference, Main.MoflonExportTreeTaggedValueName);
            EReference      eReference  = null;

            if (mocaTreeTag == null)
            {
                eReference = new EReference(eaReference, repository);
                eReference.saveTreeToEATaggedValue(true);
                mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaReference, Main.MoflonExportTreeTaggedValueName);
            }

            MocaNode referenceEndNode = new MocaNode();

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

            SQLElement eTypeElement = null;

            if (clientOrSupplier == "Client")
            {
                referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.ClientReferenceChildNodeName).Children[0];
                eTypeElement     = repository.GetElementByID(eaReference.ClientID);
            }
            else if (clientOrSupplier == "Supplier")
            {
                referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.SupplierReferenceChildNodeName).Children[0];
                eTypeElement     = repository.GetElementByID(eaReference.SupplierID);
            }

            Export.computeAndAddToDependencies(repository, eTypeElement);

            this.currentNode.appendChildNode(referenceEndNode);
        }
Ejemplo n.º 2
0
        public void EA_OnNotifyContextItemModified(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(Repository, false);

            if (ot == EA.ObjectType.otPackage)
            {
                EA.Package eaPackage = Repository.GetPackageByGuid(GUID);
                if (eaPackage.Element.Stereotype.ToLower() == ECOREModelingMain.EPackageStereotype.ToLower())
                {
                    EPackage ePackage = new EPackage(sqlRepository.GetPackageByID(eaPackage.PackageID), sqlRepository);
                    Main.addToTreeQueue(GUID, ePackage);
                }

                // track changes for metamodelevolution
                savePackageChangesToEATaggedValue(sqlRepository, GUID);
            }
            if (ot == EA.ObjectType.otElement)
            {
                SQLElement eaElement = sqlRepository.GetElementByGuid(GUID);

                if (eaElement.Stereotype.ToLower() == EClassStereotype.ToLower() && eaElement.Type == Main.EAClassType)
                {
                    EClass eClass = new EClass(eaElement, sqlRepository);
                    eClass.saveTreeToEATaggedValue(false);

                    // track changes for metamodelevolution
                    saveElementChangesToEATaggedValue(eaElement, GUID, sqlRepository);
                }
                else if (eaElement.Stereotype.ToLower() == EDatatypeStereotype.ToLower())
                {
                    EDatatype eDataType = new EDatatype(eaElement, sqlRepository);
                    eDataType.saveTreeToEATaggedValue(false);
                }
                else if (eaElement.Stereotype.ToLower() == EEnumStereotype.ToLower())
                {
                    EEnum eEnum = new EEnum(eaElement, sqlRepository);
                    eEnum.saveTreeToEATaggedValue(false);
                }
            }

            if (ot == EA.ObjectType.otConnector)
            {
                SQLConnector eaConnector = sqlRepository.GetConnectorByGuid(GUID);
                if (eaConnector.Type == EReferenceConnectorType && (eaConnector.Stereotype == "" || eaConnector.Stereotype.ToLower() == "ereference"))
                {
                    EReference clientReference = new EReference(eaConnector, sqlRepository);
                    clientReference.saveTreeToEATaggedValue(false);
                }
                else if (eaConnector.Type == InheritanceConnectorType)
                {
                    SQLElement connectorSource = sqlRepository.GetElementByID(eaConnector.ClientID);
                    if (connectorSource.Stereotype == EClassStereotype)
                    {
                        EClass eClass = new EClass(connectorSource, sqlRepository);
                        eClass.saveTreeToEATaggedValue(false);
                    }
                }
            }
        }
 public override void doRuleQuickFix(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage)
 {
     if (i == 0)
     {
         EReference eref = new EReference(eaConnector, repository);
         eref.saveTreeToEATaggedValue(true);
     }
 }
        public override void doRuleQuickFix(SQLConnector eaConnector2, SQLRepository repository, int i, String errorMessage)
        {
            EA.Connector eaConnector = eaConnector2.getRealConnector();

            if (i == 0)
            {
                if (eaConnector.ClientEnd.Role != "" && eaConnector.SupplierEnd.Role != "")
                {
                    eaConnector.Direction = "Bi-Directional";
                }
                else if (eaConnector.ClientEnd.Role != "" && eaConnector.ClientEnd.Navigable != "Navigable")
                {
                    eaConnector.ClientEnd.Navigable   = "Navigable";
                    eaConnector.ClientEnd.IsNavigable = true;
                    eaConnector.ClientEnd.Update();
                    //eaConnector.Direction = Main.EATargetSourceDirection;
                    //eaConnector.Update();
                }
                else if (eaConnector.SupplierEnd.Role != "" && eaConnector.SupplierEnd.Navigable != "Navigable")
                {
                    eaConnector.SupplierEnd.Navigable   = "Navigable";
                    eaConnector.SupplierEnd.IsNavigable = true;
                    eaConnector.SupplierEnd.Update();
                    //eaConnector.Direction = "Source -> Destination";
                    //eaConnector.Update();
                }
                eaConnector.Update();

                EA.Diagram currentDiagram = repository.GetCurrentDiagram();
                if (currentDiagram != null)
                {
                    repository.ReloadDiagram(currentDiagram.DiagramID);
                }

                EReference eRef = new EReference(repository.GetConnectorByID(eaConnector.ConnectorID), repository);
                eRef.saveTreeToEATaggedValue(false);
            }
        }
Ejemplo n.º 5
0
        private EA.Element createNewCorrespondenceLink(EA.Package tggOutermostePackage, out EA.Connector connectorToSource, out EA.Connector connectorToTarget)
        {
            EA.Element tggLink = tggOutermostePackage.Elements.AddNew(textBoxLinkName.Text, Main.EAClassType) as EA.Element;
            tggLink.StereotypeEx = TGGModelingMain.TggCorrespondenceTypeStereotype;
            tggLink.Update();

            TGGCorrespondenceType correspondenceType = new TGGCorrespondenceType(sqlRepository.GetElementByID(tggLink.ElementID), sqlRepository);

            correspondenceType.saveTreeToEATaggedValue(false);

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

            connectorToSource.Update();

            EReference refToSource = new EReference(sqlRepository.GetConnectorByID(connectorToSource.ConnectorID), sqlRepository);

            refToSource.saveTreeToEATaggedValue(true);


            tggLink.Connectors.Refresh();

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

            connectorToTarget.Update();

            EReference refToTarget = new EReference(sqlRepository.GetConnectorByID(connectorToTarget.ConnectorID), sqlRepository);

            refToTarget.saveTreeToEATaggedValue(true);

            selectedCorrespondenceLinkId = tggLink.ElementID;

            EA.Diagram       curDiagram    = null;
            EA.DiagramObject sourceDiagObj = null;
            EA.DiagramObject targetDiagObj = null;
            foreach (EA.Diagram diag in tggOutermostePackage.Diagrams)
            {
                foreach (EA.DiagramObject diagObj in diag.DiagramObjects)
                {
                    if (diagObj.ElementID == clientClassifier.ElementID)
                    {
                        sourceDiagObj = diagObj;
                    }
                    else if (diagObj.ElementID == supplierClassifier.ElementID)
                    {
                        targetDiagObj = diagObj;
                    }

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

            if (curDiagram != null)
            {
                sqlRepository.SaveDiagram(curDiagram.DiagramID);
                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();

                sqlRepository.ReloadDiagram(curDiagram.DiagramID);

                tggOutermostePackage.Elements.Refresh();
            }
            return(tggLink);
        }
Ejemplo n.º 6
0
        private static void onNotifyEReferenceModified(SQLRepository sqlRepository, EA.Connector con)
        {
            EReference eRef = new EReference(sqlRepository.GetConnectorByID(con.ConnectorID), sqlRepository);

            eRef.saveTreeToEATaggedValue(true);
        }