<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 59, comments - 244, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    JBPM4.4發(fā)布zip流程包和流程圖顯示

    Posted on 2010-10-02 11:15 penngo 閱讀(8035) 評論(5)  編輯  收藏 所屬分類: JBPM
    上一篇在spring mvc下發(fā)布jbpm流程只介紹了發(fā)布jpdl的流程定義文件,并沒有把流程圖也一起發(fā)布,本篇將把流程定義文件和流程圖一起打包為zip格式發(fā)布。

    先介紹jbpm流程設(shè)計(jì)器開發(fā)(3)的代碼修改
    com.workflow.designer.view.Menu.java代碼,主要是增加生成圖片和把jpdl和圖片打包為zip文件。
     1saveItem.addActionListener(new ActionListener(){
     2            public void actionPerformed(ActionEvent e)
     3            {
     4                JFileChooser fileChooser = new JFileChooser();
     5                fileChooser.setFileFilter(new FileNameExtensionFilter("zip""zip"));
     6                int result = fileChooser.showSaveDialog(Menu.this);
     7                if(result == fileChooser.APPROVE_OPTION){
     8                    String path = fileChooser.getSelectedFile().getAbsolutePath();
     9                    Map<String, InputStream> map = new Hashtable<String, InputStream>();
    10                    SaveJpdl saveJpdl = new SaveJpdl();
    11                    saveJpdl.save(map, gv.getGraph());    
    12                    try{
    13                        Color bg = null;
    14                        bg = gv.getBackground();
    15                        BufferedImage image = mxCellRenderer
    16                        .createBufferedImage(gv.getGraph(), null1, bg,
    17                                gv.isAntiAlias(), gv.getLayoutAreaSize(),
    18                                gv.getCanvas());
    19                        ByteArrayOutputStream bs = new ByteArrayOutputStream(); 
    20                        ImageOutputStream imOut = ImageIO.createImageOutputStream(bs); 
    21                        ImageIO.write(image, "png", imOut);
    22                        InputStream is = new ByteArrayInputStream(bs.toByteArray());
    23                        map.put("process.png", is);
    24                        ZipUtil.saveZip(path + ".zip", map);
    25                    }

    26                    catch(Exception ex){
    27                        ex.printStackTrace();
    28                    }

    29                }

    30            }

    31        }
    );

    ZipUtil生成zip文件。
     1public class ZipUtil {
     2    //調(diào)用該方法生成zip文件
     3    public static void saveZip(String fileName, Map<String, InputStream> dataMap) {
     4        try {
     5            FileOutputStream fos = new FileOutputStream(fileName);
     6            JarOutputStream jos = new JarOutputStream(fos);
     7            byte buf[] = new byte[256];
     8            if (dataMap != null{
     9                Set<Entry<String, InputStream>> entrySet = dataMap.entrySet();
    10                int len = -1;
    11                for (Entry<String, InputStream> entry : entrySet) {
    12                    String name = entry.getKey();
    13                    InputStream inputStream = entry.getValue();
    14                    if (name != null && inputStream != null{
    15                        BufferedInputStream bis = new BufferedInputStream(
    16                                inputStream);
    17                        JarEntry jarEntry = new JarEntry(name);
    18                        jos.putNextEntry(jarEntry);
    19
    20                        while ((len = bis.read(buf)) >= 0{
    21                            jos.write(buf, 0, len);
    22                        }

    23
    24                        bis.close();
    25                        jos.closeEntry();
    26                    }

    27                }

    28            }

    29            jos.flush();
    30            jos.close();
    31            fos.flush();
    32            fos.close();
    33        }
     catch (Exception ex) {
    34            throw new RuntimeException(ex);
    35        }

    36    }

    37}

    繼續(xù)使用上一篇在spring mvc下發(fā)布jbpm流程代碼發(fā)布流程
    類com.mvc.rest.RestController修改
     1@Controller
     2public class RestController {
     3
     4    public RestController() {
     5
     6    }

     7
     8    @RequestMapping(value = "/welcome", method = RequestMethod.GET)
     9    public String registPost() {
    10        return "/welcome";
    11    }

    12
    13    @RequestMapping(value = "/deploy", method = RequestMethod.GET)
    14    public String deployRest() {
    15        return "/deploy";
    16    }

    17
    18
    19    @RequestMapping(value = "/end/{processId}", method = RequestMethod.GET)
    20    public void deployend(HttpServletRequest request,
    21            HttpServletResponse response, @PathVariable("processId") String processId) {    
    22        ProcessEngine processEngine = (ProcessEngine) SpringContextTool
    23        .getBean("processEngine");
    24        ProcessInstance processInstance = processEngine.getExecutionService().startProcessInstanceByKey("myprocess");
    25        ProcessDefinition processDefinition = processEngine.getRepositoryService().createProcessDefinitionQuery()
    26      .processDefinitionId(processInstance.getProcessDefinitionId())
    27      .uniqueResult();
    28        //獲取流程圖
    29        InputStream inputStream = processEngine.getRepositoryService().getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getImageResourceName());
    30        byte[] b = new byte[256];
    31        int len = -1;
    32        try{
    33             while((len = inputStream.read(b)) > 0{
    34                 response.getOutputStream().write(b, 0, len);
    35             }

    36             
    37             inputStream.close();
    38             response.getOutputStream().flush();
    39             response.getOutputStream().close();
    40        }

    41       catch(Exception e){
    42           e.printStackTrace();
    43       }

    44    }

    45    
    46    @RequestMapping(value = "/deployAction", method = RequestMethod.POST)
    47    public ModelAndView deployAction(HttpServletRequest request,
    48            HttpServletResponse response, ModelMap modelMap) {
    49        String realPath = request.getSession().getServletContext().getRealPath(
    50                "")
    51                + "/WEB-INF/deploy/"
    52        try {
    53            if (ServletFileUpload.isMultipartContent(request)) {
    54                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    55                for (Iterator it = multipartRequest.getFileNames(); it
    56                        .hasNext();) {
    57                    String key = (String) it.next();
    58                    MultipartFile file = multipartRequest.getFile(key);
    59                    if (file.getOriginalFilename().length() > 0{
    60                        String filename = file.getOriginalFilename();
    61                        
    62                        File saveFile = new File(realPath + filename);
    63                        FileOutputStream fos = new FileOutputStream(saveFile);
    64                        fos.write(file.getBytes());
    65                        fos.flush();
    66                        fos.close();
    67                        ProcessEngine processEngine = (ProcessEngine) SpringContextTool
    68                                .getBean("processEngine");
    69                        RepositoryService rs = processEngine.getRepositoryService();
    70                        File deployFile = new File(saveFile.getAbsolutePath());
    71                        if (deployFile.exists()) {
    72                            // 發(fā)布流程 
    73                            FileInputStream in = new FileInputStream(deployFile.getAbsolutePath());
    74                            ZipInputStream zin = new ZipInputStream(in);
    75                            String deploymentId = processEngine
    76                            .getRepositoryService().createDeployment().addResourcesFromZipInputStream(zin).deploy();
    77
    78                            modelMap.put("deploy""發(fā)布成功,版本號為:" + deploymentId);
    79                            in.close();
    80                            zin.close();
    81                        }

    82                    }

    83                }

    84            }

    85        }
     catch (Exception e) {
    86            modelMap.put("deploy""發(fā)布失敗!" );
    87            e.printStackTrace();
    88        }

    89
    90        return new ModelAndView("/end", modelMap);
    91    }

    92}

    WEB-INF/view增加文件end.jsp,主要用來顯示流程圖
     1<html>
     2<head>
     3<meta http-equiv="Content-Type" content="text/html; charset=GBK">
     4<title>流程發(fā)布</title>
     5</head>
     6<body>
     7<label><%=request.getAttribute("deploy")%></label>
     8<img src="end/myprocess" />
     9</body>
    10</html>

    運(yùn)行效果:
    設(shè)計(jì)器生成帶jpdl和圖片的zip流程包。
    http://m.tkk7.com/pengo/
    把該流程保存為Test.zip。

    http://m.tkk7.com/pengo/

    http://m.tkk7.com/pengo/

    終于在國慶有空,把這一篇也寫了。正好在國慶把做過的東西,整理下。

    設(shè)計(jì)器:設(shè)計(jì)器程序
    源碼:jbpmspring









    評論

    # re: JBPM4.4發(fā)布zip流程包和流程圖顯示  回復(fù)  更多評論   

    2013-05-06 20:05 by 郭貝
    =====================================
    東西不錯(cuò) 求源碼啊!下載不了 hanyijun85@163.com

    # re: JBPM4.4發(fā)布zip流程包和流程圖顯示[未登錄]  回復(fù)  更多評論   

    2013-10-22 14:44 by 小徐
    東西不錯(cuò) 謝謝分享,求代碼+設(shè)計(jì)器 xujinbiao007@163.com

    # re: JBPM4.4發(fā)布zip流程包和流程圖顯示  回復(fù)  更多評論   

    2013-11-05 10:58 by zzz
    東西不錯(cuò) 謝謝分享,求代碼+設(shè)計(jì)器 zhaozongzhan@163.com

    # re: JBPM4.4發(fā)布zip流程包和流程圖顯示  回復(fù)  更多評論   

    2014-02-19 10:40 by chenhua0725
    代碼下載不了,能不能發(fā)給我的呢?謝謝了 243857699@qq.com

    # re: JBPM4.4發(fā)布zip流程包和流程圖顯示  回復(fù)  更多評論   

    2016-02-18 14:49 by 班偉
    樓主。SpringContextTool這是個(gè)什么意思?
    主站蜘蛛池模板: 亚洲中文无码永久免费| 99re视频精品全部免费| 国产精品久久久久影院免费| 亚洲综合色丁香婷婷六月图片 | 久久最新免费视频| 亚洲一区无码精品色| 中文字幕在线观看免费| 亚洲色精品aⅴ一区区三区| 免费观看91视频| 久久亚洲精精品中文字幕| 四虎在线最新永久免费| 亚洲乱码在线卡一卡二卡新区| 免费无码AV片在线观看软件| 亚洲av无码一区二区三区四区| 拔擦拔擦8x华人免费久久| 日韩精品无码免费视频| 亚洲乱码国产一区三区| 免费国产污网站在线观看15| 亚洲电影唐人社一区二区| 妞干网在线免费视频| 羞羞视频在线观看免费| 国产V亚洲V天堂无码| 国产妇乱子伦视频免费| 亚洲AV无码精品国产成人| 国产精品亚洲αv天堂无码| 三年片在线观看免费大全电影| 亚洲国产成人久久| 国产精品无码素人福利免费| sihu国产精品永久免费| 亚洲视频一区在线| 国产乱弄免费视频| 久久国产乱子伦精品免费一| 亚洲成a人片在线看| 亚洲国产精品人人做人人爱| 亚洲免费精彩视频在线观看| 亚洲欧美日韩综合久久久久| 国产国拍亚洲精品福利| 免费国产成人高清在线观看网站| 一区免费在线观看| 亚洲理论片在线观看| 成人伊人亚洲人综合网站222|