"Java EE Learning 第58-67 Days" "OA Project Practice" "SSH Integration jbpm Workflow" "JBPM Project Combat"

Source: Internet
Author: User
Tags save file jbpm

First, SSH integration jbpm

JBPM Basic See http://www.cnblogs.com/kuangdaoyizhimei/p/4981551.html

The integration of SSH and JBPM will now be implemented.

1. Add a jar Package

(1) Under the JBPM Project/lib directory, all the jar packages and Jbpm.jar packages under the root directory are placed under the/web-inf/lib folder, and the/lib package in the Tomcat Server El-api.jar folder is deleted.

Note: You must remove the El-api.jar package, which conflicts with the three jar packages that need to be used in the JBPM project: Juel-api.jar, Juel-engine.jar, Juel-impl.jar

The best solution is to replace the El-api.jar package in the/lib folder at the root of the Tomcat server with the three jar packages above, which can also run other server programs.

That is to say, the above three jar package function can replace the function of the El-api.jar package, but the reverse is not possible.

(2) Hibernate related jar packages do not need to be added. Hibernate-related jar packages have been added to the JBPM project. The Hibernate support jar package provided in the JBPM project is recommended here. Otherwise, there may be some inexplicable problems.

(3) MySQL driver jar package also does not need to be added, because the jar package is also already available in the JBPM project. It is recommended to use the MySQL driver jar package provided in the JBPM project. Native is more reliable, but pro-test using the MySQL official website provided by the drive Jar package is also no problem.

(4) Add spring related jar package.

      

(6) Add the relevant jar package for STRUTS2.

      

(7) The relevant functions of Ajax are used in the project, and the front-end Ajax and STRUTS2 interact with the jar package provided by STRUTS2 (the custom result set can be implemented, but it is cumbersome)

      

(7) It is recommended to use the jar package grouped together to facilitate management.

      

Ext folder contains three jar packages in place of the El-api.jar package; Jstl folder No, I am using Java EE 6.0 version, with the relevant support jar package of JSTL, and the relevant jar package for unit test in JUnit folder, and the jar package does not need to be downloaded. MyEclipse, directly right-click Project->build Path->add Libraries->junit can also be added, pay attention to the use of 4.0 version.

2. configuration file Configuration

It is recommended that you place the configuration file in a single source folder, as shown in

    

SSH integration process See

Http://www.cnblogs.com/kuangdaoyizhimei/p/4855034.html

Say only a few key areas of integration with SSH and JBPM:

(1) The Hibernate.cfg.xml configuration file is replaced by the Jbpm.hibernate.cfg.xml configuration file. The contents of the two files are merged together, and finally the location of the configuration file is declared in Spring (jpbm.hibernate.cfg.xml)

<id= "Sessionfactory"  class= " Org.springframework.orm.hibernate3.LocalSessionFactoryBean ">          <  Name= "Configlocation"  value= "Classpath:jbpm/jbpm.hibernate.cfg.xml"  ></Property>    </bean>

(2) JBPM related configuration

JBPM The most important object is the Processengine object, all of the process action needs to start from this object, the task of creating the object will also need to be given to spring, note that the way to create a factory.

<!--Configuring JBPM Correlation -    <BeanID= "Springhelper"class= "Org.jbpm.pvm.internal.processengine.SpringHelper">        < Propertyname= "Jbpmcfg"value= "Jbpm/jbpm.cfg.xml"></ Property>    </Bean>    <BeanID= "Processengine"Factory-bean= "Springhelper"Factory-method= "Createprocessengine"></Bean>

(3) The rest of the configuration process is SSH integration process, do not repeat.

3.SSH integration jbpm process is mainly SSH integration process, so SSH is the foundation, must be mastered.

Second, the project demonstration

Project Project source code: Https://github.com/kdyzm/sshAndJBPM

Before the project runs, first run the Com.kdyzm.init.Init class and initialize the user data.

  1. Enter Http://localhost:8080/jbpmAndSSH on the browser, the login screen appears

    

Enter the preset username Zhang San, password Xiaozhang (all user passwords unified to Xiaozhang) login

  2. Login to the interface

        

  3. First draw a flowchart, package it into a zip archive, click the deployment process definition document for deployment.

    

After you click the OK button:

    

To view the flowchart:

    

At this point, the process deployment has been successful.

  4. Form template Management

This feature allows you to create a new process template based on an existing process definition.

Add a new Template: Upload a template file

  

After uploading successfully:

  

  5. Initiating an application

    

Click the first item: Leave process form template

    

Automatically jump to the "My Application" query page

    

  6. Application Enquiry

