KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mc > formgenerator > servlets > bonita > ModelWorkList


1 /*
2  * Created on September 2004, the 16th
3  * By the Message Center Team
4  */

5 package mc.formgenerator.servlets.bonita;
6
7 import hero.interfaces.ProjectSessionLocalHome;
8 import hero.interfaces.UserSessionLocalHome;
9 import hero.util.HeroException;
10 import hero.util.StrutsNodeValue;
11
12 import java.util.Collection JavaDoc;
13 import java.util.Hashtable JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Vector JavaDoc;
16
17 import javax.ejb.CreateException JavaDoc;
18 import javax.naming.NamingException JavaDoc;
19
20 import mc.formgenerator.bonita.Worklist;
21
22 /**
23  * Model for servlet ServletWorkList
24  * @author SEMPERE benjamin
25  *
26  */

27 public class ModelWorkList {
28     
29     //The worklists list
30
private Vector JavaDoc workList;
31     
32     
33     /**
34      * Default constructor for our class
35      *
36      */

37     public ModelWorkList(){
38         this.setWorkList(new Vector JavaDoc());
39     }
40     
41     
42     
43     
44     /**
45      * For each project of the user, store its worklist
46      * @throws CreateException
47      * @throws NamingException
48      * @throws HeroException
49      */

50     public void process()
51         throws CreateException JavaDoc, NamingException JavaDoc, HeroException{
52         
53         //Get project session bean
54
hero.interfaces.UserSessionLocalHome userh = (UserSessionLocalHome)hero.interfaces.UserSessionUtil.getLocalHome();
55         hero.interfaces.UserSessionLocal usersession = userh.create();
56         hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome)hero.interfaces.ProjectSessionUtil.getLocalHome();
57
58         //Get project list
59
Collection JavaDoc projects = usersession.getProjectList();
60         Iterator JavaDoc i = projects.iterator();
61         
62         while (i.hasNext()){
63         
64             Worklist currentWorkList = new Worklist();
65             
66             //Get current project name
67
String JavaDoc currentProject = ((hero.interfaces.BnProjectLightValue)i.next()).getName();
68             
69             //Current project todo list name
70
Vector JavaDoc todoListNames = new Vector JavaDoc(usersession.getToDoList(currentProject));
71             
72             //Current activity list for the current project
73
Vector JavaDoc activityListNames = new Vector JavaDoc(usersession.getActivityList(currentProject));
74
75             Hashtable JavaDoc readyList = new Hashtable JavaDoc();
76             Hashtable JavaDoc executingList = new Hashtable JavaDoc();
77             Hashtable JavaDoc anticipableList = new Hashtable JavaDoc();
78             Hashtable JavaDoc anticipatingList = new Hashtable JavaDoc();
79
80             //Setting worklist values
81
if (todoListNames.size() != 0 || activityListNames.size() != 0){
82                 
83                 //Setting project name
84
currentWorkList.setProjectName(currentProject);
85                 
86                 //Get project session bean
87
hero.interfaces.ProjectSessionLocal projectsession = projecth.create();
88                 projectsession.initProject(currentProject);
89             
90                 int j=0;
91                 while (j<todoListNames.size()){
92                     StrutsNodeValue stnt = new StrutsNodeValue();
93                     stnt.setProjectName(currentProject);
94                     stnt.setName(((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String JavaDoc)todoListNames.elementAt(j))).getName());
95             
96                     if (((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String JavaDoc)todoListNames.elementAt(j))).getState() == hero.interfaces.Constants.Nd.READY)
97                         readyList.put((String JavaDoc)todoListNames.elementAt(j), stnt);
98                     else
99                         anticipableList.put((String JavaDoc)todoListNames.elementAt(j), stnt);
100                     j++;
101                 }
102             
103                 j=0;
104                 while (j<activityListNames.size()){
105                     StrutsNodeValue stna = new StrutsNodeValue();
106                     stna.setProjectName(currentProject);
107                     stna.setName(((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String JavaDoc)activityListNames.elementAt(j))).getName());
108     
109                     if (((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String JavaDoc)activityListNames.elementAt(j))).getState() == hero.interfaces.Constants.Nd.ANTICIPATING)
110                         anticipatingList.put((String JavaDoc)activityListNames.elementAt(j),stna);
111         
112                     else{
113                         executingList.put((String JavaDoc)activityListNames.elementAt(j),stna);
114                     }
115                 j++;
116                 }
117                 
118                 //Initializing class attribute
119
currentWorkList.setTodoListReady(readyList);
120                 currentWorkList.setTodoListAnti(anticipableList);
121                 currentWorkList.setActivityListAnti(anticipatingList);
122                 currentWorkList.setActivityListExec(executingList);
123                 this.getWorkList().add(currentWorkList);
124             }
125         }
126     }
127
128     
129     
130     
131     /**
132      * Get the workLists list
133      * @return the workLists list as Vector
134      */

135     public Vector JavaDoc getWorkList() {
136         return workList;
137     }
138     
139     
140     
141     
142     /**
143      * Set the workLists list
144      * @param workList the workLists list to set
145      */

146     public void setWorkList(Vector JavaDoc workList) {
147         this.workList = workList;
148     }
149 }
150
151
Popular Tags