use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class TestUserChangeApprovalLegacy method assertWfContextAfterRootTaskFinishes.
protected void assertWfContextAfterRootTaskFinishes(Task rootTask, List<Task> subtasks, OperationResult result, String... processNames) throws Exception {
final Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve());
Task opTask = taskManager.createTaskInstance();
TaskType rootTaskType = modelService.getObject(TaskType.class, rootTask.getOid(), options, opTask, result).asObjectable();
assertTrue("unexpected process instance id in root task", rootTaskType.getWorkflowContext() == null || rootTaskType.getWorkflowContext().getProcessInstanceId() == null);
assertEquals("Wrong # of wf subtasks w.r.t processNames (" + Arrays.asList(processNames) + ")", processNames.length, subtasks.size());
int i = 0;
for (Task subtask : subtasks) {
TaskType subtaskType = modelService.getObject(TaskType.class, subtask.getOid(), options, opTask, result).asObjectable();
display("Subtask #" + (i + 1) + ": ", subtaskType);
assertNull("Unexpected fetch result in wf subtask: " + subtask, subtaskType.getFetchResult());
WfContextType wfc = subtaskType.getWorkflowContext();
assertNotNull("Missing workflow context in wf subtask: " + subtask, wfc);
assertNotNull("No process ID in wf subtask: " + subtask, wfc.getProcessInstanceId());
assertEquals("Wrong process ID name in subtask: " + subtask, processNames[i++], wfc.getProcessInstanceName());
assertNotNull("Missing process start time in subtask: " + subtask, wfc.getStartTimestamp());
assertNotNull("Missing process end time in subtask: " + subtask, wfc.getEndTimestamp());
assertEquals("Wrong outcome", SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE, wfc.getOutcome());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method getDeltasToAdvanceCases.
List<ItemDelta<?, ?>> getDeltasToAdvanceCases(AccessCertificationCampaignType campaign, AccessCertificationStageType stage, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
LOGGER.trace("Advancing reviewers and timestamps for cases in {}", toShortString(campaign));
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaign.getOid(), null, null, result);
List<ItemDelta<?, ?>> rv = new ArrayList<>(caseList.size());
int stageToBe = campaign.getStageNumber() + 1;
List<AccessCertificationResponseType> outcomesToStopOn = computationHelper.getOutcomesToStopOn(campaign);
AccessCertificationReviewerSpecificationType reviewerSpec = reviewersHelper.findReviewersSpecification(campaign, stageToBe, task, result);
for (AccessCertificationCaseType _case : caseList) {
if (!computationHelper.computeEnabled(campaign, _case, outcomesToStopOn)) {
continue;
}
Long caseId = _case.asPrismContainerValue().getId();
assert caseId != null;
List<ObjectReferenceType> reviewers = reviewersHelper.getReviewersForCase(_case, campaign, reviewerSpec, task, result);
List<AccessCertificationWorkItemType> workItems = createWorkItems(reviewers, stageToBe);
_case.getWorkItem().addAll(CloneUtil.cloneCollectionMembers(workItems));
AccessCertificationResponseType currentOutcome = computationHelper.computeOutcomeForStage(_case, campaign, stageToBe);
AccessCertificationResponseType overallOutcome = computationHelper.computeOverallOutcome(_case, campaign, currentOutcome);
rv.addAll(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, caseId, F_WORK_ITEM).add(PrismContainerValue.toPcvList(workItems)).item(F_CASE, caseId, F_CURRENT_STAGE_CREATE_TIMESTAMP).replace(stage.getStartTimestamp()).item(F_CASE, caseId, F_CURRENT_STAGE_DEADLINE).replace(stage.getDeadline()).item(F_CASE, caseId, F_CURRENT_STAGE_OUTCOME).replace(OutcomeUtils.toUri(currentOutcome)).item(F_CASE, caseId, F_OUTCOME).replace(OutcomeUtils.toUri(overallOutcome)).item(F_CASE, caseId, F_STAGE_NUMBER).replace(stageToBe).asItemDeltas());
}
LOGGER.debug("Created {} deltas to advance {} cases for campaign {}", rv.size(), caseList.size(), toShortString(campaign));
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM in project midpoint by Evolveum.
the class ProcessInstanceProvider method augmentTaskObject.
// doesn't throw any exceptions - these are logged and stored into the operation result
public <T extends ObjectType> void augmentTaskObject(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Task opTask, OperationResult parentResult) {
final OperationResult result = parentResult.createSubresult(OPERATION_AUGMENT_TASK_OBJECT);
result.addParam("object", ObjectTypeUtil.toShortString(object));
result.addCollectionOfSerializablesAsParam("options", options);
if (!(object.asObjectable() instanceof TaskType)) {
result.recordNotApplicableIfUnknown();
return;
}
final TaskType taskType = (TaskType) object.asObjectable();
try {
if (taskType.getWorkflowContext() == null) {
return;
}
final String instanceId = taskType.getWorkflowContext().getProcessInstanceId();
if (instanceId == null) {
return;
}
final boolean retrieveWorkItems = SelectorOptions.hasToLoadPath(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM), options);
if (!retrieveWorkItems) {
// We assume that everything (except work items) is already stored in repo.
return;
}
final List<WorkItemType> workItems = workItemProvider.getWorkItemsForProcessInstanceId(instanceId, result);
taskType.getWorkflowContext().getWorkItem().addAll(CloneUtil.cloneCollectionMembers(workItems));
} catch (RuntimeException e) {
result.recordFatalError(e.getMessage(), e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't prepare wf-related information for {}", e, ObjectTypeUtil.toShortString(object));
} finally {
result.computeStatusIfUnknown();
}
if (!result.isSuccess()) {
taskType.setFetchResult(result.createOperationResultType());
}
}
Aggregations