예제 #1
0
        /// <summary>
        /// AddConnector
        /// </summary>
        /// <param name="diagram"></param>
        /// <param name="eElement"></param>
        /// <param name="strFullOpName"></param>
        /// <param name="strEvent"></param>
        /// <param name="iSupplierID"></param>
        /// <param name="iSeqNo"></param>
        private void AddConnector(EA.Diagram diagram, EA.Element eElement, string strFullOpName, string strEvent, int iSupplierID, int iSeqNo, string strNotes)
        {
            string strLogInfo = "Connector for operation: " + strFullOpName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = null;

            //for (short i = 0; i < eElement.Connectors.Count; i++)
            //{
            //    Application.DoEvents();

            //    eConnector = eElement.Connectors.GetAt(i);

            //    if (eConnector.Name == strFullOpName)
            //    {
            //        break;
            //    }
            //    else
            //    {
            //        eConnector = null;
            //    }
            //}

            if (eConnector == null)
            {
                eConnector       = eElement.Connectors.AddNew(strFullOpName, "Sequence");
                eConnector.Notes = strNotes;

                eConnector.SequenceNo       = iSeqNo;
                eConnector.SupplierID       = iSupplierID;
                eConnector.TransitionAction = "Call";
                eConnector.TransitionEvent  = "Synchronus";
                eConnector.TransitionGuard  = "params=;paramsDlg=param1;";
                eConnector.Update();

                eConnector.StartPointY = eConnector.StartPointY + 1;
                eConnector.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strEvent, "sequence");
            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            eDiagramLink.Update();

            diagram.Update();
        }
예제 #2
0
        /// <summary>
        /// Updates values in connector ends and update them in repository.
        /// </summary>
        public void Save(GoatAssociationModel Association)
        {
            UpdateLeftOrRightConnector(Association.Left, connector.ClientEnd);
            UpdateLeftOrRightConnector(Association.Right, connector.SupplierEnd);

            //fixing design error in Sparx EA, you have to also change _connector.Direction
            if (Association.Left.Navigability == NavigabilityType.Navigable && Association.Right.Navigability == NavigabilityType.Navigable)
            {
                connector.Direction = "Bi-Directional";
            }
            else if (Association.Left.Navigability != NavigabilityType.Navigable && Association.Right.Navigability == NavigabilityType.Navigable)
            {
                connector.Direction = "Source -> Destination";
            }
            else if (Association.Left.Navigability == NavigabilityType.Navigable && Association.Right.Navigability != NavigabilityType.Navigable)
            {
                connector.Direction = "Destination -> Source";
            }
            else
            {
                connector.Direction = "Unspecified";
            }

            connector.Update(); //this is with high probability not neccessarry... could depend on EA version
        }
예제 #3
0
        private static void linkToParent(EA.Repository Repository, EA.Diagram diagram, EA.Element sample, EA.Element parent)
        {
            foreach (EA.Connector con in sample.Connectors)
            {
                logger.log("Connector:" + con.SupplierEnd.Role);
                EA.Element related = null;

                if (sample.ElementID == con.ClientID && parent.ElementID == con.SupplierID)
                {
                    logger.log("Found parent link");
                    return;
                }
                else if (sample.ElementID == con.SupplierID && parent.ElementID == con.ClientID)
                {
                    logger.log("Found parent link");
                    return;
                }
            }

            logger.log("No  parent link found");
            EA.Connector link = sample.Connectors.AddNew("", "Association");
            link.SupplierID = parent.ElementID;
            link.Update();

            EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
            dl.ConnectorID = link.ConnectorID;
            sample.Connectors.Refresh();
            dl.Update();
        }
예제 #4
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();
                        }
                    }
                }
            }
        }
예제 #5
0
        private static void sync_relationship(EA.Repository Repository, EA.Diagram diagram, String connectorGuid, EA.Element source, EA.Element target, JObject jo, EA.Package pkg)
        {
            if (checkRelationship(Repository, connectorGuid, source, target))
            {
                //logger.log("Relationship exists:"+source.Name+":"+target.Name);
            }
            else
            {
                logger.log("Adding Relationship:" + source.Name + ":" + target.Name);

                //Add relationship  logger.log("No  parent link found");
                EA.Connector link = source.Connectors.AddNew("", "Association");
                link.SupplierID = target.ElementID;
                link.Update();
                source.Update();
                target.Update();

                EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
                dl.ConnectorID = link.ConnectorID;
                dl.Update();

                source.Connectors.Refresh();
                target.Connectors.Refresh();
            }
        }
