11 Replies Latest reply on Jun 20, 2008 9:15 AM by olivier_debels

    Duplication of processDefinition

    npe

      Hi,

      I looked through all the documentation and on this forum but didn't find anything really pertinent.

      I would like to duplicate a process definition and all its childs (nodes task transitions).

      Is there any simple way to do this ? The only one I found so far is to create new objects and copy the properties wich is heavy and complex and so should be forgot.

      The idea is to be able to modify the copied process definition.

      Thanks in advance for your replies.

        • 1. Re: Duplication of processDefinition
          npe

          It is important to precise that I create my process definitions programatically and so I don't have any access to the XML definition.

          • 2. Re: Duplication of processDefinition
            kukeltje

            maybe something like a deep hibernate copy works

            • 3. Re: Duplication of processDefinition
              npe

              Hi,

              Thanks for the reply. I didn't know about deep copy and all this stuff so I had a look at it. I tried to use this library : http://sourceforge.net/projects/beanlib/
              in order to create a process Definition copy.

              Then, I bumped into a problem quite unexpected :
              In process definition there are two setters for startState :

               public void setStartState(Node startState) {
               this.startState = startState;
               }
              

              and
               public void setStartState(StartState startState) {
               if ( (this.startState!=startState)
               && (this.startState!=null) ){
               removeNode(this.startState);
               }
               this.startState = startState;
               if (startState!=null) {
               addNode(startState);
               }
               }
              


              The thing is that the getStartState returns a node (actually I really don't understand why a node and not a StartState and why the startState property is a node and not a StartState as well... ) and so processDefinition is not exactly a bean and the library I tried to use fail to copy because it tries to do :

              newObject.setStartState(oldObject.getStartState());
              

              with the method taking a startState.


              I am really wondering what are the technical reasons of such a thing.



              • 4. Re: Duplication of processDefinition
                kukeltje

                 

                I am really wondering what are the technical reasons of such a thing.


                Probably nothing special and it just 'evolved' into this

                • 5. Re: Duplication of processDefinition
                  npe

                  Hi,


                  After changing of problem and trying differents method to do this I am getting more and more clueless on how to do this.
                  The deep copy doesn't work because of the non-bean properties of some jbpm objects.

                  Does someone have any idea ?

                  • 6. Re: Duplication of processDefinition
                    vsevel

                    I am also interested by this topic since it is not a good idea to export a process definition as xml. see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=135563

                    What is the solution for building a new process definition which is very similar (or an extension) of a previous (already defined) process definition?
                    It is not convenient to restart from scratch.

                    Thanks,
                    Val

                    • 7. Re: Duplication of processDefinition
                      olivier_debels

                      You could start extending the previous process definition from its processdefinition.xml.

                      This one is saved in the database (besides gpd.xml en process image). Can be retrieve using FileDefinition.

                      So when extending a process definition you can retrieve its xml and start from there. Make sure you first rename the process definition.

                      Hope this helps,

                      Olivier.

                      • 8. Re: Duplication of processDefinition
                        npe

                        Hi,

                        Thanks for your reply.

                        The problem is that I design my process definition directly through the objects of the "definition graph". I don't use the eclipse graphical designer nor the XML to parse into a definition.

                        As I have very simple definitions to create I developed a web based designer that design the process directly on the objects and then deploy it on the database.

                        From this point what I want to do is duplicate a process definition and I couldn't find an "easy" way to do it.

                        • 9. Re: Duplication of processDefinition
                          olivier_debels

                          Just another thought in your case:

                          Maybe you could use serialization to do the cloning?

                          • 10. Re: Duplication of processDefinition
                            npe

                            Problem is that if you load a process definition via hibernate and then serialize it you still keep a link to hibernate and when deserializing you still have all the links to other objects and exceptions as if you were trying to save a copied instance.

                            • 11. Re: Duplication of processDefinition
                              olivier_debels

                              Isn't there a possibility to remove hibernate link before serializing? I'm sure there is (evicting...)

                              BTW: If you go for this solution (serialization) keep in mind the disadvantages:
                              http://weblogs.java.net/blog/emcmanus/archive/2007/04/cloning_java_ob.html