use of com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction in project midpoint by Evolveum.
the class BaseModelInvocationProcessingHelper method createInstructionForRoot.
/**
* Creates a root job creation instruction.
*
* @param changeProcessor reference to the change processor responsible for the whole operation
* @param modelContext model context in which the original model operation is carried out
* @param taskFromModel task in which the original model operation is carried out
* @param contextForRoot model context that should be put into the root task (might be different from the modelContext)
* @return the job creation instruction
* @throws SchemaException
*/
public WfTaskCreationInstruction createInstructionForRoot(ChangeProcessor changeProcessor, ModelContext modelContext, Task taskFromModel, ModelContext contextForRoot, OperationResult result) throws SchemaException {
WfTaskCreationInstruction instruction;
if (contextForRoot != null) {
instruction = WfTaskCreationInstruction.createModelOnly(changeProcessor, contextForRoot);
} else {
instruction = WfTaskCreationInstruction.createEmpty(changeProcessor);
}
instruction.setTaskName(determineRootTaskName(modelContext));
instruction.setTaskObject(determineRootTaskObject(modelContext));
instruction.setTaskOwner(taskFromModel.getOwner());
instruction.setCreateTaskAsWaiting();
instruction.setRequesterRef(getRequester(taskFromModel, result));
return instruction;
}
use of com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction in project midpoint by Evolveum.
the class GeneralChangeProcessor method applyScenario.
private HookOperationMode applyScenario(GeneralChangeProcessorScenarioType scenarioType, GcpScenarioBean scenarioBean, ModelContext context, Task taskFromModel, WfConfigurationType wfConfigurationType, OperationResult result) {
try {
// ========== preparing root task ===========
WfTaskCreationInstruction rootInstruction = baseModelInvocationProcessingHelper.createInstructionForRoot(this, context, taskFromModel, result);
WfTask rootWfTask = baseModelInvocationProcessingHelper.submitRootTask(rootInstruction, taskFromModel, wfConfigurationType, result);
// ========== preparing child task, starting WF process ===========
WfTaskCreationInstruction instruction = scenarioBean.prepareJobCreationInstruction(scenarioType, (LensContext<?>) context, rootWfTask, taskFromModel, result);
wfTaskController.submitWfTask(instruction, rootWfTask, wfConfigurationType, result);
// ========== complete the action ===========
baseModelInvocationProcessingHelper.logJobsBeforeStart(rootWfTask, result);
rootWfTask.startWaitingForSubtasks(result);
return HookOperationMode.BACKGROUND;
} catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ObjectAlreadyExistsException | ExpressionEvaluationException | RuntimeException | Error e) {
LoggingUtils.logUnexpectedException(LOGGER, "Workflow process(es) could not be started", e);
result.recordFatalError("Workflow process(es) could not be started: " + e, e);
return HookOperationMode.ERROR;
// todo rollback - at least close open tasks, maybe stop workflow process instances
}
}
use of com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction in project midpoint by Evolveum.
the class BaseGcpScenarioBean method prepareJobCreationInstruction.
@Override
public WfTaskCreationInstruction prepareJobCreationInstruction(GeneralChangeProcessorScenarioType scenarioType, LensContext<?> context, WfTask rootWfTask, com.evolveum.midpoint.task.api.Task taskFromModel, OperationResult result) throws SchemaException {
GeneralChangeProcessorSpecificContent processorInstruction = new GeneralChangeProcessorSpecificContent(context);
processorInstruction.setScenarioBeanName(scenarioType.getBeanName());
WfTaskCreationInstruction instruction = WfTaskCreationInstruction.createWfOnly(rootWfTask.getChangeProcessor(), processorInstruction, null);
instruction.setProcessName(scenarioType.getProcessName());
instruction.setRequesterRef(taskFromModel.getOwner());
instruction.setTaskName("Workflow-monitoring task");
instruction.setProcessInterfaceBean(defaultProcessMidPointInterface);
return instruction;
}
use of com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction in project midpoint by Evolveum.
the class PrimaryChangeProcessor method submitTask0.
// Child task0 - in modes 2, 3 we have to prepare first child that executes all changes that do not require approval
private WfTask submitTask0(ModelContext context, ObjectTreeDeltas changesWithoutApproval, WfTask rootWfTask, ExecutionMode executionMode, WfConfigurationType wfConfigurationType, OperationResult result) throws SchemaException, ObjectNotFoundException {
if (changesWithoutApproval != null && !changesWithoutApproval.isEmpty() && executionMode != ALL_AFTERWARDS) {
ModelContext task0context = contextCopyWithDeltasReplaced(context, changesWithoutApproval);
WfTaskCreationInstruction instruction0 = WfTaskCreationInstruction.createModelOnly(rootWfTask.getChangeProcessor(), task0context);
instruction0.setTaskName("Executing changes that do not require approval");
return wfTaskController.submitWfTask(instruction0, rootWfTask, wfConfigurationType, result);
} else {
return null;
}
}
use of com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction in project midpoint by Evolveum.
the class PrimaryChangeProcessor method submitRootTask.
private WfTask submitRootTask(ModelContext context, ObjectTreeDeltas changesWithoutApproval, Task taskFromModel, ExecutionMode executionMode, WfConfigurationType wfConfigurationType, OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
LensContext lensContextForRootTask = determineLensContextForRootTask(context, changesWithoutApproval, executionMode);
WfTaskCreationInstruction instructionForRoot = baseModelInvocationProcessingHelper.createInstructionForRoot(this, context, taskFromModel, lensContextForRootTask, result);
if (executionMode != ALL_IMMEDIATELY) {
// gather all deltas from child objects
instructionForRoot.setHandlersBeforeModelOperation(WfPrepareRootOperationTaskHandler.HANDLER_URI);
}
return baseModelInvocationProcessingHelper.submitRootTask(instructionForRoot, taskFromModel, wfConfigurationType, result);
}
Aggregations