Exemple #1
0
 public static EA.ConnectorTag setTaggedValueNotes(SQLRepository repository, EA.Connector connector, String name, String notes)
 {
     connector.TaggedValues.Refresh();
     EA.ConnectorTag aTag = setTaggedValue(repository, connector, name, "<memo>");
     aTag.Notes = notes;
     aTag.Update();
     return(aTag);
 }
        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);
            }
        }
Exemple #3
0
 /// <summary>
 /// Creates or editExistingLink the ConnectorTag with the given name and value of the given connector
 /// </summary>
 /// <param name="element"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns>the created or edited ConnectorTag</returns>
 public static EA.ConnectorTag setTaggedValue(SQLRepository repository, EA.Connector con, String name, String value)
 {
     EA.Connector connector = con;
     connector.TaggedValues.Refresh();
     EA.ConnectorTag aTag = findTaggedValue(connector, name);
     if (aTag == null)
     {
         aTag = (EA.ConnectorTag)connector.TaggedValues.AddNew(name, value);
     }
     aTag.Value = value;
     aTag.Update();
     return(aTag);
 }
Exemple #4
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);
        }
        public static void TaggedValueSet(EA.Connector connector, string tagName, string tagValue)
        {
            EA.ConnectorTag tag = null;
            try
            {
                tag = connector.TaggedValues.GetByName(tagName);
            }
            catch (Exception ex)
            {
                if (ex.Message != "Index out of bounds")
                {
                    throw ex;
                }
            }

            if (tag == null)
            {
                tag = connector.TaggedValues.AddNew(tagName, tagValue);
            }

            tag.Value = tagValue;
            bool res = tag.Update();
            //connector.Update(); // is it needed?
        }
