Search in sources :

Example 11 with IArchimateRelationship

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);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 12 with IArchimateRelationship

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();
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 13 with IArchimateRelationship

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);
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) CSVParseException(com.archimatetool.csv.CSVParseException)

Example 14 with IArchimateRelationship

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Example 15 with IArchimateRelationship

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Aggregations

IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)74 Test (org.junit.Test)39 IArchimateElement (com.archimatetool.model.IArchimateElement)33 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)22 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)15 ArrayList (java.util.ArrayList)15 IArchimateConcept (com.archimatetool.model.IArchimateConcept)14 IDiagramModel (com.archimatetool.model.IDiagramModel)12 IArchimateModel (com.archimatetool.model.IArchimateModel)9 EObject (org.eclipse.emf.ecore.EObject)9 IIssue (com.archimatetool.hammer.validation.issues.IIssue)7 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)7 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)4 IFolder (com.archimatetool.model.IFolder)4 EClass (org.eclipse.emf.ecore.EClass)4 Command (org.eclipse.gef.commands.Command)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3