?? assignmenthandler.java
字號(hào):
/* */package com.sun.j2ee.workflow.control.actions;import java.util.HashMap;import java.util.ArrayList;import java.util.Locale;import java.util.Enumeration;import java.util.Calendar;import java.sql.Date;import javax.servlet.http.HttpSession;import com.sun.j2ee.workflow.util.WebKeys;import com.sun.j2ee.workflow.util.JSPUtil;import javax.servlet.http.HttpServletRequest;import com.sun.j2ee.workflow.util.Debug;import com.sun.j2ee.workflow.control.exceptions.WorkflowActionException;import com.sun.j2ee.workflow.control.exceptions.WorkflowAppException;import com.sun.j2ee.workflow.control.exceptions.SigninFailedException;import com.sun.j2ee.workflow.assignment.model.AssignmentModel;import com.sun.j2ee.workflow.assignment.dao.AssignmentDAOImpl;import com.sun.j2ee.workflow.assignment.exceptions.AssignmentDAOSysException;import com.sun.j2ee.workflow.assignment.exceptions.AssignmentDAOAppException;import com.sun.j2ee.workflow.assignment.exceptions.AssignmentDAODBUpdateException;import com.sun.j2ee.workflow.assignment.exceptions.AssignmentDAOFinderException;import com.sun.j2ee.workflow.assignment.exceptions.AssignmentDAODupKeyException;/** AssignmentHandler * @author Jian (James) Cai */public class AssignmentHandler extends ActionHandlerSupport { private static final int CREATE_ASSIGNMENT = 1; private static final int UPDATE_ASSIGNMENT = 2; private static final int REMOVE_ASSIGNMENT = 3; private static final int UNKNOWN = 0; public void perform(HashMap assignmentevent) throws WorkflowActionException{ Debug.println("AssignmentHandler: perform()"); //session of the request are passed as partof the event HttpSession session = (HttpSession)assignmentevent.get("session"); //Locale currentLocale = JSPUtil.getLocale(session); switch (this.mapactiontype((String)assignmentevent.get("actiontype"))) { case CREATE_ASSIGNMENT: { Debug.println("AssignmentHandler: CREATE_ASSIGNMENT event"); try { AssignmentDAOImpl assignmentDa = new AssignmentDAOImpl(); assignmentDa.create(getAssignmentModel(assignmentevent)); } catch (AssignmentDAOSysException pse) { throw new WorkflowActionException(" Error Create Assignment " + pse); } catch (AssignmentDAODupKeyException pde) { throw new WorkflowActionException(" Error Create Assignment " + pde); } catch (AssignmentDAODBUpdateException pue) { throw new WorkflowActionException(" Error Create Assignment" + pue); } catch (AssignmentDAOAppException pue) { throw new WorkflowActionException(" Error Create Assignment" + pue); } } break; case UPDATE_ASSIGNMENT: { Debug.println("AssignmentHandler: UPDATE_ASSIGNMENT event"); try { AssignmentDAOImpl assignmentDa = new AssignmentDAOImpl(); AssignmentModel assignmentMd = getAssignmentModel(assignmentevent); assignmentDa.store(assignmentMd); Debug.println("AssignmentHandler: updating assignment " + (String)assignmentevent.get("assignment_name")); this.context.setAttribute("assignmentupdate", assignmentMd.getAssign_ID()); } catch (AssignmentDAOSysException pse) { throw new WorkflowActionException(" Error Update Assignment " + pse); } catch (AssignmentDAODupKeyException pde) { throw new WorkflowActionException(" Error Update Assignment " + pde); } catch (AssignmentDAODBUpdateException pue) { throw new WorkflowActionException(" Error Update Assignment" + pue); } catch (AssignmentDAOAppException pue) { throw new WorkflowActionException(" Error Create Assignment" + pue); } } break; case REMOVE_ASSIGNMENT: { Debug.println("AssignmentHandler: REMOVE_ASSIGNMENT event"); try { AssignmentDAOImpl assignmentDa = new AssignmentDAOImpl(); assignmentDa.remove((String)assignmentevent.get("assignment_ID")); Debug.println("AssignmentHandler: removing assignment " + (String)assignmentevent.get("assignment_ID")); //should add methods to remove the rows in other table } catch (AssignmentDAOSysException pse) { throw new WorkflowActionException(" Error Remove Assignment " + pse); } catch (AssignmentDAODBUpdateException pue) { throw new WorkflowActionException(" Error Remove Assignment" + pue); } } break; default: Debug.print("Error: not implemented yet"); break; } } private int mapactiontype(String actiontype) { Debug.println("inside mapactiontype: "+ actiontype); if (actiontype.equals("CREATE_ASSIGNMENT")) return this.CREATE_ASSIGNMENT; else if (actiontype.equals("UPDATE_ASSIGNMENT")) return this.UPDATE_ASSIGNMENT; else if (actiontype.equals("REMOVE_ASSIGNMENT")) return this.REMOVE_ASSIGNMENT; else return this.UNKNOWN; } private AssignmentModel getAssignmentModel(HashMap te){ AssignmentModel pjm = new AssignmentModel((String)te.get("assignment_ID"), (String)te.get("assignment_name"), (String)te.get("task"), (String)te.get("user"), (String)te.get("desc"), (String)te.get("comment") ); return pjm; } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -