Activiti Learning-Integrating Activitimodeler into the project

Source: Internet
Author: User

Learning sources

Learning Activiti, mainly by dismantling and re-assembling the Coffee rabbit project.

Coffee Bunny Blog: http://www.kafeitu.me/

Project Address: Https://github.com/henryyan/kft-activiti-demo

Basic Preparation

The above GitHub has a MAVEN version and a no-maven version, and I'm under the No-maven version.

Kft-activiti-demo-no-maven Download

Unzip and deploy the project

Project structure, error place is XML or JS file, can be ignored

Project

This article is for the purpose of splitting the corresponding function: process management, model workspace, create features

Realization idea of function realization
    1. Copy the classes we can use in the Coffee Rabbit project.

    2. Refer to the Coffee Rabbit project, modify the corresponding configuration file

    3. Copy the relevant files from Activiti-explorer.war in the Activiti5.16.4 project to the specified location in your project

    4. Jar package uses the jar package in the official sample

    5. Why not use all of the Coffee rabbit project files is because I completely use the Coffee rabbit project files can't get out. No way, we had to use the official example to control the reference.

Copy Coffee Rabbit Project related documents

Reference to the Coffee Rabbit project, found that its model " new " interface is called by the Create method in Modelcontroller

Copy to the controller in your project and analyze its code

With HttpServletResponse, the project needs to introduce Servlet-api.jar in Tomcat's Lib

Using to the /service/editor interface, it is found that the interface is not in spring management according to the log, it is possible that the servlet configured in Web. xml

See the Web. Xml of the Coffee Rabbit project is inside, add the following code in your project's Web. xml

Local code

    <!--Restlet adapter, used to expose Modeler functionality through REST--    <servlet>        <servlet-name>Explorerrestletservlet</servlet-name>        <servlet-class>Org.restlet.ext.servlet.ServerServlet</servlet-class>        <init-param>            <!--Application class name --            <param-name>Org.restlet.application</param-name>            <param-value>Org.activiti.explorer.rest.ExplorerRestApplication</param-value>        </init-param>    </servlet>    <servlet-mapping>        <servlet-name>Explorerrestletservlet</servlet-name>        <url-pattern>/service/*</url-pattern>    </servlet-mapping>

Use to org.activiti.explorer.rest.ExplorerRestApplicatio This class, began to think is the file in the jar package, looking for half a day not found, later saw incredibly is the project own package path (⊙﹏⊙) b, Make a decisive copy of your project

At this point, the available code for the Coffee Rabbit project has been copied.

Create method

    @RequestMapping(Value ="/create", method = Requestmethod.post) Public void Geteditor(            @Requestparam("description") String description, @Requestparam("name") String name, @Requestparam("Key") String Key, HttpServletRequest request, httpservletresponse response) {Try{Objectmapper Objectmapper =NewObjectmapper ();            Objectnode Editornode = Objectmapper.createobjectnode (); Editornode.put ("id","Canvas"); Editornode.put ("ResourceId","Canvas");            Objectnode Stencilsetnode = Objectmapper.createobjectnode (); Stencilsetnode.put ("namespace","http://b3mn.org/stencilset/bpmn2.0#"); Editornode.put ("Stencilset", Stencilsetnode);            Model modeldata = Repositoryservice.newmodel ();            Objectnode Modelobjectnode = Objectmapper.createobjectnode ();            Modelobjectnode.put (Modeldatajsonconstants.model_name, NAME); Modelobjectnode.put (Modeldatajsonconstants.model_revision,1);            Description = stringutils.defaultstring (description);            Modelobjectnode.put (Modeldatajsonconstants.model_description, DESCRIPTION);            Modeldata.setmetainfo (Modelobjectnode.tostring ());            Modeldata.setname (name);            Modeldata.setkey (stringutils.defaultstring (key));            Repositoryservice.savemodel (Modeldata); Repositoryservice.addmodeleditorsource (Modeldata.getid (), editornode.tostring (). GetBytes ("Utf-8")); System.out.println ("Jump page"); Response.sendredirect (Request.getcontextpath () +"/service/editor?id="+ Modeldata.getid ()); }Catch(Exception e) {System.out.println ("Create model failed"); }    }
Copy official sample related files

Find the Activiti-explorer.war in the downloaded Activiti5.16.4, unzip the deployment folder

Copy the specified folder to the Webroot

Copy the files in web-inf->classes to the SRC of your project

Why is the above documents, can only be said that the 1.1-point control of the Coffee Rabbit Project, (⊙﹏⊙) b people stupid to get it

Write your own new page

is to invoke the Controller's page, you need to pass three parameters, how to implement all can,

I'm using the bootstrap-3.3.5 framework.

Submitted using Form form.

Example results

Page

New

Save successfully and jump to Activitimodeler

You can view the data you just added in the database table Act_re_model

Sample Download

Click to download the sample

There is a problem classnotfound

Jar package is not copied, directly to the official example of the jar package copy all over, really not, directly download this example, directly on the above to try

Subsequent

Subsequent decomposition of the coffee Rabbit project can be studied

Activiti Learning-Integrate Activitimodeler into your project

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.