public OperationExecutorStrategy getOperationExecutorStrategy(final SOperation operation) throws SOperationExecutionException { final String operatorTypeName = getStrategyKey(operation); final OperationExecutorStrategy operationExecutorStrategy = operationStrategies.get(operatorTypeName); if (operationExecutorStrategy == null) { throw new SOperationExecutionException("Unable to find an executor for operation type " + operatorTypeName); } return operationExecutorStrategy; }
public OperationServiceImpl(final OperationExecutorStrategyProvider operationExecutorStrategyProvider, final LeftOperandHandlerProvider leftOperandHandlerProvider, final ExpressionResolverService expressionResolverService, final PersistRightOperandResolver persistRightOperandResolver, final TechnicalLoggerService logger) { super(); this.operationExecutorStrategyProvider = operationExecutorStrategyProvider; this.expressionResolverService = expressionResolverService; this.persistRightOperandResolver = persistRightOperandResolver; this.logger = logger; final List<LeftOperandHandler> leftOperandHandlers = leftOperandHandlerProvider.getLeftOperandHandlers(); leftOperandHandlersMap = new HashMap<>(leftOperandHandlers.size()); for (final LeftOperandHandler leftOperandHandler : leftOperandHandlers) { leftOperandHandlersMap.put(leftOperandHandler.getType(), leftOperandHandler); } }
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; }
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); } } }
protected void updateActivityInstanceVariables(final List<Operation> operations, final Map<String, Serializable> operationsContext, final long activityInstanceId, final Long processDefinitionID) throws SOperationExecutionException { SExpressionContext sExpressionContext = buildExpressionContext(operationsContext, activityInstanceId, processDefinitionID); List<SOperation> sOperations = ServerModelConvertor.convertOperations(operations); getOperationService().execute(sOperations, activityInstanceId, DataInstanceContainer.ACTIVITY_INSTANCE.name(), sExpressionContext); }
public OperationExecutorStrategyProvider(final List<OperationExecutorStrategy> operationExecutors) { operationStrategies = new HashMap<>(operationExecutors.size()); for (final OperationExecutorStrategy operationExecutorStrategy : operationExecutors) { operationStrategies.put(operationExecutorStrategy.getOperationType(), operationExecutorStrategy); } }
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; }
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); } } }
protected void updateActivityInstanceVariables(final List<Operation> operations, final Map<String, Serializable> operationsContext, final long activityInstanceId, final Long processDefinitionID) throws SOperationExecutionException { SExpressionContext sExpressionContext = buildExpressionContext(operationsContext, activityInstanceId, processDefinitionID); List<SOperation> sOperations = ServerModelConvertor.convertOperations(operations); getOperationService().execute(sOperations, activityInstanceId, DataInstanceContainer.ACTIVITY_INSTANCE.name(), sExpressionContext); }
public OperationExecutorStrategy getOperationExecutorStrategy(final SOperation operation) throws SOperationExecutionException { final String operatorTypeName = getStrategyKey(operation); final OperationExecutorStrategy operationExecutorStrategy = operationStrategies.get(operatorTypeName); if (operationExecutorStrategy == null) { throw new SOperationExecutionException("Unable to find an executor for operation type " + operatorTypeName); } return operationExecutorStrategy; }
public OperationServiceImpl(final OperationExecutorStrategyProvider operationExecutorStrategyProvider, final LeftOperandHandlerProvider leftOperandHandlerProvider, final ExpressionResolverService expressionResolverService, final PersistRightOperandResolver persistRightOperandResolver, final TechnicalLoggerService logger) { super(); this.operationExecutorStrategyProvider = operationExecutorStrategyProvider; this.expressionResolverService = expressionResolverService; this.persistRightOperandResolver = persistRightOperandResolver; this.logger = logger; final List<LeftOperandHandler> leftOperandHandlers = leftOperandHandlerProvider.getLeftOperandHandlers(); leftOperandHandlersMap = new HashMap<>(leftOperandHandlers.size()); for (final LeftOperandHandler leftOperandHandler : leftOperandHandlers) { leftOperandHandlersMap.put(leftOperandHandler.getType(), leftOperandHandler); } }
public OperationExecutorStrategyProvider(final List<OperationExecutorStrategy> operationExecutors) { operationStrategies = new HashMap<>(operationExecutors.size()); for (final OperationExecutorStrategy operationExecutorStrategy : operationExecutors) { operationStrategies.put(operationExecutorStrategy.getOperationType(), operationExecutorStrategy); } }
protected void executeOperations(final List<SOperation> operations, final Map<String, Object> context, SExpressionContext expressionContext, final SExpressionContext expressionContextToEvaluateOperations, final SProcessInstance sProcessInstance) throws SBonitaException { if (operations != null && !operations.isEmpty()) { SExpressionContext currentExpressionContext = expressionContextToEvaluateOperations != null ? expressionContextToEvaluateOperations : expressionContext; currentExpressionContext.setInputValues(context); if (currentExpressionContext.getContainerId() == null) { currentExpressionContext.setContainerId(sProcessInstance.getId()); currentExpressionContext.setContainerType(DataInstanceContainer.PROCESS_INSTANCE.name()); } operationService.execute(new ArrayList<>(operations), sProcessInstance.getId(), DataInstanceContainer.PROCESS_INSTANCE.name(), currentExpressionContext); } }
protected void executeOperations(final List<SOperation> operations, final Map<String, Object> context, SExpressionContext expressionContext, final SExpressionContext expressionContextToEvaluateOperations, final SProcessInstance sProcessInstance) throws SBonitaException { if (operations != null && !operations.isEmpty()) { SExpressionContext currentExpressionContext = expressionContextToEvaluateOperations != null ? expressionContextToEvaluateOperations : expressionContext; currentExpressionContext.setInputValues(context); if (currentExpressionContext.getContainerId() == null) { currentExpressionContext.setContainerId(sProcessInstance.getId()); currentExpressionContext.setContainerType(DataInstanceContainer.PROCESS_INSTANCE.name()); } operationService.execute(new ArrayList<>(operations), sProcessInstance.getId(), DataInstanceContainer.PROCESS_INSTANCE.name(), currentExpressionContext); } }
@Override public void executeOutputOperation(final List<SOperation> outputs, final SExpressionContext expressionContext, final ConnectorResult result) throws SConnectorException { final long startTime = System.currentTimeMillis(); try { expressionContext.putAllInputValues(result.getResult()); operationService.execute(outputs, expressionContext.getContainerId(), expressionContext.getContainerType(), expressionContext);// data is in disconnect(result); } catch (final SOperationExecutionException e) { throw new SConnectorException(e); } finally { if (timeTracker.isTrackable(TimeTrackerRecords.EXECUTE_CONNECTOR_OUTPUT_OPERATIONS)) { final long endTime = System.currentTimeMillis(); String desc = "ConnectorResult: " + result; timeTracker.track(TimeTrackerRecords.EXECUTE_CONNECTOR_OUTPUT_OPERATIONS, desc, endTime - startTime); } } }
@Override public void executeOutputOperation(final List<SOperation> outputs, final SExpressionContext expressionContext, final ConnectorResult result) throws SConnectorException { final long startTime = System.currentTimeMillis(); try { expressionContext.putAllInputValues(result.getResult()); operationService.execute(outputs, expressionContext.getContainerId(), expressionContext.getContainerType(), expressionContext);// data is in disconnect(result); } catch (final SOperationExecutionException e) { throw new SConnectorException(e); } finally { if (timeTracker.isTrackable(TimeTrackerRecords.EXECUTE_CONNECTOR_OUTPUT_OPERATIONS)) { final long endTime = System.currentTimeMillis(); String desc = "ConnectorResult: " + result; timeTracker.track(TimeTrackerRecords.EXECUTE_CONNECTOR_OUTPUT_OPERATIONS, desc, endTime - startTime); } } }
private void executeFlowNode(final long flowNodeInstanceId, final OperationsWithContext operations) throws SFlowNodeReadException, SFlowNodeExecutionException { // in same thread because we delete the message instance after triggering the catch event. The data is of the message // is deleted so we will be unable to execute the flow node instance if (operations.getOperations() != null && !operations.getOperations().isEmpty()) { try { operationService.execute(operations.getOperations(), flowNodeInstanceId, DataInstanceContainer.ACTIVITY_INSTANCE.name(), operations.getContext()); } catch (SOperationExecutionException e) { throw new SFlowNodeExecutionException("Unable to execute operation before executing flow node " + flowNodeInstanceId, e); } } containerRegistry.executeFlowNodeInSameThread(flowNodeInstanceId, operations.getContainerType()); }
private void executeFlowNode(final long flowNodeInstanceId, final OperationsWithContext operations) throws SFlowNodeReadException, SFlowNodeExecutionException { // in same thread because we delete the message instance after triggering the catch event. The data is of the message // is deleted so we will be unable to execute the flow node instance if (operations.getOperations() != null && !operations.getOperations().isEmpty()) { try { operationService.execute(operations.getOperations(), flowNodeInstanceId, DataInstanceContainer.ACTIVITY_INSTANCE.name(), operations.getContext()); } catch (SOperationExecutionException e) { throw new SFlowNodeExecutionException("Unable to execute operation before executing flow node " + flowNodeInstanceId, e); } } containerRegistry.executeFlowNodeInSameThread(flowNodeInstanceId, operations.getContainerType()); }
public void executeOperations(final SProcessDefinition processDefinition, final SActivityInstance activityInstance) throws SActivityStateExecutionException { try { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(activityInstance.getFlowNodeDefinitionId()); if (flowNode instanceof SActivityDefinition) { final SActivityDefinition activityDefinition = (SActivityDefinition) flowNode; final List<SOperation> sOperations = activityDefinition.getSOperations(); final SExpressionContext sExpressionContext = new SExpressionContext(activityInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), processDefinition.getId()); operationService.execute(sOperations, sExpressionContext); } } catch (final SOperationExecutionException e) { throw new SActivityStateExecutionException(e); } }
public void executeOperations(final SProcessDefinition processDefinition, final SActivityInstance activityInstance) throws SActivityStateExecutionException { try { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(activityInstance.getFlowNodeDefinitionId()); if (flowNode instanceof SActivityDefinition) { final SActivityDefinition activityDefinition = (SActivityDefinition) flowNode; final List<SOperation> sOperations = activityDefinition.getSOperations(); final SExpressionContext sExpressionContext = new SExpressionContext(activityInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), processDefinition.getId()); operationService.execute(sOperations, sExpressionContext); } } catch (final SOperationExecutionException e) { throw new SActivityStateExecutionException(e); } }