use of org.osate.ge.errormodel.model.KeywordPropagationPoint 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.ge.errormodel.model.KeywordPropagationPoint in project osate2 by osate.
the class ErrorModelBusinessObjectProvider method getChildBusinessObjects.
@Override
public Stream<?> getChildBusinessObjects(final BusinessObjectProviderContext ctx) {
final Object bo = ctx.getBusinessObjectContext().getBusinessObject();
if (bo instanceof AadlPackage) {
return ErrorModelGeUtil.getErrorModelLibrary((AadlPackage) bo).map(lib -> Stream.concat(Stream.concat(lib.getTypes().stream(), lib.getTypesets().stream()), lib.getBehaviors().stream())).orElseGet(Stream::empty);
} else if (bo instanceof ErrorBehaviorStateMachine) {
final ErrorBehaviorStateMachine stateMachine = (ErrorBehaviorStateMachine) bo;
return Stream.concat(Stream.concat(stateMachine.getEvents().stream(), stateMachine.getStates().stream()), stateMachine.getTransitions().stream());
} else if (bo instanceof ErrorBehaviorTransition) {
// See ErrorBehaviorTransitionHandler for details regarding how the business objects related to error behavior transitions are represented.
final ErrorBehaviorTransition t = (ErrorBehaviorTransition) bo;
return t.getDestinationBranches().isEmpty() ? Stream.empty() : Stream.concat(Stream.of(new BehaviorTransitionTrunk(t)), t.getDestinationBranches().stream());
} else if (bo instanceof ErrorType) {
final ErrorType errorType = (ErrorType) bo;
if (errorType.getSuperType() != null) {
return Stream.of(new ErrorTypeExtension(errorType.getSuperType(), errorType));
}
} else if (bo instanceof Classifier || bo instanceof Subcomponent) {
// Anytime the children of a classifier or subcomponent is requested, process of error model subclauses
// in the element or extended elements and cache the result.
// Ideally, we would only do this if the classifier has changed but it would require a reliable means to
// determine if a classifier or any classifiers it extends has changed. If extended classifiers are in another
// package, the classifier be the same instance.
// The object is cached so it is available when calling the business object provider on children.
final Classifier classifier = ErrorModelGeUtil.getClassifier(ctx.getBusinessObjectContext()).orElse(null);
if (classifier != null) {
final CombinedErrorModelSubclause cacheEntry = CombinedErrorModelSubclause.create(classifier);
classifierCache.put(classifier, cacheEntry);
if (cacheEntry.subclauseExists()) {
final Set<KeywordPropagationPointType> usedKeywordTypes = cacheEntry.getUsedKeywordPropagations();
return Stream.of(cacheEntry.getPoints(), cacheEntry.getPaths(), cacheEntry.getFlows(), Arrays.stream(KeywordPropagationPointType.values()).map(t -> new KeywordPropagationPoint(classifier, t, usedKeywordTypes.contains(t)))).flatMap(Function.identity());
}
}
} else if (bo instanceof Feature || bo instanceof PropagationPoint || bo instanceof KeywordPropagationPoint) {
// Propagation(and containment) objects
final CombinedErrorModelSubclause cacheEntry = getClassifierCacheEntry(ctx.getBusinessObjectContext());
return PropagationTreeUtil.getPropagationsForBusinessObjectContext(cacheEntry.getPropagations(), ctx.getBusinessObjectContext());
}
return Stream.empty();
}
Aggregations