1 package hero.struts.actions; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpSession ; 8 import javax.servlet.http.HttpServletResponse ; 9 import org.apache.struts.action.ActionError; 10 import org.apache.struts.action.ActionErrors; 11 import org.apache.struts.action.ActionForm; 12 import org.apache.struts.action.ActionMapping; 13 import org.apache.struts.action.ActionForward; 14 15 import java.util.*; 16 17 import hero.struts.activity.*; 18 import hero.interfaces.*; 19 import hero.util.*; 20 21 27 28 public class WorklistAction extends AbstStrutsActionBase 29 { 30 public boolean authenticate(String username, String password) 31 { 32 return(true); 33 } 34 42 public ActionForward perform(ActionMapping mapping, ActionForm form, 43 HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 44 { 45 46 ActionForward actionForward = mapping.findForward(WORKLIST); 47 ActionErrors errors = new ActionErrors(); 49 HttpSession session = request.getSession(); 50 51 try 52 { 53 Vector workList = new Vector(); 54 hero.interfaces.UserSessionLocalHome userh = (UserSessionLocalHome)hero.interfaces.UserSessionUtil.getLocalHome(); 55 hero.interfaces.UserSessionLocal usersession = userh.create(); 56 57 hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome)hero.interfaces.ProjectSessionUtil.getLocalHome(); 58 59 request.getSession(true).setAttribute("username", usersession.getUser()); 60 request.getSession(true).setAttribute("password", usersession.getUserPassword()); 61 62 Collection projects = usersession.getProjectList(); 63 Iterator i = projects.iterator(); 64 while (i.hasNext()) 65 { 66 Hashtable todoListReady = new Hashtable(); 67 Hashtable todoListAnti = new Hashtable(); 68 Hashtable activityListAnti = new Hashtable(); 69 Hashtable activityListExec = new Hashtable(); 70 71 String currentProject = ((hero.interfaces.BnProjectLightValue)i.next()).getName(); 72 Vector todoListNames = new Vector(usersession.getToDoList(currentProject)); 73 Vector activityListNames = new Vector(usersession.getActivityList(currentProject)); 74 75 if (todoListNames.size() != 0 || activityListNames.size() != 0) 76 { 77 try{ 78 Worklist wl = new Worklist(); 79 wl.setProjectName(currentProject); 80 hero.interfaces.ProjectSessionLocal projectsession = projecth.create(); 81 projectsession.initProject(currentProject); 82 83 int j=0; 84 while (j<todoListNames.size()) 85 { 86 StrutsNodeValue stnt = new StrutsNodeValue(); 87 stnt.setProjectName(currentProject); 88 stnt.setName(((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String )todoListNames.elementAt(j))).getName()); 89 if (((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String )todoListNames.elementAt(j))).getState() == hero.interfaces.Constants.Nd.READY) 90 todoListReady.put((String )todoListNames.elementAt(j),stnt); 91 else 92 todoListAnti.put((String )todoListNames.elementAt(j),stnt); 93 j++; 94 } 95 j=0; 96 while (j<activityListNames.size()) 97 { 98 StrutsNodeValue stna = new StrutsNodeValue(); 99 stna.setProjectName(currentProject); 100 stna.setName(((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String )activityListNames.elementAt(j))).getName()); 101 102 if (((hero.interfaces.BnNodeValue)projectsession.getNodeValue((String )activityListNames.elementAt(j))).getState() == hero.interfaces.Constants.Nd.ANTICIPATING) 103 activityListAnti.put((String )activityListNames.elementAt(j),stna); 104 105 else 106 activityListExec.put((String )activityListNames.elementAt(j),stna); 107 j++; 108 109 } 110 wl.setTodoListReady(todoListReady); 111 wl.setTodoListAnti(todoListAnti); 112 wl.setActivityListAnti(activityListAnti); 113 wl.setActivityListExec(activityListExec); 114 workList.add(wl); 115 }catch(Exception ex){}; 116 } 117 } 118 request.getSession(true).setAttribute("worklist", workList); 119 request.getSession(true).setAttribute("worklistSize", Long.toString(workList.size())); 120 request.getSession(true).setAttribute("wsname",null); 121 122 actionForward = mapping.findForward(WORKLIST); 123 }catch(Exception e){errors.add("activity_error", new ActionError("error.deadline.mismatch"));} 124 125 if (!errors.empty()) { 126 saveErrors(request, errors); 127 } 128 129 return (actionForward); 131 } 132 133 } 134
| Popular Tags
|