public static String makeNiceFromUri(String outcome) { Boolean value = approvalBooleanValueFromUri(outcome); if (value != null) { return value ? DECISION_APPROVED_NICE : DECISION_REJECTED_NICE; } else { return outcome; } }
public static boolean isApprovedFromUri(String uri) { return isApproved(fromUri(uri)); }
public static Boolean approvalBooleanValueNice(String decision) { return parse(decision, DECISION_APPROVED_NICE, DECISION_REJECTED_NICE); }
public static Boolean approvalBooleanValueFromUri(String uri) { return approvalBooleanValue(fromUri(uri)); }
@NotNull private static Collection<String> getApproverComments(WfContextType wfc, PerformerCommentsFormatter formatter, Task opTask, OperationResult result) { if (wfc == null) { return emptySet(); } return wfc.getEvent().stream() .flatMap(MiscUtil.instancesOf(WorkItemCompletionEventType.class)) .filter(e -> ApprovalUtils.isApproved(e.getOutput()) && e.getInitiatorRef() != null) .map(e -> formatter.formatComment(e, opTask, result)) .filter(Objects::nonNull) .collect(Collectors.toSet()); }
public ChangesByState getChangesByStateForRoot(TaskType rootTask, ModelInteractionService modelInteractionService, PrismContext prismContext, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { ChangesByState rv = new ChangesByState(prismContext); recordChanges(rv, rootTask.getModelOperationContext(), modelInteractionService, task, result); for (TaskType subtask : rootTask.getSubtask()) { recordChanges(rv, subtask.getModelOperationContext(), modelInteractionService, task, result); final WfContextType wfc = subtask.getWorkflowContext(); if (wfc != null && wfc.getProcessInstanceId() != null) { Boolean isApproved = ApprovalUtils.approvalBooleanValueFromUri(wfc.getOutcome()); if (isApproved == null) { if (wfc.getEndTimestamp() == null) { recordChangesWaitingToBeApproved(rv, wfc, prismContext); } else { recordChangesCanceled(rv, wfc, prismContext); } } else if (isApproved) { recordChangesApprovedIfNeeded(rv, subtask, rootTask, prismContext); } else { recordChangesRejected(rv, wfc, prismContext); } } } return rv; }
@Override public void completeWorkItem(String taskId, boolean decision, String comment, ObjectDelta additionalDelta, WorkItemEventCauseInformationType causeInformation, OperationResult parentResult) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { workItemManager.completeWorkItem(taskId, ApprovalUtils.toUri(decision), comment, additionalDelta, causeInformation, parentResult); }
public static boolean isApproved(AbstractWorkItemOutputType result) { return BooleanUtils.isTrue(approvalBooleanValue(result)); }
private static WorkflowResult fromWfAnswer(String answer) { if (answer == null) { return UNKNOWN; } else { Boolean booleanValue = ApprovalUtils.approvalBooleanValueNice(answer); if (booleanValue == null) { return OTHER; } else if (booleanValue) { return APPROVED; } else { return REJECTED; } } }
public String getAnswerNice() { return ApprovalUtils.makeNiceFromUri(getOutcome()); }
public static S_FilterExit filterForGroups(S_FilterEntryOrEmpty q, String userOid, RepositoryService repositoryService, RelationRegistry relationRegistry, OperationResult result) throws SchemaException { return q.item(WorkItemType.F_CANDIDATE_REF).ref(getGroupsForUser(userOid, repositoryService, relationRegistry, result)); }
/** * Prepares deltaOut from deltaIn, based on process instance variables. * (Default implementation of the method from PrimaryChangeAspect.) * * In the default case, mapping deltaIn -> deltaOut is extremely simple. * DeltaIn contains a delta that has to be approved. Workflow answers simply yes/no. * Therefore, we either copy DeltaIn to DeltaOut, or generate an empty list of modifications. */ public ObjectTreeDeltas prepareDeltaOut(ProcessEvent event, PcpWfTask pcpJob, OperationResult result) throws SchemaException { ObjectTreeDeltas deltaIn = pcpJob.retrieveDeltasToProcess(); if (ApprovalUtils.isApprovedFromUri(event.getOutcome())) { return deltaIn; } else { return null; } }
/** * Augments work item query by including filter to see only work items assigned to the current user or any of his delegators, * providing that the limitation(s) allow it. * * Note that work item limitations are supported only in the current (crude) form: all or none. */ public static S_AtomicFilterExit filterForAssignees(S_FilterEntryOrEmpty q, MidPointPrincipal principal, QName limitationItemName, RelationRegistry relationRegistry) { if (principal == null) { return q.none(); } else { return q.item(WorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssigneesForUser(principal, limitationItemName, relationRegistry)); } }
protected void recordChangesWaitingToBeApproved(ChangesByState rv, WfContextType wfc, PrismContext prismContext) throws SchemaException { if (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType) { WfPrimaryChangeProcessorStateType ps = (WfPrimaryChangeProcessorStateType) wfc.getProcessorSpecificState(); rv.getWaitingToBeApproved().merge(fromObjectTreeDeltasType(ps.getDeltasToProcess(), prismContext)); } }
protected void recordChangesCanceled(ChangesByState rv, WfContextType wfc, PrismContext prismContext) throws SchemaException { if (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType) { WfPrimaryChangeProcessorStateType ps = (WfPrimaryChangeProcessorStateType) wfc.getProcessorSpecificState(); rv.getCanceled().merge(fromObjectTreeDeltasType(ps.getDeltasToProcess(), prismContext)); } }
private void recordChangesRejected(ChangesByState rv, WfContextType wfc, PrismContext prismContext) throws SchemaException { if (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType) { WfPrimaryChangeProcessorStateType ps = (WfPrimaryChangeProcessorStateType) wfc.getProcessorSpecificState(); if (ObjectTreeDeltas.isEmpty(ps.getResultingDeltas())) { rv.getRejected().merge(fromObjectTreeDeltasType(ps.getDeltasToProcess(), prismContext)); } else { // it's actually hard to decide what to display as 'rejected' - because the delta was partly approved // however, this situation will not currently occur } } }
public static Boolean approvalBooleanValue(AbstractWorkItemOutputType result) { return result != null ? approvalBooleanValue(fromUri(result.getOutcome())) : null; }
@SuppressWarnings("unused") private void notUsed() { ApprovalUtils.approvalBooleanValueFromUri(""); }
private Function<Object, Object> createOutcomeConvertor() { return (o) -> { if (o == null || o instanceof String) { return o; } else if (o instanceof ApprovalLevelOutcomeType) { return ApprovalUtils.toUri((ApprovalLevelOutcomeType) o); } else if (o instanceof QName) { return QNameUtil.qNameToUri((QName) o); } else { //throw new IllegalArgumentException("Couldn't create an URI from " + o); return o; // let someone else complain about this } }; } }
private static boolean isApproved(WorkItemOutcomeType outcome) { return BooleanUtils.isTrue(approvalBooleanValue(outcome)); }