13 Replies Latest reply on May 23, 2010 10:28 PM by rebody

    Generate Image from ProcessDefinition

    afgomez

      How I can generate programatically the image of the work flow or process definition?

      Please help me.

        • 1. Re: Generate Image from ProcessDefinition
          koen.aers

          In the GPD it is done using the provided features of the Eclipse GEF framework. I am afraid that this is the only way it is currently possible.

          Regards,
          Koen

          • 2. Re: Generate Image from ProcessDefinition

            is there a solution (programmatically) with the new version?

             

            creating a png file from the ProcessDefinition

            • 3. Re: Generate Image from ProcessDefinition
              kukeltje
              no, sorry.
              • 4. Re: Generate Image from ProcessDefinition
                bestage

                Like Ronald answered, there is no ready solution to do that.

                 

                But actually you can achieve what you want... Here is the concept:

                • for any Process Definition you can get the iImage resource name by calling   String getImageResourceName()...
                • now you can use RepositoryService and say getResourceAsStream(java.lang.String deploymentId,                      java.lang.String resourceName) that will return you the InputStream of the process image
                • now you can use RepositoryService again and say getActivityCoordinates(java.lang.String processDefinitionId,                         java.lang.String activityName)
                • and now presuming you know the name of the current activity in your given process instance (= execution) you can draw that rectangle on the image... How exactly this can be done, can't say for now, but that shouldn't be impossible.

                 

                By the way this is not my original idea, this was mentioned somewhere on this forum. Also maybe have a look at the GWT console, the guys have solved the same problem already.

                 

                NB: for this to work your deployment must contain the process image: deployment.addResourceFromClasspath(path/to/your/process/image.png

                 

                The original discussion was here: http://community.jboss.org/thread/119104


                • 5. Re: Generate Image from ProcessDefinition
                  kukeltje

                  Henry,

                   

                  Sorry, but you miss his point (I think, but I might be wrong instead)

                  NB: for this to work your deployment must contain the process image: deployment.addResourceFromClasspath(path/to/your/process/image.png



                  Because generating this image itself is what he wants to achieve...

                   

                  Cheers,

                   

                  Ronald

                  • 6. Re: Generate Image from ProcessDefinition
                    bestage

                    Oh, right... it's too late now I guess

                    • 7. Re: Generate Image from ProcessDefinition
                      sreeraaman

                      Hi All,

                       

                      I am not sure if this is what you are looking at. Assuming that you designed the process using the GPD eclipse plugin, after deployment of the process (.par archive), you can get the image of the process as a byte[] as shown below:

                       

                      public byte[] getProcessDiagram(Long processDefinitionId) {
                              byte[] returnValue = null;
                              JbpmContext context = getJbpmContext();
                              try{
                                  GraphSession graphSession = context.getGraphSession();
                                  ProcessDefinition processDefinition = graphSession.getProcessDefinition(processDefinitionId);
                                  FileDefinition fileDefinition = processDefinition.getFileDefinition();
                                  returnValue = fileDefinition.getBytes("processimage.jpg");
                              }
                              catch(Exception e){
                                  e.printStackTrace();
                              }
                              finally{
                                  context.close();
                              }
                              return returnValue;
                          }

                       

                      Form the returning byte[] you can manipulate the image as desired. This is as of JBPM 3.2.3.

                      • 8. Re: Generate Image from ProcessDefinition

                        As Ronald saied: "Generating this image itself is what he wants to achieve..."

                         

                        yes I am creating the process for the first time and then i am going to deply it and i want to create it's image and deploy it with the process.

                         

                        so my problem is how to create the image for the first time.

                        • 9. Re: Generate Image from ProcessDefinition
                          sreeraaman

                          Hi All,

                           

                          When you create a jbpm process with GPD plugin, the image is already created for you as part of the process archive by GPD plugin.

                           

                          The par file generated will have the following structure:

                           

                          test.par

                             |

                             |____ gpd.xml

                             |
                             |____ processdefinition.xml

                             |

                             |____ processimage.jpg

                           

                           

                          When you deploy the test.par file, the processimage.jpg gets stored in the jbpm tables that can later be retrieved using the code shown above.

                           

                          Hope this helps.

                          • 10. Re: Generate Image from ProcessDefinition
                            as i saied the problem is how to create a jbpm image programatically, without using GPD?
                            • 11. Re: Generate Image from ProcessDefinition
                              kukeltje
                              As I said before, there is no solution, other then implementing something yourself
                              • 12. Re: Generate Image from ProcessDefinition
                                shar

                                It is very a pity. In my opinion, it there would be a useful function.
                                By the way, how to create an image for schemes bpmn2 using GPD?
                                It seems to me, visual editing only for jpdl schemes.

                                • 13. Re: Generate Image from ProcessDefinition
                                  rebody

                                  Hi Andrej,

                                   

                                  Because most of server cannot support image library, so we can just upload a image file to server.  Even if we provide a plugin to generate image from xml, it could be very limited.