org.activiti.bpmn.model.UserTask Java Examples
The following examples show how to use
org.activiti.bpmn.model.UserTask.
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: AddBpmnModelTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 7 votes |
private static BpmnModel createProcessModel() { // 创建BPMN模型 BpmnModel model = new BpmnModel(); // 创建一个流程定义 Process process = new Process(); model.addProcess(process); process.setId("myProcess"); process.setName("My Process"); // 开始事件 StartEvent startEvent = new StartEvent(); startEvent.setId("startEvent"); process.addFlowElement(startEvent); // 用户任务 UserTask userTask = new UserTask(); userTask.setName("User Task"); userTask.setId("userTask"); process.addFlowElement(userTask); // 结束事件 EndEvent endEvent = new EndEvent(); endEvent.setId("endEvent"); process.addFlowElement(endEvent); // 添加流程顺序 process.addFlowElement(new SequenceFlow("startEvent", "userTask")); process.addFlowElement(new SequenceFlow("userTask", "endEvent")); return model; }
Example #2
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 #3
Source File: AlfrescoUserTaskBpmnParseHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { ActivityImpl activity = findActivity(bpmnParse, userTask.getId()); ActivityBehavior activitybehaviour = activity.getActivityBehavior(); if (activitybehaviour instanceof UserTaskActivityBehavior) { addListeners((UserTaskActivityBehavior) activity.getActivityBehavior()); } else if(activitybehaviour instanceof MultiInstanceActivityBehavior) { MultiInstanceActivityBehavior multiInstance = (MultiInstanceActivityBehavior) activitybehaviour; if(multiInstance.getInnerActivityBehavior() instanceof UserTaskActivityBehavior) { addListeners((UserTaskActivityBehavior) multiInstance.getInnerActivityBehavior()); } } }
Example #4
Source File: MyPostParseHandler.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@Override public void parse(BpmnParse bpmnParse, BaseElement element) { if (element instanceof Process) { ProcessDefinitionEntity processDefinition = bpmnParse.getCurrentProcessDefinition(); String key = processDefinition.getKey(); processDefinition.setKey(key + "-modified-by-post-parse-handler"); } else if (element instanceof UserTask) { UserTask userTask = (UserTask) element; List<SequenceFlow> outgoingFlows = userTask.getOutgoingFlows(); System.out.println("UserTask:[" + userTask.getName() + "]的输出流:"); for (SequenceFlow outgoingFlow : outgoingFlows) { System.out.println("\t" + outgoingFlow.getTargetRef()); } System.out.println(); } }
Example #5
Source File: TestProcessUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static org.activiti.bpmn.model.Process createOneTaskProcess() { org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); process.setId("oneTaskProcess"); process.setName("The one task process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The Task"); userTask.setId("theTask"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "theTask")); process.addFlowElement(new SequenceFlow("theTask", "theEnd")); return process; }
Example #6
Source File: AddBpmnModelTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
private static BpmnModel createProcessModel() { // 创建BPMN模型 BpmnModel model = new BpmnModel(); // 创建一个流程定义 Process process = new Process(); model.addProcess(process); process.setId("myProcess"); process.setName("My Process"); // 开始事件 StartEvent startEvent = new StartEvent(); startEvent.setId("startEvent"); process.addFlowElement(startEvent); // 用户任务 UserTask userTask = new UserTask(); userTask.setName("User Task"); userTask.setId("userTask"); process.addFlowElement(userTask); // 结束事件 EndEvent endEvent = new EndEvent(); endEvent.setId("endEvent"); process.addFlowElement(endEvent); // 添加流程顺序 process.addFlowElement(new SequenceFlow("startEvent", "userTask")); process.addFlowElement(new SequenceFlow("userTask", "endEvent")); return model; }
Example #7
Source File: UserTaskXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { UserTask userTask = (UserTask) element; writeQualifiedAttribute(ATTRIBUTE_TASK_USER_ASSIGNEE, userTask.getAssignee(), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_OWNER, userTask.getOwner(), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEUSERS, convertToDelimitedString(userTask.getCandidateUsers()), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEGROUPS, convertToDelimitedString(userTask.getCandidateGroups()), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_DUEDATE, userTask.getDueDate(), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_BUSINESS_CALENDAR_NAME, userTask.getBusinessCalendarName(), xtw); writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CATEGORY, userTask.getCategory(), xtw); writeQualifiedAttribute(ATTRIBUTE_FORM_FORMKEY, userTask.getFormKey(), xtw); if (userTask.getPriority() != null) { writeQualifiedAttribute(ATTRIBUTE_TASK_USER_PRIORITY, userTask.getPriority().toString(), xtw); } if (StringUtils.isNotEmpty(userTask.getExtensionId())) { writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_EXTENSIONID, userTask.getExtensionId(), xtw); } if (userTask.getSkipExpression() != null) { writeQualifiedAttribute(ATTRIBUTE_TASK_USER_SKIP_EXPRESSION, userTask.getSkipExpression(), xtw); } // write custom attributes BpmnXMLUtil.writeCustomAttributes(userTask.getAttributes().values(), xtw, defaultElementAttributes, defaultActivityAttributes, defaultUserTaskAttributes); }
Example #8
Source File: UserTaskXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected boolean writeCustomIdentities(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { UserTask userTask = (UserTask) element; if (userTask.getCustomUserIdentityLinks().isEmpty() && userTask.getCustomGroupIdentityLinks().isEmpty()) { return didWriteExtensionStartElement; } if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } Set<String> identityLinkTypes = new HashSet<String>(); identityLinkTypes.addAll(userTask.getCustomUserIdentityLinks().keySet()); identityLinkTypes.addAll(userTask.getCustomGroupIdentityLinks().keySet()); for (String identityType : identityLinkTypes) { writeCustomIdentities(userTask, identityType, userTask.getCustomUserIdentityLinks().get(identityType), userTask.getCustomGroupIdentityLinks().get(identityType), xtw); } return didWriteExtensionStartElement; }
Example #9
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 #10
Source File: TestProcessUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static org.activiti.bpmn.model.Process createOneTaskProcess() { org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); process.setId("oneTaskProcess"); process.setName("The one task process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The Task"); userTask.setId("theTask"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "theTask")); process.addFlowElement(new SequenceFlow("theTask", "theEnd")); return process; }
Example #11
Source File: ListenerNotificationHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void executeTaskListeners(UserTask userTask, TaskEntity taskEntity, String eventType) { for (ActivitiListener activitiListener : userTask.getTaskListeners()) { String event = activitiListener.getEvent(); if (event.equals(eventType) || event.equals(TaskListener.EVENTNAME_ALL_EVENTS)) { BaseTaskListener taskListener = createTaskListener(activitiListener); if (activitiListener.getOnTransaction() != null) { planTransactionDependentTaskListener(taskEntity.getExecution(), (TransactionDependentTaskListener) taskListener, activitiListener); } else { taskEntity.setEventName(eventType); taskEntity.setCurrentActivitiListener(activitiListener); try { Context.getProcessEngineConfiguration().getDelegateInterceptor() .handleInvocation(new TaskListenerInvocation((TaskListener) taskListener, taskEntity)); } catch (Exception e) { throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e); } finally { taskEntity.setEventName(null); taskEntity.setCurrentActivitiListener(null); } } } } }
Example #12
Source File: ProxyUserTaskBpmnParseHandler.java From lemon with Apache License 2.0 | 6 votes |
public void parse(BpmnParse bpmnParse, BaseElement baseElement) { if (!(baseElement instanceof UserTask)) { return; } if (useDefaultUserTaskParser) { new UserTaskParseHandler().parse(bpmnParse, baseElement); } UserTask userTask = (UserTask) baseElement; logger.debug("bpmnParse : {}, userTask : {}", bpmnParse, userTask); TaskDefinition taskDefinition = (TaskDefinition) bpmnParse .getCurrentActivity().getProperty( UserTaskParseHandler.PROPERTY_TASK_DEFINITION); this.configEvent(taskDefinition, bpmnParse, TaskListener.EVENTNAME_CREATE); this.configEvent(taskDefinition, bpmnParse, TaskListener.EVENTNAME_ASSIGNMENT); this.configEvent(taskDefinition, bpmnParse, TaskListener.EVENTNAME_COMPLETE); this.configEvent(taskDefinition, bpmnParse, TaskListener.EVENTNAME_DELETE); }
Example #13
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 #14
Source File: ModelServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void addOrUpdateExtensionElement(String name, String value, UserTask userTask) { List<ExtensionElement> extensionElements = userTask.getExtensionElements().get(name); ExtensionElement extensionElement; if (CollectionUtils.isNotEmpty(extensionElements)) { extensionElement = extensionElements.get(0); } else { extensionElement = new ExtensionElement(); } extensionElement.setNamespace(NAMESPACE); extensionElement.setNamespacePrefix("modeler"); extensionElement.setName(name); extensionElement.setElementText(value); if (CollectionUtils.isEmpty(extensionElements)) { userTask.addExtensionElement(extensionElement); } }
Example #15
Source File: ScopedConverterTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess"); assertNotNull(flowElement); assertTrue(flowElement instanceof SubProcess); assertEquals("outerSubProcess", flowElement.getId()); SubProcess outerSubProcess = (SubProcess) flowElement; List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents(); assertEquals(1, eventList.size()); BoundaryEvent boundaryEvent = eventList.get(0); assertEquals("outerBoundaryEvent", boundaryEvent.getId()); FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess"); assertNotNull(subElement); assertTrue(subElement instanceof SubProcess); assertEquals("innerSubProcess", subElement.getId()); SubProcess innerSubProcess = (SubProcess) subElement; eventList = innerSubProcess.getBoundaryEvents(); assertEquals(1, eventList.size()); boundaryEvent = eventList.get(0); assertEquals("innerBoundaryEvent", boundaryEvent.getId()); FlowElement taskElement = innerSubProcess.getFlowElement("usertask"); assertNotNull(taskElement); assertTrue(taskElement instanceof UserTask); UserTask userTask = (UserTask) taskElement; assertEquals("usertask", userTask.getId()); eventList = userTask.getBoundaryEvents(); assertEquals(1, eventList.size()); boundaryEvent = eventList.get(0); assertEquals("taskBoundaryEvent", boundaryEvent.getId()); }
Example #16
Source File: CdiEventSupportBpmnParseHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void addActivitiListenerToUserTask(UserTask userTask, String event, Object instance) { ActivitiListener listener = new ActivitiListener(); listener.setEvent(event); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE); listener.setInstance(instance); userTask.getTaskListeners().add(listener); }
Example #17
Source File: AddListenerUserTaskParseHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { super.executeParse(bpmnParse, userTask); ActivitiListener listener = new ActivitiListener(); listener.setEvent(eventName); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE); listener.setInstance(taskListener); userTask.getTaskListeners().add(listener); }
Example #18
Source File: SubProcessConverterAutoLayoutTest.java From activiti6-boot2 with Apache License 2.0 | 5 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() == 6); List<ValuedDataObject> dataObjects = ((SubProcess) flowElement).getDataObjects(); assertTrue(dataObjects.size() == 1); ValuedDataObject dataObj = dataObjects.get(0); assertEquals("SubTest", dataObj.getName()); assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef()); assertTrue(dataObj.getValue() instanceof String); assertEquals("Testing", dataObj.getValue()); }
Example #19
Source File: UserTaskXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void writeCustomIdentities(UserTask userTask,String identityType, Set<String> users, Set<String> groups, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_CUSTOM_RESOURCE, ACTIVITI_EXTENSIONS_NAMESPACE); writeDefaultAttribute(ATTRIBUTE_NAME, identityType, xtw); List<String> identityList = new ArrayList<String>(); if (users!=null) { for (String userId: users) { identityList.add("user("+userId+")"); } } if (groups!=null) { for (String groupId: groups){ identityList.add("group("+groupId+")"); } } String delimitedString = convertToDelimitedString(identityList); xtw.writeStartElement(ELEMENT_RESOURCE_ASSIGNMENT); xtw.writeStartElement(ELEMENT_FORMAL_EXPRESSION); xtw.writeCharacters(delimitedString); xtw.writeEndElement(); // End ELEMENT_FORMAL_EXPRESSION xtw.writeEndElement(); // End ELEMENT_RESOURCE_ASSIGNMENT xtw.writeEndElement(); // End ELEMENT_CUSTOM_RESOURCE }
Example #20
Source File: EventJavaTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testStartEventWithExecutionListener() throws Exception { BpmnModel bpmnModel = new BpmnModel(); Process process = new Process(); process.setId("simpleProcess"); process.setName("Very simple process"); bpmnModel.getProcesses().add(process); StartEvent startEvent = new StartEvent(); startEvent.setId("startEvent1"); TimerEventDefinition timerDef = new TimerEventDefinition(); timerDef.setTimeDuration("PT5M"); startEvent.getEventDefinitions().add(timerDef); ActivitiListener listener = new ActivitiListener(); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); listener.setImplementation("${test}"); listener.setEvent("end"); startEvent.getExecutionListeners().add(listener); process.addFlowElement(startEvent); UserTask task = new UserTask(); task.setId("reviewTask"); task.setAssignee("kermit"); process.addFlowElement(task); SequenceFlow flow1 = new SequenceFlow(); flow1.setId("flow1"); flow1.setSourceRef("startEvent1"); flow1.setTargetRef("reviewTask"); process.addFlowElement(flow1); EndEvent endEvent = new EndEvent(); endEvent.setId("endEvent1"); process.addFlowElement(endEvent); byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel); new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml))); Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)) .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); repositoryService.deleteDeployment(deployment.getId()); }
Example #21
Source File: UserTaskXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { String resourceElement = XMLStreamReaderUtil.moveDown(xtr); if (StringUtils.isNotEmpty(resourceElement) && ELEMENT_RESOURCE_ASSIGNMENT.equals(resourceElement)) { String expression = XMLStreamReaderUtil.moveDown(xtr); if (StringUtils.isNotEmpty(expression) && ELEMENT_FORMAL_EXPRESSION.equals(expression)) { ((UserTask) parentElement).setAssignee(xtr.getElementText()); } } }
Example #22
Source File: TestProcessUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static BpmnModel createTwoTasksBpmnModel() { BpmnModel model = new BpmnModel(); org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example #23
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public BpmnModel createTwoTasksTestProcess() { BpmnModel model = new BpmnModel(); org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example #24
Source File: TestProcessUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static BpmnModel createTwoTasksBpmnModel() { BpmnModel model = new BpmnModel(); org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example #25
Source File: CompleteConverterTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1"); assertNotNull(flowElement); assertTrue(flowElement instanceof UserTask); assertEquals("userTask1", flowElement.getId()); flowElement = model.getMainProcess().getFlowElement("catchsignal"); assertNotNull(flowElement); assertTrue(flowElement instanceof IntermediateCatchEvent); assertEquals("catchsignal", flowElement.getId()); IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement; assertEquals(1, catchEvent.getEventDefinitions().size()); assertTrue(catchEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition); SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0); assertEquals("testSignal", signalEvent.getSignalRef()); flowElement = model.getMainProcess().getFlowElement("subprocess"); assertNotNull(flowElement); assertTrue(flowElement instanceof SubProcess); assertEquals("subprocess", flowElement.getId()); SubProcess subProcess = (SubProcess) flowElement; flowElement = subProcess.getFlowElement("receiveTask"); assertNotNull(flowElement); assertTrue(flowElement instanceof ReceiveTask); assertEquals("receiveTask", flowElement.getId()); }
Example #26
Source File: MyPostParseHandler.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Override public Collection<Class<? extends BaseElement>> getHandledTypes() { Set<Class< ? extends BaseElement>> types = new HashSet<Class<? extends BaseElement>>(); types.add(Process.class); types.add(UserTask.class); return types; }
Example #27
Source File: TaskAutoRedirectParseHandler.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { super.executeParse(bpmnParse, userTask); // 实验后不能添加 ActivitiListener listener = new ActivitiListener(); listener.setEvent("create"); listener.setImplementationType("class"); listener.setImplementation("me.kafeitu.activiti.chapter21.listeners.TaskAutoRedirectListener"); userTask.getTaskListeners().add(listener); }
Example #28
Source File: CustomUserTaskBpmnParseHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { // Do the regular stuff super.executeParse(bpmnParse, userTask); // Make user tasks always async ActivityImpl activity = findActivity(bpmnParse, userTask.getId()); activity.setAsync(true); }
Example #29
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public BpmnModel createTwoTasksTestProcess() { BpmnModel model = new BpmnModel(); org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example #30
Source File: EventJavaTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testStartEventWithExecutionListener() throws Exception { BpmnModel bpmnModel = new BpmnModel(); Process process = new Process(); process.setId("simpleProcess"); process.setName("Very simple process"); bpmnModel.getProcesses().add(process); StartEvent startEvent = new StartEvent(); startEvent.setId("startEvent1"); TimerEventDefinition timerDef = new TimerEventDefinition(); timerDef.setTimeDuration("PT5M"); startEvent.getEventDefinitions().add(timerDef); ActivitiListener listener = new ActivitiListener(); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); listener.setImplementation("${test}"); listener.setEvent("end"); startEvent.getExecutionListeners().add(listener); process.addFlowElement(startEvent); UserTask task = new UserTask(); task.setId("reviewTask"); task.setAssignee("kermit"); process.addFlowElement(task); SequenceFlow flow1 = new SequenceFlow(); flow1.setId("flow1"); flow1.setSourceRef("startEvent1"); flow1.setTargetRef("reviewTask"); process.addFlowElement(flow1); EndEvent endEvent = new EndEvent(); endEvent.setId("endEvent1"); process.addFlowElement(endEvent); byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel); new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml))); Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy(); repositoryService.deleteDeployment(deployment.getId()); }