use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetDestination_Relationship.
@Test
public void testGetDestination_Relationship() {
IArchimateRelationship inputElement = (IArchimateRelationship) tm.getObjectByID("460");
IArchimateElement expected = (IArchimateElement) tm.getObjectByID("289");
Object destination = provider.getDestination(inputElement);
assertEquals(expected, destination);
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CSVExporter method writeRelationships.
/**
* Write All Relationships
*/
private void writeRelationships(File file) throws IOException {
List<IArchimateConcept> concepts = getConcepts(fModel.getFolder(FolderType.RELATIONS));
sort(concepts);
// Are there any to write?
if (!fWriteEmptyFile && concepts.isEmpty()) {
return;
}
Writer writer = createOutputStreamWriter(file);
// Write BOM
writeBOM(writer);
// Write Header
String header = createHeader(RELATIONSHIPS_HEADER);
writer.write(header);
// Write Relationships
for (IArchimateConcept concept : concepts) {
if (concept instanceof IArchimateRelationship) {
writer.write(CRLF);
writer.write(createRelationshipRow((IArchimateRelationship) concept));
}
}
writer.close();
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CSVImporter method createRelationFromRecord.
/**
* Create an Archimate relationship from a given CSVRecord
*/
private void createRelationFromRecord(CSVRecord csvRecord) throws CSVParseException {
// ID
String id = csvRecord.get(0);
if (!StringUtils.isSet(id)) {
id = generateID();
} else {
checkIDForInvalidCharacters(id);
}
// Type
String type = csvRecord.get(1);
EClass eClass = (EClass) IArchimatePackage.eINSTANCE.getEClassifier(type);
if (!isArchimateRelationshipEClass(eClass)) {
throw new CSVParseException(Messages.CSVImporter_4 + id);
}
String name = normalise(csvRecord.get(2));
String documentation = csvRecord.get(3);
// Is the relation already in the model?
IArchimateRelationship relation = (IArchimateRelationship) findArchimateConceptInModel(id, eClass);
// Yes it is, so updated values
if (relation != null) {
storeUpdatedConceptFeature(relation, IArchimatePackage.Literals.NAMEABLE__NAME, name);
storeUpdatedConceptFeature(relation, IArchimatePackage.Literals.DOCUMENTABLE__DOCUMENTATION, documentation);
} else // No, create a new one
{
relation = (IArchimateRelationship) IArchimateFactory.eINSTANCE.create(eClass);
relation.setId(id);
relation.setName(name);
relation.setDocumentation(documentation);
// Get source and target ids and temporarily store their ids
String sourceID = csvRecord.get(4);
// $NON-NLS-1$
relation.setAdapter("sourceID", sourceID);
String targetID = csvRecord.get(5);
// $NON-NLS-1$
relation.setAdapter("targetID", targetID);
newConcepts.put(id, relation);
}
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ModelChecker method checkRelationsHaveElements.
List<String> checkRelationsHaveElements() {
List<String> messages = new ArrayList<String>();
for (Iterator<EObject> iter = fModel.getFolder(FolderType.RELATIONS).eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateRelationship) {
IArchimateRelationship relation = (IArchimateRelationship) eObject;
// $NON-NLS-1$ //$NON-NLS-2$
String name = " (" + relation.getId() + ")";
if (relation.getSource() == null) {
String message = Messages.ModelChecker_19 + name;
messages.add(message);
} else if (relation.getSource().getArchimateModel() == null) {
String message = Messages.ModelChecker_20 + name;
messages.add(message);
}
if (relation.getTarget() == null) {
String message = Messages.ModelChecker_21 + name;
messages.add(message);
} else if (relation.getTarget().getArchimateModel() == null) {
String message = Messages.ModelChecker_22 + name;
messages.add(message);
}
}
}
return messages;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ModelChecker method checkDiagramObjectsReferences.
List<String> checkDiagramObjectsReferences() {
List<String> messages = new ArrayList<String>();
for (Iterator<EObject> iter = fModel.getFolder(FolderType.DIAGRAMS).eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = dmo.getDiagramModel() == null ? Messages.ModelChecker_11 : " '" + dmo.getDiagramModel().getName() + "' (" + dmo.getId() + ")";
IArchimateElement element = dmo.getArchimateElement();
if (element == null) {
messages.add(Messages.ModelChecker_12 + name);
} else if (element.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_13 + name);
}
}
if (eObject instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection conn = (IDiagramModelArchimateConnection) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = conn.getDiagramModel() == null ? Messages.ModelChecker_14 : " '" + conn.getDiagramModel().getName() + "' (" + conn.getId() + ")";
IArchimateRelationship relation = conn.getArchimateRelationship();
if (relation == null) {
messages.add(Messages.ModelChecker_15 + name);
} else {
if (relation.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_16 + name);
}
if (relation.getSource() != null && relation.getSource().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_17 + name);
}
if (relation.getTarget() != null && relation.getTarget().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_18 + name);
}
}
}
}
return messages;
}
Aggregations