Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements(); Map<String, GraphicInfo> locations = new HashMap<String, GraphicInfo>(); Map<String, List<GraphicInfo>> flowLocations = new HashMap<String, List<GraphicInfo>>(); mainModel.addProcess(model.getMainProcess());
if (bpmnModel.getMainProcess() == null) { throw new UnsupportedOperationException("无法导出模型文件:" + type); byte[] exportBytes = null; String mainProcessId = bpmnModel.getMainProcess().getId();
processId = "Collaboration"; } else { processId = model.getMainProcess().getId();
ValuedDataObject foundDataObject = null; if (executionEntity.getParentId() == null) { for (ValuedDataObject dataObject : bpmnModel.getMainProcess().getDataObjects()) { if (dataObject.getName().equals(variableEntity.getName())) { foundDataObject = dataObject;
ValuedDataObject foundDataObject = null; if (executionEntity.getParentId() == null) { for (ValuedDataObject dataObject : bpmnModel.getMainProcess().getDataObjects()) { if (dataObject.getName().equals(variableEntity.getName())) { foundDataObject = dataObject;
mainProcess = model.getProcess(model.getPools().get(0).getId()); } else { mainProcess = model.getMainProcess(); shapesArrayNode); } else { processFlowElements(model.getMainProcess(), model, shapesArrayNode,
ValuedDataObject foundDataObject = null; if (executionEntity.getParentId() == null) { for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) { if (dataObjectDefinition.getName().equals(variableEntity.getName())) { foundDataObject = dataObjectDefinition;
ValuedDataObject foundDataObject = null; if (executionEntity.getParentId() == null) { for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) { if (dataObjectDefinition.getName().equals(variableEntity.getName())) { foundDataObject = dataObjectDefinition;
/** * 导出model的xml文件 */ @RequestMapping(value = "/model/export/xml/{modelId}", method = RequestMethod.GET) public void exportXml(@PathVariable("modelId") String modelId, HttpServletResponse response) { try { Model modelData = repositoryService.getModel(modelId); BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); JsonNode editorNode = objectMapper.readTree(repositoryService.getModelEditorSource(modelData.getId())); BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); BpmnXMLConverter xmlConverter = new BpmnXMLConverter(); //没有xml if (bpmnModel.getProcesses().isEmpty()) { response.setCharacterEncoding("utf-8"); response.getWriter().print("<script>modals.error('xml文件不存在,生成错误');</script>"); response.flushBuffer(); return; } byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel); ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes); IOUtils.copy(in, response.getOutputStream()); String filename = bpmnModel.getMainProcess().getId() + ".bpmn20.model.xml"; response.setHeader("Content-Disposition", "attachment; filename=" + filename); response.flushBuffer(); } catch (Exception e) { LOGGER.error("导出model的xml文件失败:modelId={}", modelId, e); } }
public static void importModel(RepositoryService repositoryService, File modelFile) throws IOException, XMLStreamException { InputStreamReader reader = new InputStreamReader(new FileInputStream(modelFile), "utf-8"); String fileContent = IOUtils.readStringAndClose(reader, (int) modelFile.length()); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(new StringStreamSourceEx(fileContent), false, false); String processName = bpmnModel.getMainProcess().getName(); if (processName == null || processName.isEmpty()) { processName = bpmnModel.getMainProcess().getId(); } Model modelData = repositoryService.newModel(); ObjectNode modelObjectNode = new ObjectMapper().createObjectNode(); modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processName); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); modelData.setMetaInfo(modelObjectNode.toString()); modelData.setName(processName); modelData.setKey(modelFile.getName()); repositoryService.saveModel(modelData); repositoryService.addModelEditorSource(modelData.getId(), fileContent.getBytes("utf-8")); Logger.getLogger(ModelUtils.class) .info(String.format("importing model file: %s", modelFile.getCanonicalPath())); } }
@RequestMapping(value = "/model/export/{id}", method = RequestMethod.GET) public void exportToXml(@PathVariable("id") String id, HttpServletResponse response) { try { Model modelData = repositoryService.getModel(id); BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); BpmnXMLConverter xmlConverter = new BpmnXMLConverter(); byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel); ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes); IOUtils.copy(in, response.getOutputStream()); String filename = bpmnModel.getMainProcess().getId() + ".bpmn20.xml"; response.setHeader("Content-Disposition", "attachment; filename=" + filename); response.flushBuffer(); } catch (Exception e) { throw new ActivitiException("导出model的xml文件失败,模型ID=" + id, e); } }
Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements(); Map<String, GraphicInfo> locations = new HashMap<String, GraphicInfo>(); Map<String, List<GraphicInfo>> flowLocations = new HashMap<String, List<GraphicInfo>>(); mainModel.addProcess(model.getMainProcess());
if (bpmnModel.getMainProcess() == null) { throw new UnsupportedOperationException("无法导出模型文件:" + type); byte[] exportBytes = null; String mainProcessId = bpmnModel.getMainProcess().getId();
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) { notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION)); if (StringUtils.isNotEmpty(bpmnModel.getMainProcess().getName())) { processName = bpmnModel.getMainProcess().getName(); } else { processName = bpmnModel.getMainProcess().getId();
/** * 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."); } } } } }
/** * 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."); } } } } }
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) { notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION));
FlowElement startEvent = null, endEvent = null; LinkedList<ActivityNode> nodes = new LinkedList<ActivityNode>(); Collection<FlowElement> elements = bpmnModel.getMainProcess().getFlowElements(); for (FlowElement element : elements) { if (element instanceof StartEvent) {
BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); BpmnModel model = jsonConverter.convertToBpmnModel(editorNode); filename = model.getMainProcess().getId() + ".bpmn20.xml"; bpmnBytes = new BpmnXMLConverter().convertToXML(model);
ValuedDataObject foundDataObject = null; if (executionEntity.getParentId() == null) { for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) { if (dataObjectDefinition.getName().equals(variableEntity.getName())) { foundDataObject = dataObjectDefinition;