⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assignmenthandler.java

📁 J2EE & Tomcat books published by hope
💻 JAVA
字号:
/* */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; } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -