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