/** * Finds the index of operation of type {@link SLeftOperand#TYPE_BUSINESS_DATA} that references the expression of type * {@link ExpressionType#TYPE_BUSINESS_DATA} with given name directly on the right operand or in transitive dependencies. * * @param businessDataName the expression content * @param fromIndex index of operation from which the analyse must begins * @param operations list of operations @return the index of operation that references the expression with given name and type. */ public int findBusinessDataDependencyIndex(String businessDataName, int fromIndex, final List<SOperation> operations) { if (fromIndex >= operations.size()) { return -1; } for (int i = fromIndex; i < operations.size(); i++) { SOperation operation = operations.get(i); SExpression rightOperand = operation.getRightOperand(); if (matches(businessDataName, operation, rightOperand)) { return i; } } return -1; }
/** * Finds the index of operation of type {@link SLeftOperand#TYPE_BUSINESS_DATA} that references the expression of type * {@link ExpressionType#TYPE_BUSINESS_DATA} with given name directly on the right operand or in transitive dependencies. * * @param businessDataName the expression content * @param fromIndex index of operation from which the analyse must begins * @param operations list of operations @return the index of operation that references the expression with given name and type. */ public int findBusinessDataDependencyIndex(String businessDataName, int fromIndex, final List<SOperation> operations) { if (fromIndex >= operations.size()) { return -1; } for (int i = fromIndex; i < operations.size(); i++) { SOperation operation = operations.get(i); SExpression rightOperand = operation.getRightOperand(); if (matches(businessDataName, operation, rightOperand)) { return i; } } return -1; }
SDataInstance createDataInstance(SProcessInstance processInstance, SExpressionContext expressionContext, List<SOperation> operations, Map<String, Object> context, SExpressionContext expressionContextToEvaluateOperations, SDataDefinition sDataDefinition) throws SExpressionTypeUnknownException, SExpressionEvaluationException, SExpressionDependencyMissingException, SInvalidExpressionException, SDataInstanceNotWellFormedException { SExpression expression; SExpressionContext currentExpressionContext; final SOperation operation; if ((operation = getOperationToSetData(sDataDefinition.getName(), operations)) != null) { expression = operation.getRightOperand(); currentExpressionContext = expressionContextToEvaluateOperations != null ? expressionContextToEvaluateOperations : expressionContext; currentExpressionContext.setInputValues(context); operations.remove(operation); } else { expression = sDataDefinition.getDefaultValueExpression(); currentExpressionContext = expressionContext; } return createDataInstanceObject(processInstance, sDataDefinition, evaluateExpression(sDataDefinition, expression, currentExpressionContext)); }
SDataInstance createDataInstance(SProcessInstance processInstance, SExpressionContext expressionContext, List<SOperation> operations, Map<String, Object> context, SExpressionContext expressionContextToEvaluateOperations, SDataDefinition sDataDefinition) throws SExpressionTypeUnknownException, SExpressionEvaluationException, SExpressionDependencyMissingException, SInvalidExpressionException, SDataInstanceNotWellFormedException { SExpression expression; SExpressionContext currentExpressionContext; final SOperation operation; if ((operation = getOperationToSetData(sDataDefinition.getName(), operations)) != null) { expression = operation.getRightOperand(); currentExpressionContext = expressionContextToEvaluateOperations != null ? expressionContextToEvaluateOperations : expressionContext; currentExpressionContext.setInputValues(context); operations.remove(operation); } else { expression = sDataDefinition.getDefaultValueExpression(); currentExpressionContext = expressionContext; } return createDataInstanceObject(processInstance, sDataDefinition, evaluateExpression(sDataDefinition, expression, currentExpressionContext)); }
@Override public Object computeNewValueForLeftOperand(final SOperation operation, final Object valueToSetObjectWith, final SExpressionContext expressionContext, final boolean shouldPersistValue) throws SOperationExecutionException { final Object objectToInvokeJavaMethodOn; objectToInvokeJavaMethodOn = extractObjectToInvokeFromContext(operation, expressionContext); final String methodName = extractMethodName(operation); final String operatorType = extractParameterType(operation); try { return new JavaMethodInvoker().invokeJavaMethod(operation.getRightOperand().getReturnType(), valueToSetObjectWith, objectToInvokeJavaMethodOn, methodName, operatorType); } catch (final Exception e) { throw new SOperationExecutionException("Unable to evaluate operation " + operation, e); } }
@Override public Object computeNewValueForLeftOperand(final SOperation operation, final Object valueToSetObjectWith, final SExpressionContext expressionContext, final boolean shouldPersistValue) throws SOperationExecutionException { final Object objectToInvokeJavaMethodOn; objectToInvokeJavaMethodOn = extractObjectToInvokeFromContext(operation, expressionContext); final String methodName = extractMethodName(operation); final String operatorType = extractParameterType(operation); try { return new JavaMethodInvoker().invokeJavaMethod(operation.getRightOperand().getReturnType(), valueToSetObjectWith, objectToInvokeJavaMethodOn, methodName, operatorType); } catch (final Exception e) { throw new SOperationExecutionException("Unable to evaluate operation " + operation, e); } }
private LeftOperandUpdateStatus calculateRightOperandValue(final SOperation operation, final SExpressionContext expressionContext, boolean shouldPersistValue) throws SOperationExecutionException { final SLeftOperand leftOperand = operation.getLeftOperand(); final LeftOperandUpdateStatus currentUpdateStatus = new LeftOperandUpdateStatus(operation.getType()); if (currentUpdateStatus.shouldUpdate()) { final OperationExecutorStrategy operationExecutorStrategy = operationExecutorStrategyProvider.getOperationExecutorStrategy(operation); final Object rightOperandValue = evaluateRightOperandExpression(operation, expressionContext, operation.getRightOperand()); shouldPersistValue = persistRightOperandResolver .shouldPersistByValue(rightOperandValue, shouldPersistValue, operationExecutorStrategy.shouldPersistOnNullValue()); final Object value = operationExecutorStrategy.computeNewValueForLeftOperand(operation, rightOperandValue, expressionContext, shouldPersistValue); expressionContext.getInputValues().put(leftOperand.getName(), value); logOperation(TechnicalLogSeverity.DEBUG, operation, rightOperandValue, expressionContext); } return currentUpdateStatus; }
private LeftOperandUpdateStatus calculateRightOperandValue(final SOperation operation, final SExpressionContext expressionContext, boolean shouldPersistValue) throws SOperationExecutionException { final SLeftOperand leftOperand = operation.getLeftOperand(); final LeftOperandUpdateStatus currentUpdateStatus = new LeftOperandUpdateStatus(operation.getType()); if (currentUpdateStatus.shouldUpdate()) { final OperationExecutorStrategy operationExecutorStrategy = operationExecutorStrategyProvider.getOperationExecutorStrategy(operation); final Object rightOperandValue = evaluateRightOperandExpression(operation, expressionContext, operation.getRightOperand()); shouldPersistValue = persistRightOperandResolver .shouldPersistByValue(rightOperandValue, shouldPersistValue, operationExecutorStrategy.shouldPersistOnNullValue()); final Object value = operationExecutorStrategy.computeNewValueForLeftOperand(operation, rightOperandValue, expressionContext, shouldPersistValue); expressionContext.getInputValues().put(leftOperand.getName(), value); logOperation(TechnicalLogSeverity.DEBUG, operation, rightOperandValue, expressionContext); } return currentUpdateStatus; }
public static Operation toOperation(final SOperation operation) { final OperationImpl operationImpl = new OperationImpl(); operationImpl.setRightOperand(toExpression(operation.getRightOperand())); operationImpl.setOperator(operation.getOperator()); operationImpl.setType(toOperatorType(operation.getType())); final LeftOperandImpl leftOperand = new LeftOperandImpl(); final SLeftOperand sLeftOperand = operation.getLeftOperand(); leftOperand.setName(sLeftOperand.getName()); leftOperand.setType(sLeftOperand.getType()); operationImpl.setLeftOperand(leftOperand); return operationImpl; }
public static Operation toOperation(final SOperation operation) { final OperationImpl operationImpl = new OperationImpl(); operationImpl.setRightOperand(toExpression(operation.getRightOperand())); operationImpl.setOperator(operation.getOperator()); operationImpl.setType(toOperatorType(operation.getType())); final LeftOperandImpl leftOperand = new LeftOperandImpl(); final SLeftOperand sLeftOperand = operation.getLeftOperand(); leftOperand.setName(sLeftOperand.getName()); leftOperand.setType(sLeftOperand.getType()); operationImpl.setLeftOperand(leftOperand); return operationImpl; }