public String evaluateAutoCompleteExpression(ApprovalStageDefinitionType stageDef, ExpressionVariables variables, Task opTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { List<String> outcomes = evaluationHelper.evaluateExpression(stageDef.getAutomaticallyCompleted(), variables, "automatic completion expression", String.class, DOMUtil.XSD_STRING, false, createOutcomeConvertor(), opTask, result); LOGGER.trace("Pre-completed = {} for stage {}", outcomes, stageDef); Set<String> distinctOutcomes = new HashSet<>(outcomes); if (distinctOutcomes.isEmpty()) { return null; } else if (distinctOutcomes.size() == 1) { return distinctOutcomes.iterator().next(); } else { throw new IllegalStateException("Ambiguous result from 'automatically completed' expression: " + distinctOutcomes); } }
@Override public boolean checkEmpty(PcpChildWfTaskCreationInstruction instruction, WfStageComputeHelper stageComputeHelper, ModelInvocationContext ctx, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { List<ApprovalStageDefinitionType> stages = WfContextUtil.getStages(approvalSchemaType); // first pass: if there is any stage that is obviously not skippable, let's return false without checking the expressions for (ApprovalStageDefinitionType stage : stages) { if (stage.getAutomaticallyCompleted() == null) { return false; } } // second pass: check the conditions for (ApprovalStageDefinitionType stage : stages) { if (!SchemaConstants.MODEL_APPROVAL_OUTCOME_SKIP.equals( evaluateAutoCompleteExpression(stage, instruction, stageComputeHelper, ctx, result))) { return false; } } return true; }
if (rv.predeterminedOutcome == null && stageDef.getAutomaticallyCompleted() != null) { try { if (expressionVariables == null) {