protected String getStrategyKey(final SOperation operation) { String key = operation.getType().name(); String leftOperandType = operation.getLeftOperand().getType(); if (leftOperandType.equals(SLeftOperand.TYPE_BUSINESS_DATA) && key.equals(SOperatorType.ASSIGNMENT.name())) { key += "_" + leftOperandType; } return key; }
SOperation getOperationToSetData(final String dataName, final List<SOperation> operations) { SOperation dataOperation = null; final Iterator<SOperation> iterator = operations.iterator(); boolean found = false; while (iterator.hasNext() && !found) { final SOperation operation = iterator.next(); if (SOperatorType.ASSIGNMENT.equals(operation.getType()) && SLeftOperand.TYPE_DATA.equals(operation.getLeftOperand().getType()) && dataName.equals(operation.getLeftOperand().getName())) { found = true; dataOperation = operation; } } return dataOperation; }
SOperation getOperationToSetData(final String dataName, final List<SOperation> operations) { SOperation dataOperation = null; final Iterator<SOperation> iterator = operations.iterator(); boolean found = false; while (iterator.hasNext() && !found) { final SOperation operation = iterator.next(); if (SOperatorType.ASSIGNMENT.equals(operation.getType()) && SLeftOperand.TYPE_DATA.equals(operation.getLeftOperand().getType()) && dataName.equals(operation.getLeftOperand().getName())) { found = true; dataOperation = operation; } } return dataOperation; }
protected String getStrategyKey(final SOperation operation) { String key = operation.getType().name(); String leftOperandType = operation.getLeftOperand().getType(); if (leftOperandType.equals(SLeftOperand.TYPE_BUSINESS_DATA) && key.equals(SOperatorType.ASSIGNMENT.name())) { key += "_" + leftOperandType; } return key; }
void retrieveLeftOperandsAndPutItInExpressionContextIfNotIn(final List<SOperation> operations, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { //if the container where we execute the operation is not the same than the container of the expression (call activity data mapping) we skip the loading of left operand final String containerType = expressionContext.getContainerType(); final Long containerId = expressionContext.getContainerId(); if (containerId == null || containerType == null) { return; } final HashMap<String, List<SLeftOperand>> leftOperandHashMap = new HashMap<>(); for (final SOperation operation : operations) { if (!operation.getType().equals(SOperatorType.ASSIGNMENT)) { // this operation will set a data, we retrieve it and put it in context final SLeftOperand leftOperand = operation.getLeftOperand(); if (!leftOperandHashMap.containsKey(leftOperand.getType())) { leftOperandHashMap.put(leftOperand.getType(), new ArrayList<>()); } leftOperandHashMap.get(leftOperand.getType()).add(leftOperand); } } for (final Entry<String, List<SLeftOperand>> leftOperandByType : leftOperandHashMap.entrySet()) { try { getLeftOperandHandler(leftOperandByType.getKey()) .loadLeftOperandInContext(leftOperandByType.getValue(), leftOperandContainerId, leftOperandContainerType, expressionContext); } catch (final SBonitaReadException e) { throw new SOperationExecutionException("Unable to retrieve value for operation " + leftOperandByType.getValue(), e); } } }
void retrieveLeftOperandsAndPutItInExpressionContextIfNotIn(final List<SOperation> operations, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { //if the container where we execute the operation is not the same than the container of the expression (call activity data mapping) we skip the loading of left operand final String containerType = expressionContext.getContainerType(); final Long containerId = expressionContext.getContainerId(); if (containerId == null || containerType == null) { return; } final HashMap<String, List<SLeftOperand>> leftOperandHashMap = new HashMap<>(); for (final SOperation operation : operations) { if (!operation.getType().equals(SOperatorType.ASSIGNMENT)) { // this operation will set a data, we retrieve it and put it in context final SLeftOperand leftOperand = operation.getLeftOperand(); if (!leftOperandHashMap.containsKey(leftOperand.getType())) { leftOperandHashMap.put(leftOperand.getType(), new ArrayList<>()); } leftOperandHashMap.get(leftOperand.getType()).add(leftOperand); } } for (final Entry<String, List<SLeftOperand>> leftOperandByType : leftOperandHashMap.entrySet()) { try { getLeftOperandHandler(leftOperandByType.getKey()) .loadLeftOperandInContext(leftOperandByType.getValue(), leftOperandContainerId, leftOperandContainerType, expressionContext); } catch (final SBonitaReadException e) { throw new SOperationExecutionException("Unable to retrieve value for operation " + leftOperandByType.getValue(), 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; }