use of org.osate.ge.CanonicalBusinessObjectReference in project osate2 by osate.
the class FilterByBusinessObjectCanonicalReferenceQuery method run.
@Override
void run(final Deque<DefaultQuery<T>> remainingQueries, final BusinessObjectContext ctx, final QueryExecutionState<T> state, final QueryResults result) {
// Look in the cache for the reference and build a new reference string if it is not found
final CanonicalBusinessObjectReference boRef = (CanonicalBusinessObjectReference) state.cache.computeIfAbsent(this, t -> {
final Object bo = boSupplier.apply(state.arg);
CanonicalBusinessObjectReference newValue = bo == null ? nullBoRef : state.refBuilder.getCanonicalReference(bo);
if (newValue == null) {
newValue = nullBoRef;
}
return newValue;
});
if (boRef == nullBoRef) {
return;
}
// Compare references
final CanonicalBusinessObjectReference ctxCanonicalReference = state.refBuilder.getCanonicalReference(ctx.getBusinessObject());
if (ctxCanonicalReference != null && ctxCanonicalReference.equals(boRef)) {
processResultValue(remainingQueries, ctx, state, result);
}
}
use of org.osate.ge.CanonicalBusinessObjectReference in project osate2 by osate.
the class AgeDiagramUtil method getConfigurationContextBusinessObject.
/**
* Resolves and returns the diagram's context
* Diagram configurations have an optional business object which provides a context for the diagram.
* This function returns the context business object referenced by the diagram's configuration.
* @param diagram the diagram for which to retrieve the context
* @param referenceService the service to use to resolve the context reference
* @return the diagram's context. Will return null if the object cannot be found or if the configuration does not reference a business object.
*/
public static Object getConfigurationContextBusinessObject(final AgeDiagram diagram, final ProjectReferenceService referenceService) {
final CanonicalBusinessObjectReference contextBoReference = diagram.getConfiguration().getContextBoReference();
final Object diagramBo;
if (contextBoReference == null) {
diagramBo = null;
} else {
diagramBo = referenceService.resolve(contextBoReference);
}
return diagramBo;
}
use of org.osate.ge.CanonicalBusinessObjectReference in project osate2 by osate.
the class AgeEditor method selectDiagramElementsForBusinessObject.
@Override
public void selectDiagramElementsForBusinessObject(final Object bo) {
final CanonicalBusinessObjectReference searchRef = referenceService.getCanonicalReference(bo);
final List<DiagramElement> elementsForBo = diagram.getAllDiagramNodes().filter(DiagramElement.class::isInstance).map(DiagramElement.class::cast).filter(de -> Objects.equals(searchRef, referenceService.getCanonicalReference(de.getBusinessObject()))).collect(Collectors.toList());
selectDiagramNodes(elementsForBo);
}
use of org.osate.ge.CanonicalBusinessObjectReference 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.ge.CanonicalBusinessObjectReference in project osate2 by osate.
the class DefaultDiagramService method getRuntimeReferencesFromChildren.
/**
* Gets references from open editors.
*/
private void getRuntimeReferencesFromChildren(final InternalDiagramEditor editor, final DiagramNode node, final Collection<CanonicalBusinessObjectReference> originalCanonicalReferences, final InternalReferencesToUpdate references) {
for (final DiagramElement child : node.getChildren()) {
final Object currentBo = child.getBusinessObject();
final CanonicalBusinessObjectReference currentCanonicalRef = currentBo == null ? null : referenceService.getCanonicalReference(currentBo);
if (currentCanonicalRef != null && originalCanonicalReferences.contains(currentCanonicalRef)) {
references.addReference(editor, currentCanonicalRef, new OpenDiagramElementReference(child));
}
getRuntimeReferencesFromChildren(editor, child, originalCanonicalReferences, references);
}
}
Aggregations