use of com.evolveum.midpoint.repo.common.query.LinkedSelectorToFilterTranslator in project midpoint by Evolveum.
the class LinkedObjectsFunctions method findLinkedSources.
<T extends AssignmentHolderType> List<T> findLinkedSources(String linkType) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Task currentTask = midpointFunctions.getCurrentTask();
OperationResult currentResult = midpointFunctions.getCurrentResult();
LensFocusContext<?> focusContext = (LensFocusContext<?>) midpointFunctions.getFocusContext();
if (focusContext == null) {
throw new IllegalStateException("No focus context");
}
LinkTypeDefinitionType definition = focusContext.getSourceLinkTypeDefinition(linkType, linkManager, currentResult);
if (definition == null) {
throw new IllegalStateException("No definition for source link type " + linkType + " for " + focusContext);
}
PrismReferenceValue focusReference = midpointFunctions.getFocusObjectReference().asReferenceValue();
LinkedSelectorToFilterTranslator translator = new LinkedSelectorToFilterTranslator(definition.getSelector(), focusReference, "finding linked sources for " + focusContext, prismContext, expressionFactory, currentTask, currentResult);
ObjectQuery query = prismContext.queryFactory().createQuery(translator.createFilter());
// noinspection unchecked
return (List<T>) midpointFunctions.searchObjects(translator.getNarrowedTargetType(), query, null);
}
Aggregations