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; }
private String buildLogMessage(final SOperation operation, final Object operationValue, final SExpressionContext expressionContext) { String stb = "Executed operation on container [id: '" + expressionContext.getContainerId() + "', type: '" + expressionContext.getContainerType() + "']. Operation: [left operand: '" + operation.getLeftOperand().getName() + "', operator: '" + operation.getOperator() + "', operation value: '" + operationValue + "']"; return stb; }
/** * 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; }
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; }
private boolean isBusinessData(final SOperation operation) { return SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()); }
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; }
protected String extractParameterType(final SOperation operation) { final String[] split = operation.getOperator().split(":", 2); if (split.length > 1) { return split[1]; } return null; }
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; }
private boolean isBusinessData(final SOperation operation) { return SLeftOperand.TYPE_BUSINESS_DATA.equals(operation.getLeftOperand().getType()); }
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; }
protected String extractParameterType(final SOperation operation) { final String[] split = operation.getOperator().split(":", 2); if (split.length > 1) { return split[1]; } return null; }
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; }
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; }
private String buildLogMessage(final SOperation operation, final Object operationValue, final SExpressionContext expressionContext) { String stb = "Executed operation on container [id: '" + expressionContext.getContainerId() + "', type: '" + expressionContext.getContainerType() + "']. Operation: [left operand: '" + operation.getLeftOperand().getName() + "', operator: '" + operation.getOperator() + "', operation value: '" + operationValue + "']"; return stb; }
/** * 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; }
protected String extractMethodName(final SOperation operation) { final String[] split = operation.getOperator().split(":", 2); return split[0]; }
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; }
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; }
final boolean shouldPersistValue) throws SOperationExecutionException { try { final String dataInstanceName = operation.getLeftOperand().getName(); final Document document = builder.parse(new InputSource(new StringReader(dataValue))); final XPath xpath = XPathFactory.newInstance().newXPath(); final String xpathExpression = operation.getOperator(); final Node node = (Node) xpath.compile(xpathExpression).evaluate(document, XPathConstants.NODE); if (isSetAttribute(xpathExpression, variableValue)) {
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)); }