use of com.evolveum.midpoint.wf.impl.processors.ModelInvocationContext in project midpoint by Evolveum.
the class ApprovalSchemaExecutionInformationHelper method getApprovalSchemaPreview.
List<ApprovalSchemaExecutionInformationType> getApprovalSchemaPreview(ModelContext<?> modelContext, Task opTask, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
WfConfigurationType wfConfiguration = configurationHelper.getWorkflowConfiguration(modelContext, result);
ModelInvocationContext<?> ctx = new ModelInvocationContext<>(modelContext, wfConfiguration, prismContext, repositoryService, opTask);
List<PcpStartInstruction> taskInstructions = primaryChangeProcessor.previewModelInvocation(ctx, result);
List<ApprovalSchemaExecutionInformationType> rv = new ArrayList<>();
for (PcpStartInstruction taskInstruction : taskInstructions) {
OperationResult childResult = result.createMinorSubresult(ApprovalSchemaExecutionInformationHelper.class + ".getApprovalSchemaPreview");
try {
CaseType aCase = taskInstruction.getCase();
rv.add(getApprovalSchemaExecutionInformation(aCase, true, opTask, childResult));
childResult.computeStatus();
} catch (Throwable t) {
childResult.recordFatalError("Couldn't preview approval schema for " + taskInstruction, t);
}
}
return rv;
}
use of com.evolveum.midpoint.wf.impl.processors.ModelInvocationContext in project midpoint by Evolveum.
the class WfHook method processModelInvocation.
private HookOperationMode processModelInvocation(@NotNull ModelContext<? extends ObjectType> modelContext, WfConfigurationType wfConfigurationType, @NotNull Task opTask, @NotNull OperationResult result) {
try {
modelContext.reportProgress(new ProgressInformation(WORKFLOWS, ENTERING));
ModelInvocationContext<?> ctx = new ModelInvocationContext<>(modelContext, wfConfigurationType, prismContext, repositoryService, opTask);
for (ChangeProcessor changeProcessor : wfConfiguration.getChangeProcessors()) {
LOGGER.trace("Trying change processor: {}", changeProcessor.getClass().getName());
try {
HookOperationMode hookOperationMode = changeProcessor.processModelInvocation(ctx, result);
if (hookOperationMode != null) {
return hookOperationMode;
}
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Exception while running change processor {}: {}", e, changeProcessor.getClass().getName(), e.getMessage());
result.recordFatalError("Exception while running change processor " + changeProcessor.getClass().getSimpleName() + ": " + e.getMessage(), e);
return HookOperationMode.ERROR;
}
}
} finally {
if (result.isInProgress()) {
// a bit of hack: IN_PROGRESS for workflows actually means "success"
OperationResult r = result.clone();
r.recordSuccess();
modelContext.reportProgress(new ProgressInformation(WORKFLOWS, r));
} else {
modelContext.reportProgress(new ProgressInformation(WORKFLOWS, result));
}
}
LOGGER.trace("No change processor caught this request, returning the FOREGROUND flag.");
return HookOperationMode.FOREGROUND;
}
Aggregations