Search in sources :

Example 1 with LinkedSelectorToFilterTranslator

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LinkedSelectorToFilterTranslator(com.evolveum.midpoint.repo.common.query.LinkedSelectorToFilterTranslator) LensFocusContext(com.evolveum.midpoint.model.impl.lens.LensFocusContext) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

LensFocusContext (com.evolveum.midpoint.model.impl.lens.LensFocusContext)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 LinkedSelectorToFilterTranslator (com.evolveum.midpoint.repo.common.query.LinkedSelectorToFilterTranslator)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1