List<SFlowNodeDefinition> extractElementThatAreSourceAndTarget(List<SFlowNodeDefinition> sourceElements, List<SFlowNodeDefinition> targetElements) { List<SFlowNodeDefinition> sourceAndTarget = new ArrayList<SFlowNodeDefinition>(); Iterator<SFlowNodeDefinition> iterator = sourceElements.iterator(); while (iterator.hasNext()){ SFlowNodeDefinition sourceElement = iterator.next(); if(targetElements.contains(sourceElement) || sourceElement.getIncomingTransitions().isEmpty() /* if it's a start element it's also considered as a target */){ iterator.remove(); targetElements.remove(sourceElement); sourceAndTarget.add(sourceElement); } } return sourceAndTarget; }
private List<String> checkFlowNodesAreSupported(List<String> flowNodeNames, List<String> foundFlowNodes, SProcessDefinition processDefinition) { List<String> problems = new ArrayList<>(); for (SFlowNodeDefinition flowNode : processDefinition.getProcessContainer().getFlowNodes()) { boolean invalidType = SFlowNodeType.BOUNDARY_EVENT.equals(flowNode.getType()) || SFlowNodeType.SUB_PROCESS.equals(flowNode.getType()) || SFlowNodeType.GATEWAY.equals(flowNode.getType()); if (flowNodeNames.contains(flowNode.getName())) { foundFlowNodes.add(flowNode.getName()); if (invalidType) { problems.add(buildInvalidTypeErrorMessage(processDefinition, flowNode)); } } } return problems; }
public void updateDisplayNameAndDescription(final SProcessDefinition processDefinition, final SFlowNodeInstance flowNodeInstance) throws SActivityStateExecutionException { try { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); if (flowNode != null) { final SExpression displayNameExpression = flowNode.getDisplayName(); final SExpression displayDescriptionExpression = flowNode.getDisplayDescription(); final SExpressionContext sExpressionContext = new SExpressionContext(flowNodeInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), processDefinition.getId()); final String displayName; if (displayNameExpression != null) { displayName = (String) expressionResolverService.evaluate(displayNameExpression, sExpressionContext); } else { displayName = flowNode.getName(); } final String displayDescription; if (displayDescriptionExpression != null) { displayDescription = (String) expressionResolverService.evaluate(displayDescriptionExpression, sExpressionContext); } else { displayDescription = flowNode.getDescription(); } activityInstanceService.updateDisplayName(flowNodeInstance, displayName); activityInstanceService.updateDisplayDescription(flowNodeInstance, displayDescription); } } catch (final SBonitaException e) { throw new SActivityStateExecutionException("error while updating display name and description", e); } }
@Override public boolean mustSelect(SFlowNodeDefinition element) { return flowNodeNames.contains(element.getName()); }
FlowNodeTransitionsWrapper buildTransitionsWrapper(final SFlowNodeDefinition flowNode, final SProcessDefinition sProcessDefinition, final SFlowNodeInstance child) throws SBonitaException { final FlowNodeTransitionsWrapper transitionsDescriptor = new FlowNodeTransitionsWrapper(); // Retrieve all outgoing transitions if (flowNode == null) { // not in definition transitionsDescriptor.setInputTransitionsSize(0); transitionsDescriptor.setAllOutgoingTransitionDefinitions(Collections.<STransitionDefinition> emptyList()); } else { transitionsDescriptor.setInputTransitionsSize(flowNode.getIncomingTransitions().size()); transitionsDescriptor.setAllOutgoingTransitionDefinitions(new ArrayList<>(flowNode.getOutgoingTransitions())); transitionsDescriptor.setDefaultTransition(flowNode.getDefaultTransition()); } // Evaluate all outgoing transitions, and retrieve valid outgoing transitions transitionsDescriptor.setValidOutgoingTransitionDefinitions(evaluateOutgoingTransitions(transitionsDescriptor, sProcessDefinition, child)); return transitionsDescriptor; } }
if (flowNodes != null) { for (final SFlowNodeDefinition sFlowNodeDefinition : flowNodes) { final List<SConnectorDefinition> flowNodeConnectors = sFlowNodeDefinition.getConnectors(); if (flowNodeConnectors != null) { for (final SConnectorDefinition sConnectorDefinition : flowNodeConnectors) { } catch (final SConnectorException e) { final Problem problem = new ProblemImpl(Level.ERROR, sConnectorDefinition.getName(), "connector", "The connector '" + sConnectorDefinition.getName() + "' of flow node '" + sFlowNodeDefinition.getName() + "' has no implementation"); problems.add(problem);
@Override public boolean mustSelect(SFlowNodeDefinition flowNode) { return flowNode.getId() == id; } }
public List<SConnectorDefinition> getConnectorDefinitions(SProcessDefinition processDefinition, SFlowNodeInstance flowNodeInstance, ConnectorEvent connectorEvent) { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNodeDefinition = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); if (flowNodeDefinition == null) { return Collections.emptyList(); } return flowNodeDefinition.getConnectors(connectorEvent); }
private void updateActivityInstance(final long parentContainerId, final SFlowElementsContainerType parentContainerType, final SFlowNodeDefinition sFlowNodeDefinition, final SActivityInstanceBuilder builder) { updateFlowNodeInstance(parentContainerId, parentContainerType, builder); builder.setDescription(sFlowNodeDefinition.getDescription()); }
protected STransitionDefinition getDefaultTransition(final SProcessDefinition sDefinition, final SFlowNodeInstance flowNodeInstance) { final SFlowElementContainerDefinition processContainer = sDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); return flowNode.getDefaultTransition(); }
@Override protected SConnectorDefinition getSConnectorDefinition(final ProcessDefinitionService processDefinitionService) throws SBonitaException { final SProcessDefinition processDefinition = processDefinitionService.getProcessDefinition(processDefinitionId); final SFlowNodeDefinition flowNodeDefinition = processDefinition.getProcessContainer() .getFlowNode(flowNodeDefinitionId); final SConnectorDefinition sConnectorDefinition = flowNodeDefinition .getConnectorDefinition(connectorDefinitionName); if (sConnectorDefinition == null) { throw new SConnectorDefinitionNotFoundException( "Couldn't find the connector definition [" + connectorDefinitionName + "]"); } return sConnectorDefinition; }
public void updateDisplayDescriptionAfterCompletion(final SProcessDefinition processDefinition, final SFlowNodeInstance flowNodeInstance) throws SActivityStateExecutionException { try { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); if (flowNode != null) { final SExpression displayDescriptionAfterCompletionExpression = flowNode.getDisplayDescriptionAfterCompletion(); final SExpressionContext sExpressionContext = new SExpressionContext(flowNodeInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), processDefinition.getId()); final String displayDescriptionAfterCompletion; if (displayDescriptionAfterCompletionExpression != null) { displayDescriptionAfterCompletion = (String) expressionResolverService.evaluate(displayDescriptionAfterCompletionExpression, sExpressionContext); activityInstanceService.updateDisplayDescription(flowNodeInstance, displayDescriptionAfterCompletion); } } } catch (final SBonitaException e) { throw new SActivityStateExecutionException("error while updating display name and description", e); } }
public void updateDisplayNameAndDescription(final SProcessDefinition processDefinition, final SFlowNodeInstance flowNodeInstance) throws SActivityStateExecutionException { try { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNode = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); if (flowNode != null) { final SExpression displayNameExpression = flowNode.getDisplayName(); final SExpression displayDescriptionExpression = flowNode.getDisplayDescription(); final SExpressionContext sExpressionContext = new SExpressionContext(flowNodeInstance.getId(), DataInstanceContainer.ACTIVITY_INSTANCE.name(), processDefinition.getId()); final String displayName; if (displayNameExpression != null) { displayName = (String) expressionResolverService.evaluate(displayNameExpression, sExpressionContext); } else { displayName = flowNode.getName(); } final String displayDescription; if (displayDescriptionExpression != null) { displayDescription = (String) expressionResolverService.evaluate(displayDescriptionExpression, sExpressionContext); } else { displayDescription = flowNode.getDescription(); } activityInstanceService.updateDisplayName(flowNodeInstance, displayName); activityInstanceService.updateDisplayDescription(flowNodeInstance, displayDescription); } } catch (final SBonitaException e) { throw new SActivityStateExecutionException("error while updating display name and description", e); } }
@Override public boolean mustSelect(SFlowNodeDefinition element) { return flowNodeNames.contains(element.getName()); }
FlowNodeTransitionsWrapper buildTransitionsWrapper(final SFlowNodeDefinition flowNode, final SProcessDefinition sProcessDefinition, final SFlowNodeInstance child) throws SBonitaException { final FlowNodeTransitionsWrapper transitionsDescriptor = new FlowNodeTransitionsWrapper(); // Retrieve all outgoing transitions if (flowNode == null) { // not in definition transitionsDescriptor.setInputTransitionsSize(0); transitionsDescriptor.setAllOutgoingTransitionDefinitions(Collections.<STransitionDefinition> emptyList()); } else { transitionsDescriptor.setInputTransitionsSize(flowNode.getIncomingTransitions().size()); transitionsDescriptor.setAllOutgoingTransitionDefinitions(new ArrayList<>(flowNode.getOutgoingTransitions())); transitionsDescriptor.setDefaultTransition(flowNode.getDefaultTransition()); } // Evaluate all outgoing transitions, and retrieve valid outgoing transitions transitionsDescriptor.setValidOutgoingTransitionDefinitions(evaluateOutgoingTransitions(transitionsDescriptor, sProcessDefinition, child)); return transitionsDescriptor; } }
private List<String> checkFlowNodesAreSupported(List<String> flowNodeNames, List<String> foundFlowNodes, SProcessDefinition processDefinition) { List<String> problems = new ArrayList<>(); for (SFlowNodeDefinition flowNode : processDefinition.getProcessContainer().getFlowNodes()) { boolean invalidType = SFlowNodeType.BOUNDARY_EVENT.equals(flowNode.getType()) || SFlowNodeType.SUB_PROCESS.equals(flowNode.getType()) || SFlowNodeType.GATEWAY.equals(flowNode.getType()); if (flowNodeNames.contains(flowNode.getName())) { foundFlowNodes.add(flowNode.getName()); if (invalidType) { problems.add(buildInvalidTypeErrorMessage(processDefinition, flowNode)); } } } return problems; }
if (flowNodes != null) { for (final SFlowNodeDefinition sFlowNodeDefinition : flowNodes) { final List<SConnectorDefinition> flowNodeConnectors = sFlowNodeDefinition.getConnectors(); if (flowNodeConnectors != null) { for (final SConnectorDefinition sConnectorDefinition : flowNodeConnectors) { } catch (final SConnectorException e) { final Problem problem = new ProblemImpl(Level.ERROR, sConnectorDefinition.getName(), "connector", "The connector '" + sConnectorDefinition.getName() + "' of flow node '" + sFlowNodeDefinition.getName() + "' has no implementation"); problems.add(problem);
@Override public boolean mustSelect(SFlowNodeDefinition flowNode) { return flowNode.getId() == id; } }
public List<SConnectorDefinition> getConnectorDefinitions(SProcessDefinition processDefinition, SFlowNodeInstance flowNodeInstance, ConnectorEvent connectorEvent) { final SFlowElementContainerDefinition processContainer = processDefinition.getProcessContainer(); final SFlowNodeDefinition flowNodeDefinition = processContainer.getFlowNode(flowNodeInstance.getFlowNodeDefinitionId()); if (flowNodeDefinition == null) { return Collections.emptyList(); } return flowNodeDefinition.getConnectors(connectorEvent); }