예제 #6
0
        private void updateConnectorEnd()
        {
            foreach (string eadId in eaIdConnectorIdMap.Keys)
            {
                int          id  = eaIdConnectorIdMap[eadId];
                EA.Connector con = this.repository.GetConnectorByID(id);
                if (eaIdPackageIdMap.ContainsKey(connectorSrcMap[id]))
                {
                    con.ClientID = repository.GetPackageByID(eaIdPackageIdMap[connectorSrcMap[id]]).Element.ElementID;
                }
                else if (eAIdElementIdMap.ContainsKey(connectorSrcMap[id]))
                {
                    con.ClientID = repository.GetElementByID(eAIdElementIdMap[connectorSrcMap[id]]).ElementID;
                }
                else
                {
                    continue;
                }

                if (eaIdPackageIdMap.ContainsKey(connectorTgtMap[id]))
                {
                    con.SupplierID = repository.GetPackageByID(eaIdPackageIdMap[connectorTgtMap[id]]).Element.ElementID;
                }
                else if (eAIdElementIdMap.ContainsKey(connectorTgtMap[id]))
                {
                    con.SupplierID = repository.GetElementByID(eAIdElementIdMap[connectorTgtMap[id]]).ElementID;
                }
                else
                {
                    continue;
                }
                con.Update();
            }
        }
        private int AddConnector(EA.Diagram diagram, EA.Element eaElSource, EA.Element eaElDest, string strText, string strControlType, string strPath = "")
        {
            string strLogInfo = "Connector for operation: " + strText;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = eaElSource.Connectors.AddNew(strText, strControlType);
            if (eConnector == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            // eConnector.Notes = strNotes;
            eConnector.SupplierID = eaElDest.ElementID;
            eConnector.Width      = 2;
            eConnector.Update();

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strText, strControlType);
            if (eDiagramLink == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            if (strPath != "")
            {
                eDiagramLink.Path = strPath;
            }
            eDiagramLink.Update();

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(0);
        }
예제 #8
0
        private void setCompilerInstruction(R2ModelElementHolder dl, R2Const.Qualifier qualifier, string change_note = null)
        {
            // If there is no Compiler Instruction, create one
            if (dl.compilerInstructionEAElement == null)
            {
                dl.compilerInstructionEAElement            = (EA.Element)profileDefinitionPackage.Elements.AddNew(dl.baseModelEAElement.Name, "Class");
                dl.compilerInstructionEAElement.Stereotype = R2Const.ST_COMPILERINSTRUCTION;
                dl.compilerInstructionEAElement.Update();
                if (dl.baseModelEAElement.Type == "Package")
                {
                    EA.Connector con = (EA.Connector)dl.compilerInstructionEAElement.Connectors.AddNew("", "Dependency");
                    con.Stereotype = "Generalization";
                    con.SupplierID = dl.baseModelEAElement.ElementID;
                    con.Update();
                }
                else
                {
                    EA.Connector con = (EA.Connector)dl.compilerInstructionEAElement.Connectors.AddNew("", "Generalization");
                    con.SupplierID = dl.baseModelEAElement.ElementID;
                    con.Update();
                }
                dl.compilerInstructionEAElement.Connectors.Refresh();
                dl.modelElement = R2ModelV2.EA_API.Factory.Create(repository, dl.compilerInstructionEAElement);
                profileDefinitionPackage.Elements.Refresh();
            }

            switch (qualifier)
            {
            case R2Const.Qualifier.Deprecate:
                EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "DEP");
                break;

            case R2Const.Qualifier.Delete:
                EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "D");
                break;

            case R2Const.Qualifier.Exclude:
                EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "EXCLUDE");
                break;

            case R2Const.Qualifier.None:
            default:
                EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "");
                break;
            }

            if (!string.IsNullOrEmpty(change_note))
            {
                EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_CHANGENOTE, "<memo>", change_note);
            }
            else
            {
                EAHelper.DeleteTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_CHANGENOTE);
            }

            dl.compilerInstructionEAElement.TaggedValues.Refresh();
            dl.compilerInstructionEAElement.Refresh();
        }
        private bool Update(EA.Connector con)
        {
            bool result = con.Update();

            if (result == false)
            {
                throw new Exception("Update Didn't work out properlly!!!");
            }
            return(result);
        }
예제 #10
0
 private void addMessagePortRelation(EA.Diagram diagram, int startElementId, int endElementId)
 {
     EA.Element   startElement = this.repository.GetElementByID(startElementId);
     EA.Connector cn           = startElement.Connectors.AddNew("", "Association");
     cn.Stereotype = "UOPMessagePort";
     cn.SupplierID = endElementId;
     cn.Direction  = "Source -> Destination";
     cn.Update();
     startElement.Connectors.Refresh();
 }
