use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.
the class NestedElementsChecker method isNestedWithoutValidRelation.
boolean isNestedWithoutValidRelation(IDiagramModelArchimateObject parent, IDiagramModelArchimateObject child) {
IArchimateElement parentElement = parent.getArchimateElement();
IArchimateElement childElement = child.getArchimateElement();
// Ignore nested Junctions
if (childElement instanceof IJunction) {
return false;
}
// Specialization relationship goes the other way around
for (IArchimateRelationship relation : parentElement.getTargetRelationships()) {
if (relation.getSource() == childElement) {
if (relation instanceof ISpecializationRelationship) {
return false;
}
}
}
// Other relationships
for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
if (relation.getTarget() == childElement) {
if (relation instanceof ICompositionRelationship || relation instanceof IAggregationRelationship || relation instanceof IAssignmentRelationship || relation instanceof IRealizationRelationship || relation instanceof IAccessRelationship) {
return false;
}
}
}
return true;
}
use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.
the class DiagramModelUtilsTests method testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram.
// =================================================================================================
@Test
public void testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
dm.getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
dm.getChildren().add(dmo2);
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
List<?> list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
assertEquals(1, list.size());
list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
assertEquals(1, list.size());
list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
assertEquals(1, list.size());
// Duplicate
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
assertEquals(2, list.size());
list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
assertEquals(2, list.size());
list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
assertEquals(2, list.size());
}
use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.
the class ColorFactoryTests method testGetUserDefaultLineColor_Connection.
@Test
public void testGetUserDefaultLineColor_Connection() {
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
Color color = ColorFactory.getUserDefaultLineColor(relation);
assertNull(color);
Preferences.STORE.setValue(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR, "#010203");
color = ColorFactory.getUserDefaultLineColor(relation);
assertEquals(1, color.getRed());
assertEquals(2, color.getGreen());
assertEquals(3, color.getBlue());
Preferences.STORE.setToDefault(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR);
}
Aggregations