Java Code Examples for org.activiti.bpmn.model.BpmnModel#getProcesses()
The following examples show how to use
org.activiti.bpmn.model.BpmnModel#getProcesses() .
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: 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 2
Source File: ActivitiTestCaseProcessValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public List<ValidationError> validate(BpmnModel bpmnModel) { List<ValidationError> errorList = new ArrayList<ValidationError>(); CustomParseValidator customParseValidator = new CustomParseValidator(); for (Process process : bpmnModel.getProcesses()) { customParseValidator.executeParse(bpmnModel, process); } for (String errorRef : bpmnModel.getErrors().keySet()) { ValidationError error = new ValidationError(); error.setValidatorSetName("Manual BPMN parse validator"); error.setProblem(errorRef); error.setActivityId(bpmnModel.getErrors().get(errorRef)); errorList.add(error); } return errorList; }
Example 3
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 4
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 5
Source File: BpmnModelValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void validate(BpmnModel bpmnModel, List<ValidationError> errors) { // If all process definitions of this bpmnModel are not executable, raise an error boolean isAtLeastOneExecutable = validateAtLeastOneExecutable(bpmnModel, errors); // If at least one process definition is executable, show a warning for each of the none-executables if (isAtLeastOneExecutable) { for (Process process : bpmnModel.getProcesses()) { if (!process.isExecutable()) { addWarning(errors, Problems.PROCESS_DEFINITION_NOT_EXECUTABLE, process, process, "Process definition is not executable. Please verify that this is intentional."); } handleProcessConstraints(bpmnModel, process, errors); } } handleBPMNModelConstraints(bpmnModel, errors); }
Example 6
Source File: ActivitiTestCaseProcessValidator.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public List<ValidationError> validate(BpmnModel bpmnModel) { List<ValidationError> errorList = new ArrayList<ValidationError>(); CustomParseValidator customParseValidator = new CustomParseValidator(); for (Process process : bpmnModel.getProcesses()) { customParseValidator.executeParse(bpmnModel, process); } for (String errorRef : bpmnModel.getErrors().keySet()) { ValidationError error = new ValidationError(); error.setValidatorSetName("Manual BPMN parse validator"); error.setProblem(errorRef); error.setActivityId(bpmnModel.getErrors().get(errorRef)); errorList.add(error); } return errorList; }
Example 7
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 8
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 9
Source File: BpmnImageTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void scaleDiagram(BpmnModel bpmnModel, double scaleFactor) { for (Pool pool : bpmnModel.getPools()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId()); scaleGraphicInfo(graphicInfo, scaleFactor); } for (Process process : bpmnModel.getProcesses()) { scaleFlowElements(process.getFlowElements(), bpmnModel, scaleFactor); scaleArtifacts(process.getArtifacts(), bpmnModel, scaleFactor); for (Lane lane : process.getLanes()) { scaleGraphicInfo(bpmnModel.getGraphicInfo(lane.getId()), scaleFactor); } } }
Example 10
Source File: ModelImageService.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void scaleDiagram(BpmnModel bpmnModel, double scaleFactor) { for (Pool pool : bpmnModel.getPools()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId()); scaleGraphicInfo(graphicInfo, scaleFactor); } for (Process process : bpmnModel.getProcesses()) { scaleFlowElements(process.getFlowElements(), bpmnModel, scaleFactor); scaleArtifacts(process.getArtifacts(), bpmnModel, scaleFactor); for (Lane lane : process.getLanes()) { scaleGraphicInfo(bpmnModel.getGraphicInfo(lane.getId()), scaleFactor); } } }
Example 11
Source File: ModelServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public byte[] getBpmnXML(BpmnModel bpmnModel) { for (Process process : bpmnModel.getProcesses()) { if (StringUtils.isNotEmpty(process.getId())) { char firstCharacter = process.getId().charAt(0); // no digit is allowed as first character if (Character.isDigit(firstCharacter)) { process.setId("a" + process.getId()); } } } byte[] xmlBytes = bpmnXMLConverter.convertToXML(bpmnModel); return xmlBytes; }
Example 12
Source File: DefaultProcessDiagramGenerator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static List<Artifact> gatherAllArtifacts(BpmnModel bpmnModel) { List<Artifact> artifacts = new ArrayList<Artifact>(); for (Process process : bpmnModel.getProcesses()) { artifacts.addAll(process.getArtifacts()); } return artifacts; }
Example 13
Source File: DefaultProcessDiagramGenerator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static List<FlowNode> gatherAllFlowNodes(BpmnModel bpmnModel) { List<FlowNode> flowNodes = new ArrayList<FlowNode>(); for (Process process : bpmnModel.getProcesses()) { flowNodes.addAll(gatherAllFlowNodes(process)); } return flowNodes; }
Example 14
Source File: CustomProcessDiagramGenerator.java From lemon with Apache License 2.0 | 5 votes |
protected static List<Artifact> gatherAllArtifacts(BpmnModel bpmnModel) { List<Artifact> artifacts = new ArrayList<Artifact>(); for (org.activiti.bpmn.model.Process process : bpmnModel.getProcesses()) { artifacts.addAll(process.getArtifacts()); } return artifacts; }
Example 15
Source File: CustomProcessDiagramGenerator.java From lemon with Apache License 2.0 | 5 votes |
protected static List<FlowNode> gatherAllFlowNodes(BpmnModel bpmnModel) { List<FlowNode> flowNodes = new ArrayList<FlowNode>(); for (org.activiti.bpmn.model.Process process : bpmnModel.getProcesses()) { flowNodes.addAll(gatherAllFlowNodes(process)); } return flowNodes; }
Example 16
Source File: ProcessLevelValidator.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void validate(BpmnModel bpmnModel, List<ValidationError> errors) { for (Process process : bpmnModel.getProcesses()) { executeValidation(bpmnModel, process, errors); } }
Example 17
Source File: SubprocessXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public byte[] convertToXML(BpmnModel model, String encoding) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer); DefinitionsRootExport.writeRootElement(model, xtw, encoding); CollaborationExport.writePools(model, xtw); DataStoreExport.writeDataStores(model, xtw); SignalAndMessageDefinitionExport.writeSignalsAndMessages(model, xtw); for (Process process : model.getProcesses()) { if (process.getFlowElements().isEmpty() && process.getLanes().isEmpty()) { // empty process, ignore it continue; } ProcessExport.writeProcess(process, xtw); for (FlowElement flowElement : process.getFlowElements()) { createXML(flowElement, model, xtw); } for (Artifact artifact : process.getArtifacts()) { createXML(artifact, model, xtw); } // end process element xtw.writeEndElement(); } // refactor each subprocess into a separate Diagram List<BpmnModel> subModels = parseSubModels(model); for (BpmnModel tempModel : subModels) { if (!tempModel.getFlowLocationMap().isEmpty() || !tempModel.getLocationMap().isEmpty()) { BPMNDIExport.writeBPMNDI(tempModel, xtw); } } // end definitions root element xtw.writeEndElement(); xtw.writeEndDocument(); xtw.flush(); byte[] bytes = outputStream.toByteArray().clone(); // cleanup outputStream.close(); xtw.close(); return bytes; } catch (Exception e) { LOGGER.error("Error writing BPMN XML", e); throw new XMLException("Error writing BPMN XML", e); } }
Example 18
Source File: BpmnXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public byte[] convertToXML(BpmnModel model, String encoding) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer); DefinitionsRootExport.writeRootElement(model, xtw, encoding); CollaborationExport.writePools(model, xtw); DataStoreExport.writeDataStores(model, xtw); SignalAndMessageDefinitionExport.writeSignalsAndMessages(model, xtw); for (Process process : model.getProcesses()) { if (process.getFlowElements().isEmpty() && process.getLanes().isEmpty()) { // empty process, ignore it continue; } ProcessExport.writeProcess(process, xtw); for (FlowElement flowElement : process.getFlowElements()) { createXML(flowElement, model, xtw); } for (Artifact artifact : process.getArtifacts()) { createXML(artifact, model, xtw); } // end process element xtw.writeEndElement(); } BPMNDIExport.writeBPMNDI(model, xtw); // end definitions root element xtw.writeEndElement(); xtw.writeEndDocument(); xtw.flush(); outputStream.close(); xtw.close(); return outputStream.toByteArray(); } catch (Exception e) { LOGGER.error("Error writing BPMN XML", e); throw new XMLException("Error writing BPMN XML", e); } }
Example 19
Source File: DeploymentServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override @Transactional public Deployment updateAppDefinition(Model appDefinitionModel, User user) { Deployment deployment = null; AppDefinition appDefinition = resolveAppDefinition(appDefinitionModel); if (CollectionUtils.isNotEmpty(appDefinition.getModels())) { DeploymentBuilder deploymentBuilder = repositoryService.createDeployment() .name(appDefinitionModel.getName()) .key(appDefinitionModel.getKey()); Map<String, Model> formMap = new HashMap<String, Model>(); Map<String, Model> decisionTableMap = new HashMap<String, Model>(); for (AppModelDefinition appModelDef : appDefinition.getModels()) { AbstractModel processModel = modelService.getModel(appModelDef.getId()); if (processModel == null) { logger.error("Model " + appModelDef.getId() + " for app definition " + appDefinitionModel.getId() + " could not be found"); throw new BadRequestException("Model for app definition could not be found"); } List<Model> referencedModels = modelRepository.findModelsByParentModelId(processModel.getId()); for (Model childModel : referencedModels) { if (Model.MODEL_TYPE_FORM == childModel.getModelType()) { formMap.put(childModel.getId(), childModel); } else if (Model.MODEL_TYPE_DECISION_TABLE == childModel.getModelType()) { decisionTableMap.put(childModel.getId(), childModel); } } BpmnModel bpmnModel = modelService.getBpmnModel(processModel, formMap, decisionTableMap); Map<String, StartEvent> startEventMap = processNoneStartEvents(bpmnModel); for (Process process : bpmnModel.getProcesses()) { processUserTasks(process.getFlowElements(), process, startEventMap); } byte[] modelXML = modelService.getBpmnXML(bpmnModel); deploymentBuilder.addInputStream(processModel.getKey().replaceAll(" ", "") + ".bpmn", new ByteArrayInputStream(modelXML)); } if (formMap.size() > 0) { for (String formId : formMap.keySet()) { Model formInfo = formMap.get(formId); deploymentBuilder.addString("form-" + formInfo.getKey() + ".form", formInfo.getModelEditorJson()); } } if (decisionTableMap.size() > 0) { for (String decisionTableId : decisionTableMap.keySet()) { Model decisionTableInfo = decisionTableMap.get(decisionTableId); try { JsonNode decisionTableNode = objectMapper.readTree(decisionTableInfo.getModelEditorJson()); DmnDefinition dmnDefinition = dmnJsonConverter.convertToDmn(decisionTableNode, decisionTableInfo.getId(), decisionTableInfo.getVersion(), decisionTableInfo.getLastUpdated()); byte[] dmnXMLBytes = dmnXMLConverter.convertToXML(dmnDefinition); deploymentBuilder.addBytes("dmn-" + decisionTableInfo.getKey() + ".dmn", dmnXMLBytes); } catch (Exception e) { logger.error("Error converting decision table to XML " + decisionTableInfo.getName(), e); throw new InternalServerErrorException("Error converting decision table to XML " + decisionTableInfo.getName()); } } } deployment = deploymentBuilder.deploy(); } return deployment; }