use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class DiagramModelUtils method findDiagramModelConnectionsForRelationByReference.
/**
* Find all (visible and extant) Diagram Model Connections for a given Archimate relationship in a Diagram Model.
* This is the faster method.
* @param diagramModel The parent diagram model to search in.
* @param relationship The relationship to check on.
* @return The list of active Diagram Model Connections. May be empty, but never null.
*/
static List<IDiagramModelArchimateConnection> findDiagramModelConnectionsForRelationByReference(IDiagramModel diagramModel, IArchimateRelationship relationship) {
List<IDiagramModelArchimateConnection> list = new ArrayList<IDiagramModelArchimateConnection>();
List<IDiagramModelArchimateConnection> connections = findDiagramModelConnectionsForRelation(relationship);
for (IDiagramModelArchimateConnection connection : connections) {
if (connection.getDiagramModel() == diagramModel) {
list.add(connection);
}
}
return list;
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ModelChecker method checkDiagramObjectsReferences.
List<String> checkDiagramObjectsReferences() {
List<String> messages = new ArrayList<String>();
for (Iterator<EObject> iter = fModel.getFolder(FolderType.DIAGRAMS).eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = dmo.getDiagramModel() == null ? Messages.ModelChecker_11 : " '" + dmo.getDiagramModel().getName() + "' (" + dmo.getId() + ")";
IArchimateElement element = dmo.getArchimateElement();
if (element == null) {
messages.add(Messages.ModelChecker_12 + name);
} else if (element.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_13 + name);
}
}
if (eObject instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection conn = (IDiagramModelArchimateConnection) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = conn.getDiagramModel() == null ? Messages.ModelChecker_14 : " '" + conn.getDiagramModel().getName() + "' (" + conn.getId() + ")";
IArchimateRelationship relation = conn.getArchimateRelationship();
if (relation == null) {
messages.add(Messages.ModelChecker_15 + name);
} else {
if (relation.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_16 + name);
}
if (relation.getSource() != null && relation.getSource().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_17 + name);
}
if (relation.getTarget() != null && relation.getTarget().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_18 + name);
}
}
}
}
return messages;
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ModelCheckerTests method checkDiagramObjectsReferences_Connection.
@Test
public void checkDiagramObjectsReferences_Connection() {
model.getDefaultDiagramModel().setName("dm");
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
model.getDefaultDiagramModel().getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
model.getDefaultDiagramModel().getChildren().add(dmo2);
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
List<String> messages = modelChecker.checkDiagramObjectsReferences();
assertEquals(0, messages.size());
model.getFolder(FolderType.RELATIONS).getElements().remove(relation);
model.getFolder(FolderType.BUSINESS).getElements().remove(actor);
model.getFolder(FolderType.BUSINESS).getElements().remove(role);
messages = modelChecker.checkDiagramObjectsReferences();
assertEquals(5, messages.size());
assertTrue(messages.get(0).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
assertTrue(messages.get(1).startsWith("Diagram Connection has orphaned ArchiMate relation in 'dm'"));
assertTrue(messages.get(2).startsWith("Diagram Connection has orphaned ArchiMate source element in 'dm'"));
assertTrue(messages.get(3).startsWith("Diagram Connection has orphaned ArchiMate target element in 'dm'"));
assertTrue(messages.get(4).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ArchimateDiagramModelFactory method createDiagramModelArchimateConnection.
/**
* Factory method for creating a new IDiagramModelArchimateConnection for an IRelationship
* @param element
* @return a new IDiagramModelArchimateConnection
*/
public static IDiagramModelArchimateConnection createDiagramModelArchimateConnection(IArchimateRelationship relation) {
IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
connection.setArchimateRelationship(relation);
// Set user default colors as set in prefs
ColorFactory.setDefaultColors(connection);
return connection;
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class MyImporter method createAndAddConnectionsToView.
protected void createAndAddConnectionsToView(IDiagramModel diagramModel, IArchimateRelationship relationship) {
List<IDiagramModelArchimateComponent> sources = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship.getSource());
List<IDiagramModelArchimateComponent> targets = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship.getTarget());
for (IDiagramModelComponent dmcSource : sources) {
for (IDiagramModelComponent dmcTarget : targets) {
IDiagramModelArchimateConnection dmc = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
dmc.setArchimateRelationship(relationship);
dmc.connect((IDiagramModelObject) dmcSource, (IDiagramModelObject) dmcTarget);
idLookup.put(dmc.getId(), dmc);
}
}
}
Aggregations