org.activiti.bpmn.model.Process Java Examples
The following examples show how to use
org.activiti.bpmn.model.Process.
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: ModelImageService.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected GraphicInfo calculateDiagramSize(BpmnModel bpmnModel) { GraphicInfo diagramInfo = new GraphicInfo(); for (Pool pool : bpmnModel.getPools()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId()); double elementMaxX = graphicInfo.getX() + graphicInfo.getWidth(); double elementMaxY = graphicInfo.getY() + graphicInfo.getHeight(); if (elementMaxX > diagramInfo.getWidth()) { diagramInfo.setWidth(elementMaxX); } if (elementMaxY > diagramInfo.getHeight()) { diagramInfo.setHeight(elementMaxY); } } for (Process process : bpmnModel.getProcesses()) { calculateWidthForFlowElements(process.getFlowElements(), bpmnModel, diagramInfo); calculateWidthForArtifacts(process.getArtifacts(), bpmnModel, diagramInfo); } return diagramInfo; }
Example #2
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 #3
Source File: IntermediateCatchEventValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<IntermediateCatchEvent> intermediateCatchEvents = process.findFlowElementsOfType(IntermediateCatchEvent.class); for (IntermediateCatchEvent intermediateCatchEvent : intermediateCatchEvents) { EventDefinition eventDefinition = null; if (!intermediateCatchEvent.getEventDefinitions().isEmpty()) { eventDefinition = intermediateCatchEvent.getEventDefinitions().get(0); } if (eventDefinition == null) { addError(errors, Problems.INTERMEDIATE_CATCH_EVENT_NO_EVENTDEFINITION, process, intermediateCatchEvent, "No event definition for intermediate catch event "); } else { if (!(eventDefinition instanceof TimerEventDefinition) && !(eventDefinition instanceof SignalEventDefinition) && !(eventDefinition instanceof MessageEventDefinition)) { addError(errors, Problems.INTERMEDIATE_CATCH_EVENT_INVALID_EVENTDEFINITION, process, intermediateCatchEvent, "Unsupported intermediate catch event type"); } } } }
Example #4
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 #5
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 #6
Source File: BpmnImageTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected GraphicInfo calculateDiagramSize(BpmnModel bpmnModel) { GraphicInfo diagramInfo = new GraphicInfo(); for (Pool pool : bpmnModel.getPools()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId()); double elementMaxX = graphicInfo.getX() + graphicInfo.getWidth(); double elementMaxY = graphicInfo.getY() + graphicInfo.getHeight(); if (elementMaxX > diagramInfo.getWidth()) { diagramInfo.setWidth(elementMaxX); } if (elementMaxY > diagramInfo.getHeight()) { diagramInfo.setHeight(elementMaxY); } } for (Process process : bpmnModel.getProcesses()) { calculateWidthForFlowElements(process.getFlowElements(), bpmnModel, diagramInfo); calculateWidthForArtifacts(process.getArtifacts(), bpmnModel, diagramInfo); } return diagramInfo; }
Example #7
Source File: JobDefinitionServiceImpl.java From herd with Apache License 2.0 | 6 votes |
/** * Asserts that the first asyncable task in the given model is indeed asynchronous. Only asserts when the configuration is set to true. * * @param bpmnModel The BPMN model */ private void assertFirstTaskIsAsync(BpmnModel bpmnModel) { if (Boolean.TRUE.equals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ASSERT_ASYNC, Boolean.class))) { Process process = bpmnModel.getMainProcess(); for (StartEvent startEvent : process.findFlowElementsOfType(StartEvent.class)) { for (SequenceFlow sequenceFlow : startEvent.getOutgoingFlows()) { String targetRef = sequenceFlow.getTargetRef(); FlowElement targetFlowElement = process.getFlowElement(targetRef); if (targetFlowElement instanceof Activity) { Assert.isTrue(((Activity) targetFlowElement).isAsynchronous(), "Element with id \"" + targetRef + "\" must be set to activiti:async=true. All tasks which start the workflow must be asynchronous to prevent certain undesired " + "transactional behavior, such as records of workflow not being saved on errors. Please refer to Activiti and herd documentations " + "for details."); } } } } }
Example #8
Source File: SubprocessValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class); for (SubProcess subProcess : subProcesses) { if (!(subProcess instanceof EventSubProcess)) { // Verify start events List<StartEvent> startEvents = process.findFlowElementsInSubProcessOfType(subProcess, StartEvent.class, false); if (startEvents.size() > 1) { addError(errors, Problems.SUBPROCESS_MULTIPLE_START_EVENTS, process, subProcess, "Multiple start events not supported for subprocess"); } for (StartEvent startEvent : startEvents) { if (!startEvent.getEventDefinitions().isEmpty()) { addError(errors, Problems.SUBPROCESS_START_EVENT_EVENT_DEFINITION_NOT_ALLOWED, process, startEvent, "event definitions only allowed on start event if subprocess is an event subprocess"); } } } } }
Example #9
Source File: EventValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<Event> events = process.findFlowElementsOfType(Event.class); for (Event event : events) { if (event.getEventDefinitions() != null) { for (EventDefinition eventDefinition : event.getEventDefinitions()) { if (eventDefinition instanceof MessageEventDefinition) { handleMessageEventDefinition(bpmnModel, process, event, eventDefinition, errors); } else if (eventDefinition instanceof SignalEventDefinition) { handleSignalEventDefinition(bpmnModel, process, event, eventDefinition, errors); } else if (eventDefinition instanceof TimerEventDefinition) { handleTimerEventDefinition(process, event, eventDefinition, errors); } else if (eventDefinition instanceof CompensateEventDefinition) { handleCompensationEventDefinition(bpmnModel, process, event, eventDefinition, errors); } } } } }
Example #10
Source File: CachingAndArtifactsManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Ensures that the process definition is cached in the appropriate places, including the * deployment's collection of deployed artifacts and the deployment manager's cache, as well * as caching any ProcessDefinitionInfos. */ public void updateCachingAndArtifacts(ParsedDeployment parsedDeployment) { CommandContext commandContext = Context.getCommandContext(); final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache = processEngineConfiguration.getDeploymentManager().getProcessDefinitionCache(); DeploymentEntity deployment = parsedDeployment.getDeployment(); for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { BpmnModel bpmnModel = parsedDeployment.getBpmnModelForProcessDefinition(processDefinition); Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition); ProcessDefinitionCacheEntry cacheEntry = new ProcessDefinitionCacheEntry(processDefinition, bpmnModel, process); processDefinitionCache.add(processDefinition.getId(), cacheEntry); addDefinitionInfoToCache(processDefinition, processEngineConfiguration, commandContext); // Add to deployment for further usage deployment.addDeployedArtifact(processDefinition); } }
Example #11
Source File: WorkflowBuilderTest.java From maven-framework-project with MIT License | 6 votes |
@Test public void testBuildDefault() { BpmnModel model = workflowBldr.defaultDocumentApprove(); Process process = model.getProcesses().get(0); SubProcess sub = (SubProcess)process.getFlowElement(Workflow.SUB_PROC_ID_DOC_APPROVAL); log.debug(sub.getName()); Collection<FlowElement> flowElements = sub.getFlowElements(); List<UserTask> userTasks = Lists.newArrayList(); for(FlowElement el : flowElements){ log.debug(el.getClass().getName() + " -- " + el.getId()); if (el.getClass().equals(org.activiti.bpmn.model.UserTask.class)){ userTasks.add((UserTask)(el)); } } int i = 1; for(UserTask uTask : userTasks){ Approval approval = new Approval(); approval.setPosition(i); i++; approval.setCandidateGroups(Lists.newArrayList(uTask.getCandidateGroups())); approval.setCandidateUsers(Lists.newArrayList(uTask.getCandidateUsers())); } }
Example #12
Source File: ServiceTaskValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void verifyType(Process process, ServiceTask serviceTask, List<ValidationError> errors) { if (StringUtils.isNotEmpty(serviceTask.getType())) { if (!serviceTask.getType().equalsIgnoreCase("mail") && !serviceTask.getType().equalsIgnoreCase("mule") && !serviceTask.getType().equalsIgnoreCase("camel") && !serviceTask.getType().equalsIgnoreCase("shell") && !serviceTask.getType().equalsIgnoreCase("dmn")) { addError(errors, Problems.SERVICE_TASK_INVALID_TYPE, process, serviceTask, "Invalid or unsupported service task type"); } if (serviceTask.getType().equalsIgnoreCase("mail")) { validateFieldDeclarationsForEmail(process, serviceTask, serviceTask.getFieldExtensions(), errors); } else if (serviceTask.getType().equalsIgnoreCase("shell")) { validateFieldDeclarationsForShell(process, serviceTask, serviceTask.getFieldExtensions(), errors); } else if (serviceTask.getType().equalsIgnoreCase("dmn")) { validateFieldDeclarationsForDmn(process, serviceTask, serviceTask.getFieldExtensions(), errors); } } }
Example #13
Source File: BpmnModelValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Returns 'true' if at least one process definition in the {@link BpmnModel} is executable. */ protected boolean validateAtLeastOneExecutable(BpmnModel bpmnModel, List<ValidationError> errors) { int nrOfExecutableDefinitions = 0; for (Process process : bpmnModel.getProcesses()) { if (process.isExecutable()) { nrOfExecutableDefinitions++; } } if (nrOfExecutableDefinitions == 0) { addError(errors, Problems.ALL_PROCESS_DEFINITIONS_NOT_EXECUTABLE, "All process definition are set to be non-executable (property 'isExecutable' on process). This is not allowed."); } return nrOfExecutableDefinitions > 0; }
Example #14
Source File: PoolsConverterTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void validateModel(BpmnModel model) { assertEquals(1, model.getPools().size()); Pool pool = model.getPools().get(0); assertEquals("pool1", pool.getId()); assertEquals("Pool", pool.getName()); Process process = model.getProcess(pool.getId()); assertNotNull(process); assertEquals(2, process.getLanes().size()); Lane lane = process.getLanes().get(0); assertEquals("lane1", lane.getId()); assertEquals("Lane 1", lane.getName()); assertEquals(2, lane.getFlowReferences().size()); lane = process.getLanes().get(1); assertEquals("lane2", lane.getId()); assertEquals("Lane 2", lane.getName()); assertEquals(2, lane.getFlowReferences().size()); FlowElement flowElement = process.getFlowElement("flow1"); assertNotNull(flowElement); assertTrue(flowElement instanceof SequenceFlow); }
Example #15
Source File: SendTaskValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void verifyWebservice(BpmnModel bpmnModel, Process process, SendTask sendTask, List<ValidationError> errors) { if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) { boolean operationFound = false; if (bpmnModel.getInterfaces() != null && !bpmnModel.getInterfaces().isEmpty()) { for (Interface bpmnInterface : bpmnModel.getInterfaces()) { if (bpmnInterface.getOperations() != null && !bpmnInterface.getOperations().isEmpty()) { for (Operation operation : bpmnInterface.getOperations()) { if (operation.getId() != null && operation.getId().equals(sendTask.getOperationRef())) { operationFound = true; } } } } } if (!operationFound) { addError(errors, Problems.SEND_TASK_WEBSERVICE_INVALID_OPERATION_REF, process, sendTask, "Invalid operation reference for send task"); } } }
Example #16
Source File: ActivitiTestCaseProcessValidator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeParse(BpmnModel bpmnModel, Process element) { for (FlowElement flowElement : element.getFlowElements()) { if (!ServiceTask.class.isAssignableFrom(flowElement.getClass())) { continue; } ServiceTask serviceTask = (ServiceTask) flowElement; validateAsyncAttribute(serviceTask, bpmnModel, flowElement); } }
Example #17
Source File: BpmnParseTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testParseDiagramInterchangeElements() { // Graphical information is not yet exposed publicly, so we need to do some plumbing BpmnModel bpmnModel = repositoryService.getBpmnModel(repositoryService.createProcessDefinitionQuery().singleResult().getId()); Process process = bpmnModel.getMainProcess(); // Check if diagram has been created based on Diagram Interchange when it's not a headless instance List<String> resourceNames = repositoryService.getDeploymentResourceNames(repositoryService.createProcessDefinitionQuery().singleResult().getDeploymentId()); assertEquals(2, resourceNames.size()); assertActivityBounds(bpmnModel, "theStart", 70, 255, 30, 30); assertActivityBounds(bpmnModel, "task1", 176, 230, 100, 80); assertActivityBounds(bpmnModel, "gateway1", 340, 250, 40, 40); assertActivityBounds(bpmnModel, "task2", 445, 138, 100, 80); assertActivityBounds(bpmnModel, "gateway2", 620, 250, 40, 40); assertActivityBounds(bpmnModel, "task3", 453, 304, 100, 80); assertActivityBounds(bpmnModel, "theEnd", 713, 256, 28, 28); assertSequenceFlowWayPoints(bpmnModel, "flowStartToTask1", 100, 270, 176, 270); assertSequenceFlowWayPoints(bpmnModel, "flowTask1ToGateway1", 276, 270, 340, 270); assertSequenceFlowWayPoints(bpmnModel, "flowGateway1ToTask2", 360, 250, 360, 178, 445, 178); assertSequenceFlowWayPoints(bpmnModel, "flowGateway1ToTask3", 360, 290, 360, 344, 453, 344); assertSequenceFlowWayPoints(bpmnModel, "flowTask2ToGateway2", 545, 178, 640, 178, 640, 250); assertSequenceFlowWayPoints(bpmnModel, "flowTask3ToGateway2", 553, 344, 640, 344, 640, 290); assertSequenceFlowWayPoints(bpmnModel, "flowGateway2ToEnd", 660, 270, 713, 270); }
Example #18
Source File: ScriptTaskValidator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<ScriptTask> scriptTasks = process.findFlowElementsOfType(ScriptTask.class); for (ScriptTask scriptTask : scriptTasks) { if (StringUtils.isEmpty(scriptTask.getScript())) { addError(errors, Problems.SCRIPT_TASK_MISSING_SCRIPT, process, scriptTask, "No script provided for script task"); } } }
Example #19
Source File: LaneExtensionTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Test @Deployment public void testLaneExtensionElement() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("swimlane-extension").singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel); System.out.println(new String(xml)); Process bpmnProcess = bpmnModel.getMainProcess(); for (Lane l : bpmnProcess.getLanes()) { Map<String, List<ExtensionElement>> extensions = l.getExtensionElements(); Assert.assertTrue(extensions.size() > 0); } }
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)).deploy(); repositoryService.deleteDeployment(deployment.getId()); }
Example #21
Source File: SyncProcessCmd.java From lemon with Apache License 2.0 | 5 votes |
/** * 全局配置. */ public void processGlobal(BpmnModel bpmnModel, int priority, BpmConfBase bpmConfBase) { Process process = bpmnModel.getMainProcess(); BpmConfNodeManager bpmConfNodeManager = getBpmConfNodeManager(); BpmConfNode bpmConfNode = bpmConfNodeManager.findUnique( "from BpmConfNode where code=? and bpmConfBase=?", process.getId(), bpmConfBase); if (bpmConfNode == null) { bpmConfNode = new BpmConfNode(); bpmConfNode.setCode(""); bpmConfNode.setName("全局"); bpmConfNode.setType("process"); bpmConfNode.setConfUser(2); bpmConfNode.setConfListener(0); bpmConfNode.setConfRule(2); bpmConfNode.setConfForm(0); bpmConfNode.setConfOperation(2); bpmConfNode.setConfNotice(2); bpmConfNode.setPriority(priority); bpmConfNode.setBpmConfBase(bpmConfBase); bpmConfNodeManager.save(bpmConfNode); } // 配置监听器 processListener(process.getExecutionListeners(), bpmConfNode); }
Example #22
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 #23
Source File: ProcessExport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static void writeProcess(Process process, XMLStreamWriter xtw) throws Exception { // start process element xtw.writeStartElement(ELEMENT_PROCESS); xtw.writeAttribute(ATTRIBUTE_ID, process.getId()); if (StringUtils.isNotEmpty(process.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, process.getName()); } xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable())); if (!process.getCandidateStarterUsers().isEmpty()) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers())); } if (!process.getCandidateStarterGroups().isEmpty()) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups())); } // write custom attributes BpmnXMLUtil.writeCustomAttributes(process.getAttributes().values(), xtw, defaultProcessAttributes); if (StringUtils.isNotEmpty(process.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(process.getDocumentation()); xtw.writeEndElement(); } boolean didWriteExtensionStartElement = ActivitiListenerExport.writeListeners(process, false, xtw); didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(process, didWriteExtensionStartElement, xtw); if (didWriteExtensionStartElement) { // closing extensions element xtw.writeEndElement(); } LaneExport.writeLanes(process, xtw); }
Example #24
Source File: EventValidator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void handleCompensationEventDefinition(BpmnModel bpmnModel, Process process, Event event, EventDefinition eventDefinition, List<ValidationError> errors) { CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) eventDefinition; // Check activityRef if ((StringUtils.isNotEmpty(compensateEventDefinition.getActivityRef()) && process.getFlowElement(compensateEventDefinition.getActivityRef(), true) == null)) { addError(errors, Problems.COMPENSATE_EVENT_INVALID_ACTIVITY_REF, process, event, "Invalid attribute value for 'activityRef': no activity with the given id"); } }
Example #25
Source File: BpmnXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected FlowNode getFlowNodeFromScope(String elementId, BaseElement scope) { FlowNode flowNode = null; if (StringUtils.isNotEmpty(elementId)) { if (scope instanceof Process) { flowNode = (FlowNode) ((Process) scope).getFlowElement(elementId); } else if (scope instanceof SubProcess) { flowNode = (FlowNode) ((SubProcess) scope).getFlowElement(elementId); } } return flowNode; }
Example #26
Source File: ActivitiEventListenerParser.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { EventListener listener = new EventListener(); 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_DELEGATEEXPRESSION))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE))) { String eventType = xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE); if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_SIGNAL.equals(eventType)) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT); listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME)); } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_GLOBAL_SIGNAL.equals(eventType)) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT); listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME)); } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_MESSAGE.equals(eventType)) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT); listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_MESSAGE_EVENT_NAME)); } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_ERROR.equals(eventType)) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT); listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_ERROR_EVENT_CODE)); } else { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT); } } listener.setEvents(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENTS)); listener.setEntityType(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_ENTITY_TYPE)); Process parentProcess = (Process) parentElement; parentProcess.getEventListeners().add(listener); }
Example #27
Source File: ValidatorImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void addError(List<ValidationError> validationErrors, String problem, Process process, String id, String description) { ValidationError error = new ValidationError(); if (process != null) { error.setProcessDefinitionId(process.getId()); error.setProcessDefinitionName(process.getName()); } error.setProblem(problem); error.setDefaultDescription(description); error.setActivityId(id); addError(validationErrors, error); }
Example #28
Source File: BpmnParse.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Parses the 'definitions' root element */ protected void applyParseHandlers() { sequenceFlows = new HashMap<String, SequenceFlow>(); for (Process process : bpmnModel.getProcesses()) { currentProcess = process; if (process.isExecutable()) { bpmnParserHandlers.parseElement(this, process); } } }
Example #29
Source File: ProcessParseHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) { ProcessDefinitionEntity currentProcessDefinition = Context.getCommandContext().getProcessDefinitionEntityManager().create(); bpmnParse.setCurrentProcessDefinition(currentProcessDefinition); /* * Mapping object model - bpmn xml: processDefinition.id -> generated by activiti engine processDefinition.key -> bpmn id (required) processDefinition.name -> bpmn name (optional) */ currentProcessDefinition.setKey(process.getId()); currentProcessDefinition.setName(process.getName()); currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace()); currentProcessDefinition.setDescription(process.getDocumentation()); currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId()); if (bpmnParse.getDeployment().getEngineVersion() != null) { currentProcessDefinition.setEngineVersion(bpmnParse.getDeployment().getEngineVersion()); } createEventListeners(bpmnParse, process.getEventListeners()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey()); } bpmnParse.processFlowElements(process.getFlowElements()); processArtifacts(bpmnParse, process.getArtifacts()); return currentProcessDefinition; }
Example #30
Source File: UserTaskValidator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<UserTask> userTasks = process.findFlowElementsOfType(UserTask.class); for (UserTask userTask : userTasks) { if (userTask.getTaskListeners() != null) { for (ActivitiListener listener : userTask.getTaskListeners()) { if (listener.getImplementation() == null || listener.getImplementationType() == null) { addError(errors, Problems.USER_TASK_LISTENER_IMPLEMENTATION_MISSING, process, userTask, "Element 'class' or 'expression' is mandatory on executionListener"); } } } } }