Search in sources :

Example 1 with FeatureorPPReference

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

the class FeatureorPPReferenceImpl method basicSetNext.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetNext(FeatureorPPReference newNext, NotificationChain msgs) {
    FeatureorPPReference oldNext = next;
    next = newNext;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ErrorModelPackage.FEATUREOR_PP_REFERENCE__NEXT, oldNext, newNext);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 2 with FeatureorPPReference

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

the class EMV2Util method getErrorPropagationFeatureDirection.

/**
 * returns the feature instance in the component instance that is referenced by the Error Propagation (or Containment)
 * @param ep
 * @param ci
 * @return
 */
public static DirectionType getErrorPropagationFeatureDirection(ErrorPropagation ep) {
    FeatureorPPReference fref = ep.getFeatureorPPRef();
    boolean inverse = false;
    NamedElement f = null;
    DirectionType featuredir = DirectionType.IN_OUT;
    while (fref != null) {
        f = fref.getFeatureorPP();
        fref = fref.getNext();
        if (f instanceof FeatureGroup && fref != null) {
            FeatureGroup fg = (FeatureGroup) f;
            FeatureGroupType fgt = fg.getAllFeatureGroupType();
            if (fg.isInverse()) {
                inverse = !inverse;
            }
            if (fgt != null && fgt.getInverse() != null && !fgt.getOwnedFeatures().contains(fref.getFeatureorPP())) {
                inverse = !inverse;
            }
        }
    }
    if (f instanceof DirectedFeature) {
        featuredir = ((DirectedFeature) f).getDirection();
        if (inverse) {
            return featuredir.getInverseDirection();
        } else {
            return featuredir;
        }
    }
    return featuredir;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DirectedFeature(org.osate.aadl2.DirectedFeature) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 3 with FeatureorPPReference

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

the class CreateErrorPropagationPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    final Object bo = ctx.getTarget().getBusinessObject();
    if (bo instanceof Feature) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the feature in the context of the EMV subclause. This is needed for reliable serialization.
            final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(ctx.getTarget(), ErrorModelGeUtil.getClassifierSourceBoc(ctx.getTarget()).get(), new ArrayList<>());
            newPropagation.setFeatureorPPRef(buildFeatureReference(subclause.eResource().getResourceSet(), path));
        });
    } else if (bo instanceof KeywordPropagationPoint) {
        final KeywordPropagationPoint kw = (KeywordPropagationPoint) bo;
        if (kw.getType() != KeywordPropagationPointType.ALL) {
            return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> newPropagation.setKind(kw.getType().getKind()));
        }
    } else if (bo instanceof PropagationPoint) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the propagation in the context of the EMV subclause.
            // Check inherited subclauses as well. This is needed for reliable serialization.
            final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(subclause.getContainingClassifier());
            final String boName = ((PropagationPoint) bo).getName();
            final PropagationPoint pp = combined.getPoints().filter(p -> Objects.equal(p.getName(), boName)).findAny().orElseThrow(() -> new AadlGraphicalEditorException("Unable to find propagation point"));
            final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
            ppRef.setFeatureorPP(pp);
            newPropagation.setFeatureorPPRef(ppRef);
        });
    }
    return Optional.empty();
}
Also used : URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPointType(org.osate.ge.errormodel.model.KeywordPropagationPointType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) PropagationTreeUtil(org.osate.ge.errormodel.combined.PropagationTreeUtil) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) ErrorModelUiUtil(org.osate.ge.errormodel.ui.ErrorModelUiUtil) BiConsumer(java.util.function.BiConsumer) DirectionType(org.osate.aadl2.DirectionType) Objects(com.google.common.base.Objects) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext) Operation(org.osate.ge.operations.Operation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) Display(org.eclipse.swt.widgets.Display) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) PropagationNode(org.osate.ge.errormodel.combined.PropagationNode) StringUtil(org.osate.ge.StringUtil) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) TargetedPaletteCommand(org.osate.ge.palette.TargetedPaletteCommand) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) EObject(org.eclipse.emf.ecore.EObject) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) Feature(org.osate.aadl2.Feature) URI(org.eclipse.emf.common.util.URI) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 4 with FeatureorPPReference

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

the class ErrorPropagationHandler method getCanonicalReference.

@Override
public CanonicalBusinessObjectReference getCanonicalReference(final ReferenceContext ctx) {
    final ErrorPropagation bo = ctx.getBusinessObject(ErrorPropagation.class).get();
    // Determine exact number of segments
    int numberOfSegments = 4;
    if (bo.getKind() == null) {
        for (FeatureorPPReference t = bo.getFeatureorPPRef(); t != null; t = t.getNext()) {
            numberOfSegments++;
        }
    } else {
        numberOfSegments++;
    }
    // Build segments
    final String[] segments = new String[numberOfSegments];
    int segmentIndex = 0;
    segments[segmentIndex++] = ErrorModelReferenceUtil.TYPE_PROPAGATION;
    segments[segmentIndex++] = ctx.getReferenceBuilder().getCanonicalReference(bo.getContainingClassifier()).encode();
    if (bo.getKind() == null) {
        for (FeatureorPPReference t = bo.getFeatureorPPRef(); t != null; t = t.getNext()) {
            final String name = t.getFeatureorPP() == null ? null : t.getFeatureorPP().getName();
            segments[segmentIndex++] = Strings.isNullOrEmpty(name) ? "?" : name;
        }
    } else {
        segments[segmentIndex++] = bo.getKind();
    }
    segments[segmentIndex++] = Boolean.toString(bo.isNot());
    segments[segmentIndex] = bo.getDirection() == null ? "<null>" : bo.getDirection().getLiteral();
    // Create reference
    return new CanonicalBusinessObjectReference(segments);
}
Also used : CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 5 with FeatureorPPReference

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

the class ErrorFlowHandler method getBusinessObjectPathToPropagationFeatureOrPP.

/**
 * Gets an array of business objects representing the path to the specified error propagation
 * @param p the propagation to get the path for
 * @return the path or null if a model element was not available
 */
private static Object[] getBusinessObjectPathToPropagationFeatureOrPP(final ErrorPropagation p) {
    if (p.getFeatureorPPRef() == null) {
        return null;
    }
    // Determine the needed size for the array
    int count = 0;
    for (FeatureorPPReference t = p.getFeatureorPPRef(); t != null; t = t.getNext()) {
        if (t.getFeatureorPP() == null) {
            return null;
        }
        count++;
    }
    // Populate the array with the path
    final Object[] path = new Object[count];
    int index = 0;
    for (FeatureorPPReference t = p.getFeatureorPPRef(); t != null; t = t.getNext()) {
        path[index++] = t.getFeatureorPP();
    }
    return path;
}
Also used : KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Aggregations

FeatureorPPReference (org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)8 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 Feature (org.osate.aadl2.Feature)3 NamedElement (org.osate.aadl2.NamedElement)3 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 DirectedFeature (org.osate.aadl2.DirectedFeature)2 DirectionType (org.osate.aadl2.DirectionType)2 AadlGraphicalEditorException (org.osate.ge.aadl2.AadlGraphicalEditorException)2 KeywordPropagationPoint (org.osate.ge.errormodel.model.KeywordPropagationPoint)2 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)2 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)2 Objects (com.google.common.base.Objects)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 BiConsumer (java.util.function.BiConsumer)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1