Search in sources :

Example 1 with IAssignmentRelationship

use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.

the class DiagramModelUtilsTests method hasExistingConnectionType.

@Test
public void hasExistingConnectionType() {
    IDiagramModelObject source = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
    IDiagramModelObject target = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    IDiagramModelConnection conn = ArchimateTestModel.createDiagramModelArchimateConnection(relation);
    conn.connect(source, target);
    assertTrue(DiagramModelUtils.hasExistingConnectionType(source, target, relation.eClass()));
    assertFalse(DiagramModelUtils.hasExistingConnectionType(source, target, IArchimatePackage.eINSTANCE.getAccessRelationship()));
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 2 with IAssignmentRelationship

use of com.archimatetool.model.IAssignmentRelationship 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'"));
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 3 with IAssignmentRelationship

use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.

the class ArchimateDiagramModelFactoryTests method testGetNewObjectArchimateConnection.

@Test
public void testGetNewObjectArchimateConnection() {
    Preferences.STORE.setValue(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR, true);
    Preferences.STORE.setValue(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR, "#ababab");
    ICreationFactory factory = new ArchimateDiagramModelFactory(IArchimatePackage.eINSTANCE.getAssignmentRelationship());
    IDiagramModelArchimateConnection connection = (IDiagramModelArchimateConnection) factory.getNewObject();
    assertTrue(connection.getArchimateRelationship() instanceof IAssignmentRelationship);
    assertEquals("#ababab", connection.getLineColor());
    assertEquals("", connection.getName());
    Preferences.STORE.setToDefault(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR);
    Preferences.STORE.setToDefault(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR);
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) Test(org.junit.Test)

Example 4 with IAssignmentRelationship

use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.

the class CreateDiagramArchimateConnectionWithDialogCommandTests method testCreationOfConnectionAndRelationship.

@Test
public void testCreationOfConnectionAndRelationship() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(IArchimateFactory.eINSTANCE.createBusinessActor());
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(IArchimateFactory.eINSTANCE.createBusinessRole());
    model.getDefaultDiagramModel().getChildren().add(dmo1);
    model.getDefaultDiagramModel().getChildren().add(dmo2);
    cmd.setSource(dmo1);
    cmd.setTarget(dmo2);
    cmd.execute();
    IDiagramModelConnection connection = cmd.fConnection;
    assertTrue(connection instanceof IDiagramModelArchimateConnection);
    assertSame(dmo1, connection.getSource());
    assertSame(dmo2, connection.getTarget());
    IArchimateRelationship relationship = ((IDiagramModelArchimateConnection) connection).getArchimateRelationship();
    assertTrue(relationship instanceof IAssignmentRelationship);
    assertNotNull(relationship.eContainer());
    cmd.undo();
    assertNull(relationship.eContainer());
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 5 with IAssignmentRelationship

use of com.archimatetool.model.IAssignmentRelationship in project archi by archimatetool.

the class ZestViewerLabelProvider method selfStyleConnection.

// ========================================================================================
// ISelfStyleProvider
// ========================================================================================
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
    connection.setLineWidth(0);
    connection.setTooltip(getTooltip(element));
    connection.setLineColor(ColorConstants.black);
    connection.setText(getText(element));
    PolylineConnection conn = (PolylineConnection) connection.getConnectionFigure();
    if (element instanceof ISpecializationRelationship) {
        conn.setTargetDecoration(SpecializationConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof ICompositionRelationship) {
        conn.setSourceDecoration(CompositionConnectionFigure.createFigureSourceDecoration());
    } else if (element instanceof IAggregationRelationship) {
        conn.setSourceDecoration(AggregationConnectionFigure.createFigureSourceDecoration());
    } else if (element instanceof IAssignmentRelationship) {
        conn.setSourceDecoration(AssignmentConnectionFigure.createFigureSourceDecoration());
        conn.setTargetDecoration(AssignmentConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IRealizationRelationship) {
        conn.setTargetDecoration(RealizationConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 2 });
    } else if (element instanceof ITriggeringRelationship) {
        conn.setTargetDecoration(TriggeringConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IFlowRelationship) {
        conn.setTargetDecoration(FlowConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 6, 3 });
    } else if (element instanceof IServingRelationship) {
        conn.setTargetDecoration(ServingConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IAccessRelationship) {
        switch(((IAccessRelationship) element).getAccessType()) {
            case IAccessRelationship.WRITE_ACCESS:
            default:
                conn.setSourceDecoration(null);
                // arrow at target endpoint
                conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                break;
            case IAccessRelationship.READ_ACCESS:
                // arrow at source endpoint
                conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                conn.setTargetDecoration(null);
                break;
            case IAccessRelationship.UNSPECIFIED_ACCESS:
                // no arrows
                conn.setSourceDecoration(null);
                conn.setTargetDecoration(null);
                break;
            case IAccessRelationship.READ_WRITE_ACCESS:
                // both arrows
                conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                break;
        }
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 2 });
    } else if (element instanceof IInfluenceRelationship) {
        conn.setTargetDecoration(InfluenceConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 6, 3 });
    }
    conn.setAntialias(SWT.ON);
}
Also used : IInfluenceRelationship(com.archimatetool.model.IInfluenceRelationship) ICompositionRelationship(com.archimatetool.model.ICompositionRelationship) IRealizationRelationship(com.archimatetool.model.IRealizationRelationship) ITriggeringRelationship(com.archimatetool.model.ITriggeringRelationship) ISpecializationRelationship(com.archimatetool.model.ISpecializationRelationship) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IAggregationRelationship(com.archimatetool.model.IAggregationRelationship) IFlowRelationship(com.archimatetool.model.IFlowRelationship) IAccessRelationship(com.archimatetool.model.IAccessRelationship) IServingRelationship(com.archimatetool.model.IServingRelationship) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

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