0 Replies Latest reply on Jul 24, 2007 5:49 PM by harpritt k

    My filtered pooledTaskInstanceList

    harpritt k Novice

      I needed a filtered version of the pooledTaskInstanceList so that i could select tasks assigned to a given actor pool.

      the two actor pools tasks that i needed were CRS_Releaser and CRS_Processor.

      i can use following to get my filtered lists

      #{cRSReleaserPooledTaskInstanceList}


      #c{RSProcessorrPooledTaskInstanceList}



      i dont know how "good" my solution is.... any comments would be nice.

      anyway i hope this helps someone else out there.

      package main.java.com.sms.crs.customComponents;
      
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Factory;
      import org.jbpm.taskmgmt.exe.TaskInstance;
      
      
      import java.util.List;
      import java.util.Iterator;
      import java.util.ArrayList;
      
      @Name("customSeamComponents")
      public class CustomSeamComponent {
      
       @In(required = true)
       private List pooledTaskInstanceList;
      
       //could make this filter on more than a single actor..really this is a group
      
       @Factory("cRSReleaserPooledTaskInstanceList")
       public List cRSReleaserPooledTaskInstanceList() {
       return filteredPooledTaskInstanceList("CRS_Releaser");
       }
      
       @Factory("cRSProcessorPooledTaskInstanceList")
       public List cRSProcessorPooledTaskInstanceList() {
       return filteredPooledTaskInstanceList("CRS_Processor");
       }
      
      
       //pooled actor is a Role
       private List filteredPooledTaskInstanceList(String pooledActor) {
       List taskInstanceList = new ArrayList();
       Iterator pooledTaskItr = pooledTaskInstanceList.iterator();
       while (pooledTaskItr.hasNext()) {
       TaskInstance taskInstance = (TaskInstance) pooledTaskItr.next();
       if (taskInstance.getTask().getPooledActorsExpression().equals(pooledActor)) {
       taskInstanceList.add(taskInstance);
       }
       }
       return taskInstanceList;
       }
      
      
      }