Search in sources :

Example 16 with ClusterStatusInformation

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with ClusterStatusInformation

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ArrayList(java.util.ArrayList) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ClusterStatusInformation (com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)6 NotNull (org.jetbrains.annotations.NotNull)5 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)4 ArrayList (java.util.ArrayList)4 Task (com.evolveum.midpoint.task.api.Task)3 NodeType (com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 TaskQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 XmlTypeConverter (com.evolveum.midpoint.prism.xml.XmlTypeConverter)1 com.evolveum.midpoint.task.api (com.evolveum.midpoint.task.api)1 TaskRunResultStatus (com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus)1 TaskManagerQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskManagerQuartzImpl)1 TaskQuartzImplUtil (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImplUtil)1 LoggingUtils (com.evolveum.midpoint.util.logging.LoggingUtils)1