public bool EA_OnContextItemDoubleClicked(EAAPI.Repository repository, string guid, EAAPI.ObjectType objectType) { bool result = false; if (objectType == EAAPI.ObjectType.otElement) { EAAPI.Element element = repository.GetElementByGuid(guid); ViewModelBase viewModel = null; viewModel = GetEditorViewModel(repository, element); if (viewModel != null) { FMCElementPropertyWindow newAgentWindow = new FMCElementPropertyWindow(); newAgentWindow.DataContext = viewModel; newAgentWindow.ShowDialog(); repository.AdviseElementChange(element.ElementID); result = true; } } else if (objectType == EAAPI.ObjectType.otConnector) { EAAPI.Connector connector = repository.GetConnectorByGuid(guid) as EAAPI.Connector; if (connector != null && connector.Stereotype == "access type" && _mainViewModel != null) { _mainViewModel.ShowConnectorDirectionDialogCommand.Execute(connector); repository.AdviseConnectorChange(connector.ConnectorID); result = true; } } return(result); }
private void ConstructTemplateBinding(Ecore.IEGenericType eGenericType, Ecore.IEGenericType ecoreTypeArgument, EA.Connector connectorEa) { int positionTypeArgument = eGenericType.ETypeArguments.IndexOf(ecoreTypeArgument); Ecore.IETypeParameter typeParameter = eGenericType.EClassifier.ETypeParameters[positionTypeArgument]; string bindedName = ecoreTypeArgument.EClassifier.Name; EnAr.Element bindedClass = ConstructClassifier(ecoreTypeArgument.EClassifier); dynamic templateBinding = connectorEa.TemplateBindings.AddNew(bindedName, ""); templateBinding.formalname = typeParameter.Name; templateBinding.ActualGUID = bindedClass.ElementGUID; try { templateBinding.Update(); } catch (Exception) { // ignored } connectorEa.Update(); }
private void SynchronizePortReferenceOfConnector(EAAPI.Element originalPort, EAAPI.Element referencePort) { for (short i = 0; i < referencePort.Connectors.Count; i++) { EAAPI.Connector con = (EA.Connector)referencePort.Connectors.GetAt(i); if (con.Type == "Dependency" && con.Stereotype == "referenceOf" && con.ClientID == referencePort.ElementID && con.SupplierID == originalPort.ElementID) { return; } } // no match logger.Info("Adding referenceOf connector to port."); EAAPI.Connector newConnector = referencePort.AddConnector(originalPort, "Dependency"); newConnector.Stereotype = "referenceOf"; newConnector.Update(); originalPort.Connectors.Refresh(); referencePort.Connectors.Refresh(); }
private void DeleteWrongPortReferenceOfConnections(int originalElementID) { for (short connectorCount = 0; connectorCount < _referenceElement.EmbeddedElements.Count; connectorCount++) { EAAPI.Element embeddedElement = _referenceElement.EmbeddedElements.GetAt(connectorCount) as EAAPI.Element; if (embeddedElement.Type == "Port") { for (short portCounter = 0; portCounter < embeddedElement.Connectors.Count; portCounter++) { EAAPI.Connector referencePortConnector = (EAAPI.Connector)embeddedElement.Connectors.GetAt(portCounter); if (referencePortConnector.ClientID == embeddedElement.ElementID && referencePortConnector.SupplierID != embeddedElement.ElementID && referencePortConnector.Type == "Dependency" && referencePortConnector.Stereotype == "referenceOf") { EAAPI.Element referencedElement = _repository.GetElementByID(referencePortConnector.SupplierID); if (referencedElement.Type == "Port" && referencedElement.ParentID == originalElementID) { // correct reference } else { logger.Info("Deleting wrong referenceOf connector."); _repository.DeleteConnector(referencePortConnector); } } } } } }
public EAElementWrapper(EA.Connector con, Repository repository) { EA.Element client = repository.GetElementByID(con.ClientID); EA.Element supplier = repository.GetElementByID(con.SupplierID); this.name = con.Name + "(from: " + client.Name + " to: " + supplier.Name + ")"; this.stereotype = con.Stereotype; this.type = con.Type; }
private void ExecuteShowConnectorDirectionCommand(EAAPI.Connector connector) { ConnectorDirectionViewModel connectorDirectionViewModel = new ConnectorDirectionViewModel(connector); ConnectorDirectionWindow connectorDirectionWindow = new ConnectorDirectionWindow(); connectorDirectionWindow.DataContext = connectorDirectionViewModel; connectorDirectionWindow.ShowDialog(); }
/// <summary> /// Select diagram object for the passed connector. Save diagram and reload / refresh it. /// </summary> public void SelectDiagramObject(EA.Connector con) { Unselect(); Save(); Rep.ReloadDiagram(_dia.DiagramID); EA.DiagramObject diaObj = _dia.GetDiagramObjectByID(con.SupplierID, ""); _dia.SelectedObjects.AddNew(diaObj.ElementID.ToString(), diaObj.ObjectType.ToString()); }
private EnAr.Element ConstructClass(Ecore.IEClass eClass) { EnAr.Package parentPackage; EnAr.Element clazz; if (!eclassifier2Class.ContainsKey(eClass)) { parentPackage = ConstructMetamodelPackage(eClass.EPackage); clazz = (EnAr.Element)parentPackage.Elements.AddNew(eClass.Name, "Class"); eclassifier2Class[eClass] = clazz; clazz.Abstract = Bool2String(eClass.Abstract.GetValueOrDefault() || eClass.Interface.GetValueOrDefault()); // Manage normal super types foreach (Ecore.IEClass superEClass in eClass.ESuperTypes) { ConstructGeneralization(superEClass, clazz); } // Manage super types that possess type parameters foreach (Ecore.IEGenericType eGenericSuperType in eClass.EGenericSuperTypes) { if (eGenericSuperType.EClassifier != null) { EnAr.Connector generalization = ConstructGeneralization((Ecore.IEClass)eGenericSuperType.EClassifier, clazz); EA.Connector generalizationEa = explorer.GetEaObject(generalization); foreach (Ecore.IEGenericType eTypeArgument in eGenericSuperType.ETypeArguments) { ConstructTemplateBinding(eGenericSuperType, eTypeArgument, generalizationEa); } } } foreach (Ecore.IEStructuralFeature eStructuralFeature in eClass.EStructuralFeatures) { ConstructAttributeOrAssociation(eclassifier2Class[eClass], eStructuralFeature); } // eClass.EOperations //TODO } else { parentPackage = ePackage2Package[eClass.EPackage]; clazz = eclassifier2Class[eClass]; } parentPackage.Elements.Refresh(); parentPackage.Update(); clazz.Update(); clazz.Connectors.Refresh(); return(clazz); }
public SpecIfMetadata CreateMetaDataForDiagramLink(EAAPI.DiagramLink diagramLink, EAAPI.Connector connector, EAAPI.DiagramObject sourceDiagramObject, EAAPI.DiagramObject targetDiagramObject, EAAPI.Element sourceElement, EAAPI.Element targetElement) { SpecIfMetadata result = new SpecIfMetadata(); EAAPI.Element srcElement = sourceElement; EAAPI.Element trgtElement = targetElement; string directionAttribute = null; // unspecified if (connector.Direction == "Source -> Destination") { directionAttribute = "unidirectional"; } else if (connector.Direction == "Destination -> Source") { srcElement = targetElement; trgtElement = sourceElement; directionAttribute = "unidirectional"; } else if (connector.Direction == "Bi-Directional") { directionAttribute = "bidirectional"; } Edge edge = new Edge { Waypoints = new List <Waypoint>(), References = new List <SpecIfReferenceBase>(), SourceResourceReference = new ResourceReference { IdReference = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(srcElement.ElementGUID), RevisionReference = EaDateToRevisionConverter.ConvertDateToRevision(srcElement.Modified) }, TargetResourceReference = new ResourceReference { IdReference = EaSpecIfGuidConverter.ConvertEaGuidToSpecIfGuid(trgtElement.ElementGUID), RevisionReference = EaDateToRevisionConverter.ConvertDateToRevision(trgtElement.Modified) }, Direction = directionAttribute }; edge.Waypoints = CalculateWaypointsForDiagramLink(diagramLink, sourceDiagramObject, targetDiagramObject); result.Edge = edge; return(result); }
public bool GetConnector(out EA.Connector connector) { connector = null; int connectorId; if (GetEAObjectId(ConnectorID, out connectorId)) { connector = repository.GetConnectorByID(connectorId); return(connector != null); } return(false); }
public bool EA_OnPostNewConnector(EAAPI.Repository repository, EAAPI.EventProperties info) { bool result = true; int connectorId = Convert.ToInt32(info.Get(0).Value.ToString()); _channelDataTransferHelper.SetPropertyTypeAndDirectionOnFlowPortCreation(connectorId, "channel", "access type", "FMC4SE Channel"); EAAPI.Connector connector = repository.GetConnectorByID(connectorId) as EAAPI.Connector; if (connector != null && connector.Stereotype == "access type" && _mainViewModel != null) { _mainViewModel.ShowConnectorDirectionDialogCommand.Execute(connector); } return(result); }
public void Generate_otConnector_content( Repository m_Repository, string TOI_GUID, string TOI_Name, string TOI_Type, out EA.Connector MyLink, out Dictionary <string, string> ConnectorDictionary) { EA.Package MyModel = (EA.Package)m_Repository.Models.GetAt(0); MyLink = m_Repository.GetConnectorByGuid(TOI_GUID); // EA.DiagramLink MyDiagramLink = (EA.DiagramLink)DiagramToShow.DiagramLinks.GetAt(iDO); ConnectorDictionary = new Dictionary <string, string>(); MyLink = (EA.Connector)m_Repository.GetConnectorByGuid(TOI_GUID); ConnectorDictionary.Add("Name", TOI_Name); ConnectorDictionary.Add("Type", TOI_Type); ConnectorDictionary.Add("GUID", TOI_GUID); ConnectorDictionary.Add("Alias", MyLink.Alias); ConnectorDictionary.Add("Colour", MyLink.Color.ToString()); ConnectorDictionary.Add("Direction", MyLink.Notes); ConnectorDictionary.Add("Connector ID", MyLink.ConnectorID.ToString()); ConnectorDictionary.Add("Sterotype", MyLink.Stereotype); int ID = m_Repository.GetConnectorByID(MyLink.ConnectorID).ConnectorID; EA.Connector con; try //Try and get the connector object from the repository { con = (EA.Connector)m_Repository.GetConnectorByID(ID); // ListOfLinkURLs.Add(con.Name + "|" + con.ObjectType + "|" + con.ConnectorGUID); // ListOfLinksName.Add(con.Name); } catch { } }
public EA.Connector FindorCreateConnector(string fromElementGUID, string toElementGUID, string connectorDirection, string connectorStereoType) { EA.Element fromElement = eaRepository.GetElementByGuid(fromElementGUID); EA.Element toElement = eaRepository.GetElementByGuid(toElementGUID); EA.Connector connectorFound = null; foreach (EA.Connector connector in fromElement.Connectors) { if (connector.SupplierID == toElement.ElementID) { connectorFound = connector; } } if (null == connectorFound) { connectorFound = (EA.Connector)fromElement.Connectors.AddNew("", connectorStereoType); connectorFound.SupplierID = toElement.ElementID; connectorFound.Direction = connectorDirection; connectorFound.Update(); } return(connectorFound); }
/// <summary> /// Determine the component location in relation to the other component. /// </summary> /// <param name="srcComponentElementId">The source component.</param> /// <param name="destComponentElementId">The destination component.</param> /// <returns>The comoartment location. in = internal component.</returns> private CompartmentDirection DetermineDestinationDecomposition( int srcComponentElementId, int destComponentElementId) { EAShared.Element srcEl = Rep.GetElementByID(srcComponentElementId); for (short i = 0; i < srcEl.Connectors.Count; i++) { EAShared.Connector con = (EAShared.Connector)srcEl.Connectors.GetAt(i); if (con.Type == "Aggregation") { if (con.ClientID == srcComponentElementId && con.SupplierID == destComponentElementId) { return(CompartmentDirection.Out); } if (con.ClientID == destComponentElementId && con.SupplierID == srcComponentElementId) { return(CompartmentDirection.In); } } } return(CompartmentDirection.Unknown); }
//------------------------------------------------------------------------------ // Create default Elements for Statemachine //------------------------------------------------------------------------------ // // init // state 'State1' // final // transition from init to 'State1' public static bool CreateDefaultElementsForStateDiagram(Repository rep, EA.Diagram dia, EA.Element stateChart) { // check if init and final node are available bool init = false; bool final = false; foreach (EA.Element node in stateChart.Elements) { if (node.Type == "StateNode" & node.Subtype == 100) { init = true; } if (node.Type == "StateNode" & node.Subtype == 101) { final = true; } } EA.Element initNode = null; if (!init) { initNode = (EA.Element)stateChart.Elements.AddNew("", "StateNode"); initNode.Subtype = 3; initNode.ParentID = stateChart.ElementID; initNode.Update(); if (dia != null) { HoUtil.AddSequenceNumber(rep, dia); EA.DiagramObject initDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew("l=295;r=315;t=125;b=135;", ""); initDiaNode.Sequence = 1; initDiaNode.ElementID = initNode.ElementID; initDiaNode.Update(); HoUtil.SetSequenceNumber(rep, dia, initDiaNode, "1"); } } EA.Element finalNode = null; // create final node if (!final) { finalNode = (EA.Element)stateChart.Elements.AddNew("", "StateNode"); finalNode.Subtype = 4; finalNode.ParentID = stateChart.ElementID; finalNode.Update(); if (dia != null) { HoUtil.AddSequenceNumber(rep, dia); EA.DiagramObject finalDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew("l=285;r=305;t=745;b=765;", ""); finalDiaNode.Sequence = 1; finalDiaNode.ElementID = finalNode.ElementID; finalDiaNode.Update(); HoUtil.SetSequenceNumber(rep, dia, finalDiaNode, "1"); } } // create state node EA.Element stateNode = (EA.Element)stateChart.Elements.AddNew("", "State"); stateNode.Subtype = 0; // state stateNode.Name = "State1"; stateNode.ParentID = stateChart.ElementID; stateNode.Update(); if (dia != null) { HoUtil.AddSequenceNumber(rep, dia); string pos = "l=300;r=400;t=-400;b=-470"; EA.DiagramObject stateDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew(pos, ""); stateDiaNode.Sequence = 1; stateDiaNode.ElementID = stateNode.ElementID; stateDiaNode.Update(); HoUtil.SetSequenceNumber(rep, dia, stateDiaNode, "1"); // draw a transition EA.Connector con = (EA.Connector)finalNode.Connectors.AddNew("", "StateFlow"); con.SupplierID = stateNode.ElementID; con.ClientID = initNode.ElementID; con.Update(); finalNode.Connectors.Refresh(); stateChart.Elements.Refresh(); dia.DiagramObjects.Refresh(); dia.Update(); rep.ReloadDiagram(dia.DiagramID); } return(true); }
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); }
/// <summary> /// Write the EA dependencies according to ReqIF between the requirements /// </summary> public bool WriteRelations() { // Read all requirements string stereotypePredicate = _settings.Stereotype == "" ? "" : $" AND stereotype = '{_settings.Stereotype}' "; string sql = $@"select * from t_object o inner join t_package pkg on pkg.package_id = o.package_id where pkg.ea_guid in ( {_settings.PackageGuidCommaList} ) AND o.object_type = '{_settings.ObjectType}' {stereotypePredicate}"; EA.Collection reqCol = _rep.GetElementSet(sql, 2); foreach (EA.Element req in reqCol) { _requirements.Add(req); } // All EA requirements and their target try { // check not existing references var notExistingTargets = (from r in _reqIf.CoreContent[0].SpecRelations join eaRS in _requirements on r.Source.Identifier ?? "" equals eaRS.Multiplicity ?? "" where r.Target == null select $"{eaRS.Multiplicity}:{eaRS.Name}").ToArray(); if (notExistingTargets.Length > 0) { MessageBox.Show($@"{String.Join("\r\n", notExistingTargets)}", @"Target Requirements for Link not available, skip links"); } var relations = from r in _reqIf.CoreContent[0].SpecRelations join eaRS in _requirements on r.Source?.Identifier ?? "" equals eaRS.Multiplicity ?? "" join eaRT in _requirements on r.Target?.Identifier ?? "" equals eaRT.Multiplicity ?? "" orderby r.Source?.Identifier ?? "" select new { SourceReq = eaRS, TargetReq = eaRT, SObjectId = r.Source.Identifier ?? "", TObjectId = r.Target.Identifier ?? "", }; // Create the relations EA.Element el = null; foreach (var rel in relations) { if (el != rel.SourceReq) { el = rel.SourceReq; if (el != null) { DeleteDependencies(el, _settings.PackageGuidList); } } EA.Connector con = (EA.Connector)el.Connectors.AddNew("", "Dependency"); con.Stereotype = _settings.StereotypeDependency; con.ClientID = rel.TargetReq.ElementID; con.SupplierID = rel.SourceReq.ElementID; con.Update(); el.Connectors.Refresh(); el.Update(); } return(true); } catch (Exception e) { MessageBox.Show($@"Related link to requirement not available File: '{_settings.InputFile}' {e}", @"Can't write ReqIF relations in EA, skip relations!"); return(false); } }
public void SynchronizeReferenceWithOriginal() { List <EAAPI.Element> originals = new List <EAAPI.Element>(); EAAPI.Element original = null; // search for originals for (short connectorCount = 0; connectorCount < _referenceElement.Connectors.Count; connectorCount++) { EAAPI.Connector connector = (EAAPI.Connector)_referenceElement.Connectors.GetAt(connectorCount); if (connector.ClientID == _referenceElement.ElementID && connector.SupplierID != _referenceElement.ElementID) { if (connector.Type == "Dependency" && connector.Stereotype == "referenceOf") { original = _repository.GetElementByID(connector.SupplierID); if (original.Type == "Object" && original.ClassifierID == _referenceElement.ClassifierID) { originals.Add(original); } } } } if (originals.Count == 1) { original = originals[0]; if (original.ClassifierID != _referenceElement.ClassfierID) { logger.Info("Synchronizing element type."); _referenceElement.ClassifierID = _referenceElement.ClassifierID; _referenceElement.Update(); } DeleteWrongPortReferenceOfConnections(original.ElementID); SynchronizePortsOfReferenceElement(original); // synchronize descriptional notes logger.Info("Synchronizing descriptional notes."); _referenceElement.Notes = original.Notes; _referenceElement.Update(); _referenceElement.Stereotype = original.Stereotype; _referenceElement.Update(); SynchronizeTaggedValues(original, _referenceElement); logger.Info("Port synchoronization finished."); } else if (originals.Count == 0) { // return if no original was found logger.Info("No original element found."); return; } else { logger.Error("Error: Reference is not unique."); } }
/// <summary> /// Set attributes and tags of supplier port when port is created or connected. /// </summary> /// <param name="connectorId">The created item flow connector.</param> /// <param name="portStereotype">The stereotype of the port.</param> /// <param name="connectorStereotype">The stereotype of the port connectiong flow connector.</param> /// <param name="supplierName">The EA default name for the new created supplier port.</param> public void SetPropertyTypeAndDirectionOnFlowPortCreation(int connectorId, string portStereotype, string connectorStereotype, string supplierName) { EAShared.Connector connector = Rep.GetConnectorByID(connectorId); EAShared.Element client = Rep.GetElementByID(connector.ClientID); EAShared.Element supplier = Rep.GetElementByID(connector.SupplierID); if ((supplier.Stereotype == portStereotype) && (connector.Stereotype == connectorStereotype)) { CopyTaggedValuesFromClientToSupplierPort(client, supplier); if (supplier.PropertyType == 0) { supplier.PropertyType = client.PropertyType; if (supplier.Alias == "") { supplier.Alias = client.Alias; } if (supplier.Multiplicity == "") { supplier.Multiplicity = client.Multiplicity; } // Copy notes text from client to supplier if (supplier.Notes == "") { supplier.Notes = client.Notes; } } else if (supplier.PropertyType == client.PropertyType) { if (supplier.Alias == "") { supplier.Alias = client.Alias; } if (supplier.Multiplicity == "") { supplier.Multiplicity = client.Multiplicity; } // Copy notes text from client to supplier if (supplier.Notes == "") { supplier.Notes = client.Notes; } } if (supplier.Name.StartsWith(supplierName) || supplier.Name == "") { supplier.Name = client.Name; } supplier.Update(); supplier.Refresh(); } // if }
private void SynchronizePortsOfReferenceElement(EAAPI.Element originalElement) { List <int> orphanPorts = new List <int>(); // search for orphan ports for (short count = 0; count < originalElement.EmbeddedElements.Count; count++) { EAAPI.Element originalPort = (EAAPI.Element)originalElement.EmbeddedElements.GetAt(count); if (originalPort.Type == "Port") { bool found = false; for (short connectorCount = 0; connectorCount < originalPort.Connectors.Count; connectorCount++) { EAAPI.Connector originalPortConnector = (EAAPI.Connector)originalPort.Connectors.GetAt(connectorCount); if (originalPortConnector.SupplierID == originalPort.ElementID && originalPortConnector.ClientID != originalPort.ElementID && originalPortConnector.Type == "Dependency" && originalPortConnector.Stereotype == "referenceOf") { EAAPI.Element referencePort = _repository.GetElementByID(originalPortConnector.ClientID); if (referencePort.Type == "Port" && referencePort.ParentID == _referenceElement.ElementID) { // reference port found - synch data by connector logger.Info("ReferenceOf connection found for port, synchronizing data for element " + originalPort.Name); SynchronizePortData(originalPort, referencePort); found = true; break; } } } // for if (!found) { orphanPorts.Add(originalPort.ElementID); } } } // synchronize the orphan ports foreach (int orphanPortID in orphanPorts) { bool match = false; for (short referencePortCounter = 0; referencePortCounter < _referenceElement.EmbeddedElements.Count; referencePortCounter++) { EAAPI.Element referencePort = (EAAPI.Element)_referenceElement.EmbeddedElements.GetAt(referencePortCounter); if (referencePort.Type == "Port") { bool synchByConnector = false; for (short referenceConnectorCount = 0; referenceConnectorCount < referencePort.Connectors.Count; referenceConnectorCount++) { EAAPI.Connector portConnector = (EAAPI.Connector)referencePort.Connectors.GetAt(referenceConnectorCount); if (portConnector.ClientID == referencePort.ElementID && portConnector.SupplierID != referencePort.ElementID && portConnector.Type == "Dependency" && portConnector.Stereotype == "referenceOf") { EAAPI.Element originalPort = _repository.GetElementByID(portConnector.SupplierID); if (originalPort.ParentID == originalElement.ElementID) { synchByConnector = true; } } } if (!synchByConnector) { EAAPI.Element originalPort = _repository.GetElementByID(orphanPortID); if (referencePort.Name == originalPort.Name && referencePort.PropertyType == originalPort.PropertyType) { match = true; SynchronizePortData(originalPort, referencePort); SynchronizePortReferenceOfConnector(originalPort, referencePort); break; } } } } if (!match) // port is in original but not in reference { logger.Info("Adding new Port to reference. ID=" + orphanPortID); EAAPI.Element originalPort = _repository.GetElementByID(orphanPortID); EAAPI.Element newReferencePort = _referenceElement.EmbeddedElements.AddNew("unnamed", "Port") as EAAPI.Element; _referenceElement.EmbeddedElements.Refresh(); SynchronizePortData(originalPort, newReferencePort); SynchronizePortReferenceOfConnector(originalPort, newReferencePort); } } }
public ConnectorDirectionViewModel(EAAPI.Connector connector) : this() { _connectorUnderEdit = connector; ConnectorDirection = connector.Direction; }