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);
}
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));
}
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));
}
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'"));
}
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'"));
}
Aggregations