5 Replies Latest reply on Nov 9, 2007 8:36 AM by olivier.ch

    How to get process jpg and gpd

    lachelt

      OK. I've done my homework... but I can't figure out how to get the jpg and gpd for a given ProcessDefinition. I see that the data is there in the database, so I know that it has to be available somehow.

      Does the API provide a way to get those? Is there an existing discussion on this?

      Thanks,
      -Jon

        • 1. Re: How to get process jpg and gpd
          cahimoped

          Found it in the old webapp code :

          processDefinition.getFileDefinition().getBytes("processimage.jpg")


          And you can get the ProcessDefinition from GraphSession.

          • 2. Re: How to get process jpg and gpd
            lachelt

            Ah, that helps me understand the FileDefinition class.
            Thanks for the quick and simple reply.

            • 3. Re: How to get process jpg and gpd
              olivier.ch

              I have tryed your solution but when I get the FileDefinition, this object is null...
              Is there something to do when you deploy your process to be able to get this image ... ?

              my code to get this FileDefinition is :

              
              JbpmContext context = Jbpmconfiguration.createJbpmContext();
              
              ProcessInstance pi = context.loadProcessInstance(idProcess);
              
              ProcessDefinition processDefinition = context.getGraphSession().loadProcessDefinition(pi.getProcessDefinition().getId());
              
              FileDefinition fileDefinition = processDefinition.getFileDefinition();
              byte[] bytes = fileDefinition.getBytes("processimage.jpg");
              
              


              I get a nullPointerException on the last line, of course my fileDefinition is null ... why ?



              • 4. Re: How to get process jpg and gpd
                heinerniehues

                Hi

                Did you before upload the processimage.jpg and the gpd.xml ?
                This is necessery because the ProcessDefinition.xml doesnt contain this files.
                You have to add these files to the processdefinition like this:

                ProcessDefinition pi = jbpmContext.getGraphSession().loadProcessDefinition(pid);
                
                 FileDefinition fileDefinition = pi.getFileDefinition();
                 if (fileDefinition == null) {
                 fileDefinition = new FileDefinition();
                 pi.addDefinition(fileDefinition);
                 }
                 fileDefinition.addFile(name, inputStream);
                 jbpmContext.getGraphSession().saveProcessDefinition(pi);
                


                • 5. Re: How to get process jpg and gpd
                  olivier.ch

                  Perfect it works ... thanks a lot ...

                  Olivier