@Override public void loadLeftOperandInContext(final List<SLeftOperand> sLeftOperand,final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SBonitaReadException { for (SLeftOperand leftOperand : sLeftOperand) { loadLeftOperandInContext(leftOperand, leftOperandContainerId, leftOperandContainerType, expressionContext); } }
protected Object computeJavaOperation(final SOperation operation, final Object valueToSetObjectWith, final SExpressionContext expressionContext, final boolean shouldPersistValue) throws SOperationExecutionException { return super.computeNewValueForLeftOperand(operation, valueToSetObjectWith, expressionContext, shouldPersistValue); }
@Override public void execute(final List<SOperation> operations, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { if (operations.isEmpty()) { return; } // retrieve all left operand to set and put it in context retrieveLeftOperandsAndPutItInExpressionContextIfNotIn(operations, leftOperandContainerId, leftOperandContainerType, expressionContext); // execute operation and put it in context again final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandUpdates = executeOperators(operations, expressionContext); // update data updateLeftOperands(leftOperandUpdates, leftOperandContainerId, leftOperandContainerType, expressionContext); }
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; }
Map<SLeftOperand, LeftOperandUpdateStatus> executeOperators(final List<SOperation> operations, final SExpressionContext expressionContext) throws SOperationExecutionException { final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandsToUpdate = new HashMap<>(); for (int i = 0; i < operations.size(); i++) { final SOperation currentOperation = operations.get(i); final boolean shouldPersistValue = persistRightOperandResolver.shouldPersistByPosition(i, operations); final LeftOperandUpdateStatus currentUpdateStatus = calculateRightOperandValue(currentOperation, expressionContext, shouldPersistValue); if (shouldUpdateLeftOperandContext(leftOperandsToUpdate, currentOperation.getLeftOperand(), currentUpdateStatus)) { leftOperandsToUpdate.put(currentOperation.getLeftOperand(), currentUpdateStatus); } } return leftOperandsToUpdate; }
void updateLeftOperands(final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandUpdates, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { for (final Entry<SLeftOperand, LeftOperandUpdateStatus> update : leftOperandUpdates.entrySet()) { final SLeftOperand leftOperand = update.getKey(); final LeftOperandHandler leftOperandHandler = getLeftOperandHandler(leftOperand.getType()); if (update.getValue().shouldUpdate()) { leftOperandHandler.update(leftOperand, expressionContext.getInputValues(), expressionContext.getInputValues().get(leftOperand.getName()), leftOperandContainerId, leftOperandContainerType); } else { leftOperandHandler.delete(leftOperand, leftOperandContainerId, leftOperandContainerType); } } }
@Override public void execute(final SOperation operation, final long containerId, final String containerType, final SExpressionContext expressionContext) throws SOperationExecutionException { execute(Arrays.asList(operation), containerId, containerType, expressionContext); }
boolean shouldUpdateLeftOperandContext(final Map<SLeftOperand, LeftOperandUpdateStatus> updateLeftOperands, final SLeftOperand leftOperand, final LeftOperandUpdateStatus currentUpdateStatus) { final LeftOperandUpdateStatus previousStatus = updateLeftOperands.get(leftOperand); return previousStatus == null || !previousStatus.shouldDelete() && currentUpdateStatus.shouldDelete(); }
private void logOperation(final TechnicalLogSeverity severity, final SOperation operation, final Object operationValue, final SExpressionContext expressionContext) { if (logger.isLoggable(this.getClass(), severity)) { final String message = buildLogMessage(operation, operationValue, expressionContext); logger.log(this.getClass(), severity, message); } }
@Override public Object computeNewValueForLeftOperand(final SOperation operation, final Object value, final SExpressionContext expressionContext, final boolean shouldPersistValue) throws SOperationExecutionException { // do not check if value is external, see ENGINE-1739 if (operation.getLeftOperand().getType().equals(SLeftOperand.TYPE_DATA)) { checkReturnType(value, operation, expressionContext); } // no processing on the value, just return it return value; }
@Override public void execute(final List<SOperation> operations, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { if (operations.isEmpty()) { return; } // retrieve all left operand to set and put it in context retrieveLeftOperandsAndPutItInExpressionContextIfNotIn(operations, leftOperandContainerId, leftOperandContainerType, expressionContext); // execute operation and put it in context again final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandUpdates = executeOperators(operations, expressionContext); // update data updateLeftOperands(leftOperandUpdates, leftOperandContainerId, leftOperandContainerType, expressionContext); }
Map<SLeftOperand, LeftOperandUpdateStatus> executeOperators(final List<SOperation> operations, final SExpressionContext expressionContext) throws SOperationExecutionException { final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandsToUpdate = new HashMap<>(); for (int i = 0; i < operations.size(); i++) { final SOperation currentOperation = operations.get(i); final boolean shouldPersistValue = persistRightOperandResolver.shouldPersistByPosition(i, operations); final LeftOperandUpdateStatus currentUpdateStatus = calculateRightOperandValue(currentOperation, expressionContext, shouldPersistValue); if (shouldUpdateLeftOperandContext(leftOperandsToUpdate, currentOperation.getLeftOperand(), currentUpdateStatus)) { leftOperandsToUpdate.put(currentOperation.getLeftOperand(), currentUpdateStatus); } } return leftOperandsToUpdate; }
void updateLeftOperands(final Map<SLeftOperand, LeftOperandUpdateStatus> leftOperandUpdates, final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SOperationExecutionException { for (final Entry<SLeftOperand, LeftOperandUpdateStatus> update : leftOperandUpdates.entrySet()) { final SLeftOperand leftOperand = update.getKey(); final LeftOperandHandler leftOperandHandler = getLeftOperandHandler(leftOperand.getType()); if (update.getValue().shouldUpdate()) { leftOperandHandler.update(leftOperand, expressionContext.getInputValues(), expressionContext.getInputValues().get(leftOperand.getName()), leftOperandContainerId, leftOperandContainerType); } else { leftOperandHandler.delete(leftOperand, leftOperandContainerId, leftOperandContainerType); } } }
@Override public void execute(final SOperation operation, final long containerId, final String containerType, final SExpressionContext expressionContext) throws SOperationExecutionException { execute(Arrays.asList(operation), containerId, containerType, expressionContext); }
@Override public void loadLeftOperandInContext(final List<SLeftOperand> sLeftOperand,final long leftOperandContainerId, final String leftOperandContainerType, final SExpressionContext expressionContext) throws SBonitaReadException { for (SLeftOperand leftOperand : sLeftOperand) { loadLeftOperandInContext(leftOperand, leftOperandContainerId, leftOperandContainerType, expressionContext); } }
protected Object computeJavaOperation(final SOperation operation, final Object valueToSetObjectWith, final SExpressionContext expressionContext, final boolean shouldPersistValue) throws SOperationExecutionException { return super.computeNewValueForLeftOperand(operation, valueToSetObjectWith, expressionContext, shouldPersistValue); }
boolean shouldUpdateLeftOperandContext(final Map<SLeftOperand, LeftOperandUpdateStatus> updateLeftOperands, final SLeftOperand leftOperand, final LeftOperandUpdateStatus currentUpdateStatus) { final LeftOperandUpdateStatus previousStatus = updateLeftOperands.get(leftOperand); return previousStatus == null || !previousStatus.shouldDelete() && currentUpdateStatus.shouldDelete(); }
private void logOperation(final TechnicalLogSeverity severity, final SOperation operation, final Object operationValue, final SExpressionContext expressionContext) { if (logger.isLoggable(this.getClass(), severity)) { final String message = buildLogMessage(operation, operationValue, expressionContext); logger.log(this.getClass(), severity, message); } }
@Override public void execute(final List<SOperation> operations, final SExpressionContext expressionContext) throws SOperationExecutionException { execute(operations, expressionContext.getContainerId(), expressionContext.getContainerType(), expressionContext); }
@Override public void execute(final List<SOperation> operations, final SExpressionContext expressionContext) throws SOperationExecutionException { execute(operations, expressionContext.getContainerId(), expressionContext.getContainerType(), expressionContext); }