예제 #11
0
        private int CreateUseCaseDigram(string strUseCaseName, EA.Package eaPackage, XElement elUseCase, EA.Element eaElUCClassElement)
        {
            int iErrorCount = 0;

            EA.Diagram UCdiagram = EAImporter.AddDiagram(eaPackage, "Use Case Diagram", "Use Case");

            Hashtable UCRefActors = EAImporter.m_Actors.GetActorUseCaseRefs();

            EA.Element eaElUseCase = eaPackage.Elements.AddNew(strUseCaseName, "Use Case");

            int iErrCnt = AddUCToUCDiagram(eaPackage, UCdiagram, eaElUseCase.ElementID, eaElUCClassElement.ElementID, UCRefActors.Count / 2);

            EA.Connector con2 = eaElUCClassElement.Connectors.AddNew("describes", "Dependancy");
            con2.SupplierID = eaElUseCase.ElementID;
            con2.Update();
            eaElUCClassElement.Connectors.Refresh();

            m_NoUseCaseActors = 0;

            foreach (DictionaryEntry deActorRef1 in UCRefActors)
            {
                string strActorName = (string)deActorRef1.Key;

                EA.Element eaElActor = EAImporter.m_Actors.GetActor(strActorName);

                iErrorCount = iErrorCount + AddActorToUCDiagram(eaPackage, UCdiagram, eaElActor.ElementID);

                EA.Connector con1 = eaElUseCase.Connectors.AddNew("", "UseCase");
                con1.SupplierID = eaElActor.ElementID;
                con1.Update();

                EA.ConnectorTag eaTgVal = con1.TaggedValues.AddNew("furtherInformation", "TaggedValue");

                eaTgVal.Value = ((ImportFieldsValidator)deActorRef1.Value)["furtherInformation"].Value;
                eaTgVal.Update();

                con1.Update();

                eaElUseCase.Connectors.Refresh();
            }

            return(iErrorCount);
        }
예제 #12
0
        public static string setOvMethodCallExpressionGui(ObjectVariable ov)
        {
            SQLTaggedValue mceVisTag = EAUtil.findTaggedValue(ov.sqlElement, ObjectVariable.MceVisualizationTaggedValueName);


            Expression BindingExpression = ov.BindingExpression;

            if (BindingExpression != null)

            {
                deletePossibleBindingConnectors(ov.sqlElement.getRealElement());

                if (BindingExpression is MethodCallExpression)
                {
                    var mcE = BindingExpression as MethodCallExpression;

                    ObjectVariableExpression firstOvExpression = null;

                    if (mcE.OwnedParameterBinding.Count == 1 && (mceVisTag == null || mceVisTag.Value == "true"))
                    {
                        foreach (ParameterBinding paramBinding in mcE.OwnedParameterBinding)
                        {
                            if (paramBinding.ValueExpression is ObjectVariableExpression)
                            {
                                firstOvExpression = paramBinding.ValueExpression as ObjectVariableExpression;
                            }
                        }

                        if (firstOvExpression != null)
                        {
                            EA.Element firstOvEaElement = ov.Repository.GetOriginalRepository().GetElementByGuid(firstOvExpression.ObjectVariableGUID);

                            if (firstOvEaElement.ParentID == ov.sqlElement.ParentID)
                            {
                                EA.Connector bindingLink = firstOvEaElement.Connectors.AddNew("", Main.EADependencyType) as EA.Connector;
                                bindingLink.Stereotype = SDMModelingMain.BindingExpressionLinkStereotype;
                                bindingLink.Name       = mcE.Target + "." + mcE.MethodName;
                                bindingLink.SupplierID = ov.sqlElement.ElementID;
                                bindingLink.Update();
                                EA.Element realElement = ov.sqlElement.getRealElement();
                                realElement.Connectors.Refresh();
                                realElement.Notes = "";
                                realElement.Update();

                                EAUtil.setTaggedValue(ov.Repository, realElement, ObjectVariable.BindingExpressionOutputTaggedValueName, "");

                                return("");
                            }
                        }
                    }
                }
                return(BindingExpression.ToString());
            }
            return("");
        }
