Search in sources :

Example 6 with SubcomponentElement

use of org.osate.xtext.aadl2.errormodel.errorModel.SubcomponentElement in project osate2 by osate.

the class CreatePropagatonPathPaletteCommand method createQualifiedPropagationPoint.

/**
 * Creates a {@link QualifiedPropagationPoint} for referencing a business object context using business objects contained
 * in the same resource as the specified subclause. Throws an exception on error.
 * @param subclause is the subclause used to find the resource set.
 * @param boc is the business object context which contains the element to reference
 * @param classifierSource is the classifier which serves as the root of the path.
 * @return the new {@link QualifiedPropagationPoint} instance.
 */
private static QualifiedPropagationPoint createQualifiedPropagationPoint(final ErrorModelSubclause subclause, final BusinessObjectContext boc, final BusinessObjectContext classifierSource) {
    final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(boc, classifierSource, new ArrayList<>());
    QualifiedPropagationPoint result = null;
    QualifiedPropagationPoint lastSegmentRef = null;
    final ResourceSet rs = subclause.eResource().getResourceSet();
    for (final URI pathSegmentUri : path) {
        final EObject pathSegment = rs.getEObject(pathSegmentUri, true);
        // Create the QualifiedPropagationPoint instance for the path segment
        final QualifiedPropagationPoint newPoint = ErrorModelFactory.eINSTANCE.createQualifiedPropagationPoint();
        if (pathSegment instanceof Subcomponent) {
            final SubcomponentElement scElement = ErrorModelFactory.eINSTANCE.createSubcomponentElement();
            scElement.setSubcomponent((Subcomponent) pathSegment);
            newPoint.setSubcomponent(scElement);
        } else if (pathSegment instanceof NamedElement) {
            newPoint.setPropagationPoint((NamedElement) pathSegment);
        } else {
            throw new AadlGraphicalEditorException("Unexpected path segment: " + pathSegment);
        }
        if (result == null) {
            result = newPoint;
        } else {
            lastSegmentRef.setNext(newPoint);
        }
        lastSegmentRef = newPoint;
    }
    return result;
}
Also used : SubcomponentElement(org.osate.xtext.aadl2.errormodel.errorModel.SubcomponentElement) EObject(org.eclipse.emf.ecore.EObject) Subcomponent(org.osate.aadl2.Subcomponent) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) QualifiedPropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedPropagationPoint) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

SubcomponentElement (org.osate.xtext.aadl2.errormodel.errorModel.SubcomponentElement)5 BasicEList (org.eclipse.emf.common.util.BasicEList)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 ArrayRange (org.osate.aadl2.ArrayRange)1 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)1 BooleanLiteral (org.osate.aadl2.BooleanLiteral)1 ClassifierValue (org.osate.aadl2.ClassifierValue)1 ComputedValue (org.osate.aadl2.ComputedValue)1 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)1 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)1 IntegerLiteral (org.osate.aadl2.IntegerLiteral)1 ListValue (org.osate.aadl2.ListValue)1 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)1