private boolean isBusinessData(final SOperation operation) { return SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()); }
private boolean isBusinessData(final SOperation operation) { return SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()); }
@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 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; }
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); } } }
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); } } }
private boolean matches(final String businessDataName, final SOperation operation, final SExpression expression) { if (expression == null) { return false; } boolean matches = SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()) && businessDataName.equals(expression.getContent()) && ExpressionType.TYPE_BUSINESS_DATA.name().equals(expression.getExpressionType()); if (!matches && expression.hasDependencies()) { Iterator<SExpression> iterator = expression.getDependencies().iterator(); while (iterator.hasNext() && !matches) { matches = matches(businessDataName, operation, iterator.next()); } } return matches; }
private boolean matches(final String businessDataName, final SOperation operation, final SExpression expression) { if (expression == null) { return false; } boolean matches = SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()) && businessDataName.equals(expression.getContent()) && ExpressionType.TYPE_BUSINESS_DATA.name().equals(expression.getExpressionType()); if (!matches && expression.hasDependencies()) { Iterator<SExpression> iterator = expression.getDependencies().iterator(); while (iterator.hasNext() && !matches) { matches = matches(businessDataName, operation, iterator.next()); } } return matches; }
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); } } }
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); } } }
/** * Check if the right operand should be persisted based on its position (it's the last operation for the given left operand) * @param currentIndex the index of current operation * @param operations the list of all operations * @return true if the right operand should be persisted; false otherwise */ public boolean shouldPersistByPosition(int currentIndex, List<SOperation> operations) { SOperation currentOperation = operations.get(currentIndex); if (!SLeftOperand.TYPE_BUSINESS_DATA.equals(currentOperation.getLeftOperand().getType())) { return false; } LeftOperandIndexes leftOperandIndexes = operationsAnalyzer.calculateIndexes(currentIndex, operations); if (currentIndex == leftOperandIndexes.getLastIndex()) { return true; } //get the index of next operation that will use the current left operand as dependency to set another business data int dependencyIndex = operationsAnalyzer.findBusinessDataDependencyIndex(currentOperation.getLeftOperand().getName(), currentIndex + 1, operations); return dependencyIndex != -1 && dependencyIndex < leftOperandIndexes.getNextIndex(); }
/** * Check if the right operand should be persisted based on its position (it's the last operation for the given left operand) * @param currentIndex the index of current operation * @param operations the list of all operations * @return true if the right operand should be persisted; false otherwise */ public boolean shouldPersistByPosition(int currentIndex, List<SOperation> operations) { SOperation currentOperation = operations.get(currentIndex); if (!SLeftOperand.TYPE_BUSINESS_DATA.equals(currentOperation.getLeftOperand().getType())) { return false; } LeftOperandIndexes leftOperandIndexes = operationsAnalyzer.calculateIndexes(currentIndex, operations); if (currentIndex == leftOperandIndexes.getLastIndex()) { return true; } //get the index of next operation that will use the current left operand as dependency to set another business data int dependencyIndex = operationsAnalyzer.findBusinessDataDependencyIndex(currentOperation.getLeftOperand().getName(), currentIndex + 1, operations); return dependencyIndex != -1 && dependencyIndex < leftOperandIndexes.getNextIndex(); }
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; }