Java Code Examples for org.flowable.bpmn.model.BpmnModel#getProcesses()
The following examples show how to use
org.flowable.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: AppDefinitionExportService.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void createBpmnZipEntries(Collection<Model> models, ZipOutputStream zipOutputStream, ConverterContext converterContext) throws Exception { for (Model model : models) { BpmnModel bpmnModel = modelService.getBpmnModel(model, converterContext); Map<String, StartEvent> noneStartEventMap = new HashMap<>(); postProcessFlowElements(new ArrayList<>(), noneStartEventMap, bpmnModel); for (Process process : bpmnModel.getProcesses()) { processUserTasks(process.getFlowElements(), process, noneStartEventMap); } byte[] modelXML = modelService.getBpmnXML(bpmnModel); // add BPMN XML model createZipEntry(zipOutputStream, "bpmn-models/" + model.getKey().replaceAll(" ", "") + ".bpmn", modelXML); // add JSON model createZipEntries(model, "bpmn-models", zipOutputStream); } }
Example 2
Source File: ModelImageService.java From flowable-engine 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 3
Source File: ActivitiTestCaseProcessValidator.java From flowable-engine 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 4
Source File: FlowableTestCaseProcessValidator.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public List<ValidationError> validate(BpmnModel bpmnModel) { List<ValidationError> errorList = new ArrayList<>(); 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 5
Source File: BpmnModelValidator.java From flowable-engine 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: BpmnModelValidator.java From flowable-engine 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 7
Source File: ResourceParser.java From flowable-engine 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.flowable.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 8
Source File: DefaultProcessDiagramGenerator.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static List<Artifact> gatherAllArtifacts(BpmnModel bpmnModel) { List<Artifact> artifacts = new ArrayList<>(); for (Process process : bpmnModel.getProcesses()) { artifacts.addAll(process.getArtifacts()); } return artifacts; }
Example 9
Source File: DefaultProcessDiagramGenerator.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static List<FlowNode> gatherAllFlowNodes(BpmnModel bpmnModel) { List<FlowNode> flowNodes = new ArrayList<>(); for (Process process : bpmnModel.getProcesses()) { flowNodes.addAll(gatherAllFlowNodes(process)); } return flowNodes; }
Example 10
Source File: ModelServiceImpl.java From flowable-engine 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 11
Source File: AppDefinitionExportService.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void createBpmnZipEntries(List<AppModelDefinition> modelDefinitions, ZipOutputStream zipOutputStream, ConverterContext converterContext) throws Exception { for (AppModelDefinition modelDef : modelDefinitions) { Model model = modelService.getModel(modelDef.getId()); List<Model> referencedModels = modelRepository.findByParentModelId(model.getId()); for (Model childModel : referencedModels) { if (Model.MODEL_TYPE_FORM == childModel.getModelType()) { converterContext.addFormModel(childModel); } else if (Model.MODEL_TYPE_DECISION_TABLE == childModel.getModelType()) { converterContext.addDecisionTableModel(childModel); } else if (Model.MODEL_TYPE_DECISION_SERVICE == childModel.getModelType()) { converterContext.addDecisionServiceModel(childModel); List<Model> referencedDecisionTableModels = modelRepository.findByParentModelId(childModel.getId()); referencedDecisionTableModels.stream() .filter(refModel -> Model.MODEL_TYPE_DECISION_TABLE == refModel.getModelType()) .forEach(converterContext::addDecisionTableModel); } } BpmnModel bpmnModel = modelService.getBpmnModel(model, converterContext); Map<String, StartEvent> noneStartEventMap = new HashMap<>(); postProcessFlowElements(new ArrayList<>(), noneStartEventMap, bpmnModel); for (Process process : bpmnModel.getProcesses()) { processUserTasks(process.getFlowElements(), process, noneStartEventMap); } byte[] modelXML = modelService.getBpmnXML(bpmnModel); // add BPMN XML model createZipEntry(zipOutputStream, "bpmn-models/" + model.getKey().replaceAll(" ", "") + ".bpmn", modelXML); // add JSON model createZipEntries(model, "bpmn-models", zipOutputStream); } }
Example 12
Source File: ModelImageService.java From flowable-engine 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 13
Source File: BaseAppDefinitionService.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void postProcessFlowElements(List<FlowElement> eventRegistryElements, Map<String, StartEvent> noneStartEventMap, BpmnModel bpmnModel) { for (Process process : bpmnModel.getProcesses()) { postProcessFlowElements(process.getFlowElements(), eventRegistryElements, noneStartEventMap, process.getId(), bpmnModel); } }
Example 14
Source File: ProcessLevelValidator.java From flowable-engine 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 15
Source File: BpmnXMLConverter.java From flowable-engine 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); EscalationDefinitionExport.writeEscalations(model, xtw); for (Process process : model.getProcesses()) { if (process.getFlowElements().isEmpty() && process.getLanes().isEmpty()) { // empty process, ignore it continue; } ProcessExport.writeProcess(process, model, 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); } }