use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetSource_Relationship.
@Test
public void testGetSource_Relationship() {
IArchimateRelationship inputElement = (IArchimateRelationship) tm.getObjectByID("460");
IArchimateElement expected = (IArchimateElement) tm.getObjectByID("409");
Object source = provider.getSource(inputElement);
assertEquals(expected, source);
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetElements_Relationship.
@Test
public void testGetElements_Relationship() {
IArchimateRelationship inputElement = (IArchimateRelationship) tm.getObjectByID("460");
Object[] elements = provider.getElements(inputElement);
assertEquals(inputElement, elements[0]);
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CSVImporter method importRelations.
// -------------------------------- Import Relations --------------------------------
/**
* Import Relations from CSV file
* @param file The file to import
* @throws IOException
* @throws CSVParseException
*/
void importRelations(File file) throws IOException, CSVParseException {
for (CSVRecord csvRecord : getRecords(file)) {
if (!isRelationsRecordCorrectSize(csvRecord)) {
throw new CSVParseException(Messages.CSVImporter_2);
}
// Header
if (isHeaderRecord(csvRecord, RELATIONSHIPS_HEADER)) {
continue;
} else // Relation
{
createRelationFromRecord(csvRecord);
}
}
// Now connect the relations
for (Entry<String, IArchimateConcept> entry : newConcepts.entrySet()) {
if (entry.getValue() instanceof IArchimateRelationship) {
IArchimateRelationship relation = (IArchimateRelationship) entry.getValue();
// Get the ids from the temporary stores
// $NON-NLS-1$
IArchimateConcept source = findReferencedConcept((String) relation.getAdapter("sourceID"));
// $NON-NLS-1$
IArchimateConcept target = findReferencedConcept((String) relation.getAdapter("targetID"));
// Is it a valid relationship?
if (!ArchimateModelUtils.isValidRelationship(source.eClass(), target.eClass(), relation.eClass())) {
throw new CSVParseException(Messages.CSVImporter_5 + relation.getId());
}
// Connect
relation.connect(source, target);
}
}
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class DeleteCommandHandler method createCommands.
/**
* Create the Delete Commands
*/
private void createCommands() {
/*
* We need to ensure that the Delete Diagram Model Commands are called first in order to close
* any open diagram editors before removing their models from parent folders.
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
if (compoundCommand != null) {
Command cmd = new DeleteDiagramModelCommand((IDiagramModel) object);
compoundCommand.add(cmd);
} else {
// $NON-NLS-1$
System.err.println("Could not get CompoundCommand in " + getClass());
}
}
}
/*
* Then the other types
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
// already done
continue;
}
CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
if (compoundCommand == null) {
// sanity check
// $NON-NLS-1$
System.err.println("Could not get CompoundCommand in " + getClass());
continue;
}
if (object instanceof IFolder) {
Command cmd = new DeleteFolderCommand((IFolder) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateElement) {
Command cmd = new DeleteArchimateElementCommand((IArchimateElement) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateRelationship) {
Command cmd = new DeleteArchimateRelationshipCommand((IArchimateRelationship) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelObject) {
Command cmd = DiagramCommandFactory.createDeleteDiagramObjectCommand((IDiagramModelObject) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelConnection) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand((IDiagramModelConnection) object);
compoundCommand.add(cmd);
}
}
}
Aggregations