3 Replies Latest reply on Jan 21, 2008 7:33 AM by Ronald van Kuijk

    variable validation

    richard bradwell Newbie

      Hi,

      I have been considering how to integrate jbpm within an application and would like to know how other people have approached this and if they could offer some advice. I'm new to this kind of approach and it's taking some time to get it straight in my mind how my application will interact with jbpm.

      My app consists of a JSF based web app. The backing beans use a service locator to call out to a stateless session bean. All the jbpm goodness is contained within the EJB. i.e. separation of layers. So for example the webapp requests the current task instance by calling the EJB. I then transform all the variables and values (and if they are readable,writable etc) to my own DTOs. It is these DTOs that get pass back and forth between the webapp and EJB.

      I was thinking about

      - How/where to do validation of variables. How do I store and pass around the variable types. Perhaps passing their type to the webapp via the DTOs? Obviously I need to do validation of variable values in the EJB. Would it be best to subclass the controller class for this? I'm thinking that I need validation for every node in the graph with variables. Therefore I need to provide something like struts forms, one for each node, perhaps using the apache validator stuff? So perhaps the EJB reads in an XML file that contains a declaration of a "form" for each node in the graph. Within a single "form" declaration is a declaration for each field and it's type. The EJB will then validate values from the UI before calling the jbpm api to set them in the process.

      - How and when to transform the process variables to my "model" and vice versa. The process is passing around individual fields as name value pairs. At somepoint I need to create a new object in my application model and copy the fields into that pojo. I already have my model sorted out. Perhaps I do that by having my subclass of action call another "resource" that can transform in both directions when in a start or end state.

      - returning the current state of the process. If I think about an app in terms of MVC my EJB calling jbpm have effectively now become the model and the controller. My web app is now just a dumb set of views. Some how I need to pass back info to the webapp to tell it were in the process we are so it can display the correct screen. Probably I can get away with passing back the current task when calling end on the current task instance. This feels a bit naff though. The model is update by the controller (i.e. EJB and jbpm) but there isn't a way to push the current state to the web app. i.e. there is no way for the controller to tell the view that the model has changed. I guess the webapp (view) could request the state but that's a bit naff as well.

      Any thoughts or suggestions are welcome.

        • 1. Re: variable validation
          Ronald van Kuijk Master

           

          How/where to do validation of variables
          Limit validation in the process. Just do it like you normally would. Store only relevant (meta?) data in the process. We hardly use the jbpm forms for production. Only for rapid prototyping

          How and when to transform the process variables to my "model" and vice versa

          Duplicate them... and see previous answer

          returning the current state of the process
          Again... do NOT make jbpm the model. Make it the process.

          If by naff you mean http://www.answers.com/topic/naff, I partly agree. Does the state have to be pushed to the webapp? Or is a tasklist only retrieved when needed? See how it is done in seam

          • 2. Re: variable validation
            richard bradwell Newbie

            kukeltje, thanks for the reply. So you are saying that you perform validation before it enters jbpm and not, for example, within an action handler? My idea was a very generic framework where you declare the variables you have in each task and how they should be validated in an XML file.

            With regards to the model you are saying treat the variables in the process as temporary state and when you reach the appropriate node i.e. some end state, then transform the individual variables into your pojo and then passing the pojo to your own service to be persisted?

            Your definition of "naff" is correct :). Apologies for using such colloquial english.

            I take your point regarding making jbpm the process not the model. Your example of a tasklist is a good one and indeed that is what I'm doing for the tasklist. However if you seperate your layers e.g. a webapp calling and EJB that utilises jbpm then a call to signal may traverse a number of nodes in the graph. This update in the state of the process needs to be communicated to the UI so that it may show the appropriate view for say the current task.

            I haven't looked at Seam at all. Would Seam simplify integration between a webapp and and ejb using jbpm? What would be passed between the two layers. Currently we have shared DTOs between the webapp and the EJB.

            Again thanks for the time, your response has been most helpful.

            regards

            Richard.

            • 3. Re: variable validation
              Ronald van Kuijk Master

               

              My idea was a very generic framework where you declare the variables you have in each task and how they should be validated in an XML file.


              I agree, that is what we also do. But we use an existing framework. Our webbased ui or message b2b definitions are complex and based on xsd's. By using a standard (trying to switch to the xforms engine called chiba) we achieve this.

              With regards to the model you are saying treat the variables in the process as temporary state and when you reach the appropriate node i.e. some end state, then transform the individual variables into your pojo and then passing the pojo to your own service to be persisted?


              No, just take e.g. a case number from your message/page and store it in jBPM. Also add e.g. certain numbers/amounts needed by decisionnodes. But store the normal data always in your model and signal the engine within the same transaction

              Your definition of "naff" is correct :). Apologies for using such colloquial english.


              colloquial? ;-) Thankfully I know the meaning of word so it saved me searching the internet again.

              This update in the state of the process needs to be communicated to the UI so that it may show the appropriate view for say the current task.
              We always go back to a tasklist or more generic file/dossie overview. Never directly to the next task

              I haven't looked at Seam at all. Would Seam simplify integration between a webapp and and ejb using jbpm?


              Yes

              What would be passed between the two layers. Currently we have shared DTOs between the webapp and the EJB.


              Certainly not DTO's just you model objects. e.g. your hibernate objects are automagically jsf beans...