8 Replies Latest reply on Dec 10, 2010 3:35 AM by koen.aers

    Creating Process Definition

    justin.l

      Hi

       

      I am new to jBPM and learning it. Is there any API available in jBPM to create process definition programatically.

       

      Please guide me.
      Thanks for your valuable reply.

        • 1. Re: Creating Process Definition
          krisverlaenen

          Yes, you could use a Java API to create our processes, although that might not be the best way to get started (as it might be rather low-level).  Usually, the easiest way to get started is using the Eclipse plugin (you can use the installer to get a working environment) and start using the graphical editor there (and you can see what it spits out as underlying XML as well).

           

          An example of the API to create processes:

          https://github.com/krisv/jbpm/blob/master/jbpm-flow/src/test/java/org/jbpm/process/ProcessFactoryTest.java

          To be honest, this API probably needs some polishing to update it and maybe make it more BPMN2-focussed.

           

          Kris

          • 2. Re: Creating Process Definition
            justin.l

            Thanks Kris!

             

            The requirement is, our application should allow the user to configure the workflow by selecting some pre-defined workflow steps. Right now we are using XML API to generate the process definixion xml file once client completes the configuration.

            Is this correct way of generating process definition xml file?

             

            Also there is another requirement that forking should be done dynamically in system based on user input. I am not sure how to achieve this and just looking at the jBPM examples to get an idea.

             

            Any ideas will be greatly appreciated.

            Thank You!

            • 3. Re: Creating Process Definition
              krisverlaenen

              Yes, it's perfectly fine to generate the XML.

               

              Not sure what you mean with forking dynamically based on user input, could you give an example?

               

              Kris

              • 4. Re: Creating Process Definition
                justin.l

                Let's consider the below process definition xml file from User Guide. Based on this pre-deined transitions at fork, the single execution path is devided into three executions (correct me if i am wrong). What if i want to create n exeuctions at fork based on the user input. How can i achieve this?
                Please guide me.

                 

                <process name="ConcurrencyGraphBased" xmlns="http://jbpm.org/4.4/jpdl">

                   <start>
                      <transition to="fork"/>
                   </start>

                   <fork name="fork">
                      <transition to="send invoice" />
                      <transition to="load truck"/>
                      <transition to="print shipping documents" />
                   </fork>

                   <state name="send invoice" >
                      <transition to="final join" />
                   </state>

                   <state name="load truck" >
                      <transition to="shipping join" />
                   </state>

                   <state name="print shipping documents">
                      <transition to="shipping join" />
                   </state>

                   <join name="shipping join" >
                      <transition to="drive truck to destination" />
                   </join>

                   <state name="drive truck to destination" >
                      <transition to="final join" />
                   </state>

                   <join name="final join" >
                      <transition to="end"/>
                   </join>

                   <end name="end" />

                </process>

                 

                Thanks!

                • 5. Re: Creating Process Definition
                  krisverlaenen

                  You probably want a for each then (execute something for each element in the input).

                  jBPM4 has some action handler that can support this I think.

                  jBPM5 has a separate node construct for this even, to simplify this even further.

                   

                  Kris

                  • 6. Re: Creating Process Definition
                    koen.aers

                    The foreach node also exists in jBPM 4.4

                     

                    Regards,

                    Koen

                    • 7. Re: Creating Process Definition
                      justin.l

                      Hi Koen,

                       

                      We are using jBPM 4.2 for our development. I am not sure how to implement this with 4.2. If you have any thoughts, can you please share with me.

                       

                      Thanks!

                      • 8. Re: Creating Process Definition
                        koen.aers

                        Hi Justin,

                         

                        It should be not too hard to upgrade 4.2 to 4.4. If that is not possible you can check out the 4.4 source code and backport the implementation of the foreach node.

                         

                        Cheers,

                        Koen