8 Replies Latest reply on Feb 22, 2010 11:11 PM by praneet

    implementing java logic inside task node

    praneet

      hello everyone,

          my usecase is like this , am building a student registration process using spring 2.5 and jbpm 4.0,

          first of user fills a initial form ,when he clicks a submit button process instance is started and it goes to mail node and

      a mail is sended to student using mail node. now my execution comes in wait state where it waits untill a link is clicked by the student.

      when user clicks the link he goes to the login page  and he has to complete two form contaning personal and educational detail.now my execution is wating in task node which is assigned to current student.

                                                   now what i want is when student submits the final form it should come to next node which is again a mail node for sending welcome mail.

      problem is what to do in task node whether i should write event listner in task node to call java method containig logic of saving form object in database or to use java node instead of task node?.

       

      please help

       

      thankyou

        • 1. Re: implementing java logic inside task node
          yushanyuan

          in my way, i do this in two steps. first, save the student form in database, second, signal the process. one point that you should remember is these

          two steps should be done in one transaction.

          1 of 1 people found this helpful
          • 2. Re: implementing java logic inside task node
            praneet

            he lele thanks for replying

               just look what i am doing this is my task node where asignee is student who has filled the form.

             

                 <task assignee="#{student.Name}" g="117,198,166,52" name="complete-registration-online">

                  <transition name="to send-welcome-email" to="send-welcome-email" g="-114,-18"/>

               </task>

             

                 then in the service class i am written following method. when student sumit the form

                 following method is called .

             

             

             

            public void saveForm(Form form) {

            String name=form.getStudent().getName();

            List<Task> tasks=taskService.findPersonalTasks(name);

            System.out.println(tasks.get(0));

            hibernateTemplate.saveOrUpdate(form);

            taskService.completeTask(tasks.get(0).getId());

             

            }

             

             

              in this method when form is saved what i have done is i have  called the complete task method.

             

                  so my question is this is write way to implement the task node or i have to do something different please suugest

            • 3. Re: implementing java logic inside task node
              yushanyuan
              your code is right. just make sure that happen in one transaction.
              • 4. Re: implementing java logic inside task node
                yushanyuan
                you`d better put the List<Task> tasks=taskService.findPersonalTasks(name); in another method. and taskid can be used as a parameter
                • 5. Re: implementing java logic inside task node
                  praneet

                  thanks lee ,

                      i have done as u said.its working fine.

                      but tell me situation in which i should write event listner in the task node instead of doing what i have done previously

                  • 6. Re: implementing java logic inside task node
                    yushanyuan
                    i am sorry. i never done this in a event listener before. so can not help.
                    • 7. Re: implementing java logic inside task node
                      kukeltje

                      or do it in a data/process access layer, completely outside the process that just shares the transaction or.... take your pick.... it depends on what you want to do with the data...

                       

                      EDIT:

                      Oops sorry, all the other responses were not visible... strange...

                      1 of 1 people found this helpful
                      • 8. Re: implementing java logic inside task node
                        praneet
                        can i do something like this in eventlistner of task node  i will call the my java method that is task assigned to the assignee between the task start and task complete block.