1 2 Previous Next 18 Replies Latest reply on Jul 1, 2007 11:31 AM by knowbuddy wayne

    Storage of process variables outside jbpm?

    Alex Oguz Newbie

      Hi,

      Until now I have stored all process variables by using the mechanisms that are built in jBPM. I fetch my objects using hql statements that check some process variable values. No prob here.

      This was fine until my customer expressed his wish that a separation between jbpm specific data and process variables needed to be done. To be more specific: 1) No process variables inside the jbpm tables plus 2) the process variables of one process definition must not be saved on the same database schema as variables of another process definition. This is quite comprehensible against the fact that 1) different departments want to have a look at their data, run analyses on, etc. and 2) don't want other departments to do this on their data.

      Has anyone run into that kind of problem yet?

        • 1. Re: Storage of process variables outside jbpm?
          Alex Oguz Newbie

          @Ronald:Haven't you done this before by storing some of your data in an extra database? I have a past conversation/thread-name-I-can't-remember in mind where you mentioned something like that. How did you handle your transactions?

          Right now I think of the (quick&dirty) alternative to set up views on the jbpm schema that only show you data of one process definition. What do you think?

          • 2. Re: Storage of process variables outside jbpm?
            Ronald van Kuijk Master

            Stupid me, responding from my holiday ;-)

            Transactions were managed by the appserver. We configured hibernate to use the appserver transactions and used 2 datasources, one for jBPM, one for our own data. They used the same connetionpool so no XA issues arose.

            • 3. Re: Storage of process variables outside jbpm?
              jbpmndc Newbie

              I've come to the conclusion domain data should exist separately. Only data that must be used by the process is managed by jBPM.

              • 4. Re: Storage of process variables outside jbpm?
                meeru kis Newbie

                hi the_dude

                I fetch my objects using hql statements that check some process variable values. No prob here.


                a quick question regarding the above, i would also like to query my process instances(task instances to be exact) with some variables, however, i cannot seem to achieve it(been struggling for quite some time now!), this is how i do it currently with just the process names:

                String q = "from org.jbpm.graph.exe.ProcessInstance as pi" +
                " where pi.rootToken.node.name = '" + Constants.JBPM_WF_PROCESS_APPROVED+ "'";
                
                Query qry = context.getSession().createQuery(q);
                List result = qry.list();
                


                This returns me all the instances of approved status.
                I actually have 100,000 instances in approved status, and they all contain a variable "CollectionName", which has only 4 different values. Eg. Photo Collection, Text Collection etc.

                So my question is how i can retreive instances for a particular collection? (presumably by adding collectionname = 'Photo Collection' somewhere in the hql query)

                Thanks in advance!

                meeru

                • 5. Re: Storage of process variables outside jbpm?
                  meeru kis Newbie

                  i got it to work,

                  is this the right approach to do it?

                  String q = "select pi from org.jbpm.graph.exe.ProcessInstance as pi, org.jbpm.context.exe.VariableInstance as vi" + " where pi.id = vi.processInstance and pi.rootToken.node.name = '" + wfStatus + "' and vi.value='"+ variableValue + "' and vi.name='" + variableName + "'";
                  




                  • 6. Re: Storage of process variables outside jbpm?
                    Jitendra Singh Newbie

                    hi Meeru77,

                    There is an WIP class called org.jbpm.db.ContextSession . The purpose of that class is to take care of issues like searching for a process instance based on variable instances.

                    You can update that class with thi query, that IMO will be an approach more in line with jbpm line of thinking.

                    cheers!

                    • 7. Re: Storage of process variables outside jbpm?
                      Alex Oguz Newbie

                       

                      "meeru777" wrote:
                      i got it to work,

                      is this the right approach to do it?

                      String q = "select pi from org.jbpm.graph.exe.ProcessInstance as pi,
                      org.jbpm.context.exe.VariableInstance as vi"
                      + " where pi.id = vi.processInstance and pi.rootToken.node.name = '" +
                      wfStatus + "' and vi.value='"+ variableValue + "' and vi.name='" +
                      variableName + "'";
                      



                      1. Does it deliver the expected result set? If so --> Looks good :-)
                      2. Why do you check the node name? I ask because I basically look for
                      task instances that are assigned to a user (ti.actorId = :userId)
                      and have a set of process variables/values like status and order number.

                      I try to keep as much process specific knowledge outside my application.


                      • 8. Re: Storage of process variables outside jbpm?
                        meeru kis Newbie

                        1. Delivers superbly, i enhanced it to get a paginated list, which i can plug right into my ui.

                         List l = query.setFirstResult(page * pageSize).setMaxResults(pageSize+1).list();
                        

                        2. to get the status of the process, i have a different ui / status. In my case i have 10,000 pieces of works checked in as tasks(so getting them by actor id will get me all of them), i filter them based on some variable like 'collectionName', which splits up the tasks by collection, hence much more manageable, faster performance.

                        cheers

                        • 9. Re: Storage of process variables outside jbpm?
                          Alex Oguz Newbie

                           

                          "kukeltje" wrote:

                          Transactions were managed by the appserver. We configured hibernate to use the appserver transactions and used 2 datasources,
                          one for jBPM, one for our own data. They used the same connetionpool so no XA issues arose.


                          Mhm. What about your HQL statements? I haven't manage to build the solution you describe* (two datasources + appserver transactions)
                          but create my domain model inside the jbpm schema. In doing so I run into recreating all HQL statements for selecting task instances
                          by some variable value which could be quite time demanding. How do you handle this?

                          Something different: I have to use several processdefinitions and wonder how to organize my data. These options come into my mind:
                          a) Put all, processdefinitions and domain data inside one datasource and write the domain data, depending on the process it is connected to to different tables
                          b) Do the same as in a) but use one datasource per processdefinition
                          c) Use two datasources put the jbpm data in one and the domain data in the other datasource
                          d) Use one datasource for jbpm data and one datasource for domain model for each processdefinition (== 2 datasources per processdefinition)

                          I tend to give c) a try [if I figure out how ;-)] but don't know about performance or other issues.

                          What do you think?



                          * Could you describe it in detail how you've done this or give some links, hints & snippets?

                          • 10. Re: Storage of process variables outside jbpm?
                            meeru kis Newbie

                            Hi "the_dude",

                            I have written a tutorial on integrating jbpm + springmodules + appfuse here, using 2 datasources. If you have any questions please let me know.

                            http://raibledesigns.com/wiki/IntegratingJBPMIntoAppFuse.html


                            Ameer

                            • 11. Re: Storage of process variables outside jbpm?
                              Ronald van Kuijk Master

                              Sorry,, missed the question:

                              HQL? Our own domainmodel did not use Hibernate (yet). It was a usertransaction with inserts/updates into our domain model and then a call to the jbpm API (with a hibernate config that uses the transaction that is already running).

                              • 12. Re: Storage of process variables outside jbpm?
                                Ronald van Kuijk Master

                                Ameer,

                                Great work, compliments. I also found the second part

                                • 13. Re: Storage of process variables outside jbpm?
                                  Ronald van Kuijk Master

                                  which (as I found out only now) is still under construction ;-)

                                  • 14. Re: Storage of process variables outside jbpm?
                                    meeru kis Newbie

                                    Thanks for the compliments!
                                    damn those indexing spiders, am working on part 2(those late night endeavours), it will be much more interesting than the 1st one. jBPM is running smooth as ever now, will post all my findings and tips in part 2, hopefully it should be done by halloween else thanksgiving

                                    1 2 Previous Next