Search in sources :

Example 1 with IAccessRelationship

use of com.archimatetool.model.IAccessRelationship in project archi by archimatetool.

the class CSVImporter method createPropertyFromRecord.

/**
 * Create a Property from a given CSVRecord
 */
private void createPropertyFromRecord(CSVRecord csvRecord) throws CSVParseException {
    // ID
    String id = csvRecord.get(0);
    if (!StringUtils.isSet(id)) {
        throw new CSVParseException(Messages.CSVImporter_6);
    } else {
        checkIDForInvalidCharacters(id);
    }
    // Find referenced concept in newly created list
    IProperties propertiesObject = newConcepts.get(id);
    // Not found, check if it's referencing an existing element in the model
    if (propertiesObject == null) {
        EObject eObject = ArchimateModelUtils.getObjectByID(fModel, id);
        if (eObject instanceof IProperties) {
            propertiesObject = (IProperties) eObject;
        }
    }
    // Not found, check if it's referencing the model
    if (propertiesObject == null && id.equals(modelID)) {
        propertiesObject = fModel;
    }
    // Not found at all
    if (propertiesObject == null) {
        throw new CSVParseException(Messages.CSVImporter_7 + id);
    }
    String key = normalise(csvRecord.get(1));
    String value = normalise(csvRecord.get(2));
    // Special properties for relationship attributes
    if (INFLUENCE_STRENGTH.equals(key) && propertiesObject instanceof IInfluenceRelationship) {
        storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, value);
        return;
    } else if (ACCESS_TYPE.equals(key) && propertiesObject instanceof IAccessRelationship) {
        int newvalue = ACCESS_TYPES.indexOf(value);
        storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.ACCESS_RELATIONSHIP__ACCESS_TYPE, newvalue);
        return;
    }
    // Is there already a property with this key?
    IProperty property = getProperty(propertiesObject, key);
    if (property != null) {
        updatedProperties.put(property, value);
    } else // No, create new one
    {
        property = IArchimateFactory.eINSTANCE.createProperty();
        property.setKey(key);
        property.setValue(value);
        newProperties.put(property, propertiesObject);
    }
}
Also used : IInfluenceRelationship(com.archimatetool.model.IInfluenceRelationship) IProperty(com.archimatetool.model.IProperty) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IProperties(com.archimatetool.model.IProperties) IAccessRelationship(com.archimatetool.model.IAccessRelationship) CSVParseException(com.archimatetool.csv.CSVParseException)

Example 2 with IAccessRelationship

use of com.archimatetool.model.IAccessRelationship in project archi by archimatetool.

the class ZestViewerLabelProvider method selfStyleConnection.

// ========================================================================================
// ISelfStyleProvider
// ========================================================================================
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
    connection.setLineWidth(0);
    connection.setTooltip(getTooltip(element));
    connection.setLineColor(ColorConstants.black);
    connection.setText(getText(element));
    PolylineConnection conn = (PolylineConnection) connection.getConnectionFigure();
    if (element instanceof ISpecializationRelationship) {
        conn.setTargetDecoration(SpecializationConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof ICompositionRelationship) {
        conn.setSourceDecoration(CompositionConnectionFigure.createFigureSourceDecoration());
    } else if (element instanceof IAggregationRelationship) {
        conn.setSourceDecoration(AggregationConnectionFigure.createFigureSourceDecoration());
    } else if (element instanceof IAssignmentRelationship) {
        conn.setSourceDecoration(AssignmentConnectionFigure.createFigureSourceDecoration());
        conn.setTargetDecoration(AssignmentConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IRealizationRelationship) {
        conn.setTargetDecoration(RealizationConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 2 });
    } else if (element instanceof ITriggeringRelationship) {
        conn.setTargetDecoration(TriggeringConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IFlowRelationship) {
        conn.setTargetDecoration(FlowConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 6, 3 });
    } else if (element instanceof IServingRelationship) {
        conn.setTargetDecoration(ServingConnectionFigure.createFigureTargetDecoration());
    } else if (element instanceof IAccessRelationship) {
        switch(((IAccessRelationship) element).getAccessType()) {
            case IAccessRelationship.WRITE_ACCESS:
            default:
                conn.setSourceDecoration(null);
                // arrow at target endpoint
                conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                break;
            case IAccessRelationship.READ_ACCESS:
                // arrow at source endpoint
                conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                conn.setTargetDecoration(null);
                break;
            case IAccessRelationship.UNSPECIFIED_ACCESS:
                // no arrows
                conn.setSourceDecoration(null);
                conn.setTargetDecoration(null);
                break;
            case IAccessRelationship.READ_WRITE_ACCESS:
                // both arrows
                conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
                break;
        }
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 2 });
    } else if (element instanceof IInfluenceRelationship) {
        conn.setTargetDecoration(InfluenceConnectionFigure.createFigureTargetDecoration());
        connection.setLineStyle(SWT.LINE_CUSTOM);
        conn.setLineDash(new float[] { 6, 3 });
    }
    conn.setAntialias(SWT.ON);
}
Also used : IInfluenceRelationship(com.archimatetool.model.IInfluenceRelationship) ICompositionRelationship(com.archimatetool.model.ICompositionRelationship) IRealizationRelationship(com.archimatetool.model.IRealizationRelationship) ITriggeringRelationship(com.archimatetool.model.ITriggeringRelationship) ISpecializationRelationship(com.archimatetool.model.ISpecializationRelationship) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IAggregationRelationship(com.archimatetool.model.IAggregationRelationship) IFlowRelationship(com.archimatetool.model.IFlowRelationship) IAccessRelationship(com.archimatetool.model.IAccessRelationship) IServingRelationship(com.archimatetool.model.IServingRelationship) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 3 with IAccessRelationship

