Skip to content

Commit

Permalink
[Label Expressions] Source and Target of connections get model object…
Browse files Browse the repository at this point in the history
…s not view objects part 2

- Just get the model relationship
  • Loading branch information
Phillipus committed Oct 10, 2023
1 parent 7c0efdd commit 9af3bfd
Showing 1 changed file with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.archimatetool.model.IArchimateConcept;
import com.archimatetool.model.IArchimateModelObject;
import com.archimatetool.model.IArchimateRelationship;
import com.archimatetool.model.IConnectable;
import com.archimatetool.model.IDiagramModel;
import com.archimatetool.model.IDiagramModelArchimateComponent;
import com.archimatetool.model.IDiagramModelComponent;
Expand Down Expand Up @@ -95,38 +94,22 @@ protected IArchimateModelObject getObjectFromPrefix(IArchimateModelObject object
}

// Linked Source object from a connection/relation
if(prefix.endsWith(":source") && object instanceof IConnectable connectable) {
if(prefix.endsWith(":source") && actualObject instanceof IArchimateConcept concept) {
prefix = prefix.replace(":source", "");

// Has at least one source connection that matches...
for(IDiagramModelConnection connection : connectable.getTargetConnections()) {
IArchimateModelObject relationship = getActualObject(connection);
if(relationship.eClass().getName().toLowerCase().contains(prefix)) {
return getActualObject(connection.getSource());
}
}

// No connection, so has at least one source relation that matches...
for(IArchimateRelationship relationship : ((IArchimateConcept)actualObject).getTargetRelationships()) {
// Has at least one source relation that matches...
for(IArchimateRelationship relationship : concept.getTargetRelationships()) {
if(relationship.eClass().getName().toLowerCase().contains(prefix)) {
return relationship.getSource();
}
}
}
// Linked Target object from a connection/relation
else if(prefix.endsWith(":target") && object instanceof IConnectable connectable) {
else if(prefix.endsWith(":target") && actualObject instanceof IArchimateConcept concept) {
prefix = prefix.replace(":target", "");

// Has at least one target connection that matches...
for(IDiagramModelConnection connection : connectable.getSourceConnections()) {
IArchimateModelObject relationship = getActualObject(connection);
if(relationship.eClass().getName().toLowerCase().contains(prefix)) {
return getActualObject(connection.getTarget());
}
}

// No connection, so has at least one target relation that matches...
for(IArchimateRelationship relationship : ((IArchimateConcept)actualObject).getSourceRelationships()) {
// Has at least one target relation that matches...
for(IArchimateRelationship relationship : concept.getSourceRelationships()) {
if(relationship.eClass().getName().toLowerCase().contains(prefix)) {
return relationship.getTarget();
}
Expand Down

0 comments on commit 9af3bfd

Please sign in to comment.