@Override public Object update(final SLeftOperand sLeftOperand, Map<String, Object> inputValues, final Object newValue, final long containerId, final String containerType) throws SOperationExecutionException { try { return entitiesActionsExecutor.executeAction(newValue, new BusinessDataContext(sLeftOperand.getName(), new Container(containerId, containerType)), updateDataRefAction); } catch (SEntityActionExecutionException e) { throw new SOperationExecutionException(e); } }
private SRefBusinessDataInstance getRefBusinessDataInFlowNode(BusinessDataContext context) throws SBonitaReadException { try { return refBusinessDataService.getFlowNodeRefBusinessDataInstance(context.getName(), context.getContainer().getId()); } catch (final SRefBusinessDataInstanceNotFoundException sbe) { try { return refBusinessDataService.getSAFlowNodeRefBusinessDataInstance(context.getName(), context.getContainer().getId()); } catch (SRefBusinessDataInstanceNotFoundException e) { return null; } } }
private boolean isProcessContext(BusinessDataContext context) { return DataInstanceContainer.PROCESS_INSTANCE.name().equals(context.getContainer().getType()); }
@Override public Object update(final SLeftOperand sLeftOperand, Map<String, Object> inputValues, final Object newValue, final long containerId, final String containerType) throws SOperationExecutionException { try { return entitiesActionsExecutor.executeAction(newValue, new BusinessDataContext(sLeftOperand.getName(), new Container(containerId, containerType)), updateDataRefAction); } catch (SEntityActionExecutionException e) { throw new SOperationExecutionException(e); } }
private SRefBusinessDataInstance getRefBusinessDataUsingProcessContext(BusinessDataContext context) throws SBonitaReadException, SRefBusinessDataInstanceNotFoundException, SProcessInstanceReadException, SProcessInstanceNotFoundException, SFlowNodeReadException, SFlowNodeNotFoundException { return getRefBusinessDataInProcess(context, getProcessInstanceIdThatCanContainBusinessData(context.getContainer().getId())); }
private boolean isProcessContext(BusinessDataContext context) { return DataInstanceContainer.PROCESS_INSTANCE.name().equals(context.getContainer().getType()); }
@Override public void delete(final SLeftOperand sLeftOperand, final long containerId, final String containerType) throws SOperationExecutionException { try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext(sLeftOperand .getName(), new Container(containerId, containerType))); removeBusinessData(refBusinessDataInstance); dereferenceBusinessData(refBusinessDataInstance); } catch (final Exception e) { throw new SOperationExecutionException(e); } }
private SRefBusinessDataInstance getRefBusinessDataUsingProcessContext(BusinessDataContext context) throws SBonitaReadException, SRefBusinessDataInstanceNotFoundException, SProcessInstanceReadException, SProcessInstanceNotFoundException, SFlowNodeReadException, SFlowNodeNotFoundException { return getRefBusinessDataInProcess(context, getProcessInstanceIdThatCanContainBusinessData(context.getContainer().getId())); }
@Override public void delete(final SLeftOperand sLeftOperand, final long containerId, final String containerType) throws SOperationExecutionException { try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext(sLeftOperand .getName(), new Container(containerId, containerType))); removeBusinessData(refBusinessDataInstance); dereferenceBusinessData(refBusinessDataInstance); } catch (final Exception e) { throw new SOperationExecutionException(e); } }
private SRefBusinessDataInstance getRefBusinessDataInFlowNode(BusinessDataContext context) throws SBonitaReadException { try { return refBusinessDataService.getFlowNodeRefBusinessDataInstance(context.getName(), context.getContainer().getId()); } catch (final SRefBusinessDataInstanceNotFoundException sbe) { try { return refBusinessDataService.getSAFlowNodeRefBusinessDataInstance(context.getName(), context.getContainer().getId()); } catch (SRefBusinessDataInstanceNotFoundException e) { return null; } } }
@SuppressWarnings("unchecked") protected Object getBusinessData(final String businessDataName, final long containerId, final String containerType) throws SBonitaReadException { try { final SRefBusinessDataInstance reference = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext(businessDataName, new Container(containerId, containerType))); final Class<Entity> dataClass = (Class<Entity>) Thread.currentThread().getContextClassLoader().loadClass(reference.getDataClassName()); if (reference instanceof SSimpleRefBusinessDataInstance) { final SSimpleRefBusinessDataInstance simpleRef = (SSimpleRefBusinessDataInstance) reference; final Long dataId = simpleRef.getDataId(); if (dataId != null) { return businessDataRepository.findById(dataClass, dataId); } return dataClass.newInstance(); } final SMultiRefBusinessDataInstance multiRef = (SMultiRefBusinessDataInstance) reference; final List<Long> dataIds = multiRef.getDataIds(); if (!dataIds.isEmpty()) { return businessDataRepository.findByIds(dataClass, dataIds); } return new ArrayList<Entity>(); } catch (final Exception e) { throw new SBonitaReadException(e); } }
private long getProcessInstanceIdFromFlowNode(BusinessDataContext context) throws SFlowNodeReadException, SBonitaReadException, SProcessInstanceReadException { try { SFlowNodeInstance flowNodeInstance = flowNodeInstanceService.getFlowNodeInstance(context.getContainer().getId()); SProcessInstance processInstance = processInstanceService.getProcessInstance(flowNodeInstance.getParentProcessInstanceId()); if (isSubProcess(processInstance)) { return getParentOfSubProcess(processInstance); } return flowNodeInstance.getParentProcessInstanceId(); } catch (SFlowNodeNotFoundException | SProcessInstanceNotFoundException e) { SAFlowNodeInstance lastArchivedFlowNodeInstance = flowNodeInstanceService .getLastArchivedFlowNodeInstance(SAFlowNodeInstance.class, context.getContainer().getId()); //No caller type in archived process instance, get archive business data not supported from event subprocess return lastArchivedFlowNodeInstance.getParentProcessInstanceId(); } }
@SuppressWarnings("unchecked") protected Object getBusinessData(final String businessDataName, final long containerId, final String containerType) throws SBonitaReadException { try { final SRefBusinessDataInstance reference = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext(businessDataName, new Container(containerId, containerType))); final Class<Entity> dataClass = (Class<Entity>) Thread.currentThread().getContextClassLoader().loadClass(reference.getDataClassName()); if (reference instanceof SSimpleRefBusinessDataInstance) { final SSimpleRefBusinessDataInstance simpleRef = (SSimpleRefBusinessDataInstance) reference; final Long dataId = simpleRef.getDataId(); if (dataId != null) { return businessDataRepository.findById(dataClass, dataId); } return dataClass.newInstance(); } final SMultiRefBusinessDataInstance multiRef = (SMultiRefBusinessDataInstance) reference; final List<Long> dataIds = multiRef.getDataIds(); if (!dataIds.isEmpty()) { return businessDataRepository.findByIds(dataClass, dataIds); } return new ArrayList<Entity>(); } catch (final Exception e) { throw new SBonitaReadException(e); } }
private long getProcessInstanceIdFromFlowNode(BusinessDataContext context) throws SFlowNodeReadException, SBonitaReadException, SProcessInstanceReadException { try { SFlowNodeInstance flowNodeInstance = flowNodeInstanceService.getFlowNodeInstance(context.getContainer().getId()); SProcessInstance processInstance = processInstanceService.getProcessInstance(flowNodeInstance.getParentProcessInstanceId()); if (isSubProcess(processInstance)) { return getParentOfSubProcess(processInstance); } return flowNodeInstance.getParentProcessInstanceId(); } catch (SFlowNodeNotFoundException | SProcessInstanceNotFoundException e) { SAFlowNodeInstance lastArchivedFlowNodeInstance = flowNodeInstanceService .getLastArchivedFlowNodeInstance(SAFlowNodeInstance.class, context.getContainer().getId()); //No caller type in archived process instance, get archive business data not supported from event subprocess return lastArchivedFlowNodeInstance.getParentProcessInstanceId(); } }
@Override public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions, final ContainerState containerState) throws SExpressionEvaluationException { final String businessDataName = expression.getContent(); if (context.containsKey(businessDataName)) { return context.get(businessDataName); } final Long containerId = (Long) context.get(SExpressionContext.CONTAINER_ID_KEY); final String containerType = (String) context.get(SExpressionContext.CONTAINER_TYPE_KEY); try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext( businessDataName, new Container(containerId, containerType))); return businessDataRetriever.getBusinessData(refBusinessDataInstance); } catch (final SBonitaReadException | SFlowNodeReadException e) { throw new SExpressionEvaluationException("Unable to retrieve business data instance with name " + businessDataName, e, businessDataName); } catch (final SBonitaException e) { setProcessInstanceId(containerId, containerType, e); throw new SExpressionEvaluationException(e, expression.getName()); } }
@Override public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions, final ContainerState containerState) throws SExpressionEvaluationException { final String businessDataName = expression.getContent(); if (context.containsKey(businessDataName)) { return context.get(businessDataName); } final Long containerId = (Long) context.get(SExpressionContext.CONTAINER_ID_KEY); final String containerType = (String) context.get(SExpressionContext.CONTAINER_TYPE_KEY); try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext( businessDataName, new Container(containerId, containerType))); return businessDataRetriever.getBusinessData(refBusinessDataInstance); } catch (final SBonitaReadException | SFlowNodeReadException e) { throw new SExpressionEvaluationException("Unable to retrieve business data instance with name " + businessDataName, e, businessDataName); } catch (final SBonitaException e) { setProcessInstanceId(containerId, containerType, e); throw new SExpressionEvaluationException(e, expression.getName()); } }
@Override public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions, final ContainerState containerState) throws SExpressionEvaluationException { final String businessDataName = expression.getContent(); final Long containerId = (Long) context.get(SExpressionContext.CONTAINER_ID_KEY); final String containerType = (String) context.get(SExpressionContext.CONTAINER_TYPE_KEY); try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext( businessDataName, new Container(containerId, containerType))); return ModelConvertor.toBusinessDataReference(refBusinessDataInstance); } catch (final SBonitaReadException e) { throw new SExpressionEvaluationException(e, "Unable to retrieve business data instance with name " + businessDataName); } catch (final SBonitaException e) { setProcessInstanceId(containerId, containerType, e); throw new SExpressionEvaluationException(e, expression.getName()); } }
@Override public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions, final ContainerState containerState) throws SExpressionEvaluationException { final String businessDataName = expression.getContent(); final Long containerId = (Long) context.get(SExpressionContext.CONTAINER_ID_KEY); final String containerType = (String) context.get(SExpressionContext.CONTAINER_TYPE_KEY); try { final SRefBusinessDataInstance refBusinessDataInstance = refBusinessDataRetriever.getRefBusinessDataInstance(new BusinessDataContext( businessDataName, new Container(containerId, containerType))); return ModelConvertor.toBusinessDataReference(refBusinessDataInstance); } catch (final SBonitaReadException e) { throw new SExpressionEvaluationException(e, "Unable to retrieve business data instance with name " + businessDataName); } catch (final SBonitaException e) { setProcessInstanceId(containerId, containerType, e); throw new SExpressionEvaluationException(e, expression.getName()); } }