instanceoperation.java

来自「这是一个工作流管理的后端EJB实现」· Java 代码 · 共 452 行

JAVA
452
字号
/*
 * Created on May 17, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.coshare.joyteam.projectMgr.webbeans;



import javax.servlet.http.HttpServletResponse;
import com.coshare.joyteam.projectMgr.businessDelegate.DelegateException;
import com.coshare.joyteam.projectMgr.businessDelegate.ProjectMgrDelegate;
import com.coshare.joyteam.projectMgr.dto.InstanceDTO;


/**
 * @author Edward
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class InstanceOperation {
	private InstanceDTO insDto;
	
	private String instanceId;
	private String instanceName;
	private String templateID;
	private String startTime;
	private String endTime;
	private String expireTime;
	private String statusKey;
	private String managerId;
	private String managerType;
	private String requesterId;
	private String requesterType;
	private String theDescription;
	
	private HttpServletResponse response=null;
	private String css;
	private String linkcss;
	
	int operate;//代表操作的种类,1为启动,2为暂停,3为恢复,4为中止,5为结束,6为提交
	
	public void setLinkcss(String linkcss){
		this.linkcss = linkcss;
	}
	
	public void setOperate(int operate){
		this.operate=operate;
	}
	
	/**
	 * 设置显示表格的css
	 * @param css
	 */
	public void setCss(String css){
		this.css = css;
	}
	/**
	 * 活动显示表格额css
	 * @return
	 */
	public String getCss(){
		return this.css;
	}
	
	public void setResponse( HttpServletResponse response ){
		this.response = response;
	}
	
	/**
	 * @return Returns the endTime.
	 */
	public String getEndTime() {
		return endTime;
	}

	/**
	 * @param endTime The endTime to set.
	 */
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	/**
	 * @return Returns the expireTime.
	 */
	public String getExpireTime() {
		return expireTime;
	}

	/**
	 * @param expireTime The expireTime to set.
	 */
	public void setExpireTime(String expireTime) {
		this.expireTime = expireTime;
	}

	/**
	 * @return Returns the instanceId.
	 */
	public String getInstanceId() {
		return instanceId;
	}

	/**
	 * @param instanceId The instanceId to set.
	 */
	public void setInstanceId(String instanceId) {
		this.instanceId = instanceId;
	}
	

	
	/**
	 * @return Returns the instanceName.
	 */
	public String getInstanceName() {
		return instanceName;
	}

	/**
	 * @param instanceName The instanceName to set.
	 */
	public void setInstanceName(String instanceName) {
		this.instanceName = instanceName;
	}

	/**
	 * @return Returns the managerType.
	 */
	public String getManagerType() {
		return managerType;
	}

	/**
	 * @param managerType The managerType to set.
	 */
	public void setManagerType(String managerType) {
		this.managerType = managerType;
	}

	/**
	 * @return Returns the managerId.
	 */
	public String getManagerId() {
		return managerId;
	}

	/**
	 * @param managerId The managerId to set.
	 */
	public void setManagerId(String managerId) {
		this.managerId = managerId;
	}

	/**
	 * @return Returns the requesterId.
	 */
	public String getRequesterId() {
		return requesterId;
	}

	/**
	 * @param requesterId The requesterId to set.
	 */
	public void setRequesterId(String requesterId) {
		this.requesterId = requesterId;
	}

	/**
	 * @return Returns the requesterType.
	 */
	public String getRequesterType() {
		return requesterType;
	}

	/**
	 * @param requesterType The requesterType to set.
	 */
	public void setRequesterType(String requesterType) {
		this.requesterType = requesterType;
	}

	/**
	 * @return Returns the startTime.
	 */
	public String getStartTime() {
		return startTime;
	}

	/**
	 * @param startTime The startTime to set.
	 */
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	/**
	 * @return Returns the statusKey.
	 */
	public String getStatusKey() {
		return statusKey;
	}

	/**
	 * @param statusKey The statusKey to set.
	 */
	public void setStatusKey(String statusKey) {
		this.statusKey = statusKey;
	}

	/**
	 * @return Returns the templateID.
	 */
	public String getTemplateID() {
		return templateID;
	}

	/**
	 * @param templateID The templateID to set.
	 */
	public void setTemplateID(String templateID) {
		this.templateID = templateID;
	}

	/**
	 * @return Returns the theDescription.
	 */
	public String getTheDescription() {
		return theDescription;
	}

	/**
	 * @param theDescription The theDescription to set.
	 */
	public void setTheDescription(String theDescription) {
		this.theDescription = theDescription;
	}
	
	public boolean getInstanceDto(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	insDto= td.getInstance(this.instanceName);
		   	td.remove();
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return false;
		}
		return true;
	}
	public String showOperations(){
		StringBuffer tableStr=new StringBuffer();
		tableStr.append("<Table class=\""+this.linkcss+"\" ><TBODY>");
		tableStr.append("<TR >");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=1")
				+"\">"+"启动工作流"+"</A></TD>");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=2")
				+"\">"+"暂停工作流"+"</A></TD>");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=3")
				+"\">"+"恢复工作流"+"</A></TD>");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=4")
				+"\">"+"废除工作流"+"</A></TD>");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=5")
				+"\">"+"停止工作流"+"</A></TD>");
		tableStr.append("<TD ><A href=\""+
	      		response.encodeURL("checkOperateInst.jsp?operate=6")
				+"\">"+"提交工作流"+"</A></TD>");
		tableStr.append("</TR >");
	    tableStr.append("</TBODY></Table>");

	    return tableStr.toString();
	}
	public String getExpression(){
		StringBuffer tableStr=new StringBuffer();
		tableStr.append("<Table class=\""+this.css+"\" ><TBODY>");
		this.organizeTable(tableStr);
		
	    
	    tableStr.append("</TBODY></Table>");

	    return tableStr.toString();
	}
	
	public String startInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.startInstance(this.insDto))
		   		return "启动工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "启动工作流操作失败";
		}
		return "启动工作流操作成功";
	}
	
	public String resumeInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.resumeInstance(this.insDto))
		   		return "恢复工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "恢复工作流操作失败";
		}
		return "恢复工作流操作成功";
	}
	public String suspendInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.suspendInstance(this.insDto))
		   		return "暂停工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "暂停工作流操作失败";
		}
		return "暂停工作流操作成功";
	}
	public String abortInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.abortInstance(this.insDto))
		   		return "废除工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "废除工作流操作失败";
		}
		return "废除工作流操作成功";
	}
	public String terminateInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.terminateInstance(this.insDto))
		   		return "停止工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "停止工作流操作失败";
		}
		return "停止工作流操作成功";
	}
	public String submitInstance(){
		ProjectMgrDelegate td=null;
		try{
		   	td = new ProjectMgrDelegate();
		   	if(!td.submitInstance(this.insDto))
		   		return "提交工作流操作失败";
		   	try{
	   			td.remove();
	   		}catch(DelegateException de){}
		}catch( DelegateException  e){
		   		e.printStackTrace();
		   		try{
		   			td.remove();
		   		}catch(DelegateException de){}
		   		return "提交工作流操作失败";
		}
		return "提交工作流操作成功";
	}
	
	private void organizeTable(StringBuffer tableStr ){
		 
			
		 tableStr.append("<TR >");
		   tableStr.append("<TD >"+"工作流ID"+"</TD>");
		   tableStr.append("<TD >"+"工作流名"+"</TD>");
		   tableStr.append("<TD >"+"模板ID"+"</TD>");
		   tableStr.append("<TD >"+"开始时间"+"</TD>");
		   tableStr.append("<TD >"+"结束时间"+"</TD>");
		   tableStr.append("<TD >"+"预计时间"+"</TD>");
		   tableStr.append("<TD >"+"状态"+"</TD>");
		   tableStr.append("<TD >"+"负责人ID"+"</TD>");
		   tableStr.append("<TD >"+"负责人类型"+"</TD>");
		   tableStr.append("<TD >"+"发起人ID"+"</TD>");
		   tableStr.append("<TD >"+"发起人类型"+"</TD>");
		   tableStr.append("<TD >"+"描述"+"</TD>");
		   tableStr.append("</TR>");
		   
		   tableStr.append("<TR >");
		   tableStr.append("<TD >"+insDto.getInstanceId().getId()+"</TD>");
		   tableStr.append("<TD >"+insDto.getInstanceName()+"</TD>");
		   tableStr.append("<TD >"+insDto.getTemplateID().getId()+"</TD>");
		   tableStr.append("<TD >"+insDto.getStartTime()+"</TD>");
		   tableStr.append("<TD >"+insDto.getEndTime()+"</TD>");
		   tableStr.append("<TD >"+insDto.getExpireTime()+"</TD>");
		   tableStr.append("<TD >"+insDto.getStatusKey()+"</TD>");
		   tableStr.append("<TD >"+insDto.getManagerId()+"</TD>");
		   tableStr.append("<TD >"+insDto.getManagerType()+"</TD>");
		   tableStr.append("<TD >"+insDto.getRequesterId()+"</TD>");
		   tableStr.append("<TD >"+insDto.getRequesterType()+"</TD>");
		   tableStr.append("<TD >"+insDto.getTheDescription()+"</TD>");
	   	   tableStr.append("</TR>");
	}
	public String operate(){
		switch(this.operate){
			case 1:return this.startInstance();
			case 2:return this.suspendInstance();
			case 3:return this.resumeInstance();
			case 4:return this.abortInstance();
			case 5:return this.terminateInstance();
			case 6:return this.submitInstance();
			default: return "未定义的操作";
		}
	}
	

}

⌨️ 快捷键说明

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