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

📄 configalteraction.java

📁 本人课程设计时做的一个用struts框架实现的基于cmmi2的项目管理系统的原型。还有部分功能尚未实现
💻 JAVA
字号:
package com.cmmi2pms.cm.configalter;import org.apache.log4j.Logger;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpSession;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.lang.*;import org.apache.struts.action.Action;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import com.cmmi2pms.sa.user.Employee;import com.cmmi2pms.sa.project.Project;import com.cmmi2pms.common.*;public class ConfigAlterAction extends Action {    private static Logger logger = Logger.getLogger ("ConfigAlterAction");	public ActionForward execute(ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response)		throws Exception {						ActionErrors errors = new ActionErrors();        ConfigAlterAttr[] theAttrList = new ConfigAlterAttr[5]  ;        ConfigAlterAttr attrDetail = new ConfigAlterAttr();                HttpSession session = request.getSession();                Employee user = (Employee) session.getAttribute(com.cmmi2pms.common.Constants.USER_KEY);        Integer userID = new Integer(user.getUserID());        Project thtProject = (Project) session.getAttribute(com.cmmi2pms.common.Constants.PROJECT_KEY);        AlterMgr theAlterMgr = new AlterMgr(thtProject.getProjectID(),userID.intValue());                ConfigAlterForm aForm = (ConfigAlterForm) form;                // If all exceptions are registered with handlers        // the try .. catch clause can be omitted        System.out.println("ConfigAlterAction is invoked");        String forwardKey = new String();        String blanch1 = new String("viewItem");        String blanch2 = new String("viewDetail");        String blanch3 = new String("applyAlter");                String theAlterId = new String();        String toDo ;                //String blanch4 = new String("submitApply");        try {        	if (request.getParameter("toDo") == null)        	{        		logger.info("toDo para is null;act =" + aForm.getact());        		if (aForm.getact().equals("addNewAlter"))        		{        		    logger.info("In blanch null subblanch addNewAlter");        		            		//write to database        	    	int a =theAlterMgr.getAlterItemNum() + 1;        		    theAlterMgr.modifyAppTab(-1,aForm.getalteritem(),aForm.getreason(),        		                         aForm.getrequisttype(),aForm.getcontent());        		    //aForm.setact("applied");        		    forwardKey = "applyNewAlter";        	    }         	    else if (aForm.getact().equals("approveAlter"))        		{        		    logger.info("In blanch null subblanch approveAlter");        		            		logger.info("aForm's applyid = "+aForm.getalterapplyid());         		    theAlterMgr.modifyApproveTab(aForm.getalterapplyid(),aForm.getstatus(),aForm.getapprovereport(),aForm.getapprover(),aForm.getvalidator());            	   		           // logger.info("Before Return from ConfigAlterAction");        		            		    //aForm.setact("approved");        		    forwardKey = "saveApproveAlter";        	    }        	            	     else         	    {        	        forwardKey = "approveAlter";        	    }        	            	}        	else         	{        		toDo= new String(request.getParameter("toDo"));        		logger.info("toDo is not null :" + toDo);        		        		if (toDo.equals(blanch1))        	    {        	    	aForm.setact("");        		    int itemNum = theAlterMgr.getAlterItemNum();        	        theAttrList = new ConfigAlterAttr[itemNum];        	        theAttrList = theAlterMgr.getAlterAttrList();        	                	        //System.out.println("write to session ");		            session.setAttribute("theAttrList",theAttrList );		            //System.out.println("writing finished");		            //session.getValue("theAttrList");		            forwardKey = "viewAlterItem";        	    }        	        	    else if (toDo.equals(blanch2))        	    {        	    	aForm.setact("");        		    System.out.println("Blanch 2");        		    System.out.println("aid="+request.getParameter("theAlterId"));        		                		theAlterId = request.getParameter("theAlterId");            		System.out.println("标识"+theAlterId);            		Integer tmp = new Integer(theAlterId);        		        		        		            		attrDetail = theAlterMgr.getDetailInfo(tmp.intValue());            		            		System.out.println("write to session ");		            session.setAttribute("theAttrDetail",attrDetail );		            System.out.println("writing finished");		            forwardKey = "viewDetailItem";		                    	    } else if (toDo.equals(blanch3))        	    {        		    logger.info("In blanch 3 applyAlter");            		aForm.setact("addNewAlter");            		logger.info("aForm's act = "+aForm.getact());            		            		forwardKey = "applyNewAlter";            		         	    } else if (toDo.equals("approveAlter"))        	    {        		            		    logger.info("In blanch 4 approveAlter");            		aForm.setact("approveAlter");            		            		theAlterId = request.getParameter("theAlterId");            		Integer id = new Integer(theAlterId);            		aForm.setalterapplyid(id.intValue());            		logger.info("aForm's act = "+aForm.getact());              		logger.info("aForm's applyid = "+aForm.getalterapplyid());          		            		            		forwardKey = "approveAlter";        	       /*        	       theAlterId = request.getParameter("theAlterId");            	   logger.info("标识"+theAlterId);            	               	   Integer tmp = new Integer(theAlterId);            	               	   theAlterMgr.modifyApproveTab(tmp.intValue(),aForm.getstatus(),aForm.getapprovereport(),aForm.getapprover(),aForm.getvalidator());            	   		           logger.info("Before Return from ConfigAlterAction");		           */        	    }        	    else if (toDo.equals("delAlter"))        		{        		    logger.info("In blanch 5 subblanch delAlter");        		            		forwardKey = "delAlter";                   		            		theAlterId = (String) request.getParameter("theAlterId");	                 	               	    theAlterMgr.delAlter(theAlterId); 	                   	    }        	    else         	    {        	        forwardKey = "approveAlter";        	    }        	}        }        // * Catch your business exceptions here *        catch (Exception e) {        	// Log and print to error console        	logger.error("Exception: " + e.getMessage() );        	e.printStackTrace();        	// General error message        	errors.add(ActionErrors.GLOBAL_ERROR,        		new ActionError("error.general"));        	// Generate error message from exceptions        	errors.add(ActionErrors.GLOBAL_ERROR,        	new ActionError("error.detail",e.getMessage()));        	        }        // Report any errors        if (!errors.empty()) {        	//写日志        	StringBuffer message =                new StringBuffer("Error in XXXX: '");            message.append("your error information.");            message.append(session.getId());            servlet.log(message.toString());        	        	//写错误信息,供页面显示,返回输入页面        	saveErrors(request, errors);        	if (mapping.getInput()!=null)        		return (new ActionForward(mapping.getInput()));        	// If no input page, use error forwarding        	return (mapping.findForward("Error"));		}    	// * If your business logic created any *    	// * helper objects, save them before returning *    	// * request.setAttribute("yourKey",yourBusinessObject); *    	// * Return the ActionForward you use for success *    	/*            if (request.getParameter("toDo")!= null)        	{        		String toDo2 = new String(request.getParameter("toDo"));        		if (toDo2.equals( "viewItem" ))                {                	        	        HttpSession session = request.getSession();        	        System.out.println("write to session ");		            session.setAttribute("theAttrList",theAttrList );		            System.out.println("writing finished");		            //session.getValue("theAttrList");		            forwardKey = "viewAlterItem";		        } else if (toDo2.equals("viewDetail"))                {        	        HttpSession session = request.getSession();        	        System.out.println("write to session ");		            session.setAttribute("theAttrDetail",attrDetail );		            System.out.println("writing finished");		            forwardKey = "viewDetailItem";       	                } else if ( toDo2.equals(blanch3) )               {        	       forwardKey = "applyNewAlter";               } else if ( toDo2.equals("approveAlter") )               {        	       forwardKey = "approveAlter";        	               	       theAlterId = request.getParameter("theAlterId");            	   logger.info("标识"+theAlterId);            	               	   Integer tmp = new Integer(theAlterId);            	               	   theAlterMgr.modifyApproveTab(tmp.intValue(),"通过审核",aForm.getapprovereport(),aForm.getapprover(),aForm.getvalidator());            	   		           logger.info("Before Return from ConfigAlterAction");               }        	               }        */		logger.info("Before Return from ConfigAlterAction");		logger.info("forwardKey = "+forwardKey);		return (mapping.findForward(forwardKey));   	    }}

⌨️ 快捷键说明

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