예제 #13
0
        private void addTGGLinkVariableCopyToRule(EA.Connector connectorToBeCopied)
        {
            EA.Element newSource = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.ClientID]];
            EA.Element newTarget = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.SupplierID]];

            EA.Connector newConnector = newSource.Connectors.AddNew("", connectorToBeCopied.Type) as EA.Connector;
            newConnector.Stereotype       = TGGModelingMain.TggLinkVariableStereotype;
            newConnector.ClientEnd.Role   = connectorToBeCopied.ClientEnd.Role;
            newConnector.SupplierEnd.Role = connectorToBeCopied.SupplierEnd.Role;
            newConnector.SupplierID       = newTarget.ElementID;
            newConnector.ClientID         = newSource.ElementID;
            newConnector.Update();
            if (connectorToBeCopied.Stereotype == TGGModelingMain.TggLinkVariableStereotype)
            {
                foreach (EA.ConnectorTag tag in connectorToBeCopied.TaggedValues)
                {
                    EA.ConnectorTag newTag = newConnector.TaggedValues.AddNew(tag.Name, "") as EA.ConnectorTag;
                    if (!checkBoxExactCopy.Checked)
                    {
                        newTag.Value = tag.Value.Replace("create", "check_only");
                        newTag.Notes = tag.Notes.Replace("\"bindingOperator\" value=\"create", "\"bindingOperator\" value=\"check_only");
                    }
                    else
                    {
                        newTag.Value = tag.Value;
                        newTag.Notes = tag.Notes;
                    }
                    newTag.Update();
                }
            }
            EA.DiagramLink newDiagramLink = newRuleDiagram.DiagramLinks.AddNew("", newConnector.Type) as EA.DiagramLink;
            newDiagramLink.ConnectorID = newConnector.ConnectorID;
            newDiagramLink.Update();
            if (connectorToBeCopied.Stereotype != TGGModelingMain.TggLinkVariableStereotype)
            {
                LinkDialogueEntry linkEntry = new LinkDialogueEntry();
                linkEntry.direction = LinkDialogueEntryDirection.RIGHT;
                linkEntry.CorrespondingConnectorGuid = connectorToBeCopied.ConnectorGUID;
                if (newConnector.ClientEnd.Role != "")
                {
                    linkEntry.supplierRoleName = newConnector.ClientEnd.Role;
                }
                else if (newConnector.SupplierEnd.Role != "")
                {
                    linkEntry.supplierRoleName = newConnector.SupplierEnd.Role;
                }
                TGGLinkVariable tggLv = new TGGLinkVariable(repository.GetConnectorByID(newConnector.ConnectorID), repository);
                tggLv.linkDialogueEntry = linkEntry;
                if (!checkBoxExactCopy.Checked)
                {
                    tggLv.BindingOperator = SDMModeling.SDMExportWrapper.patterns.BindingOperator.CREATE;
                }
                tggLv.saveTreeToEATaggedValue(true);
            }
        }
예제 #14
0
        private void addInheritanceLinkToOriginalRule()
        {
            EA.Element baseRule   = this.newRuleElement;
            EA.Element parentRule = this.originalRuleElement.getRealElement();

            EA.Connector refinementConnector = baseRule.Connectors.AddNew("", "TGGCustomGeneralization") as EA.Connector;
            refinementConnector.SupplierID = parentRule.ElementID;
            refinementConnector.Update();
            baseRule.Update();
            parentRule.Update();
        }
예제 #15
0
        private void setConnectorInfo(EA.Package p, EA.Connector connector, XmlNode xmlNode)
        {
            string src = xmlNode.Attributes.GetNamedItem("client").Value, tgt = xmlNode.Attributes.GetNamedItem("supplier").Value;

            connector.ClientID   = p.PackageID;
            connector.SupplierID = p.PackageID;
            connector.Update();
            connectorSrcMap[connector.ConnectorID] = src;
            connectorTgtMap[connector.ConnectorID] = tgt;
            eaIdConnectorIdMap[xmlNode.Attributes.GetNamedItem("xmi:id").Value] = connector.ConnectorID;
        }
예제 #16
0
        private void addInformationFlow(EA.Package p, XmlNode xmlNode)
        {
            EA.Connector connector = p.Connectors.AddNew("", "InformationFlow");
            string       src = xmlNode.Attributes.GetNamedItem("informationSource").Value, tgt = xmlNode.Attributes.GetNamedItem("informationTarget").Value;

            connector.ClientID   = p.PackageID;
            connector.SupplierID = p.PackageID;
            connector.Update();
            connectorSrcMap[connector.ConnectorID] = src;
            connectorTgtMap[connector.ConnectorID] = tgt;
            eaIdConnectorIdMap[xmlNode.Attributes.GetNamedItem("xmi:id").Value] = connector.ConnectorID;
        }
예제 #17
0
        private void addAssociation(EA.Package p, XmlNode xmlNode)
        {
            string src = "", tgt = "";
            string srcEleId = "", tgtEleId = "";
            string name = xmlNode.Attributes.GetNamedItem("name") == null ? "" : xmlNode.Attributes.GetNamedItem("name").Value;

            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                if (node.Name == "memberEnd")
                {
                    string idRef = node.Attributes.GetNamedItem("xmi:idref").Value;
                    if (idRef.Contains("src"))
                    {
                        src = idRef;
                    }
                    else
                    {
                        tgt = idRef;
                    }
                }
            }
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                if (node.Name == "ownedEnd")
                {
                    string id = node.Attributes.GetNamedItem("xmi:id").Value;
                    foreach (XmlNode n in node.ChildNodes)
                    {
                        if (n.Name == "type")
                        {
                            string eleId = n.Attributes.GetNamedItem("xmi:idref").Value;
                            if (id == src)
                            {
                                srcEleId = eleId;
                            }
                            else if (id == tgt)
                            {
                                tgtEleId = eleId;
                            }
                        }
                    }
                }
            }
            EA.Connector connector = p.Connectors.AddNew(name, "Association");
            connector.ClientID   = p.PackageID;
            connector.SupplierID = p.PackageID;
            connector.Update();
            connectorSrcMap[connector.ConnectorID] = srcEleId;
            connectorTgtMap[connector.ConnectorID] = tgtEleId;
            eaIdConnectorIdMap[xmlNode.Attributes.GetNamedItem("xmi:id").Value] = connector.ConnectorID;
        }
예제 #18
0
        public EA.Connector getOrCreateConnector(SQLElement client, SQLElement supplier, String guid, String connectorType)
        {
            String oldGuid = guid.Replace("Client", "").Replace("Supplier", "");

            EA.Connector connector = getConnector(oldGuid);
            if (connector == null)
            {
                connector            = client.getRealElement().Connectors.AddNew("", connectorType) as EA.Connector;
                connector.SupplierID = supplier.ElementID;
                connector.Update();
                if (oldGuid != "")
                {
                    repository.Execute("update t_connector set ea_guid = '" + oldGuid + "' where ea_guid = '" + connector.ConnectorGUID + "'");
                    connector = repository.GetConnectorByGuid(oldGuid);
                }
            }
            connector.ClientID   = client.ElementID;
            connector.SupplierID = supplier.ElementID;

            connector.Update();

            return(connector);
        }
예제 #19
0
        private void addCSPConstraintLinkCopy(EA.Connector connectorToBeCopied)
        {
            EA.Element newSource = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.ClientID]];
            EA.Element newTarget = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.SupplierID]];

            EA.Connector newConnector = newSource.Connectors.AddNew("", connectorToBeCopied.Type) as EA.Connector;
            newConnector.Stereotype       = connectorToBeCopied.Stereotype;
            newConnector.ClientEnd.Role   = connectorToBeCopied.ClientEnd.Role;
            newConnector.SupplierEnd.Role = connectorToBeCopied.SupplierEnd.Role;
            newConnector.Name             = connectorToBeCopied.Name;
            newConnector.SupplierID       = newTarget.ElementID;
            newConnector.ClientID         = newSource.ElementID;
            newConnector.Update();
        }
예제 #20
0
        private void importCriteria(EA.Element functionElement, XElement xFunction)
        {
            string functionID = getXElementValue(xFunction, "ID");

            foreach (XElement xCriteria in xFunction.Elements("Criteria"))
            {
                string criteriaID   = string.Format("{0}#{1:00}", functionID, int.Parse(getXElementValue(xCriteria, "ID")));
                string criteriaText = getXElementValue(xCriteria, "Text");
                string criteriaOpt  = getXElementValue(xCriteria, "Optionality");
                string criteriaRow  = xCriteria.Attribute("Row").Value;
                string criteriaCond = getXElementValue(xCriteria, "Conditional");
                string criteriaDep  = getXElementValue(xCriteria, "Dependent");

                EA.Element criteriaElement = (EA.Element)functionElement.Elements.AddNew(criteriaID, "Requirement");
                elements.Add(criteriaID, criteriaElement);
                criteriaElement.Notes      = criteriaText;
                criteriaElement.Stereotype = R2Const.ST_CRITERION;
                R2Config.config.updateStyle(criteriaElement);
                criteriaElement.Update();
                criteriaElement.Locked = LOCK_ELEMENTS;

                // Create TaggedValues for extra metadata
                addTaggedValue(criteriaElement, "Row", criteriaRow);
                addTaggedValue(criteriaElement, "Optionality", criteriaOpt);
                addTaggedValue(criteriaElement, "Conditional", criteriaCond);
                addTaggedValue(criteriaElement, "Dependent", criteriaDep);
                addReferenceTags(criteriaElement, xCriteria);

                // Add a Connector from Criteria to Function
                EA.Connector connector = (EA.Connector)criteriaElement.Connectors.AddNew("", "Association");
                connector.SupplierID = functionElement.ElementID;
                connector.Update();

                IEnumerable <XElement> linkList = xCriteria.XPathSelectElements("ConsequenceLink/FunctionID");
                foreach (XElement id in linkList)
                {
                    addConsequenceLink(functionID, id.Value, String.Format("{0} is the source of this link", criteriaID));
                }
                IEnumerable <XElement> seeAlsoList = xCriteria.XPathSelectElements("SeeAlso/FunctionID");
                foreach (XElement id in seeAlsoList)
                {
                    addSeeAlsoLink(criteriaID, id.Value.Trim());
                }
            }
        }
