Java Code Examples for org.activiti.bpmn.model.ActivitiListener#setEvent()
The following examples show how to use
org.activiti.bpmn.model.ActivitiListener#setEvent() .
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: CustomSequenceFlowBpmnParseHandler.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void executeParse(BpmnParse bpmnParse, SequenceFlow flow) { // Do the regular stuff super.executeParse(bpmnParse, flow); // Add extension element conditions Map<String, List<ExtensionElement>> extensionElements = flow.getExtensionElements(); if (extensionElements.containsKey("activiti_custom_condition")) { List<ExtensionElement> conditionsElements = extensionElements.get("activiti_custom_condition"); CustomSetConditionsExecutionListener customFlowListener = new CustomSetConditionsExecutionListener(); customFlowListener.setFlowId(flow.getId()); for (ExtensionElement conditionElement : conditionsElements) { customFlowListener.addCondition(conditionElement.getElementText()); } ActivitiListener activitiListener = new ActivitiListener(); activitiListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE); activitiListener.setInstance(customFlowListener); activitiListener.setEvent("start"); flow.getSourceFlowElement().getExecutionListeners().add(activitiListener); } }
Example 2
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()); }
Example 3
Source File: CdiEventSupportBpmnParseHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void addActivitiListenerToElement(FlowElement flowElement, String event, Object instance) { ActivitiListener listener = new ActivitiListener(); listener.setEvent(event); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE); listener.setInstance(instance); flowElement.getExecutionListeners().add(listener); }
Example 4
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 5
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 6
Source File: ActivitiListenerParser.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { ActivitiListener listener = new ActivitiListener(); BpmnXMLUtil.addXMLLocation(listener, xtr); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } listener.setEvent(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENT)); listener.setOnTransaction(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_ON_TRANSACTION)); if (StringUtils.isNotEmpty((xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS)))) { listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS)); listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION))) { listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION)); listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION))) { listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION)); listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } addListenerToParent(listener, parentElement); parseChildElements(xtr, listener, model, new FieldExtensionParser()); }
Example 7
Source File: ExecutionListenerParser.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void addListenerToParent(ActivitiListener listener, BaseElement parentElement) { if (parentElement instanceof HasExecutionListeners) { if (StringUtils.isEmpty(listener.getEvent()) && parentElement instanceof SequenceFlow) { // No event type on a sequenceflow = 'take' implied listener.setEvent("take"); } ((HasExecutionListeners) parentElement).getExecutionListeners().add(listener); } }
Example 8
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 9
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 10
Source File: ProxyUserTaskBpmnParseHandler.java From lemon with Apache License 2.0 | 5 votes |
public void configEvent(TaskDefinition taskDefinition, BpmnParse bpmnParse, String eventName) { ActivitiListener activitiListener = new ActivitiListener(); activitiListener.setEvent(eventName); activitiListener .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); activitiListener.setImplementation("#{" + taskListenerId + "}"); taskDefinition .addTaskListener(eventName, bpmnParse.getListenerFactory() .createDelegateExpressionTaskListener(activitiListener)); }
Example 11
Source File: BpmnJsonConverterUtil.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected static void parseListeners(JsonNode listenersNode, BaseElement element, boolean isTaskListener) { if (listenersNode == null) return; listenersNode = validateIfNodeIsTextual(listenersNode); for (JsonNode listenerNode : listenersNode) { listenerNode = validateIfNodeIsTextual(listenerNode); JsonNode eventNode = listenerNode.get(PROPERTY_LISTENER_EVENT); if (eventNode != null && eventNode.isNull() == false && StringUtils.isNotEmpty(eventNode.asText())) { ActivitiListener listener = new ActivitiListener(); listener.setEvent(eventNode.asText()); if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode))) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); listener.setImplementation(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode)); } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode))) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); listener.setImplementation(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode)); } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode))) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); listener.setImplementation(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode)); } JsonNode fieldsNode = listenerNode.get(PROPERTY_LISTENER_FIELDS); if (fieldsNode != null) { for (JsonNode fieldNode : fieldsNode) { JsonNode nameNode = fieldNode.get(PROPERTY_FIELD_NAME); if (nameNode != null && nameNode.isNull() == false && StringUtils.isNotEmpty(nameNode.asText())) { FieldExtension fieldExtension = new FieldExtension(); fieldExtension.setFieldName(nameNode.asText()); fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING_VALUE, fieldNode)); if (StringUtils.isEmpty(fieldExtension.getStringValue())) { fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING, fieldNode)); } if (StringUtils.isEmpty(fieldExtension.getStringValue())) { fieldExtension.setExpression(getValueAsString(PROPERTY_FIELD_EXPRESSION, fieldNode)); } listener.getFieldExtensions().add(fieldExtension); } } } if (element instanceof Process) { ((Process) element).getExecutionListeners().add(listener); } else if (element instanceof SequenceFlow) { ((SequenceFlow) element).getExecutionListeners().add(listener); } else if (element instanceof UserTask) { if (isTaskListener) { ((UserTask) element).getTaskListeners().add(listener); } else { ((UserTask) element).getExecutionListeners().add(listener); } } else if (element instanceof FlowElement) { ((FlowElement) element).getExecutionListeners().add(listener); } } } }