Search in sources :

Example 6 with IAssignmentRelationship

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;
}
Also used : ICompositionRelationship(com.archimatetool.model.ICompositionRelationship) IRealizationRelationship(com.archimatetool.model.IRealizationRelationship) ISpecializationRelationship(com.archimatetool.model.ISpecializationRelationship) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IAggregationRelationship(com.archimatetool.model.IAggregationRelationship) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IAccessRelationship(com.archimatetool.model.IAccessRelationship) IJunction(com.archimatetool.model.IJunction)

Example 7 with IAssignmentRelationship

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());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler) Test(org.junit.Test)

Example 8 with IAssignmentRelationship

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);
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) Color(org.eclipse.swt.graphics.Color) Test(org.junit.Test)

Aggregations

IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)8 Test (org.junit.Test)6 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)3 IAccessRelationship (com.archimatetool.model.IAccessRelationship)2 IAggregationRelationship (com.archimatetool.model.IAggregationRelationship)2 IArchimateModel (com.archimatetool.model.IArchimateModel)2 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)2 ICompositionRelationship (com.archimatetool.model.ICompositionRelationship)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 IRealizationRelationship (com.archimatetool.model.IRealizationRelationship)2 ISpecializationRelationship (com.archimatetool.model.ISpecializationRelationship)2 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)2 DuplicateCommandHandler (com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler)1 IDiagramModel (com.archimatetool.model.IDiagramModel)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 IFlowRelationship (com.archimatetool.model.IFlowRelationship)1 IInfluenceRelationship (com.archimatetool.model.IInfluenceRelationship)1 IJunction (com.archimatetool.model.IJunction)1