예제 #21
0
        private static void sync_relationship(EA.Repository Repository, EA.Diagram diagram, EA.Element source, EA.Element target, JObject jo, EA.Package pkg)
        {
            logger.log("Adding Relationship:");

            //Add relationship  logger.log("No  parent link found");
            EA.Connector link = source.Connectors.AddNew("", "Association");
            link.SupplierID = target.ElementID;
            link.Update();
            source.Update();
            target.Update();

            EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
            dl.ConnectorID = link.ConnectorID;
            dl.Update();

            source.Connectors.Refresh();
            target.Connectors.Refresh();
        }
예제 #22
0
        private EA.Connector createNewConnection(Dictionary <SQLElement, EA.DiagramObject> elementsToDiagramObjects, EA.Diagram currentDiagram, String objectName, String attributeName)
        {
            foreach (SQLElement diagramElement in elementsToDiagramObjects.Keys)
            {
                if (diagramElement.Name == objectName)
                {
                    EA.Connector connector = constraintElement.getRealElement().Connectors.AddNew(attributeName, Main.EADependencyType) as EA.Connector;
                    connector.SupplierID   = diagramElement.ElementID;
                    connector.StereotypeEx = "ConstraintLink";
                    connector.Update();

                    EA.DiagramLink diagramLink = currentDiagram.DiagramLinks.AddNew("", Main.EADependencyType) as EA.DiagramLink;
                    diagramLink.ConnectorID = connector.ConnectorID;
                    diagramLink.Update();
                    return(connector);
                }
            }
            return(null);
        }
예제 #23
0
 private int addRealizeRelation(EA.Element element)
 {
     if (eAElementEAClassMap.ContainsKey(element.ElementID))
     {
         EAClass eAClass    = eAElementEAClassMap[element.ElementID];
         string  aimClassId = eAClass.RealizeClassID;
         if (aimClassId != null && eAIdElementIdMap.ContainsKey(aimClassId))
         {
             EA.Connector cn = element.Connectors.AddNew("", "Association");
             cn.SupplierID = eAIdElementIdMap[aimClassId];
             cn.Stereotype = "Realize";
             cn.Direction  = "Source -> Destination";
             cn.Update();
             element.Connectors.Refresh();
             return(cn.SupplierID);
         }
     }
     return(-1);
 }
예제 #24
0
 private int addAxisRelation(string startClassId)
 {
     if (measurementAxisMap.ContainsKey(startClassId))
     {
         string aimClassId = measurementAxisMap[startClassId];
         if (aimClassId != null && eAIdElementIdMap.ContainsKey(aimClassId))
         {
             EA.Element   startElement = this.repository.GetElementByID(eAIdElementIdMap[startClassId]);
             EA.Element   endElement   = this.repository.GetElementByID(eAIdElementIdMap[aimClassId]);
             EA.Connector cn           = startElement.Connectors.AddNew("", "Association");
             cn.Stereotype = "Axis";
             cn.SupplierID = eAIdElementIdMap[aimClassId];
             cn.Direction  = "Source -> Destination";
             cn.Update();
             startElement.Connectors.Refresh();
             return(cn.SupplierID);
         }
     }
     return(-1);
 }
