Activiti flowchart view, activiti Flowchart

Source: Internet
Author: User

Activiti flowchart view, activiti Flowchart

1. view images for test cases

Public void viewImage () throws Exception {// create a repository service to object RepositoryService repositoryService = processEngine. getRepositoryService (); // find the file to be displayed from the repository String deploymentId = "701"; List <String> names = repositoryService. getDeploymentResourceNames (deploymentId); String imageName = null; for (String name: names) {if (name. indexOf (". png ")> = 0) {imageName = name;} if (imageName! = Null) {// System. out. println (imageName); File f = new File ("e:/" + imageName); // The input stream InputStream in = repositoryService of the File is obtained by the deployment ID and File name. getResourceAsStream (deploymentId, imageName); FileUtils. copyInputStreamToFile (in, f );}

Note:

1) deploymentId is the process deployment ID

2) resourceName is the value of the NAME _ column in The act_ge_bytearray table.

3) use the getDeploymentResourceNames method of repositoryService to obtain the names of all files under the specified deployment.

4) use the getResourceAsStream method of the repositoryService to pass in the deployment ID and file name to get the input stream of the specified name file under the deployment.

5) for the last IO stream operation, use the copyInputStreamToFile method of the FileUtils tool to copy the process flow to the file.

 

2. view images on the process definition page of a web project

Public String viewImage () {InputStream in = repositoryService. getResourceAsStream. getImageStream (deploymentId, imageName); // the actual project of this method should be placed in the service HttpServletResponse resp = ServletActionContext. getResponse (); try {OutputStream out = resp. getOutputStream (); // write the input process of the image to the output stream of resp. byte [] B = new byte [1024]; for (int len =-1; (len = in. read (B ))! =-1;) {out. write (B, 0, len);} // close the stream out. close (); in. close ();} catch (IOException e) {e. printStackTrace ();} return null ;}

Note:

1) deploymentId is the process deployment ID and imageName is the image name.

2) because the process definition list page displays images, the id and imageName can be obtained from the process definition (ProcessDefinition) (String getDeploymentId (); and String getDiagramResourceName ();)

3) web page tag <a target = "_ blank" href = "viewImage? Deploymentid1_1&imagename=imagename.png "> View flowcharts </a>

 

3. view the current flowchart (show activity nodes) on the web project task list page)

Public String viewCurrentImage () {ProcessDefinition pd = service. getProcessDefinitionByTaskId (taskId); // 1. obtain the process deployment ID putContext ("deploymentId", pd. getDeploymentId (); // 2. obtain the process image name putContext ("imageName", pd. getDiagramResourceName (); // 3. obtains the coordinates of the current activity. Map <String, Object> currentActivityCoordinates = service. getCurrentActivityCoordinates (taskId); putContext ("acs", currentActivityCoordinates); return "image ";}

Here, the code implementation of service. getProcessDefinitionByTaskId (taskId:

Public ProcessDefinition getProcessDefinitionByTaskId (String taskId) {// 1. obtain task Task = taskService. createTaskQuery (). taskId (taskId ). singleResult (); // 2. obtain the process definition object ProcessDefinition pd = repositoryService by using the pdid of the task object. getProcessDefinition (task. getProcessDefinitionId (); return pd ;}

Here, the code implementation of service. getCurrentActivityCoordinates (taskId:

Public Map <String, Object> getCurrentActivityCoordinates (String taskId) {Map <String, Object> coordinates = new HashMap <String, Object> (); // 1. obtains the ID of the current activity. Task task Task = taskService. createTaskQuery (). taskId (taskId ). singleResult (); ProcessInstance pi = runtimeService. createProcessInstanceQuery (). processInstanceId (task. getProcessInstanceId ()). singleResult (); String currentActivitiId = pi. getActivityId (); // 2. obtain the process definition ProcessDefinitionEntity pd = (ProcessDefinitionEntity) repositoryService. getProcessDefinition (task. getProcessDefinitionId (); // 3. use the process definition to get the activity object ActivityImpl activity = pd through currentActivitiId. findActivity (currentActivitiId); // 4. obtains the coordinates of the activity coordinates. put ("x", activity. getX (); coordinates. put ("y", activity. getY (); coordinates. put ("width", activity. getWidth (); coordinates. put ("height", activity. getHeight (); return coordinates ;}

Image page

Click <a target = "_ blank" href = "/viewCurrentImage? TaskId = 1 "> view the current flowchart </a> to go to the following page

<Body> <! -- 1. obtain the rule flowchart. Here the strust2 label is used to obtain the value of the value stack above -->  & imageName = <s: property value = '# imageName'/> "> <! -- 2. dynamically draw DIV --> <div style = "position: absolute; border: 1px solid red; top: <s: property value = '# acs. y'/> px; left: <s: property value = '# acs. x'/> px; width: <s: property value = '# acs. width '/> px; height: <s: property value =' # acs. height '/> px; "> </div> </body>

 


Activiti does not automatically generate an image after drawing a flowchart using eclipse

Window --> preferences --> activiti --> save --> select create process definition image when saving the digoal

How can Activiti query the business objects associated with the process instance?

When you design your process xml, you have already set <activiti: formProperty id = "tablename" name = "table name" type = "string" required = "true" readable = "true" writable = "true"> </activiti: formProperty> put this item in xml. Then you can find this item and you will know which business table to query.
 

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.