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;
}
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;
}
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();
}
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);
}
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;
}
Aggregations