Click Query status to display all requests for "me" as shown in

Click View flow chart to view the approval process for the current process

    

The above flowchart is a more complicated flowchart, the Fork/join node mentioned in the previous note is used here. The current process example requires the project leader and the project deputy leader to agree the process flow to the general Manager approval node.

The red box is how the dynamic display is a very interesting thing, using css+div block can be precisely positioned, the border style can be set .

7. Approvals

The process flows to the project leader approval (Zhang San) and project deputy leader (John Doe) approval task node. The current account is Zhang San, the first one approved by Zhang San.

Click approval processing to view all approval tasks that currently have permission to process

    

Click approval Processing:

Click Agree directly, return to the approval list, the task has ended, so the approval list is no longer a task.

8. Check my application again to see the status of the process

9. Login to the John Doe (Deputy Leader) account for approval

Follow the same procedure as above, click Agree, switch back to Zhang San's account, review the approval progress, and find that the process has been circulated to the general manager for approval.

Login to Harry (General manager) account, approve the approval, return to Zhang San account again to view the approval progress

The process has been circulated to the CEO's task node for approval.

Next use Zhao Liu (president) of the account login system, for approval, after approval using Zhang San account login system, check the process status again, this time has not been able to view the flowchart, because the application status has been marked as "complete the application"

The current state has changed compared to the unfinished state, and the flow chart cannot be viewed:

10. The main function of this small project is so much.

Three, technical point analysis

1. File Upload

Wrote a file Upload tool class to solve the problem of file upload

 Packagecom.kdyzm.utils;ImportJava.io.File;Importjava.io.IOException;ImportJava.text.SimpleDateFormat;Importjava.util.Date;ImportJava.util.UUID;Importorg.apache.commons.io.FileUtils;ImportOrg.apache.struts2.ServletActionContext;/*** File Upload Tool class *@authorKdyzm **/ Public classFileuploadutils {/*** Save the file to the specified location * Note the problem with the saved method *@paramSourceFile *@paramInfactfilename *@return     */     Public Staticfile Saveuploadfiletodestdir (file sourcefile, String infactfilename) {SimpleDateFormat SDF=NewSimpleDateFormat ("/yyyy/mm/dd"); Date Date=NewDate (); File dir=NewFile (Servletactioncontext.getservletcontext (). Getrealpath ("/upload") +Sdf.format (date)); if(!dir.exists ())        {Dir.mkdir (); } String []arrfilenames=infactfilename.split ("\ \")); String Lastfilename=arrfilenames[arrfilenames.length-1]; File DestFile=NewFile (Dir,uuid.randomuuid (). toString (). ReplaceAll ("-", "") + "." +lastfilename); Try{fileutils.copyfile (sourcefile, destfile); } Catch(IOException e) {System.out.println ("Save file Failed!" "); }        returnDestFile; }}

The file is uploaded to the/upload//month/day folder under the project root directory.

2. File download

Things to keep in mind:

(1) Use the Urlencoder class to encode the file name, if the English name does not matter, if it is a Chinese name, you must use the class

String Filename=urlencoder.encode (Formtemplate.getname (), "utf-8");

(2) Set the response header information, tell the browser to return the content is required to download

Response.setcontenttype ("Application/force-download");        Response.setheader ("Content-disposition", "attachment;filename=" +filename);

(3) The method return value is null, in Struts2, if the return value is not NULL, the exception is reported but does not affect the download.

return null;

(4) Download form template complete case

1 /**2 * Download the method that specifies the file that the Formtemplateid points to3      */4      PublicString Downloadformtemplatebyid ()throwsexception{5HttpServletRequest request=servletactioncontext.getrequest ();6HttpServletResponse response=servletactioncontext.getresponse ();7String formtemplateid=request.getparameter ("Formtemplateid");8Formtemplate formtemplate=Formtemplateservice.getformtemplatebyid (Formtemplateid);9File file=NewFile (Formtemplate.geturl ());TenString Filename=urlencoder.encode (Formtemplate.getname (), "Utf-8"); One          AResponse.setcontenttype ("Application/force-download"); -Response.setheader ("Content-disposition", "attachment;filename=" +fileName); -FileInputStream fis=Newfileinputstream (file); theOutputStream os=Response.getoutputstream (); -         intLength=-1; -         bytebuff[]=New byte[1024]; -          while(Length=fis.read (Buff))!=-1){ +Os.write (Buff, 0, length); -         } + os.close (); A fis.close (); at         return NULL; -}

3.

    

"Java EE Learning 第58-67 Days" "OA Project Practice" "SSH Integration jbpm Workflow" "JBPM Project Combat"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.