1 2 Previous Next 27 Replies Latest reply on Jun 2, 2009 5:23 AM by kukeltje Go to original post
      • 15. Re: JBPM Identity
        sherrys

        Hi everybody,

        I'm currently using jbpm 3.2.6 SP1.

        I was trying to remove the identity component, so I searched the hibernate.cfg.xml file for the three hibernate mappings for User, Role and membership (the default one). I couldn't find them while I found two other mappings of the identity component and commented them:

        <mapping resource="hibernate.extra.hbm.xml" />
        <mapping resource="hibernate.identity.hbm.xml" />


        Then I created a simple class implemented the AssignmentHandler with this simple behavior:
        assignable.setActorId("12");


        I expect to have an Actor with id 12 each time I use any expression in my process definition but the problem is that while creating a task instance, it throws me an identity exception like:
        couldn't interpret first term in expression "blah" at org.jbpm.identity.assignment.ExpressionAssignmentHandler.resolveFirstTerm

        while I think it should not use the identity component any more ('cause of the configuration).

        Am I missing something or should there be another configurations?

        Sorry for the long post and thanks in advance for your replies,
        --Sherry

        • 16. Re: JBPM Identity
          kukeltje

          What is the relation between blah, 12 and where do you use the expression?

          • 17. Re: JBPM Identity
            sherrys

            Thank you for your fast reply Ronald,

            By blah, I mean any kind of expression in my process definition:

            <?xml version="1.0" encoding="UTF-8"?>
            <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="test2">
            
             <start-state name="start-state1">
             <transition to="task-node1"></transition>
             </start-state>
            
             <task-node name="task-node1">
             <task name="test2task">
             <assignment expression="blah"></assignment>
             </task>
             <transition to="end-state1"></transition>
             </task-node>
            
             <end-state name="end-state1"></end-state>
            
            </process-definition>


            By seeing the "expression" in the definition, jBPM should call the identity component (am I right?) I've removed the identity mappings from my hibernate.cfg, and implemented AssignmentHandler myself (I also extended the ExpressionAssignmentHandler but it didn't help either). As a result, I expect jBPM to call my assignmentHandler instead of identity's.

            In my assignment handler, I set the assignable's actorId to 12 (which is defined in the User table of the DB, although I know that this table is used by the Identity component)

            It seems that while creating a new instance of task, jBPM should call my assignment handler and not to use the identity component. so, it should returns a user with id 12, but it throws an identity exception

            thnx
            --Sherry

            • 18. Re: JBPM Identity
              kukeltje

              Ok, here is another quick reply ;-)

              Well, you are kind of there, but not completely. I have to admit, the area of extending/overriding the identitycomponent and/or the ExpressionAssignmentHandler is/was kind of not really flexible and certainly not realy documented well.

              I think the best/easiest way is to not use the identity component and explicitly put AssignmentHandlers on tasks/swimlanes and not use expressions explicitly, at least not the jpdl expressions. You could pass a string param to your custom assignmenthandler which is in fact the expression you want to use and evaluate that in your assignmenthandler. The downside to this is that you have to explicitly put the assignmenthandler everywhere you want it. This is already reduced when using swimlanes btw.

              hth a little

              • 19. Re: JBPM Identity
                sherrys

                Thanks again Ronald, :)

                Yes it seems that I should use the handler each time I want to assign a task.

                'cause as I looked at the jBPM's source code, I saw that use of the identity ExpressionAssignmentHandler is hardcoded in the readAssignmentDelegation function of "JpdlXmlReader" class when the tag "expression" is used.

                So, I have to change "JpdlXmlReader" or I have to assign all tasks using a handler and an input expression.

                But it seems that I can't use the "expression" tag of jPDL also (Am I right?)

                Thanks,
                --Sherry

                • 20. Re: JBPM Identity
                  kukeltje

                   

                  Thanks again Ronald, :)


                  Now can you imagine that some people think I'm rude? ;-)

                  'cause as I looked at the jBPM's source code, I saw that use of the identity ExpressionAssignmentHandler is hardcoded in the readAssignmentDelegation function of "JpdlXmlReader" class when the tag "expression" is used.


                  Unfortunately you are correct...

                  So, I have to change "JpdlXmlReader" or I have to assign all tasks using a handler and an input expression.


                  Unfortunately this is the case so you are right again.

                  But it seems that I can't use the "expression" tag of jPDL also (Am I right?)


                  Spot on


                  Thanks,
                  --Sherry


                  You are welcome...

                  Btw, in jBPM 4 this will be easier afaik (not tried it yet, no time :-( )

                  • 21. Re: JBPM Identity

                     

                    "kukeltje" wrote:
                    Ok, here is another quick reply ;-)

                    Well, you are kind of there, but not completely. I have to admit, the area of extending/overriding the identitycomponent and/or the ExpressionAssignmentHandler is/was kind of not really flexible and certainly not realy documented well.

                    I think the best/easiest way is to not use the identity component and explicitly put AssignmentHandlers on tasks/swimlanes and not use expressions explicitly, at least not the jpdl expressions. You could pass a string param to your custom assignmenthandler which is in fact the expression you want to use and evaluate that in your assignmenthandler. The downside to this is that you have to explicitly put the assignmenthandler everywhere you want it. This is already reduced when using swimlanes btw.

                    hth a little


                    Hi There,

                    I've been following this very interesting thread from the start and I'm really glad someone helps as much as you do.
                    I'm in a similar situation as Sherry's and if I understand well your post above, by simply not specifying any asignment expression in a task, the identity module is not used. Is this correct ?

                    If so, then the things I have to do to override the default ExpressionAssignmentHandler to define my own AssignmentHandler (say an LDAP one; for instance) are :

                    - comment these lines in the hibernate config
                    <mapping resource="hibernate.extra.hbm.xml" />
                     <mapping resource="hibernate.identity.hbm.xml" />
                    


                    - define a new class implementing AssignmentHandler interface

                    - refer to this class in the process desgin like this
                    <task-node name="createContract">
                    <task name="createContractTask">
                    <assignment
                    class="com.company.GreatAssignmentHandler"
                    />
                    </task>
                    <transition to="fork1"></transition>
                    </task-node>
                    
                    Is that right ?
                    You also recommend custom AssignmentHanlders to react to some passed variable in order to find which user the task should be assigned to. How exactly would one pass such variable to the AssignmentHanlder ?
                    
                    Thanks for precious time,
                    
                    Cheers,
                    
                    Jerome


                    • 22. Re: JBPM Identity

                      Yeah ... my last post wasn't that readable ... new try.

                      ___________________________
                      Hi There,

                      I've been following this very interesting thread from the start and I'm really glad someone helps as much as you do.
                      I'm in a similar situation as Sherry's and if I understand well your post above, by simply not specifying any asignment expression in a task, the identity module is not used. Is this correct ?

                      If so, then the things I have to do to override the default ExpressionAssignmentHandler to define my own AssignmentHandler (say an LDAP one; for instance) are :

                      - comment these lines in the hibernate config

                      <mapping resource="hibernate.extra.hbm.xml" />
                      <mapping resource="hibernate.identity.hbm.xml" />
                      


                      - define a new class implementing AssignmentHandler interface

                      - refer to this class in the process desgin like this
                      <task-node name="createContract">
                       <task name="createContractTask">
                       <assignment
                       class="com.company.GreatAssignmentHandler"
                       />
                       </task>
                       <transition to="fork1"></transition>
                      </task-node>
                      


                      Is that right ?
                      You also recommend custom AssignmentHanlders to react to some passed variable in order to find which user the task should be assigned to. How exactly would one pass such variable to the AssignmentHanlder ?

                      Thanks for precious time,

                      Cheers,

                      Jerome

                      • 23. Re: JBPM Identity
                        kukeltje

                         

                        Is that right ?


                        Yes

                        You also recommend custom AssignmentHanlders to react to some passed variable in order to find which user the task should be assigned to. How exactly would one pass such variable to the AssignmentHanlder ?


                        Well, it is not a real recommendation that you must do it that way, but it is an option. You pass the variables just like you would in a normal actionhandler. The basics are the same.

                        • 24. Re: JBPM Identity

                          Hi Ronald,

                          In the meantime, I gave my (yours in fact) idea a try and did exactly as I described in the previous post. Guess what ? It's working ! (of course it's working might you think ... :) ).

                          Thanks again.

                          Jerome

                          • 25. Re: JBPM Identity
                            kukeltje

                            Of course it is working :-P it was designed by Tom et al to work that way, so it's not even my idea.

                            Still, better plugability would have been nice, so you could configure the engine to use a certain IAM solution instead of augmenting each processdefinition.

                            • 26. Re: JBPM Identity

                              I may missing one last thing. It may sound dull, but I've been asking myself and couldn't find any cleaner solution than the one I'm finally using.
                              So here it is :
                              When I was using the default ExpressionAssignmentHandler, I used to pass it an Expression. (Well nothing stunning until now). This expression was some kind of clue to which actor was finally getting the task.

                              Now, I'm using my own AssignmentHandler, but it seems like the only possibility to pass it a clue to which user (or group) is actually getting the task is by using variables. So I end up writing something like this :

                              In the class that creates a new process instance :

                              HashMap<String,Object> variables = new HashMap<String,Object>();
                              variables.put(contractID, "" + contractID);
                              variables.put("group", "control-attendants");
                              


                              In the AssignmentHandler :
                              String group = (String)executioncontext.getVariable("group");
                              assignable.setPooledActors(group);
                              


                              It's working, but I hate it. It ties the process definition to my code : the group name is completly resolved in the code.
                              Is there any other way in the process definition to define a variable that I would get as a clue in my AssignmentHandler ?
                              Or even a cleaner solution that you would think of ?

                              Thanks for your time and opinion.

                              Cheers,

                              Jerome

                              • 27. Re: JBPM Identity
                                kukeltje

                                First of all, your code will probably never be 100% independent of the process and in reality it never caused big problems for me.

                                You can not, unfortunately, create kind of static variables in jBPM 3. But for assignmenthandlers, just like with actionhandlers, you can pass in data like described in http://docs.jboss.com/jbpm/v3.2/userguide/html/jpdl.html#delegation

                                So you variable *name* (group in your case) can be passed in to a variable (field) in the assignmenthandler and you use that field to retrieve e.g. a processvariable. That way the assignmenthandler is made more generic. You could even pass in 'expressions' and evaluate those.

                                1 2 Previous Next