1 2 Previous Next 17 Replies Latest reply on Dec 6, 2007 10:35 AM by Ronald van Kuijk

    Can we save custom variables in a ProcessDefinition

    s b Newbie

      Is there any facility for saving custom data in a ProcessDefinition?

      For example, I'd like to save the name or pathname of the processdefinition.xml file used to deploy the ProcessDefinition; also the name/path of the gpd.xml file.

      For our particular use, which is to read the file at some later point, I have seen techniques for saving FileDefinitions to a ProcessDefinition, which really reads an input stream and saves all the data in the Hibernate JBPM database, as far as I can tell.

      That is a possible solution, but sometimes just the gpd.xml file is changed without changing the processdefinition.xml file, and we'd like to deliver it just by copying it over the old one, rather than a special process to replace the FileDefinition involving a lot of code and a UI. Then we can read the file as needed with normal Java file I/O if we can retrieve the name/path from the ProcessDefinition.

      Is there some simple way to just store and retrieve a few strings in the ProcessDefinition?

        • 1. Re: Can we save custom variables in a ProcessDefinition
          s b Newbie

          I guess to answer my own question, I could store the name/paths of the files as data in a FileDefinition, and retrieve them from the FileDefinition inputstream. Seems overkill, but I guess that would work.

          • 2. Re: Can we save custom variables in a ProcessDefinition
            Michele Mauro Newbie

            I'm planning to solve the same problem using some custom action that copies in the deploy envirorment its configuration, thus transferring static process parameters.

            Mauro Michele

            • 3. Re: Can we save custom variables in a ProcessDefinition
              s b Newbie

              Mauro: I'm interested in what you end up doing. I'm also considering using a custom action to set some "process variables" from the processdefinition.xml file as the process starts. I'm not sure what is the best choice of place to "attach" the action handler (start node, start node transition, etc?). It would be nice if there was a formal way to set context variables directly in the start node.

              My interest in the FileDefinition module is for saving information that is specific to the ProcessDefinition (common to all ProcessInstances) such as the file from which the ProcessDefinition was deployed.

              • 4. Re: Can we save custom variables in a ProcessDefinition
                Michele Mauro Newbie

                A formal <process-properties> tag would certantly be nice. Our use case is similar (but not the same) as http://jira.jboss.com/jira/browse/JBPM-679. Maybe we could open a jira and link there... it's scheduled for jBPM 3.3.

                As for now, I think the value bearer action has to do the hard work. I think you should use them quite near the start node for them to be any useful.

                I think a pattern emerges here: just like I'm already researching and implementing for dynamic UI (that is, creating the UI from the Variable configuration of a standard task), an external registry (for example, of parameter and variable types and sources, or of process definition properties) can hold in the execution db all the properties that are needed to augment the standard configuration and support the process execution. The value-holder action can populate those data upon first execution (if you won't need it before that), or your admin interface can query the processdefinition and use it to correctly configure new process requests...

                I have to work a little bit more on these issues. I'm afraid however that we can share ideas, not implementations since my project is not (at the moment) Open Source.

                And I've yet to mention the Drools integration part...

                Michele Mauro

                P.S. My first name is Michele. Mauro is my family name. And I'm male: Michele is a male name here in Italy.

                • 5. Re: Can we save custom variables in a ProcessDefinition
                  s b Newbie

                  Michele!

                  Those are good ideas. I'll have to check more into the "script" tag, there are many features in jBPM which I'm not very familiar with yet that could provide solutions.

                  I'd also like the designers to consider adding a "user object" property (setUserObject(Object userObject), getUserObject()) to most of the main jBPM objects (ProcessDefinition, ProcessInstance, Task, TaskInstance, ...). The only requirement is that the user object be serializable.

                  It would also be nice to be able to create such a user object in the processdefinition.xml file using the same delegation syntax as for custom classes (such as ActionHandler classes). The tag or tag attribute and location would indicate if it belongs to the ProcessDefinition, ProcessInstance, Task, TaskInstance, Node, NodeInstance etc. The versatility of a user object is very great.

                  As a matter of fact, the open source JGraph (which we use to draw our workflow graphs based on the gpd.xml file and ProcessDefinition), allows a "user object" for each object in the graph (vertices and edges). It is immensely useful.

                  • 6. Re: Can we save custom variables in a ProcessDefinition
                    Ronald van Kuijk Master

                    userobject: care to elaboreate? I have no clue why this could be useful? Things that are to generic tend to blur usability and promote abuse.

                    • 7. Re: Can we save custom variables in a ProcessDefinition
                      Ronald van Kuijk Master

                      I forgot to add: "because often it hides other missing features"

                      • 8. Re: Can we save custom variables in a ProcessDefinition
                        PERU Nicolas Newbie

                        Hi all,

                        As far as I understood all the doc I could found and the subject of this topic, it's impossible to store variables at the process definition level.
                        It means that you have to instantiate and eventually initialize the variables each time you instantiate a process instance.
                        Can someone confirm this please ?

                        Moreover it means that the only way to store variables in the process definition (which in fact means variable that will be used and defined in every instance of this process) is to set an action that will be executed by the start state to link variable to the instance. Is that correct ?

                        The thing is that in the functional problem i'm dealing with i want to set at design time the variables that will be used by every instance, so I do not want to create variables for each instance.

                        Thanks for your time.

                        • 9. Re: Can we save custom variables in a ProcessDefinition
                          Ronald van Kuijk Master

                           

                          Can someone confirm this please ?


                          Confirmed

                          Is that correct ?


                          Yes

                          The thing is that in the functional problem i'm dealing with i want to set at design time the variables that will be used by every instance, so I do not want to create variables for each instance.


                          This is exactly what you can do with actionhandlers. You can put a value in one of the params passed to the actionhandler and set the variable designtime. AFAIK, an example has been posted to the forum before and maybe even the wiki


                          • 10. Re: Can we save custom variables in a ProcessDefinition
                            s b Newbie

                             

                            "kukeltje" wrote:
                            userobject: care to elaboreate? I have no clue why this could be useful? Things that are to generic tend to blur usability and promote abuse.


                            There is a lot of practical real-world stuff that goes into delivering and maintaining a system for real customers. Typically monitoring, tracing, troubleshooting, maintaining are very important. There are all kinds of information that would be useful to store with a processdefinition, such as the file it was deployed from, comments about it's revision history, who deployed it, etc. that can be displayed for troubleshooting/maintenance reasons.

                            There is often a lot of information about a task that is of interest: permissible roles, special instructions to users, per cent completion, graph node color, a phone number to call if the work is stalled, etc. that is of interest well after the assignment has taken place.

                            Of course we can create our own database to store additional information, but why duplicate all that effort? And why expect the workflow engine designers to imagine all the possible uses of the technology? A user object, rather than leading to abuse, prevents "creeping featurism" where features are added to solve particular problems that many users don't need. I think a "user object" property would help jBPM stay lean and mean and discourage "bloating" of the core code.



                            • 11. Re: Can we save custom variables in a ProcessDefinition
                              s b Newbie

                               

                              "kukeltje" wrote:
                              I forgot to add: "because often it hides other missing features"


                              I agree with that. Hopefully people will still request features they are interested in and the designers can see which ones truly represent a common and core need.

                              • 12. Re: Can we save custom variables in a ProcessDefinition
                                Ronald van Kuijk Master

                                Simon,

                                You can already add any tag you want to the processdefinition and when retrieving a processdefinition , also retrieve the xml file with it. You can translate that to a dom and read any element you put in there.

                                • 13. Re: Can we save custom variables in a ProcessDefinition
                                  s b Newbie

                                   

                                  "kukeltje" wrote:
                                  Simon,

                                  You can already add any tag you want to the processdefinition and when retrieving a processdefinition , also retrieve the xml file with it. You can translate that to a dom and read any element you put in there.


                                  Ok, that's good to know we can add extra tags. However, it would be useful to store such info in the ProcessDefinition object, otherwise we have to persist it ourselves some way, or re-parse the xml file a lot.

                                  If I'm not mistaken, in some ways it seems that the FileDefinition module can be used like a "user object" if it allows you to store arbitrary binary data. I don't know enough about how it works yet, and I doubt there is anything similar for a task, etc.

                                  • 14. Re: Can we save custom variables in a ProcessDefinition
                                    PERU Nicolas Newbie

                                    Actually i'm facing a problem with that and I quite agree with simon.

                                    I created my process definition programmatically with an action that creates the variables of the process at the start of a new instance, based on a map that is a field of my action handler (maybe not the best solution but it's the only one I found so far, be glad to hear about other solution).
                                    My problem now is to fill this map with some value. As i defined my ProcessDefinition without using xml, I don't have access to the XML file and the value I give to the map is not persisted when deploying the processDefinition (still programatically).

                                    So my question is :
                                    -Do I have to generate the xml file from the ProcessDefinition object and add the value "manually" in order to persist them. (and how do I do to generate this xml) ?
                                    - Or how can I persist the value I give to the action handler fields ?





                                    1 2 Previous Next