Search in sources :

Example 41 with IArchimateRelationship

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

the class ZestViewerContentProvider method getElements.

@Override
public Object[] getElements(Object inputElement) {
    if (inputElement instanceof IArchimateConcept) {
        IArchimateConcept archimateConcept = (IArchimateConcept) inputElement;
        // Check if it was deleted
        if (archimateConcept.eContainer() == null) {
            return new Object[0];
        }
        // Relationship
        if (archimateConcept instanceof IArchimateRelationship) {
            return new Object[] { inputElement };
        }
        // Element - Get its relationships
        if (archimateConcept instanceof IArchimateElement) {
            List<IArchimateRelationship> mainList = new ArrayList<IArchimateRelationship>();
            getRelations(mainList, new ArrayList<IArchimateConcept>(), archimateConcept, 0);
            return mainList.toArray();
        }
    }
    return new Object[0];
}
Also used : ArrayList(java.util.ArrayList) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Example 42 with IArchimateRelationship

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

the class ZestViewerLabelProvider method getTooltip.

public IFigure getTooltip(Object entity) {
    if (entity instanceof IArchimateConcept) {
        ToolTipFigure l = new ToolTipFigure();
        String type = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) entity).eClass());
        l.setText(ArchiLabelProvider.INSTANCE.getLabel(entity));
        // $NON-NLS-1$
        l.setType(Messages.ZestViewerLabelProvider_0 + " " + type);
        if (entity instanceof IArchimateRelationship) {
            l.setRubric(ArchiLabelProvider.INSTANCE.getRelationshipSentence((IArchimateRelationship) entity));
        }
        return l;
    }
    return null;
}
Also used : ToolTipFigure(com.archimatetool.editor.diagram.figures.ToolTipFigure) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Example 43 with IArchimateRelationship

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

the class CSVExporterTests method testCreateRelationshipRow.

@Test
public void testCreateRelationshipRow() {
    IArchimateElement elementSource = IArchimateFactory.eINSTANCE.createBusinessActor();
    elementSource.setId("cfde5463e");
    IArchimateElement elementTarget = IArchimateFactory.eINSTANCE.createBusinessActor();
    elementTarget.setId("b1234dff");
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAccessRelationship();
    relation.setId("56435fd6");
    relation.setName("My relation");
    relation.setDocumentation("This is the Documentation");
    relation.setSource(elementSource);
    relation.setTarget(elementTarget);
    assertEquals("\"56435fd6\",\"AccessRelationship\",\"My relation\",\"This is the Documentation\",\"cfde5463e\",\"b1234dff\"", exporter.createRelationshipRow(relation));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 44 with IArchimateRelationship

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

the class CSVImporterTests method testDoImportWithUpdatedElements.

@Test
public void testDoImportWithUpdatedElements() throws Exception {
    // Set up with original data
    importer.doImport(elements1File);
    testDoImportPart1();
    // Import data that is edited
    importer = new CSVImporter(model);
    importer.doImport(elements2File);
    // Ensure new concepts is empty
    assertTrue(importer.newConcepts.isEmpty());
    // Ensure new properties is empty
    assertTrue(importer.newProperties.isEmpty());
    // Model information
    assertEquals("Test Model changed", model.getName());
    assertEquals("Model Documentation Changed", model.getPurpose());
    assertEquals(2, model.getProperties().size());
    IArchimateElement element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "f00aa5b4");
    assertEquals(IArchimatePackage.eINSTANCE.getBusinessActor(), element.eClass());
    assertEquals("Name changed", element.getName());
    assertEquals("This is the Business Actor\r\nDocumentation\r\nHere \"\"\r\n", element.getDocumentation());
    assertEquals(4, element.getProperties().size());
    element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "d9fe8c17");
    assertEquals(IArchimatePackage.eINSTANCE.getBusinessInterface(), element.eClass());
    assertEquals("Business Interface", element.getName());
    assertEquals("", element.getDocumentation());
    assertEquals(0, element.getProperties().size());
    IArchimateRelationship relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "cdbfc933");
    assertEquals(IArchimatePackage.eINSTANCE.getAssignmentRelationship(), relation.eClass());
    assertEquals("Assignment relation changed", relation.getName());
    assertEquals("Assignment documentation changed", relation.getDocumentation());
    assertEquals(0, relation.getProperties().size());
    relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "5854f8a3");
    assertEquals(IArchimatePackage.eINSTANCE.getCompositionRelationship(), relation.eClass());
    assertEquals("5854f8a3", relation.getId());
    assertEquals("Compo", relation.getName());
    assertEquals("Here it is\r\nagain\r\n\r\n\r\n", relation.getDocumentation());
    assertEquals(1, relation.getProperties().size());
    IProperty property = relation.getProperties().get(0);
    assertEquals("This", property.getKey());
    assertEquals("value changes", property.getValue());
}
Also used : IProperty(com.archimatetool.model.IProperty) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 45 with IArchimateRelationship

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

the class CopySnapshot method createPasteConnections.

private List<IDiagramModelConnection> createPasteConnections() {
    List<IDiagramModelConnection> connections = new ArrayList<IDiagramModelConnection>();
    // Create new connections from basis of snapshot
    for (IConnectable connectable : fOriginalToSnapshotComponentsMapping.values()) {
        if (connectable instanceof IDiagramModelConnection) {
            IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) connectable;
            IDiagramModelConnection newConnection = (IDiagramModelConnection) snapshotConnection.getCopy();
            createID(newConnection);
            connections.add(newConnection);
            // Mapping
            fSnapshotToNewComponentMapping.put(snapshotConnection, newConnection);
            // Re-use original Archimate relationship if required
            if (!fDoCreateNewArchimateComponents && snapshotConnection instanceof IDiagramModelArchimateConnection) {
                IDiagramModelArchimateConnection originalDiagramConnection = (IDiagramModelArchimateConnection) fOriginalToSnapshotComponentsMapping.getKey(snapshotConnection);
                IArchimateRelationship relationship = originalDiagramConnection.getArchimateRelationship();
                ((IDiagramModelArchimateConnection) newConnection).setArchimateRelationship(relationship);
            }
        }
    }
    // Connect them
    for (Entry<IConnectable, IConnectable> entry : fSnapshotToNewComponentMapping.entrySet()) {
        if (entry.getKey() instanceof IDiagramModelConnection) {
            IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) entry.getKey();
            IConnectable newSource = fSnapshotToNewComponentMapping.get(snapshotConnection.getSource());
            IConnectable newTarget = fSnapshotToNewComponentMapping.get(snapshotConnection.getTarget());
            if (newSource != null && newTarget != null) {
                IDiagramModelConnection newConnection = (IDiagramModelConnection) entry.getValue();
                newConnection.connect(newSource, newTarget);
            }
        }
    }
    return connections;
}
Also used : IConnectable(com.archimatetool.model.IConnectable) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Aggregations

IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)74 Test (org.junit.Test)39 IArchimateElement (com.archimatetool.model.IArchimateElement)33 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)22 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)15 ArrayList (java.util.ArrayList)15 IArchimateConcept (com.archimatetool.model.IArchimateConcept)14 IDiagramModel (com.archimatetool.model.IDiagramModel)12 IArchimateModel (com.archimatetool.model.IArchimateModel)9 EObject (org.eclipse.emf.ecore.EObject)9 IIssue (com.archimatetool.hammer.validation.issues.IIssue)7 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)7 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)4 IFolder (com.archimatetool.model.IFolder)4 EClass (org.eclipse.emf.ecore.EClass)4 Command (org.eclipse.gef.commands.Command)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3