org.activiti.bpmn.model.FlowElement Java Examples
The following examples show how to use
org.activiti.bpmn.model.FlowElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParallelGatewayActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected DelegateExecution findMultiInstanceParentExecution(DelegateExecution execution) { DelegateExecution multiInstanceExecution = null; DelegateExecution parentExecution = execution.getParent(); if (parentExecution != null && parentExecution.getCurrentFlowElement() != null) { FlowElement flowElement = parentExecution.getCurrentFlowElement(); if (flowElement instanceof Activity) { Activity activity = (Activity) flowElement; if (activity.getLoopCharacteristics() != null) { multiInstanceExecution = parentExecution; } } if (multiInstanceExecution == null) { DelegateExecution potentialMultiInstanceExecution = findMultiInstanceParentExecution(parentExecution); if (potentialMultiInstanceExecution != null) { multiInstanceExecution = potentialMultiInstanceExecution; } } } return multiInstanceExecution; }
Example #2
Source File: SubProcessMultiDiagramConverterTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getMainProcess().getFlowElement("start1"); assertNotNull(flowElement); assertTrue(flowElement instanceof StartEvent); assertEquals("start1", flowElement.getId()); flowElement = model.getMainProcess().getFlowElement("userTask1"); assertNotNull(flowElement); assertTrue(flowElement instanceof UserTask); assertEquals("userTask1", flowElement.getId()); UserTask userTask = (UserTask) flowElement; assertTrue(userTask.getCandidateUsers().size() == 1); assertTrue(userTask.getCandidateGroups().size() == 1); flowElement = model.getMainProcess().getFlowElement("subprocess1"); assertNotNull(flowElement); assertTrue(flowElement instanceof SubProcess); assertEquals("subprocess1", flowElement.getId()); SubProcess subProcess = (SubProcess) flowElement; assertTrue(subProcess.getFlowElements().size() == 11); }
Example #3
Source File: AbstractBpmnParseHandler.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public ActivityImpl createActivityOnScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName, ScopeImpl scopeElement) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Parsing activity {}", flowElement.getId()); } ActivityImpl activity = scopeElement.createActivity(flowElement.getId()); bpmnParse.setCurrentActivity(activity); activity.setProperty("name", flowElement.getName()); activity.setProperty("documentation", flowElement.getDocumentation()); if (flowElement instanceof Activity) { Activity modelActivity = (Activity) flowElement; activity.setProperty("default", modelActivity.getDefaultFlow()); if(modelActivity.isForCompensation()) { activity.setProperty(PROPERTYNAME_IS_FOR_COMPENSATION, true); } } else if (flowElement instanceof Gateway) { activity.setProperty("default", ((Gateway) flowElement).getDefaultFlow()); } activity.setProperty("type", xmlLocalName); return activity; }
Example #4
Source File: BpmnParse.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); if (flowElement != null && sequenceFlows.containsKey(key)) { TransitionImpl sequenceFlow = sequenceFlows.get(key); List<Integer> waypoints = new ArrayList<Integer>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); waypoints.add((int) waypointInfo.getY()); } sequenceFlow.setWaypoints(waypoints); } else if (bpmnModel.getArtifact(key) != null) { // it's an association, so nothing to do } else { LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + key + " not found"); } }
Example #5
Source File: FormHandlerUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static StartFormHandler getStartFormHandler(CommandContext commandContext, ProcessDefinition processDefinition) { StartFormHandler startFormHandler = new DefaultStartFormHandler(); org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); FlowElement initialFlowElement = process.getInitialFlowElement(); if (initialFlowElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) initialFlowElement; List<FormProperty> formProperties = startEvent.getFormProperties(); String formKey = startEvent.getFormKey(); DeploymentEntity deploymentEntity = commandContext.getDeploymentEntityManager().findById(processDefinition.getDeploymentId()); startFormHandler.parseConfiguration(formProperties, formKey, deploymentEntity, processDefinition); return startFormHandler; } return null; }
Example #6
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void recordProcessInstanceStart(ExecutionEntity processInstance, FlowElement startElement) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().create(processInstance); historicProcessInstance.setStartActivityId(startElement.getId()); // Insert historic process-instance getHistoricProcessInstanceEntityManager().insert(historicProcessInstance, false); // Fire event ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher(); if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) { activitiEventDispatcher.dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); } } }
Example #7
Source File: ValidatorImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void addError(List<ValidationError> validationErrors, String problem, Process process, BaseElement baseElement, String description, boolean isWarning) { ValidationError error = new ValidationError(); error.setWarning(isWarning); if (process != null) { error.setProcessDefinitionId(process.getId()); error.setProcessDefinitionName(process.getName()); } if (baseElement != null) { error.setXmlLineNumber(baseElement.getXmlRowNumber()); error.setXmlColumnNumber(baseElement.getXmlColumnNumber()); } error.setProblem(problem); error.setDefaultDescription(description); if (baseElement instanceof FlowElement) { FlowElement flowElement = (FlowElement) baseElement; error.setActivityId(flowElement.getId()); error.setActivityName(flowElement.getName()); } addError(validationErrors, error); }
Example #8
Source File: MapExceptionConverterTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testMapExceptionWithNoExceptionClass() throws Exception { resourceName = "mapException/mapExceptionNoExceptionClass.bpmn"; BpmnModel bpmnModel = readXMLFile(); FlowElement flowElement = bpmnModel.getMainProcess().getFlowElement("servicetaskWithAndTrueAndChildren"); assertNotNull(flowElement); assertTrue(flowElement instanceof ServiceTask); assertEquals("servicetaskWithAndTrueAndChildren", flowElement.getId()); ServiceTask serviceTask = (ServiceTask) flowElement; assertNotNull(serviceTask.getMapExceptions()); assertEquals(1, serviceTask.getMapExceptions().size()); assertNotNull(serviceTask.getMapExceptions().get(0).getClassName()); assertEquals(0, serviceTask.getMapExceptions().get(0).getClassName().length()); }
Example #9
Source File: BaseBpmnJsonConverter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void processDataStoreReferences(FlowElementsContainer container, String dataStoreReferenceId, ArrayNode outgoingArrayNode) { for (FlowElement flowElement : container.getFlowElements()) { if (flowElement instanceof Activity) { Activity activity = (Activity) flowElement; if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) { for (DataAssociation dataAssociation : activity.getDataInputAssociations()) { if (dataStoreReferenceId.equals(dataAssociation.getSourceRef())) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId())); } } } } else if (flowElement instanceof SubProcess) { processDataStoreReferences((SubProcess) flowElement, dataStoreReferenceId, outgoingArrayNode); } } }
Example #10
Source File: BpmnJsonConverter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void processFlowElement(FlowElement flowElement, FlowElementsContainer container, BpmnModel model, ArrayNode shapesArrayNode, Map<String, ModelInfo> formKeyMap, Map<String, ModelInfo> decisionTableKeyMap, double containerX, double containerY) { Class<? extends BaseBpmnJsonConverter> converter = convertersToJsonMap.get(flowElement.getClass()); if (converter != null) { try { BaseBpmnJsonConverter converterInstance = converter.newInstance(); if (converterInstance instanceof FormKeyAwareConverter) { ((FormKeyAwareConverter) converterInstance).setFormKeyMap(formKeyMap); } if (converterInstance instanceof DecisionTableKeyAwareConverter) { ((DecisionTableKeyAwareConverter) converterInstance).setDecisionTableKeyMap(decisionTableKeyMap); } converterInstance.convertToJson(flowElement, this, model, container, shapesArrayNode, containerX, containerY); } catch (Exception e) { LOGGER.error("Error converting {}", flowElement, e); } } }
Example #11
Source File: EventSubscriptionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, Process process, BpmnModel bpmnModel) { if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof MessageEventDefinition) { MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition; insertMessageEvent(messageEventDefinition, startEvent, processDefinition, bpmnModel); } } } } } }
Example #12
Source File: TriggerExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void run() { FlowElement currentFlowElement = getCurrentFlowElement(execution); if (currentFlowElement instanceof FlowNode) { ActivityBehavior activityBehavior = (ActivityBehavior) ((FlowNode) currentFlowElement).getBehavior(); if (activityBehavior instanceof TriggerableActivityBehavior) { if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityStart(execution); } ((TriggerableActivityBehavior) activityBehavior).trigger(execution, null, null); if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityEnd(execution, null); } } else { throw new ActivitiException("Invalid behavior: " + activityBehavior + " should implement " + TriggerableActivityBehavior.class.getName()); } } else { throw new ActivitiException("Programmatic error: no current flow element found or invalid type: " + currentFlowElement + ". Halting."); } }
Example #13
Source File: DeploymentServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected Map<String, StartEvent> processNoneStartEvents(BpmnModel bpmnModel) { Map<String, StartEvent> startEventMap = new HashMap<String, StartEvent>(); for (Process process : bpmnModel.getProcesses()) { for (FlowElement flowElement : process.getFlowElements()) { if (flowElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) flowElement; if (CollectionUtils.isEmpty(startEvent.getEventDefinitions())) { if (StringUtils.isEmpty(startEvent.getInitiator())) { startEvent.setInitiator("initiator"); } startEventMap.put(process.getId(), startEvent); break; } } } } return startEventMap; }
Example #14
Source File: DataStoreConverterTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void validateModel(BpmnModel model) { assertEquals(1, model.getDataStores().size()); DataStore dataStore = model.getDataStore("DataStore_1"); assertNotNull(dataStore); assertEquals("DataStore_1", dataStore.getId()); assertEquals("test", dataStore.getDataState()); assertEquals("Test Database", dataStore.getName()); assertEquals("test", dataStore.getItemSubjectRef()); FlowElement refElement = model.getFlowElement("DataStoreReference_1"); assertNotNull(refElement); assertTrue(refElement instanceof DataStoreReference); assertEquals(1, model.getPools().size()); Pool pool = model.getPools().get(0); assertEquals("pool1", pool.getId()); }
Example #15
Source File: SubProcessMultiDiagramConverterNoDITest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getMainProcess().getFlowElement("start1"); assertNotNull(flowElement); assertTrue(flowElement instanceof StartEvent); assertEquals("start1", flowElement.getId()); flowElement = model.getMainProcess().getFlowElement("userTask1"); assertNotNull(flowElement); assertTrue(flowElement instanceof UserTask); assertEquals("userTask1", flowElement.getId()); UserTask userTask = (UserTask) flowElement; assertTrue(userTask.getCandidateUsers().size() == 1); assertTrue(userTask.getCandidateGroups().size() == 1); flowElement = model.getMainProcess().getFlowElement("subprocess1"); assertNotNull(flowElement); assertTrue(flowElement instanceof SubProcess); assertEquals("subprocess1", flowElement.getId()); SubProcess subProcess = (SubProcess) flowElement; assertTrue(subProcess.getFlowElements().size() == 11); }
Example #16
Source File: BpmnImageTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void scaleFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, double scaleFactor) { for (FlowElement flowElement : elementList) { List<GraphicInfo> graphicInfoList = new ArrayList<GraphicInfo>(); if (flowElement instanceof SequenceFlow) { graphicInfoList.addAll(bpmnModel.getFlowLocationGraphicInfo(flowElement.getId())); } else { graphicInfoList.add(bpmnModel.getGraphicInfo(flowElement.getId())); } scaleGraphicInfoList(graphicInfoList, scaleFactor); if (flowElement instanceof SubProcess) { SubProcess subProcess = (SubProcess) flowElement; scaleFlowElements(subProcess.getFlowElements(), bpmnModel, scaleFactor); } } }
Example #17
Source File: ResourceParser.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String resourceId = xtr.getAttributeValue(null, ATTRIBUTE_ID); String resourceName = xtr.getAttributeValue(null, ATTRIBUTE_NAME); Resource resource; if (model.containsResourceId(resourceId)) { resource = model.getResource(resourceId); resource.setName(resourceName); for (org.activiti.bpmn.model.Process process : model.getProcesses()) { for (FlowElement fe : process.getFlowElements()) { if (fe instanceof UserTask && ((UserTask) fe).getCandidateGroups().contains(resourceId)) { ((UserTask) fe).getCandidateGroups().remove(resourceId); ((UserTask) fe).getCandidateGroups().add(resourceName); } } } } else { resource = new Resource(resourceId, resourceName); model.addResource(resource); } BpmnXMLUtil.addXMLLocation(resource, xtr); }
Example #18
Source File: AbstractProcessDefinitionResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected FormDefinition getStartForm(ProcessDefinition processDefinition) { FormDefinition formDefinition = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { formDefinition = formRepositoryService.getFormDefinitionByKeyAndParentDeploymentId(startEvent.getFormKey(), processDefinition.getDeploymentId(), processDefinition.getTenantId()); } } if (formDefinition == null) { // Definition found, but no form attached throw new NotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formDefinition; }
Example #19
Source File: RuntimeDisplayJsonClientResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<String> gatherCompletedFlows(Set<String> completedActivityInstances, Set<String> currentActivityinstances, BpmnModel pojoModel) { List<String> completedFlows = new ArrayList<String>(); List<String> activities = new ArrayList<String>(completedActivityInstances); activities.addAll(currentActivityinstances); // TODO: not a robust way of checking when parallel paths are active, should be revisited // Go over all activities and check if it's possible to match any outgoing paths against the activities for (FlowElement activity : pojoModel.getMainProcess().getFlowElements()) { if (activity instanceof FlowNode) { int index = activities.indexOf(activity.getId()); if (index >= 0 && index + 1 < activities.size()) { List<SequenceFlow> outgoingFlows = ((FlowNode) activity).getOutgoingFlows(); for (SequenceFlow flow : outgoingFlows) { String destinationFlowId = flow.getTargetRef(); if (destinationFlowId.equals(activities.get(index + 1))) { completedFlows.add(flow.getId()); } } } } } return completedFlows; }
Example #20
Source File: ModelImageService.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void scaleFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, double scaleFactor) { for (FlowElement flowElement : elementList) { List<GraphicInfo> graphicInfoList = new ArrayList<GraphicInfo>(); if (flowElement instanceof SequenceFlow) { List<GraphicInfo> flowList = bpmnModel.getFlowLocationGraphicInfo(flowElement.getId()); if (flowList != null) { graphicInfoList.addAll(flowList); } } else { graphicInfoList.add(bpmnModel.getGraphicInfo(flowElement.getId())); } scaleGraphicInfoList(graphicInfoList, scaleFactor); if (flowElement instanceof SubProcess) { SubProcess subProcess = (SubProcess) flowElement; scaleFlowElements(subProcess.getFlowElements(), bpmnModel, scaleFactor); } } }
Example #21
Source File: ModelImageService.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void calculateWidthForFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, GraphicInfo diagramInfo) { for (FlowElement flowElement : elementList) { List<GraphicInfo> graphicInfoList = new ArrayList<GraphicInfo>(); if (flowElement instanceof SequenceFlow) { List<GraphicInfo> flowGraphics = bpmnModel.getFlowLocationGraphicInfo(flowElement.getId()); if (flowGraphics != null && flowGraphics.size() > 0) { graphicInfoList.addAll(flowGraphics); } } else { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowElement.getId()); if (graphicInfo != null) { graphicInfoList.add(graphicInfo); } } processGraphicInfoList(graphicInfoList, diagramInfo); } }
Example #22
Source File: PermissionService.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public boolean validateIfUserIsInitiatorAndCanCompleteTask(User user, Task task) { boolean canCompleteTask = false; if (task.getProcessInstanceId() != null) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); if (historicProcessInstance != null && StringUtils.isNotEmpty(historicProcessInstance.getStartUserId())) { String processInstanceStartUserId = historicProcessInstance.getStartUserId(); if (String.valueOf(user.getId()).equals(processInstanceStartUserId)) { BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); if (flowElement != null && flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("initiator-can-complete"); if (CollectionUtils.isNotEmpty(extensionElements)) { String value = extensionElements.get(0).getElementText(); if (StringUtils.isNotEmpty(value) && Boolean.valueOf(value)) { canCompleteTask = true; } } } } } } return canCompleteTask; }
Example #23
Source File: DeploymentServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void processUserTasks(Collection<FlowElement> flowElements, Process process, Map<String, StartEvent> startEventMap) { for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; if ("$INITIATOR".equals(userTask.getAssignee())) { if (startEventMap.get(process.getId()) != null) { userTask.setAssignee("${" + startEventMap.get(process.getId()).getInitiator() + "}"); } } } else if (flowElement instanceof SubProcess) { processUserTasks(((SubProcess) flowElement).getFlowElements(), process, startEventMap); } } }
Example #24
Source File: FormHandlerUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static TaskFormHandler getTaskFormHandlder(String processDefinitionId, String taskId) { org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); FlowElement flowElement = process.getFlowElement(taskId, true); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; ProcessDefinition processDefinitionEntity = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); DeploymentEntity deploymentEntity = Context.getProcessEngineConfiguration() .getDeploymentEntityManager().findById(processDefinitionEntity.getDeploymentId()); TaskFormHandler taskFormHandler = new DefaultTaskFormHandler(); taskFormHandler.parseConfiguration(userTask.getFormProperties(), userTask.getFormKey(), deploymentEntity, processDefinitionEntity); return taskFormHandler; } return null; }
Example #25
Source File: SyncProcessCmd.java From lemon with Apache License 2.0 | 5 votes |
/** * 配置开始事件. */ public void processStartEvent(Node node, BpmnModel bpmnModel, int priority, BpmConfBase bpmConfBase) { BpmConfNodeManager bpmConfNodeManager = getBpmConfNodeManager(); BpmConfNode bpmConfNode = bpmConfNodeManager.findUnique( "from BpmConfNode where code=? and bpmConfBase=?", node.getId(), bpmConfBase); if (bpmConfNode == null) { bpmConfNode = new BpmConfNode(); bpmConfNode.setCode(node.getId()); bpmConfNode.setName(node.getName()); bpmConfNode.setType(node.getType()); bpmConfNode.setConfUser(2); bpmConfNode.setConfListener(0); bpmConfNode.setConfRule(2); bpmConfNode.setConfForm(0); bpmConfNode.setConfOperation(2); bpmConfNode.setConfNotice(0); bpmConfNode.setPriority(priority); bpmConfNode.setBpmConfBase(bpmConfBase); bpmConfNodeManager.save(bpmConfNode); } FlowElement flowElement = bpmnModel.getFlowElement(node.getId()); // 配置监听器 this.processListener(flowElement.getExecutionListeners(), bpmConfNode); StartEvent startEvent = (StartEvent) flowElement; // 配置表单 this.processForm(startEvent, bpmConfNode); }
Example #26
Source File: StartEventJsonConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { StartEvent startEvent = new StartEvent(); startEvent.setInitiator(getPropertyValueAsString(PROPERTY_NONE_STARTEVENT_INITIATOR, elementNode)); String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode); if (STENCIL_EVENT_START_NONE.equals(stencilId)) { String formKey = getPropertyValueAsString(PROPERTY_FORMKEY, elementNode); if (StringUtils.isNotEmpty(formKey)) { startEvent.setFormKey(formKey); } else { JsonNode formReferenceNode = getProperty(PROPERTY_FORM_REFERENCE, elementNode); if (formReferenceNode != null && formReferenceNode.get("id") != null) { if (formMap != null && formMap.containsKey(formReferenceNode.get("id").asText())) { startEvent.setFormKey(formMap.get(formReferenceNode.get("id").asText())); } } } convertJsonToFormProperties(elementNode, startEvent); } else if (STENCIL_EVENT_START_TIMER.equals(stencilId)) { convertJsonToTimerDefinition(elementNode, startEvent); } else if (STENCIL_EVENT_START_ERROR.equals(stencilId)) { convertJsonToErrorDefinition(elementNode, startEvent); } else if (STENCIL_EVENT_START_MESSAGE.equals(stencilId)) { convertJsonToMessageDefinition(elementNode, startEvent); } else if (STENCIL_EVENT_START_SIGNAL.equals(stencilId)) { convertJsonToSignalDefinition(elementNode, startEvent); } return startEvent; }
Example #27
Source File: MuleTaskJsonConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { ServiceTask task = new ServiceTask(); task.setType("mule"); addField("endpointUrl", PROPERTY_MULETASK_ENDPOINT_URL, elementNode, task); addField("language", PROPERTY_MULETASK_LANGUAGE, elementNode, task); addField("payloadExpression", PROPERTY_MULETASK_PAYLOAD_EXPRESSION, elementNode, task); addField("resultVariable", PROPERTY_MULETASK_RESULT_VARIABLE, elementNode, task); return task; }
Example #28
Source File: SubProcessActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void execute(DelegateExecution execution) { SubProcess subProcess = getSubProcessFromExecution(execution); FlowElement startElement = null; if (CollectionUtil.isNotEmpty(subProcess.getFlowElements())) { for (FlowElement subElement : subProcess.getFlowElements()) { if (subElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) subElement; // start none event if (CollectionUtil.isEmpty(startEvent.getEventDefinitions())) { startElement = startEvent; break; } } } } if (startElement == null) { throw new ActivitiException("No initial activity found for subprocess " + subProcess.getId()); } ExecutionEntity executionEntity = (ExecutionEntity) execution; executionEntity.setScope(true); // initialize the template-defined data objects as variables Map<String, Object> dataObjectVars = processDataObjects(subProcess.getDataObjects()); if (dataObjectVars != null) { executionEntity.setVariablesLocal(dataObjectVars); } ExecutionEntity startSubProcessExecution = Context.getCommandContext().getExecutionEntityManager() .createChildExecution(executionEntity); startSubProcessExecution.setCurrentFlowElement(startElement); Context.getAgenda().planContinueProcessOperation(startSubProcessExecution); }
Example #29
Source File: MapExceptionConverterTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { // check service task with andChildren Set to True FlowElement flowElement = model.getMainProcess().getFlowElement("servicetaskWithAndTrueAndChildren"); assertNotNull(flowElement); assertTrue(flowElement instanceof ServiceTask); assertEquals("servicetaskWithAndTrueAndChildren", flowElement.getId()); ServiceTask serviceTask = (ServiceTask) flowElement; assertNotNull(serviceTask.getMapExceptions()); assertEquals(3, serviceTask.getMapExceptions().size()); // check a normal mapException, with hasChildren == true assertEquals("myErrorCode1", serviceTask.getMapExceptions().get(0).getErrorCode()); assertEquals("com.activiti.Something1", serviceTask.getMapExceptions().get(0).getClassName()); assertTrue(serviceTask.getMapExceptions().get(0).isAndChildren()); // check a normal mapException, with hasChildren == false assertEquals("myErrorCode2", serviceTask.getMapExceptions().get(1).getErrorCode()); assertEquals("com.activiti.Something2", serviceTask.getMapExceptions().get(1).getClassName()); assertFalse(serviceTask.getMapExceptions().get(1).isAndChildren()); // check a normal mapException, with no hasChildren Defined, default // should // be false assertEquals("myErrorCode3", serviceTask.getMapExceptions().get(2).getErrorCode()); assertEquals("com.activiti.Something3", serviceTask.getMapExceptions().get(2).getClassName()); assertFalse(serviceTask.getMapExceptions().get(2).isAndChildren()); // if no map exception is defined, getMapException should return a not // null // empty list FlowElement flowElement1 = model.getMainProcess().getFlowElement("servicetaskWithNoMapException"); assertNotNull(flowElement1); assertTrue(flowElement1 instanceof ServiceTask); assertEquals("servicetaskWithNoMapException", flowElement1.getId()); ServiceTask serviceTask1 = (ServiceTask) flowElement1; assertNotNull(serviceTask1.getMapExceptions()); assertEquals(0, serviceTask1.getMapExceptions().size()); }
Example #30
Source File: DelegateExpressionTransactionDependentExecutionListener.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void notify(String processInstanceId, String executionId, FlowElement flowElement, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) { NoExecutionVariableScope scope = new NoExecutionVariableScope(); Object delegate = expression.getValue(scope); if (delegate instanceof TransactionDependentExecutionListener) { ((TransactionDependentExecutionListener) delegate).notify(processInstanceId, executionId, flowElement, executionVariables, customPropertiesMap); } else { throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + TransactionDependentExecutionListener.class); } }