use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class ProcessInstanceProvider method augmentTaskObject.
// doesn't throw any exceptions - these are logged and stored into the operation result
public <T extends ObjectType> void augmentTaskObject(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Task opTask, OperationResult parentResult) {
final OperationResult result = parentResult.createSubresult(OPERATION_AUGMENT_TASK_OBJECT);
result.addParam("object", ObjectTypeUtil.toShortString(object));
result.addCollectionOfSerializablesAsParam("options", options);
if (!(object.asObjectable() instanceof TaskType)) {
result.recordNotApplicableIfUnknown();
return;
}
final TaskType taskType = (TaskType) object.asObjectable();
try {
if (taskType.getWorkflowContext() == null) {
return;
}
final String instanceId = taskType.getWorkflowContext().getProcessInstanceId();
if (instanceId == null) {
return;
}
final boolean retrieveWorkItems = SelectorOptions.hasToLoadPath(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM), options);
if (!retrieveWorkItems) {
// We assume that everything (except work items) is already stored in repo.
return;
}
final List<WorkItemType> workItems = workItemProvider.getWorkItemsForProcessInstanceId(instanceId, result);
taskType.getWorkflowContext().getWorkItem().addAll(CloneUtil.cloneCollectionMembers(workItems));
} catch (RuntimeException e) {
result.recordFatalError(e.getMessage(), e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't prepare wf-related information for {}", e, ObjectTypeUtil.toShortString(object));
} finally {
result.computeStatusIfUnknown();
}
if (!result.isSuccess()) {
taskType.setFetchResult(result.createOperationResultType());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class ProcessInstanceManager method getMidpointToActiviti.
private Map<String, String> getMidpointToActiviti(OperationResult result) throws SchemaException {
final Map<String, String> rv = new HashMap<>();
final List<PrismObject<TaskType>> tasks = taskManager.searchObjects(TaskType.class, null, null, result);
int tasksWithProcessId = 0;
for (PrismObject<TaskType> taskObject : tasks) {
final TaskType task = taskObject.asObjectable();
final WfContextType wfc = task.getWorkflowContext();
final String pid = wfc != null ? wfc.getProcessInstanceId() : null;
rv.put(task.getOid(), pid);
if (pid != null) {
tasksWithProcessId++;
}
}
LOGGER.info("Found {} tasks; among these, {} have a pointer to process instance id", rv.size(), tasksWithProcessId);
return rv;
}
Aggregations