Search in sources :

Example 71 with IArchimateRelationship

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

Example 72 with IArchimateRelationship

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

Example 73 with IArchimateRelationship

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);
        }
    }
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) CSVRecord(org.apache.commons.csv.CSVRecord) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) CSVParseException(com.archimatetool.csv.CSVParseException)

Example 74 with IArchimateRelationship

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);
        }
    }
}
Also used : DeleteArchimateElementCommand(com.archimatetool.editor.model.commands.DeleteArchimateElementCommand) DeleteArchimateRelationshipCommand(com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DeleteFolderCommand(com.archimatetool.editor.model.commands.DeleteFolderCommand) IDiagramModel(com.archimatetool.model.IDiagramModel) DeleteArchimateRelationshipCommand(com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand) DeleteArchimateElementCommand(com.archimatetool.editor.model.commands.DeleteArchimateElementCommand) DeleteDiagramModelCommand(com.archimatetool.editor.model.commands.DeleteDiagramModelCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DeleteFolderCommand(com.archimatetool.editor.model.commands.DeleteFolderCommand) Command(org.eclipse.gef.commands.Command) DeleteDiagramModelCommand(com.archimatetool.editor.model.commands.DeleteDiagramModelCommand) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) EObject(org.eclipse.emf.ecore.EObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IFolder(com.archimatetool.model.IFolder)

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