use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class ClassicDashboardReportExportActivityRun 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);
List<DashboardWidgetType> widgets = support.getDashboard().getWidget();
mapOfWidgetsController = new LinkedHashMap<>();
dataWriter = ReportUtils.createDashboardDataWriter(report, getActivityHandler().reportService, support.getMapOfCompiledViews());
basicWidgetController = new DashboardWidgetExportController(dataWriter, report, reportService);
basicWidgetController.initialize();
basicWidgetController.beforeBucketExecution(1, result);
for (DashboardWidgetType widget : widgets) {
if (support.isWidgetTableVisible()) {
String widgetIdentifier = widget.getIdentifier();
ContainerableReportDataSource searchSpecificationHolder = new ContainerableReportDataSource(support);
DashboardExportController<Containerable> controller = new DashboardExportController(searchSpecificationHolder, dataWriter, report, reportService, support.getCompiledCollectionView(widgetIdentifier), widgetIdentifier, support.getReportParameters());
controller.initialize(task, result);
controller.beforeBucketExecution(1, result);
mapOfWidgetsController.put(widgetIdentifier, new DashboardWidgetHolder(searchSpecificationHolder, controller));
}
}
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class TestIterativeTasks method checkLightweightSubtasks.
// called from Groovy code
@SuppressWarnings("unused")
public static void checkLightweightSubtasks(TaskType subtask) {
RunningTask parent = instance.taskManager.getLocallyRunningTaskByIdentifier(subtask.getParent());
assertNotNull("no parent running task", parent);
Collection<? extends RunningTask> subtasks = parent.getLightweightAsynchronousSubtasks();
LoggerFactory.getLogger(TestIterativeTasks.class).info("Subtask: {}, parent: {}, its subtasks: ({}): {}", subtask, parent, subtasks.size(), subtasks);
if (subtasks.size() > EXPECTED_SUBTASKS) {
AssertJUnit.fail("Exceeded the expected number of subtasks: have " + subtasks.size() + ", expected max: " + EXPECTED_SUBTASKS + ": " + subtasks);
}
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class ReportDataCreationActivityRun method initializeController.
private void initializeController(OperationResult result) throws CommonException {
RunningTask task = getRunningTask();
ReportType report = support.getReport();
if (!getActivityHandler().reportService.isAuthorizedToRunReport(report.asPrismObject(), task, result)) {
LOGGER.error("Task {} is not authorized to run report {}", task, report);
throw new SecurityViolationException("Not authorized");
}
stateCheck(getDirection(report) == EXPORT, "Only report exports are supported here");
stateCheck(report.getObjectCollection() != null, "Only collection-based reports are supported here");
SearchSpecificationHolder searchSpecificationHolder = new SearchSpecificationHolder();
ReportDataWriter<ExportedReportDataRow, ExportedReportHeaderRow> dataWriter = ReportUtils.createDataWriter(report, FileFormatTypeType.CSV, getActivityHandler().reportService, support.getCompiledCollectionView(result));
controller = new CollectionDistributedExportController<>(searchSpecificationHolder, dataWriter, report, support.getGlobalReportDataRef(), reportService, support.getCompiledCollectionView(result), support.getReportParameters());
controller.initialize(task, result);
stateCheck(searchSpecificationHolder.searchSpecification != null, "No search specification was provided");
masterSearchSpecification = searchSpecificationHolder.searchSpecification;
if (AuditEventRecordType.class.equals(masterSearchSpecification.getType())) {
initializeAuditReportBucketing(result);
}
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class SubtaskHelper method switchExecutionToChildren.
void switchExecutionToChildren(Collection<Task> children, OperationResult result) throws ActivityRunException {
try {
RunningTask runningTask = getRunningTask();
runningTask.makeWaitingForOtherTasks(TaskUnpauseActionType.EXECUTE_IMMEDIATELY);
runningTask.flushPendingModifications(result);
for (Task child : children) {
if (child.isSuspended()) {
getBeans().taskManager.resumeTask(child.getOid(), result);
LOGGER.debug("Started prepared child {}", child);
}
}
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException e) {
throw new ActivityRunException("Couldn't switch execution to activity subtask", FATAL_ERROR, PERMANENT_ERROR, e);
}
}
use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.
the class DelegatingActivityRun method createSuspendedChildTask.
private Task createSuspendedChildTask(OperationResult result) throws ActivityRunException {
try {
RunningTask parent = getRunningTask();
TaskType childToCreate = new TaskType(getPrismContext());
childToCreate.setName(PolyStringType.fromOrig(getChildTaskName(parent)));
// group?
childToCreate.setExecutionState(TaskExecutionStateType.SUSPENDED);
childToCreate.setSchedulingState(TaskSchedulingStateType.SUSPENDED);
childToCreate.setOwnerRef(CloneUtil.clone(parent.getOwnerRef()));
childToCreate.setParent(parent.getTaskIdentifier());
childToCreate.setExecutionEnvironment(CloneUtil.clone(parent.getExecutionEnvironment()));
ActivityPath localRoot = getActivityPath();
childToCreate.beginActivityState().localRoot(localRoot.toBean()).taskRole(TaskRoleType.DELEGATE);
LOGGER.debug("Creating activity subtask {} with local root {}", childToCreate.getName(), localRoot);
String childOid = getBeans().taskManager.addTask(childToCreate.asPrismObject(), result);
LOGGER.debug("Created activity subtask {}: {}", childToCreate.getName(), childOid);
// TODO eliminate this extra read some day
return getBeans().taskManager.getTaskPlain(childOid, result);
} catch (Exception e) {
throw new ActivityRunException("Couldn't create activity child task", FATAL_ERROR, PERMANENT_ERROR, e);
}
}
Aggregations