2 Replies Latest reply on Aug 22, 2007 6:42 AM by Martin Ehrlich

    What we did: Flexible IN-Parameters for Nodes

    Martin Ehrlich Newbie


      we just started using Jbpm in our productive environment in a smaller insurance company. Our aim for the coming years is to use jBPM as the base for our business process server for all our business processes.

      How far we can go this way depends on many things.

      But when we started we discovered some things missing in Jbpm where we found our own solutions for. I want to tell you about this and hope for reactions in the range of "jBPM already can do this. Just RTFM, stupid!" to "Nice, but I have some ideas how you could improve this" and "Oh, that's greeat. Tell me more".

      Our aim:
      Maximaze the reusability of nodes for the business analyst.

      We need a way to configure IN-Parameters of nodes.

      A node which reads some data from a database might be used in different processes slightly differently:
      a) Give me all data younger than the processVariable "letterRecieved"
      b) Give me all data younger than 01.02.2007
      c) Give me all data from the last two weeks.

      In this case all we have to do is to give the date to a SQL-Statment but it comes from different sources.
      In a) the source is a process variable, in b) it's a constant value and in c) it's the result of a computation.

      What we did:
      We are using the configuration mechanism of Jbpm to insert Strings in a special formatted way.

      For a) this would be in jPDL:

      <action class="abcActionHandler.AbcHandler">

      For b)
      <action class="abcActionHandler.AbcHandler">

      For c)
      <action class="abcActionHandler.AbcHandler">

      Our handler would need a selectDate class variable.

      At runtime the value of this variable would be parsed. Depending on the second parameter {VAR; CONST; FUNC} the needed date
      would be computed and used.
      a) From the process variable "letterRecieved" with type Date
      b) The constant value 01.02.2007 would be parsed to Date.
      c) An instance of funcionClass would be instantiated which is able to compute the needed Date.

      Depending on the reactions to this posting maybe I will post more.


        • 1. Re: What we did: Flexible IN-Parameters for Nodes
          masipu Newbie

          Seems nice. Just by curiosity, why you put all to that one variable? You could have made two variables:
          that is VAR, CONST or FUNC and
          that is the data used as parameter

          what I'm interested in, what did you do after this? did the process do something different depending the result?

          • 2. Re: What we did: Flexible IN-Parameters for Nodes
            Martin Ehrlich Newbie

            Hi masipu,

            why just one Variable? No special reason. It just came that way.

            For your second question:

            In our example: Depending on the parameter the node parsed the String and resolved the Date.
            a) From a (previously set - by another node or while starting the process) processVariable with the name "letterRecieved".

            b) As 01.02.2007

            c) By computing the Date two weeks ago.

            And now the node can do whatever it likes wiht the date. In our example it would use it in a SQL statement to get some data from an database since that date.

            An example node wich just displays the date might look like this.

            public final class MessageOutputHandler implements ActionHandler {
             private String selectDate;
             public void execute(ExecutionContext executionContext) throws Exception {
             //Get ContextInstance for acces to process variables
             ContextInstance contxt = executionContext.getContextInstance();
             //Parsing the selectDate IN-Parameter. At runtime it contains the formatted parameter string.
             //Possibly: CONST, VAR, FUNC
             ProcessXMLParameterInterface select = XMLParameterFactory.createProcessXMLParameter(contxt, this.selectDate);
             //By calling getValue() the parameter value gets resolved from its source.