Search in sources :

Example 21 with IArchimateElement

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

the class DiagramModelArchimateObject method addArchimateConceptToModel.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public void addArchimateConceptToModel(IFolder parent) {
    IArchimateElement element = getArchimateElement();
    if (element != null && element.eContainer() != null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("Element already has parent folder");
    }
    // If parent is null use default folder
    if (parent == null) {
        parent = getDiagramModel().getArchimateModel().getDefaultFolderForObject(element);
    }
    parent.getElements().add(element);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement)

Example 22 with IArchimateElement

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

the class DiagramModelUtilsTests method findDiagramModelComponentsForArchimateConcept_Element.

@Test
public void findDiagramModelComponentsForArchimateConcept_Element() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateComponent> list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, element);
    assertTrue(list.isEmpty());
    // Add the element to various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(element, diagramModel);
    // Should be found in diagram
    list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, element);
    assertEquals(4, list.size());
    assertTrue(list.contains(dmo1));
    assertTrue(list.contains(dmo2));
    assertTrue(list.contains(dmo3));
    assertTrue(list.contains(dmo4));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 23 with IArchimateElement

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

the class DiagramModelUtilsTests method isArchimateConceptReferencedInDiagrams.

@Test
public void isArchimateConceptReferencedInDiagrams() {
    // This should be in a diagram
    IArchimateElement element = (IArchimateElement) tm.getObjectByID(data1[0][0]);
    assertNotNull(element);
    assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
    // This should be in a diagram
    element = (IArchimateElement) tm.getObjectByID(data2[0][0]);
    assertNotNull(element);
    assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
    // This should not be in a diagram
    element = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element).getElements().add(element);
    assertFalse(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
    // Unless we add it to a diagram
    // And we'll nest it inside a Group to be cunning
    IDiagramModelArchimateObject dmo = ArchimateTestModel.createDiagramModelArchimateObject(element);
    IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    group.getChildren().add(dmo);
    model.getDefaultDiagramModel().getChildren().add(group);
    assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) Test(org.junit.Test)

Example 24 with IArchimateElement

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

the class ModelCheckerTests method checkDiagramObjectsReferences_Object.

@Test
public void checkDiagramObjectsReferences_Object() {
    model.getDefaultDiagramModel().setName("dm");
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getFolder(FolderType.BUSINESS).getElements().add(element);
    IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo.setArchimateElement(element);
    model.getDefaultDiagramModel().getChildren().add(dmo);
    List<String> messages = modelChecker.checkDiagramObjectsReferences();
    assertEquals(0, messages.size());
    model.getFolder(FolderType.BUSINESS).getElements().remove(element);
    messages = modelChecker.checkDiagramObjectsReferences();
    assertEquals(1, messages.size());
    assertTrue(messages.get(0).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 25 with IArchimateElement

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

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