6 Replies Latest reply on May 26, 2009 2:24 PM by frinux

    Clone a Process Instance

    frinux

      Hi,

      I want to clone a process instance (with all the tokens, variables contained in it, start date etc...), so that after I could modify it with the values I want. Is it possible?

      ProcessInstance is not cloneable...

      The aim is that I have to split a process instance in 2 parts, one which will be ended, and another which must continue (that's because every month a user will end all old process Instances and refresh the counters).

      I don't know if I'm clear enough!

      Thanks

        • 1. Re: Clone a Process Instance
          kukeltje

          what is the advantage of cloning? You can always modify all values and still have a history log that shows what happened. imo much easier.If you create an adhoc task in the process, that is executed at that moment, you have a specific entry in the log that everything is reset.

          • 2. Re: Clone a Process Instance
            frinux

            Sorry but i did not understand what you're telling me.
            Yes, I want to keep a trace of my process, but more than that, I wanna split my process in two:
            - one (which correspond to the part before now) will be ended (processInstance.end() )
            - and the second (which correspond to the part after now) will be kept as active

            • 3. Re: Clone a Process Instance
              kukeltje

              Yes, I understood what you 'want' but that is not easy. What I tried to say is:
              - leave the intial process running
              - create a task that 'rests' all kinds of values and e.g. call it 'reset'
              - this creates a log entry that you can always trace (it's like the 'end' of the process, but not a real end)
              - you process continues.

              Much easier to achieve

              • 4. Re: Clone a Process Instance
                frinux

                Hum I can't do it this way, because I have to retrieve both processInstance after. They have to be explicitely twho processInstance, not one which has been modified.

                I found a way though, but I can't make it work.

                I create a new ProcessInstace and give it the var I want. When saving it, I get the exception:
                save the transient instance before flushing: tokenvariablemap

                Here is my code:
                http://pastebin.com/m24690e08

                • 5. Re: Clone a Process Instance
                  kukeltje

                   

                  I found a way though, but I can't make it work.


                  That is cool. You found a way but cannot make it work. IMO you did not find a way then, at least not yet ;-)


                  Not sure but it might be related to some hibernate deepcloning stuff. Never tried this, so I'm not sure.


                  • 6. Re: Clone a Process Instance
                    frinux

                    Yep, I meant I may have found a way... At least I think it could be a pretty solution...
                    It must come from Hibernate, maybe it's not possible to manipulate 2 processInstances in the same jbpm session...
                    I'm gonna work on this way (and I have no other idea!)