9 Replies Latest reply on Oct 13, 2006 12:04 PM by Pete Muir

    End a task and begin another at the same time?

    Arthur Marinis Newbie

      Using Seam, is it possible to end a task using @EndTask (transition....) and begin another task at the same time?

        • 1. Re: End a task and begin another at the same time?
          Gavin King Master

          There are probably ways to do it, but it seems an incredibly strange thing to want to do. Are you sure you are not "using it wrong"?

          • 2. Re: End a task and begin another at the same time?
            Arthur Marinis Newbie

            I think the application could be developed better but since it is a POC I am not too fussed.

            The reason for wanting to do this is as follows

            My process definition begins with a decision, the decision depending on the action will either assign to a parent item(and begin work) or ask the user to select a parent item.

            If the user is asked to select a parent item, the next task is to assign the item and begin work.

            I should probably use a page flow as this would solve the issue but I am trying to maintain visibility at a process level for all human tasks.

            • 3. Re: End a task and begin another at the same time?
              Tom Baeyens Master

              ending a task and starting a new task normally doesn't make sense.

              there is one special situation in which this could make sense: after a task is ended, this could result in the process creating a new task for the logged in user. if that is the case, navigation could be done straight to the new task. if there is no new task for the logged in user, navigation could proceed to a task list page.

              that would be a kind of wizard like thing in the process. so that in a new session, the user can restart in the same page where he/she left off.

              apart from such situations, you should really separate pageflow from the business process.

              regards, tom.

              • 4. Re: End a task and begin another at the same time?
                Arthur Marinis Newbie

                Tom

                That is pretty much the scenario I am trying to achieve.

                The first task has an action I do not want to run again if the user exits the session.

                In essence the pageflow is only an offshoot of the current business process.

                • 5. Re: End a task and begin another at the same time?
                  Gavin King Master

                  OK, can you please explain in a bit more detail (showing code), and I will try to understand it and see if it can be done in Seam today.

                  • 6. Re: End a task and begin another at the same time?
                    Arthur Marinis Newbie

                    OK Here it goes

                    The system I am prototyping is as follows.

                    Within an insurance company, a client(member) has asked for an increase of cover. In this case, the request has come through in the format of an application form.

                    This application form is scanned and starts a process definition.

                    @CreateProcess(definition="DocumentLoader")
                     @IfInvalid(outcome=REDISPLAY)
                     public String scannedLoaderIn() {
                     try{
                     log.info("Document loaded");
                     documentLocation="sample.pdf"; //The document
                     return "complete";
                     }catch(Exception e){
                     log.info(e.getMessage());
                     }
                     return null;
                     }


                    A decision node is then executed to determine if the image should be attached to an existing case or if a new case needs to be established.

                    <decision name="CoverExists" expression="#{Exists.checkCoverExists}">
                     <transition name="NoCoverExists" to="CheckOut">
                     <action expression="#{coverTasks.createCover}"/>
                     </transition>
                     <transition name="AtleastOneCoverExists" to="SelectCover"></transition>
                     </decision>
                    


                    if no cover exists then the method createCover is executed. This in essence creates a default cover and transition is sent to the next Task Node.

                    If a cover exists, then the user is expected to select from a list of existing covers.
                    <task-node name="SelectCover">
                     <task name="choose" description="Multiple Open Covers">
                     <assignment pooled-actors="user"/>
                     </task>
                     <transition name="cancel" to="SelectCover"/>
                     <transition name="CoverSelected" to="CheckOut"></transition>
                     <transition name="NewCover" to="CheckOut">
                     <action expression="#{fileTasks.createFile}"/>
                     </transition>
                     </task-node>



                    In this instance however, instead of the user needing to select the work item from the pooled Instance list, the user should be able to continue with the same work item. ie: transition to this task automatically instead of having to select it again.

                    The code for this transition looks like this
                     @EndTask(transition="FileSelected")
                     @IfInvalid(outcome="multipleFiles")
                     public String select(){
                     if(fileId==null || fileId==0)
                     return null;
                    
                     try{
                     log.info("FileId: "+ fileId);
                     //This is where we can attach the Document to the Cover
                     Document document = new Document(em.find(Cover.class,fileId),user,(DocumentType)em.find(DocumentType.class,documentTypeId));
                     document.setComment("Added to Cover");
                     document.setFileObject(documentLocation);
                     em.persist(document);
                     em.flush();
                     log.info("Document Saved and Flushed");
                     }catch(Exception ex){
                     log.info("Failed to save Document: "+ ex.getMessage());
                     }
                     return "cover";
                     }

                    Once the selection is done, the transition moves to the next task called CheckOut. Note this is the same task as that called when there is no cover.

                    This then appears in the specified work lists as determined by the pooledTaskInstanceList.


                    as you can see above, the document(image) is simply added to the selected cover. The EndTask is to mark the transition to the next task.

                    The return "cover" displays the cover item page. I would like the user to manipulate this cover within a task, especially since they may exit there session before processing and starting a new task.

                    What I thought I could use is the annotation @Begintask at the top of the method but this obviously fails.

                    One way I thought this could be achieved is by using BeginTask with a parameter to signify starting the task after a succesful EndTask transition

                    hope this makes sense

                    • 7. Re: End a task and begin another at the same time?
                      Arthur Marinis Newbie

                      Gavin

                      Have you managed to look at this one yet?

                      let me know what you think.

                      • 8. Re: End a task and begin another at the same time?
                        Gavin King Master

                        It seems to me that you just need another decision that determines whether the task should really be created in the first place.

                        • 9. Re: End a task and begin another at the same time?
                          Pete Muir Master

                           

                          "tom.baeyens@jboss.com" wrote:
                          there is one special situation in which this could make sense: after a task is ended, this could result in the process creating a new task for the logged in user. if that is the case, navigation could be done straight to the new task. if there is no new task for the logged in user, navigation could proceed to a task list page.


                          Is this something that will work? If so how would it be done?

                          I have a task node at which the user makes a decision (there are multiple transitions out of the node), one of these leads to another task node. I would like the user to be able to start the task straight away or to start the task at a later time; because of this requirement I think it has to be two seperate tasks rather than one with a pageflow.