activiti 根据模型ID导出、预览 xml文件

    /**根据模型ID导出xml文件
     * @param response
     * @param modelId    //模型ID
     * @from  fhadmin.cn
     */
    protected void exportXmlFromModelId(HttpServletResponse response, String modelId) throws Exception{
        Model modelData = repositoryService.getModel(modelId);  
        BpmnJsonConverter jsonConverter = new BpmnJsonConverter();  
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(modelNode);  
        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(); */
        FileUpload.copyFile(in,PathUtil.getProjectpath()+Const.FILEACTIVITI,filename);         //把文件上传到文件目录里面
        FileDownload.fileDownload(response, PathUtil.getProjectpath()+Const.FILEACTIVITI+filename, filename);
        in.close();
    }
    
    /**根据模型ID预览xml文件
     * @param response
     * @param modelId    //模型ID
     * @from  fhadmin.org
     */
    protected String viewXmlFromModelId(String modelId) throws Exception{
        Model modelData = repositoryService.getModel(modelId);  
        BpmnJsonConverter jsonConverter = new BpmnJsonConverter();  
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(modelNode);  
        BpmnXMLConverter xmlConverter = new BpmnXMLConverter();  
        byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);  
        ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);  
        InputStreamReader isr = new InputStreamReader(in,"utf-8");
        BufferedReader bufferedReader = new BufferedReader(isr);
        StringBuffer xmlContent = new StringBuffer(); 
        String lineTxt = null;
        while ((lineTxt = bufferedReader.readLine()) != null) {
            xmlContent.append(lineTxt);
            xmlContent.append("\n");
        }
        isr.close();
        return xmlContent.toString();
    }
 

--------------------fhadmin.cn----------------------------------------------自定义表单
28. 定义模版:拖拽左侧表单元素到右侧区域,编辑表单元素,保存表单模版
29. 表单模版:编辑维护表单模版,复制表单模版,修改模版类型,预览表单模版
30. 我的表单:选择表单模版,编辑表单规则,是否上传图片、附件、开启富文本、挂靠流程开关等
31. 表单数据:从我的表单进去可增删改查表单数据,修改表单规则
32. 挂靠记录:记录表单数据和流程实例ID关联记录,可删除

posted @ 2021-10-27 10:36  m17098136262_1  阅读(350)  评论(0编辑  收藏  举报