Search in sources :

Example 56 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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 57 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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 58 with IArchimateElement

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

the class CopySnapshot method createPasteObject.

private IDiagramModelObject createPasteObject(IDiagramModelContainer container, IDiagramModelObject snapshotObject) {
    // Don't paste invalid objects
    if (!isValidPasteComponent(fTargetDiagramModel, snapshotObject)) {
        return null;
    }
    IDiagramModelObject pasteObject = (IDiagramModelObject) snapshotObject.getCopy();
    createID(pasteObject);
    // Offset top level objects if container is diagram
    if (container instanceof IDiagramModel) {
        IDiagramModelObject originalObject = (IDiagramModelObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
        IBounds bounds = originalObject.getBounds().getCopy();
        Point pt = new Point(bounds.getX(), bounds.getY());
        translateToAbsolute(originalObject, pt);
        bounds.setX(pt.x + fXOffSet);
        bounds.setY(pt.y + fYOffSet);
        pasteObject.setBounds(bounds);
    }
    // If Archimate object
    if (pasteObject instanceof IDiagramModelArchimateObject) {
        IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) pasteObject;
        // Re-use original ArchiMate components
        if (!fDoCreateNewArchimateComponents) {
            IDiagramModelArchimateObject originalDiagramObject = (IDiagramModelArchimateObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
            IArchimateElement element = originalDiagramObject.getArchimateElement();
            dmo.setArchimateElement(element);
        }
        // Provide new names if required
        if (fDoCreateNewArchimateComponents && isSourceAndTargetArchiMateModelSame()) {
            String name = dmo.getArchimateElement().getName();
            // $NON-NLS-1$
            dmo.getArchimateElement().setName(name + " " + Messages.CopySnapshot_1);
        }
    }
    // Add to Mapping
    fSnapshotToNewComponentMapping.put(snapshotObject, pasteObject);
    // Object is Container, so recurse
    if (snapshotObject instanceof IDiagramModelContainer) {
        for (IDiagramModelObject child : ((IDiagramModelContainer) snapshotObject).getChildren()) {
            IDiagramModelObject dmo = createPasteObject((IDiagramModelContainer) pasteObject, child);
            if (dmo != null) {
                ((IDiagramModelContainer) pasteObject).getChildren().add(dmo);
            }
        }
    }
    return pasteObject;
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IBounds(com.archimatetool.model.IBounds) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Point(org.eclipse.draw2d.geometry.Point) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 59 with IArchimateElement

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

the class ArchimateDiagramModelFactory method getNewObject.

public Object getNewObject() {
    if (fTemplate == null) {
        return null;
    }
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Connection created from Relationship Template
    if (object instanceof IArchimateRelationship) {
        return createDiagramModelArchimateConnection((IArchimateRelationship) object);
    } else // Archimate Diagram Object created from Archimate Element Template
    if (object instanceof IArchimateElement) {
        IArchimateElement element = (IArchimateElement) object;
        element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        return createDiagramModelArchimateObject(element);
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
        ((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Note
    if (object instanceof IDiagramModelNote) {
        ColorFactory.setDefaultColors((IDiagramModelObject) object);
        ((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        ColorFactory.setDefaultColors((IDiagramModelConnection) object);
    }
    return object;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote)

Example 60 with IArchimateElement

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

the class DiagramModelArchimateObject method getCopy.

@Override
public EObject getCopy() {
    IDiagramModelArchimateObject newObject = (IDiagramModelArchimateObject) super.getCopy();
    IArchimateElement element = (IArchimateElement) getArchimateElement().getCopy();
    newObject.setArchimateElement(element);
    // Clear children
    newObject.getChildren().clear();
    return newObject;
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3