use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class ActivityState method getParentTask.
/**
* @param fresh False if we are OK with the cached version of the parent task (if current task is RunningTask).
* @param result Can be null if we are 100% sure it will not be used.
*/
@NotNull
private Task getParentTask(boolean fresh, @Nullable OperationResult result) throws SchemaException, ObjectNotFoundException {
Task task = getTask();
Task parentTask;
if (!fresh && task instanceof RunningTask) {
parentTask = ((RunningTask) task).getParentTask();
} else {
parentTask = task.getParentTask(result);
}
return java.util.Objects.requireNonNull(parentTask, () -> "No parent task for " + task);
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class ActivityBasedTaskRun method setupTaskArchetypeIfNeeded.
private void setupTaskArchetypeIfNeeded(OperationResult result) throws ActivityRunException {
if (activityBasedTaskHandler.isAvoidAutoAssigningArchetypes()) {
return;
}
try {
RunningTask task = getRunningTask();
String defaultArchetypeOid = activityTree.getRootActivity().getHandler().getDefaultArchetypeOid();
if (defaultArchetypeOid != null) {
task.addArchetypeInformationIfMissing(defaultArchetypeOid);
task.flushPendingModifications(result);
}
} catch (CommonException e) {
throw new ActivityRunException("Couldn't setup the task archetype", FATAL_ERROR, PERMANENT_ERROR, e);
}
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class ClassicCollectionReportExportActivityRun method beforeRun.
@Override
public void beforeRun(OperationResult result) throws ActivityRunException, CommonException {
RunningTask task = getRunningTask();
support.beforeExecution(result);
@NotNull ReportType report = support.getReport();
support.stateCheck(result);
searchSpecificationHolder = new ContainerableReportDataSource(support);
dataWriter = ReportUtils.createDataWriter(report, FileFormatTypeType.CSV, getActivityHandler().reportService, support.getCompiledCollectionView(result));
controller = new CollectionExportController<>(searchSpecificationHolder, dataWriter, report, reportService, support.getCompiledCollectionView(result), support.getReportParameters());
controller.initialize(task, result);
controller.beforeBucketExecution(1, result);
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class MockComponentActivityRun method runLocally.
@Override
@NotNull
protected ActivityRunResult runLocally(OperationResult result) throws CommonException {
CompositeMockWorkDefinition workDef = activity.getWorkDefinition();
int steps = workDef.getSteps();
long delay = workDef.getDelay();
LOGGER.info("Mock activity starting: id={}, steps={}, delay={}, sub-activity={}:\n{}", workDef.getMessage(), steps, delay, getMockSubActivity(), debugDumpLazily());
String itemName = workDef.getMessage() + ":" + getMockSubActivity();
Operation operation = activityState.getLiveItemProcessingStatistics().recordOperationStart(new IterativeOperationStartInfo(new IterationItemInformation(itemName, null, null, null)));
RunningTask task = taskRun.getRunningTask();
if (delay > 0) {
LOGGER.trace("Sleeping for {} msecs", delay);
MiscUtil.sleepWatchfully(System.currentTimeMillis() + delay, 100, task::canRun);
}
result.recordSuccess();
getRecorder().recordExecution(itemName);
QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.SUCCESS);
operation.done(qualifiedOutcome, null);
incrementProgress(qualifiedOutcome);
LOGGER.info("Mock activity finished: id={}, sub-activity={}:\n{}", workDef.getMessage(), getMockSubActivity(), debugDumpLazily());
return standardRunResult();
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class OperationExecutionRecorderForClockwork method createTaskRef.
private void createTaskRef(OperationExecutionType operation, Context<?> ctx) {
Task task = ctx.task;
String rootTaskOid;
if (task instanceof RunningTask) {
rootTaskOid = ((RunningTask) task).getRootTaskOid();
} else if (task.getParent() == null) {
// can be null
rootTaskOid = task.getOid();
} else {
throw new IllegalStateException("Non-RunningTask with a parent? Impossible: " + task);
}
if (rootTaskOid != null) {
operation.setTaskRef(ObjectTypeUtil.createObjectRef(rootTaskOid, ObjectTypes.TASK));
}
}
Aggregations