7 Replies Latest reply on Aug 8, 2008 3:36 AM by Vt Ysh

    Getting comments through command object ?

    Leo de Blaauw Newbie

      Hey all,

      Does anybody have any experience in getting the comment entries through the use of a getTaskInstance command or getprocessInstanceCommand ? I am using these through the command EJB and this will throw a lazy init exception since the collection of Comments is lazy getting it wont work through the EJB interface since obviously the connection through hibernate and the DB is allready gone when you receive the taskinstance of processinstance...

      We could ofcourse modify the sources so this collection is not lazy, but i would rather have the option, like with variables, to set a switch on the command object to retrieve the comments or not and then have the command EJB deal with it.


      Any solutions greatly appreciated...

      Thanks and greetings,
      Leo de Blaauw

        • 1. Re: Getting comments through command object ?
          Ronald van Kuijk Master

          make a new command (almost the same a modifying the source to it not being lazy ;-))

          • 2. Re: Getting comments through command object ?
            Leo de Blaauw Newbie

            Kukeltje,

            Cool, yeah seems like the way to go. Trying that now but my new command not only does not save the new comment but also wipes out any existing ones.. hmmm ??

            Greetings,
            Leo

            "kukeltje" wrote:
            make a new command (almost the same a modifying the source to it not being lazy ;-))


            • 3. Re: Getting comments through command object ?
              Leo de Blaauw Newbie

              Ah,

              My bad.. .Seems if you attach a comment to a task it only belongs to that particular task so when the task finishes its gone. So I have now taken the route taken by kukeltje in a very very old post and have attached my comments to the rootToken wich servers my purpose just fine ! ;-)

              Greetings,
              Leo


              "lblaauw" wrote:
              Kukeltje,

              Cool, yeah seems like the way to go. Trying that now but my new command not only does not save the new comment but also wipes out any existing ones.. hmmm ??

              Greetings,
              Leo

              "kukeltje" wrote:
              make a new command (almost the same a modifying the source to it not being lazy ;-))


              • 4. Re: Getting comments through command object ?
                Vt Ysh Newbie

                Comment is not gone when the task is finished. It is just the jbpm-console problem which displays only process root token comments or task comments but doesn't display all comments at the same time.
                To display all comments you should to iterate through process tokens and display comments for all tokens. You can write custom tag for that thing.

                • 5. Re: Getting comments through command object ?
                  Vt Ysh Newbie

                  Oh, i am sorry, you didn't write anything about jbpm-console. But all other recommendations are still actual. You need to find all process instance tokens with the method findAllTokens(). Then iterate through tokens and get their comments with the method token.getComments() and add all comments to some comments list which will contain all process comments. For a knowledge whether the comment is related to some task instance you can use expression comment.getTaskInstance()!=null

                  • 6. Re: Getting comments through command object ?
                    Leo de Blaauw Newbie

                    Hey vtysh,

                    Well my usecase is actually quite simple, i just need global comments per process instance, so any task user can add comments to the whole process instance. So when i collect a users tasks per task i also collect the process instance comments for that task. Therefore i decided to use the rootToken for this. The processes are actually quite simple so no subprocesses branching etc etc. So i figured i could get away with how i did things.. ;-)

                    Regards and thanks for your reply,

                    Leo

                    "vtysh" wrote:
                    Oh, i am sorry, you didn't write anything about jbpm-console. But all other recommendations are still actual. You need to find all process instance tokens with the method findAllTokens(). Then iterate through tokens and get their comments with the method token.getComments() and add all comments to some comments list which will contain all process comments. For a knowledge whether the comment is related to some task instance you can use expression comment.getTaskInstance()!=null


                    • 7. Re: Getting comments through command object ?
                      Vt Ysh Newbie

                      I propposed you better solution. Because you can simply add comments to the task or dirrectly to the process and then know for which task the comment was done.