use of com.archimatetool.model.IAccessRelationship in project archi by archimatetool.

the class NestedElementsChecker method isNestedWithoutValidRelation.

boolean isNestedWithoutValidRelation(IDiagramModelArchimateObject parent, IDiagramModelArchimateObject child) {
    IArchimateElement parentElement = parent.getArchimateElement();
    IArchimateElement childElement = child.getArchimateElement();
    // Ignore nested Junctions
    if (childElement instanceof IJunction) {
        return false;
    }
    // Specialization relationship goes the other way around
    for (IArchimateRelationship relation : parentElement.getTargetRelationships()) {
        if (relation.getSource() == childElement) {
            if (relation instanceof ISpecializationRelationship) {
                return false;
            }
        }
    }
    // Other relationships
    for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
        if (relation.getTarget() == childElement) {
            if (relation instanceof ICompositionRelationship || relation instanceof IAggregationRelationship || relation instanceof IAssignmentRelationship || relation instanceof IRealizationRelationship || relation instanceof IAccessRelationship) {
                return false;
            }
        }
    }
    return true;
}
Also used : ICompositionRelationship(com.archimatetool.model.ICompositionRelationship) IRealizationRelationship(com.archimatetool.model.IRealizationRelationship) ISpecializationRelationship(com.archimatetool.model.ISpecializationRelationship) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IAggregationRelationship(com.archimatetool.model.IAggregationRelationship) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IAccessRelationship(com.archimatetool.model.IAccessRelationship) IJunction(com.archimatetool.model.IJunction)

Example 4 with IAccessRelationship

use of com.archimatetool.model.IAccessRelationship in project archi by archimatetool.

the class AllArchimateRelationshipTypeTests method testGetInterface_Type.

@Test
public void testGetInterface_Type() {
    // Only IAccessRelationship type
    Assume.assumeTrue(relationship instanceof IAccessRelationship);
    IAccessRelationship aRelationship = (IAccessRelationship) relationship;
    assertEquals(IAccessRelationship.WRITE_ACCESS, aRelationship.getAccessType());
    aRelationship.setAccessType(IAccessRelationship.READ_ACCESS);
    assertEquals(IAccessRelationship.READ_ACCESS, aRelationship.getAccessType());
}
Also used : IAccessRelationship(com.archimatetool.model.IAccessRelationship) Test(org.junit.Test)

Example 5 with IAccessRelationship

use of com.archimatetool.model.IAccessRelationship in project archi by archimatetool.

the class AccessConnectionFigure method getToolTip.

@Override
public IFigure getToolTip() {
    ToolTipFigure tooltip = (ToolTipFigure) super.getToolTip();
    if (tooltip == null) {
        return null;
    }
    // Show access type in tooltip
    IAccessRelationship relation = (IAccessRelationship) getModelConnection().getArchimateRelationship();
    String type = ArchiLabelProvider.INSTANCE.getDefaultName(relation.eClass());
    switch(relation.getAccessType()) {
        case IAccessRelationship.WRITE_ACCESS:
            // $NON-NLS-1$
            type += " " + Messages.AccessConnectionFigure_0;
            break;
        case IAccessRelationship.READ_ACCESS:
            // $NON-NLS-1$
            type += " " + Messages.AccessConnectionFigure_1;
            break;
        case IAccessRelationship.UNSPECIFIED_ACCESS:
            // $NON-NLS-1$
            type += " " + Messages.AccessConnectionFigure_2;
            break;
        case IAccessRelationship.READ_WRITE_ACCESS:
            // $NON-NLS-1$
            type += " " + Messages.AccessConnectionFigure_3;
            break;
        default:
            break;
    }
    // $NON-NLS-1$
    tooltip.setType(Messages.AccessConnectionFigure_4 + " " + type);
    return tooltip;
}
Also used : ToolTipFigure(com.archimatetool.editor.diagram.figures.ToolTipFigure) IAccessRelationship(com.archimatetool.model.IAccessRelationship)

Aggregations

IAccessRelationship (com.archimatetool.model.IAccessRelationship)7 IAggregationRelationship (com.archimatetool.model.IAggregationRelationship)2 IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)2 ICompositionRelationship (com.archimatetool.model.ICompositionRelationship)2 IInfluenceRelationship (com.archimatetool.model.IInfluenceRelationship)2 IRealizationRelationship (com.archimatetool.model.IRealizationRelationship)2 ISpecializationRelationship (com.archimatetool.model.ISpecializationRelationship)2 Test (org.junit.Test)2 CSVParseException (com.archimatetool.csv.CSVParseException)1 ToolTipFigure (com.archimatetool.editor.diagram.figures.ToolTipFigure)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateElement (com.archimatetool.model.IArchimateElement)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IFlowRelationship (com.archimatetool.model.IFlowRelationship)1 IJunction (com.archimatetool.model.IJunction)1 IProperties (com.archimatetool.model.IProperties)1 IProperty (com.archimatetool.model.IProperty)1 IServingRelationship (com.archimatetool.model.IServingRelationship)1 ITriggeringRelationship (com.archimatetool.model.ITriggeringRelationship)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1