예제 #25
0
        /// <summary>
        /// Функция обновляет данные коннектора пор данным переданного ConnectorData
        /// </summary>
        /// <param name="connectorData"></param>
        public static void UpdateConnectorByData(ConnectorData connectorData)
        {
            EA.Connector connector = connectorData.Connector;

            connector.Name       = connectorData.Name;
            connector.Notes      = connectorData.Notes;
            connector.ClientID   = connectorData.SourceElementID;
            connector.SupplierID = connectorData.TargetElementID;
            connector.Update();

            if (connectorData.IsLibrary)
            {
                EATVHelper.TaggedValueSet(connector, DAConst.DP_LibraryTag, "");
                EATVHelper.TaggedValueSet(connector, DAConst.DP_LinkTypeTag, connectorData.LinkType.ToString());
                EATVHelper.TaggedValueSet(connector, DAConst.DP_FlowIDTag, connectorData.FlowID);
                EATVHelper.TaggedValueSet(connector, DAConst.DP_SegmentIDTag, connectorData.SegmentID);
            }

            Context.ConnectorData[connectorData.ConnectorID] = connectorData;
        }
예제 #26
0
        public EA.Element CreateEAConnector(Item innovatorItem)
        {
            /// <summary>
            /// Create EA Connector between two EA Elements (SupplierID)
            /// <paramref name="innovatorItem"/> Innovator Item (RelationshipType)
            /// </summary>
            string sourceId         = innovatorItem.getProperty("source_id", "");
            string relatedId        = innovatorItem.getProperty("related_id", "");
            string relationshipName = innovatorItem.getProperty("name", "");

            if (sourceId != null && relatedId != null)
            {
                try
                {
                    EA.Element parentElement   = GetEAElementByInnovatorID(sourceId);
                    EA.Element childElement    = GetEAElementByInnovatorID(relatedId);
                    bool       connectorExists = false;
                    foreach (EA.Connector parentConnector in parentElement.Connectors)
                    {
                        // Check if the connector already exists
                        if (parentConnector.Name == relationshipName)
                        {
                            connectorExists = true;
                        }
                    }
                    if (!connectorExists)
                    {
                        // Add connector between structure elements
                        EA.Connector structureConnector = parentElement.Connectors.AddNew(relationshipName, "Association");
                        structureConnector.SupplierID = childElement.ElementID;
                        structureConnector.Update();
                    }
                }
                catch
                {
                    // No parent block element or no connectors
                }
            }
            return(null);
        }
        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);
            }
        }
예제 #28
0
        private void importCriteria(EA.Element functionElement, XmlNode functionNode, EA.Repository Repository)
        {
            string      functionID   = functionNode.SelectSingleNode("ID").InnerText;
            XmlNodeList criteriaList = functionNode.SelectNodes("ConformanceCriteria");

            foreach (XmlNode criteriaNode in criteriaList)
            {
                string     criteriaID      = String.Format("{0}#{1}", functionID, criteriaNode.SelectSingleNode("ID").InnerText);
                string     criteriaText    = criteriaNode.SelectSingleNode("Text").InnerText;
                EA.Element criteriaElement = (EA.Element)functionElement.Elements.AddNew(String.Format("{0} {1}", criteriaID, criteriaText), "Requirement");
                functions.Add(criteriaID, criteriaElement);
                criteriaElement.Stereotype = "Criteria";
                // apply color
                string chapter = functionID.Substring(0, functionID.IndexOf('.'));
                if (chapterColors.ContainsKey(chapter))
                {
                    criteriaElement.SetAppearance(1 /*Base*/, 0 /*BGCOLOR*/, chapterColors[chapter]);
                }
                criteriaElement.Update();
                criteriaElement.Locked = LOCK_ELEMENTS;
                string         criteriaOpt = criteriaNode.SelectSingleNode("Optionality").InnerText;
                EA.TaggedValue taggedValue = (EA.TaggedValue)criteriaElement.TaggedValues.AddNew("Optionality", "TaggedValue");
                taggedValue.Value = criteriaOpt;
                taggedValue.Update();

                // Add a Connector from Criteria to Function
                EA.Connector connector = (EA.Connector)criteriaElement.Connectors.AddNew("", "Association");
                connector.SupplierID = functionElement.ElementID;
                connector.Update();

                XmlNodeList linkList = criteriaNode.SelectNodes("Link/FunctionID");
                foreach (XmlNode id in linkList)
                {
                    addLink(functionID, id.InnerText, Repository);
                }
            }
        }
