use of org.osate.ge.aadl2.AadlGraphicalEditorException in project osate2 by osate.
the class CreateErrorPropagationPaletteCommand method buildFeatureReference.
/**
* Builds a {@link FeatureorPPReference} based on a name path. Throws an exception if unable to find any of the
* referenced features.
*/
private FeatureorPPReference buildFeatureReference(final ResourceSet resourceSet, final List<URI> path) {
FeatureorPPReference topPpRef = null;
FeatureorPPReference lastPpRef = null;
for (final URI pathSegmentUri : path) {
final EObject pathSegment = resourceSet.getEObject(pathSegmentUri, true);
if (!(pathSegment instanceof Feature)) {
throw new AadlGraphicalEditorException("Unexpected path segment: " + pathSegment);
}
final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
ppRef.setFeatureorPP((Feature) pathSegment);
if (lastPpRef == null) {
topPpRef = ppRef;
} else {
lastPpRef.setNext(ppRef);
}
lastPpRef = ppRef;
}
return topPpRef;
}
use of org.osate.ge.aadl2.AadlGraphicalEditorException 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;
}
Aggregations