use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class WorkItemProvider method searchWorkItems.
public SearchResultList<WorkItemType> searchWorkItems(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
TaskQuery taskQuery = createTaskQuery(query, true, options, result);
if (taskQuery == null) {
return new SearchResultList<>(Collections.emptyList());
}
Integer offset = query != null ? query.getOffset() : null;
Integer maxSize = query != null ? query.getMaxSize() : null;
List<Task> tasks;
if (offset == null && maxSize == null) {
tasks = taskQuery.list();
} else {
tasks = taskQuery.listPage(defaultIfNull(offset, 0), defaultIfNull(maxSize, Integer.MAX_VALUE));
}
// TODO implement based on options
boolean getAllVariables = true;
// there's no need to fill-in assignee details ; but candidates are necessary to fill-in; TODO implement based on options (resolve)
return tasksToWorkItems(tasks, null, false, false, true, getAllVariables, result);
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class ProcessInstanceManager method getProcessInstancesToKeep.
private Set<String> getProcessInstancesToKeep(OperationResult result) throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(TaskType.class, prismContext).not().item(TaskType.F_WORKFLOW_CONTEXT, WfContextType.F_PROCESS_INSTANCE_ID).isNull().build();
SearchResultList<PrismObject<TaskType>> tasks = taskManager.searchObjects(TaskType.class, query, null, result);
return tasks.stream().map(t -> t.asObjectable().getWorkflowContext().getProcessInstanceId()).collect(Collectors.toSet());
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class PipelineData method resolveQuery.
private Collection<ObjectReferenceType> resolveQuery(Class<? extends ObjectType> type, QueryType queryBean, ExecutionContext context, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
ObjectQuery query = context.getQueryConverter().createObjectQuery(type, queryBean);
SearchResultList<? extends PrismObject<? extends ObjectType>> objects = context.getModelService().searchObjects(type, query, createReadOnlyCollection(), context.getTask(), result);
return objects.stream().map(o -> ObjectTypeUtil.createObjectRef(o, context.getPrismContext())).collect(Collectors.toList());
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class NodeRetriever method searchNodes.
/**
* Gets nodes from repository and adds runtime information to them (taken from ClusterStatusInformation).
*/
@NotNull
public SearchResultList<PrismObject<NodeType>> searchNodes(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, NodeType.class, true, result);
List<PrismObject<NodeType>> nodesInRepository;
try {
nodesInRepository = repositoryService.searchObjects(NodeType.class, query, options, result);
} catch (SchemaException e) {
result.recordFatalError("Couldn't get nodes from repository: " + e.getMessage());
throw e;
}
List<PrismObject<NodeType>> list = new ArrayList<>();
if (csi != null) {
for (PrismObject<NodeType> nodeInRepositoryPrism : nodesInRepository) {
NodeType returnedNode = nodeInRepositoryPrism.asObjectable();
NodeType nodeRuntimeInfo = csi.findNodeById(returnedNode.getNodeIdentifier());
if (nodeRuntimeInfo != null) {
returnedNode.setExecutionState(nodeRuntimeInfo.getExecutionState());
returnedNode.setErrorState(nodeRuntimeInfo.getErrorState());
returnedNode.setConnectionResult(nodeRuntimeInfo.getConnectionResult());
} else {
// node is in repo, but no information on it is present in CSI
// (should not occur except for some temporary conditions, because CSI contains info on all nodes from repo)
returnedNode.setExecutionState(NodeExecutionStateType.COMMUNICATION_ERROR);
OperationResult r = new OperationResult("connect");
r.recordFatalError("Node not known at this moment");
returnedNode.setConnectionResult(r.createOperationResultType());
}
list.add(returnedNode.asPrismObject());
}
} else {
list = nodesInRepository;
}
LOGGER.trace("searchNodes returning {}", list);
return new SearchResultList<>(list);
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class ReferenceResolverImpl method resolveFromFilter.
@NotNull
private List<PrismObject<? extends ObjectType>> resolveFromFilter(Class<? extends ObjectType> targetClass, ObjectReferenceType reference, Collection<SelectorOptions<GetOperationOptions>> options, @NotNull Source source, FilterEvaluator filterEvaluator, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
LOGGER.trace("Resolving filter on {} from {}", targetClass.getSimpleName(), source);
SearchFilterType filterBean = reference.getFilter();
if (filterBean == null) {
throw new IllegalArgumentException("The OID and filter are both null in a reference: " + reference);
}
ObjectFilter filter = prismContext.getQueryConverter().parseFilter(filterBean, targetClass);
ObjectFilter evaluatedFilter = filterEvaluator != null ? filterEvaluator.evaluate(filter, result) : filter;
if (evaluatedFilter == null) {
throw new SchemaException("The OID is null and filter could not be evaluated in " + reference);
}
ObjectQuery query = prismContext.queryFactory().createQuery(evaluatedFilter);
SearchResultList<? extends PrismObject<? extends ObjectType>> objects;
switch(source) {
case REPOSITORY:
objects = repositoryService.searchObjects(targetClass, query, options, result);
break;
case MODEL:
objects = modelService.searchObjects(targetClass, query, options, task, result);
break;
default:
throw new AssertionError(source);
}
// noinspection unchecked
return (List<PrismObject<? extends ObjectType>>) objects;
}
Aggregations