예제 #29
0
        private void initConnectors(XmlNode xmlNode)
        {
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                string tagName = node.Name;
                if (tagName == "connector")
                {
                    string       id        = node.Attributes.GetNamedItem("xmi:idref").Value;
                    EA.Connector connector = this.repository.GetConnectorByID(eaIdConnectorIdMap[id]);

                    foreach (XmlNode conNode in node.ChildNodes)
                    {
                        string name = conNode.Name;
                        switch (name)
                        {
                        case "properties":
                            string direction = conNode.Attributes.GetNamedItem("direction").Value;
                            //     connector.Type = conNode.Attributes.GetNamedItem("ea_type").Value;
                            connector.Direction = direction;
                            break;

                        case "modifiers":
                            connector.IsRoot = conNode.Attributes.GetNamedItem("isRoot").Value == "true" ? true : false;
                            connector.IsLeaf = conNode.Attributes.GetNamedItem("isLeaf").Value == "true" ? true : false;
                            break;

                        case "source":
                            foreach (XmlNode sNode in conNode.ChildNodes)
                            {
                                string souceTagname = sNode.Name;
                                switch (souceTagname)
                                {
                                case "type":
                                    connector.ClientEnd.Containment = sNode.Attributes.GetNamedItem("containment").Value;
                                    connector.ClientEnd.Cardinality = sNode.Attributes.GetNamedItem("multiplicity").Value;
                                    connector.ClientEnd.Aggregation = int.Parse(sNode.Attributes.GetNamedItem("aggregation").Value);
                                    break;

                                case "modifiers":
                                    connector.ClientEnd.IsChangeable = sNode.Attributes.GetNamedItem("changeable").Value;
                                    connector.ClientEnd.IsNavigable  = sNode.Attributes.GetNamedItem("isNavigable").Value == "true" ? true : false;
                                    break;

                                case "role":
                                    connector.ClientEnd.Visibility = sNode.Attributes.GetNamedItem("visibility").Value;
                                    break;

                                default:
                                    break;
                                }
                            }
                            break;

                        case "target":
                            foreach (XmlNode sNode in conNode.ChildNodes)
                            {
                                string souceTagname = sNode.Name;
                                switch (souceTagname)
                                {
                                case "type":
                                    connector.SupplierEnd.Containment = sNode.Attributes.GetNamedItem("containment").Value;
                                    connector.SupplierEnd.Aggregation = int.Parse(sNode.Attributes.GetNamedItem("aggregation").Value);
                                    break;

                                case "modifiers":
                                    connector.SupplierEnd.IsChangeable = sNode.Attributes.GetNamedItem("changeable").Value;
                                    connector.SupplierEnd.IsNavigable  = sNode.Attributes.GetNamedItem("isNavigable").Value == "true" ? true : false;
                                    break;

                                case "role":
                                    connector.SupplierEnd.Visibility = sNode.Attributes.GetNamedItem("visibility").Value;
                                    break;

                                default:
                                    break;
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    connector.Update();
                }
            }
        }
예제 #30
0
        public EA.Connector createConnector(SQLElement client, SQLElement supplier, String guid, String connectorType, int supplierAggregation, int clientAggregation, bool hasOpposite)
        {
            int locSupAgg = supplierAggregation;
            int locCliAgg = clientAggregation;

            String oldGuid = guid.Replace("Client", "").Replace("Supplier", "");

            EA.Connector connector = client.getRealElement().Connectors.AddNew("", connectorType) as EA.Connector;
            connector.SupplierID = supplier.ElementID;
            connector.Update();

            /*
             * ClientEnds cannot be the Composite so switch Sides
             */
            if (clientAggregation == 2)
            {
                connector.ClientID   = supplier.ElementID;
                connector.SupplierID = client.ElementID;
                connector.Update();
                locSupAgg       = clientAggregation;
                locCliAgg       = supplierAggregation;
                connector.Notes = "Switched";
            }

            if (hasOpposite)
            {
                connector.SupplierEnd.Navigable = "Navigable";
                connector.SupplierEnd.Update();
                connector.Update();
                connector.ClientEnd.Navigable = "Navigable";
                connector.ClientEnd.Update();
                connector.Update();
                connector.Direction = "Bi-Directional";
                connector.Update();
            }
            else
            {
                connector.ClientEnd.Navigable = "Navigable";
                connector.ClientEnd.Update();
                connector.Direction = "Source -> Destination";
                connector.Update();
            }

            connector.SupplierEnd.Aggregation = locSupAgg;
            connector.SupplierEnd.Update();
            connector.Update();

            connector.ClientEnd.Aggregation = locCliAgg;
            connector.ClientEnd.Update();
            connector.Update();



            client.Connectors.Refresh();
            supplier.Connectors.Refresh();

            if (oldGuid != "")
            {
                repository.Execute("update t_connector set ea_guid = '" + oldGuid + "' where ea_guid = '" + connector.ConnectorGUID + "'");
                connector = repository.GetConnectorByGuid(oldGuid);
            }

            connector.Update();

            return(connector);
        }