use of com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation in project midpoint by Evolveum.
the class TaskRetriever method getTaskTypeByIdentifier.
@NotNull
public PrismObject<TaskType> getTaskTypeByIdentifier(String identifier, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException {
ObjectQuery query = prismContext.queryFor(TaskType.class).item(TaskType.F_TASK_IDENTIFIER).eq(identifier).build();
List<PrismObject<TaskType>> list = repositoryService.searchObjects(TaskType.class, query, options, result);
if (list.isEmpty()) {
throw new ObjectNotFoundException("Task with identifier " + identifier + " could not be found");
} else if (list.size() > 1) {
throw new IllegalStateException("Found more than one task with identifier " + identifier + " (" + list.size() + " of them)");
}
PrismObject<TaskType> taskPrism = list.get(0);
if (SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK_REF, options)) {
// returns null if noFetch is set
ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, TaskType.class, true, result);
fillInSubtasks(taskPrism.asObjectable(), csi, options, result);
}
return taskPrism;
}
use of com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation in project midpoint by Evolveum.
the class TaskRetriever method searchTasks.
@NotNull
public SearchResultList<PrismObject<TaskType>> searchTasks(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
// returns null if noFetch is set
ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, TaskType.class, true, result);
List<PrismObject<TaskType>> tasksInRepository;
try {
tasksInRepository = repositoryService.searchObjects(TaskType.class, query, options, result);
} catch (SchemaException e) {
result.recordFatalError("Couldn't get tasks from repository: " + e.getMessage(), e);
throw e;
}
boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options);
boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options);
boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options);
boolean loadSubtasks = SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK_REF, options);
List<PrismObject<TaskType>> tasks = new ArrayList<>();
for (PrismObject<TaskType> taskInRepository : tasksInRepository) {
addTransientTaskInformation(taskInRepository, csi, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result);
if (loadSubtasks) {
fillInSubtasks(taskInRepository, csi, options, result);
}
tasks.add(taskInRepository);
}
return new SearchResultList<>(tasks);
}
Aggregations