Exemple #6
0
        private bool importRelationships(EA.Package selectedPackage, RelationshipType[] relationships, bool deleteExisting)
        {
            bool issues = false;

            // don't know how to update this, just clear connectors for imported objects
            // and recreate if the import file has relationships otherwise ignore relationships
            if (deleteExisting)
            {
                foreach (EA.Element eaElement in eaElementDict.Values)
                {
                    bool updateElement = false;
                    int  conCount      = eaElement.Connectors.Count;
                    for (short c = (short)(conCount - 1); c >= 0; c--)
                    {
                        EA.Connector con = (EA.Connector)eaElement.Connectors.GetAt(c);
                        if (idMappings.ContainsValue(con.SupplierID))
                        {
                            eaElement.Connectors.Delete(c);
                            updateElement = true;
                        }
                    }
                    if (updateElement)
                    {
                        eaElement.Update();
                    }
                }
            }

            foreach (RelationshipType maxRel in relationships)
            {
                if (maxRel.sourceId == null || maxRel.destId == null)
                {
                    Repository.WriteOutput("MAX", "Skipped relationship missing sourceId and destId", 0);
                    issues = true;
                    continue;
                }
                else if (maxRel.sourceId == null)
                {
                    Repository.WriteOutput("MAX", string.Format("Skipped relationship dest {0}, missing sourceId", maxRel.destId), 0);
                    issues = true;
                    continue;
                }
                else if (maxRel.destId == null)
                {
                    Repository.WriteOutput("MAX", string.Format("Skipped relationship source {0}, missing destId", maxRel.id), 0);
                    issues = true;
                    continue;
                }
                string     sourceId = maxRel.sourceId.Trim().ToUpper();
                EA.Element eaSourceElement;
                if (!eaElementDict.ContainsKey(sourceId))
                {
                    // create abstract placeholder object; missing in objects list??
                    Repository.WriteOutput("MAX", string.Format("Placeholder created for missing source {0}", sourceId), 0);
                    issues                   = true;
                    eaSourceElement          = (EA.Element)selectedPackage.Elements.AddNew(string.Format("_{0}", sourceId), "Class");
                    eaSourceElement.Abstract = "1";
                    eaSourceElement.Update();
                    if (eaSourceElement.TaggedValues.GetByName(TV_MAX_ID) == null)
                    {
                        EA.TaggedValue tvID = (EA.TaggedValue)eaSourceElement.TaggedValues.AddNew(TV_MAX_ID, "");
                        tvID.Value = sourceId;
                        tvID.Update();
                    }
                    eaElementDict[sourceId] = eaSourceElement;
                }
                else
                {
                    eaSourceElement = eaElementDict[sourceId];
                }

                string     destId = maxRel.destId.Trim().ToUpper();
                EA.Element eaDestElement;
                if (!eaElementDict.ContainsKey(destId))
                {
                    // create placeholder object; missing in objects list??
                    Repository.WriteOutput("MAX", string.Format("Placeholder created for missing dest {0}", destId), 0);
                    issues                 = true;
                    eaDestElement          = (EA.Element)selectedPackage.Elements.AddNew(string.Format("_{0}", destId), "Class");
                    eaDestElement.Abstract = "1";
                    eaDestElement.Update();
                    if (eaDestElement.TaggedValues.GetByName(TV_MAX_ID) == null)
                    {
                        EA.TaggedValue tvID = ((EA.TaggedValue)eaDestElement.TaggedValues.AddNew(TV_MAX_ID, ""));
                        tvID.Value = destId;
                        tvID.Update();
                    }
                    eaElementDict[destId] = eaDestElement;
                }
                else
                {
                    eaDestElement = eaElementDict[destId];
                }

                string type = "Association";
                if (maxRel.typeSpecified)
                {
                    type = Enum.GetName(typeof(RelationshipTypeEnum), maxRel.type);
                    // Handle special types
                    switch (maxRel.type)
                    {
                    case RelationshipTypeEnum.Composition:
                        type = "Aggregation";
                        break;

                    case RelationshipTypeEnum.DirectedAssociation:
                        type = "Association";
                        break;
                    }
                }
                string label = maxRel.label;
                if (label != null)
                {
                    label = label.Trim();
                }
                else
                {
                    label = "";
                }
                EA.Connector eaCon = (EA.Connector)eaSourceElement.Connectors.AddNew(label, type);
                eaCon.SupplierID = eaDestElement.ElementID;
                // Handle special types
                switch (maxRel.type)
                {
                case RelationshipTypeEnum.Composition:
                    eaCon.SupplierEnd.Aggregation = 2;
                    break;

                case RelationshipTypeEnum.DirectedAssociation:
                    eaCon.Direction             = "Source -> Destination";
                    eaCon.SupplierEnd.Navigable = "Non-Navigable";
                    break;
                }

                // Generalization doesnot have label and card
                if (!"Generalization".Equals(type))
                {
                    if (maxRel.sourceLabel != null)
                    {
                        eaCon.ClientEnd.Role = maxRel.sourceLabel;
                    }
                    if (maxRel.sourceCard != null)
                    {
                        eaCon.ClientEnd.Cardinality = maxRel.sourceCard;
                    }
                    if (maxRel.destLabel != null)
                    {
                        eaCon.SupplierEnd.Role = maxRel.destLabel;
                    }
                    if (maxRel.destCard != null)
                    {
                        eaCon.SupplierEnd.Cardinality = maxRel.destCard;
                    }
                }
                if (maxRel.stereotype != null)
                {
                    eaCon.StereotypeEx = maxRel.stereotype.Trim();
                }
                if (maxRel.notes != null && maxRel.notes.Text != null && maxRel.notes.Text.Length > 0)
                {
                    eaCon.Notes = maxRel.notes.Text[0].Trim().Replace("\n", "\r\n");
                }
                try
                {
                    eaCon.Update();
                }
                catch (Exception)
                {
                    Repository.WriteOutput("MAX", string.Format("Illegal relationship type '{0}' between {1} and {2}", type, sourceId, destId), 0);
                    issues = true;
                }
                if (maxRel.tag != null)
                {
                    foreach (TagType maxTag in maxRel.tag)
                    {
                        string          tagName = maxTag.name.Trim();
                        EA.ConnectorTag tv      = (EA.ConnectorTag)eaCon.TaggedValues.GetByName(tagName);
                        if (tv == null)
                        {
                            tv = (EA.ConnectorTag)eaCon.TaggedValues.AddNew(tagName, "ConnectorTag");
                        }
                        if (maxTag.value != null)
                        {
                            tv.Value = maxTag.value;
                        }
                        if (maxTag.Text != null && maxTag.Text.Length > 0)
                        {
                            tv.Notes = maxTag.Text[0].Trim().Replace("\n", "\r\n");
                        }
                        tv.Update();
                    }
                }
                progress.step();
            }
            return(issues);
        }