Search in sources :

Example 1 with RunningTask

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));
        }
    }
}
Also used : NotNull(org.jetbrains.annotations.NotNull) DashboardWidgetHolder(com.evolveum.midpoint.report.impl.activity.ExportDashboardActivitySupport.DashboardWidgetHolder) RunningTask(com.evolveum.midpoint.task.api.RunningTask) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 2 with RunningTask

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);
    }
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask)

Example 3 with RunningTask

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);
    }
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask)

Example 4 with RunningTask

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);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RunningTask(com.evolveum.midpoint.task.api.RunningTask) Task(com.evolveum.midpoint.task.api.Task) RunningTask(com.evolveum.midpoint.task.api.RunningTask) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 5 with RunningTask

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);
    }
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask) ActivityPath(com.evolveum.midpoint.schema.util.task.ActivityPath) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Aggregations

RunningTask (com.evolveum.midpoint.task.api.RunningTask)20 NotNull (org.jetbrains.annotations.NotNull)6 Task (com.evolveum.midpoint.task.api.Task)4 ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)2 IterationItemInformation (com.evolveum.midpoint.schema.statistics.IterationItemInformation)2 IterativeOperationStartInfo (com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo)2 Operation (com.evolveum.midpoint.schema.statistics.Operation)2 CommonException (com.evolveum.midpoint.util.exception.CommonException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ModelBeans (com.evolveum.midpoint.model.impl.ModelBeans)1 ResourceObjectClass (com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)1 SyncItemProcessingRequest (com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest)1 ModelImplUtils (com.evolveum.midpoint.model.impl.util.ModelImplUtils)1 Containerable (com.evolveum.midpoint.prism.Containerable)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 AsyncUpdateEvent (com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent)1 AsyncUpdateEventHandler (com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)1 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)1