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

📄 projectmgrbean.java

📁 这是一个工作流管理的后端EJB实现
💻 JAVA
字号:
/*
 * Created on 2005-5-9
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.coshare.joyteam.projectMgr.sessionFacade;

import java.util.Collection;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.NamingException;

import com.coshare.joyteam.projectMgr.dto.AssignmentDTO;
import com.coshare.joyteam.projectMgr.dto.InstanceDTO;
import com.coshare.joyteam.projectMgr.dto.TaskDTO;
import com.coshare.joyteam.projectMgr.dto.TaskRelDTO;
import com.coshare.joyteam.util.ID;
import com.coshare.joyteam.projectMgr.dao.*;
import com.coshare.joyteam.projectMgr.entitybean.instance.*;
import com.coshare.joyteam.projectMgr.entitybean.task.*;
import com.coshare.joyteam.projectMgr.entitybean.taskRel.*;

/**
 * @ejb.bean name="ProjectMgr"
 *	jndi-name="ProjectMgrBean"
 *	type="Stateful" 
 **/

public class ProjectMgrBean implements SessionBean
{
	private static final long serialVersionUID = 3979274633528882487L;

	private SessionContext context;
	
	private InstanceDAO instanceDAO;
	private TaskDAO taskDAO;
	private TaskRelDAO taskRelDAO;

	public void ejbCreate()
	{
		DAOFactory factory = DAOFactory.newInstance();
		instanceDAO = factory.getInstanceDAO();
		taskDAO = factory.getTaskDAO();
		taskRelDAO = factory.getTaskRelDAO();
	}

	public void ejbActivate()
	{
//		System.out.println("ejbActivate()");
	}

	public void ejbPassivate()
	{
//		System.out.println("ejbPassivate()");
	}

	public void setSessionContext(javax.ejb.SessionContext context)
	{
//		System.out.println("setSessionContext(javax.ejb.SessionContext ctx) ");
		this.context = context;
	}

	public void unsetSessionContext()
	{
//		System.out.println("unsetSessionContext()");
		this.context = null;
	}

	public void ejbRemove()
	{
		this.instanceDAO.close();
		this.taskDAO.close();
		this.taskRelDAO.close();
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean startTask(ID instanceId, ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO startTask;
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean resumeTask(ID instanceId, ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO resumeTask;
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean abortTask(ID instanceId, ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO abortTask;
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean suspendTask(ID instanceId, ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO suspendTask;
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean terminateTask(ID instanceId, ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO terminateTask;
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean submitTask(ID taskId)
	{
		//return this.changeTaskStatus(taskId, key);
		// TODO submitTask;
		return false;
	}
	
	private boolean changeTaskStatus(ID taskId, int statusKey) {
		boolean rt = false;
		try {
			TaskLocalHome taskLocalHome = TaskUtil.getLocalHome();
			TaskPK pk = new TaskPK(taskId);
			TaskLocal task = taskLocalHome.findByPrimaryKey(pk);
			task.setStatusKey(statusKey);
			rt = true;
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (FinderException e) {
			e.printStackTrace();
		}
		return rt;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public int addTask(TaskDTO task)
	{
		int rt = 0;
		try {
			TaskLocalHome taskLocalHome = TaskUtil.getLocalHome();
			taskLocalHome.create(task);
			rt = 1;
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		}
		return rt;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public int addTaskRel(ID preTaskId, ID sucTaskId)
	{
		int rt = 0;
		try {
			TaskRelLocalHome taskRelLocalHome = TaskRelUtil.getLocalHome();
			taskRelLocalHome.create(new TaskRelDTO(sucTaskId, preTaskId));
			rt = 1;
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		}
		return rt;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public int delTaskRel(ID preTaskId, ID sucTaskId)
	{
		int rt = 0;
		try {
			TaskRelLocalHome taskRelLocalHome = TaskRelUtil.getLocalHome();
			TaskRelPK pk = new TaskRelPK(sucTaskId, preTaskId);
			taskRelLocalHome.remove(pk);
			rt = 1;
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (EJBException e) {
			e.printStackTrace();
		} catch (RemoveException e) {
			e.printStackTrace();
		}
		return rt;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public TaskDTO getTask(ID taskId)
	{
		try {
			return this.taskDAO.getTask(taskId);
		} catch (DAOException e) {
			e.printStackTrace();
			return null;
		}
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getTasksOfI(ID instanceId)
	{
		try {
			return this.taskDAO.getTasks(instanceId);
		} catch (DAOException e) {
			e.printStackTrace();
			return null;
		}
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public TaskRelDTO getTaskRel(ID taskId_1, ID taskId_2)
	{
		try {
			return this.taskRelDAO.getTaskRel(taskId_2, taskId_1);
		} catch (DAOException e) {
			e.printStackTrace();
			return null;
		}
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public int addAssignment(AssignmentDTO assignment)
	{
		return 0;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public int delAssignment(AssignmentDTO assignment)
	{
		return 0;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public AssignmentDTO getAssignment(ID holderId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public InstanceDTO createInstance(String instanceName, ID templateId)
	{
		InstanceDTO rtDTO = new InstanceDTO();
//		try {
//			WFTemplateMgrLocalHome templateMgrLocalHome = WFTemplateMgrUtil.getLocalHome();
//			WFTemplateMgrLocal templateMgr = templateMgrLocalHome.create();
//			TemplateDTO templateDTO = templateMgr.getTemplate(templateId);
//			
//		} catch (NamingException e) {
//			e.printStackTrace();
//		} catch (CreateException e) {
//			e.printStackTrace();
//		}
		rtDTO.setTemplateID(templateId);
		return rtDTO;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean startInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO startInstance
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean resumeInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO resumeInstance
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean abortInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO abortInstance
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean suspendInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO suspendInstance
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean terminateInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO terminateInstance
		return false;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public boolean submitInstance(InstanceDTO instance)
	{
		//return this.changeInstanceStatus(instance.getInstanceName(), key);
		// TODO submitInstance
		return false;
	}
	
	private boolean changeInstanceStatus(String instanceName, int statusKey) {
		boolean rt = false;
		try {
			InstanceLocalHome instanceLocalHome = InstanceUtil.getLocalHome();
			InstancePK pk = new InstancePK(instanceName);
			InstanceLocal instance = instanceLocalHome.findByPrimaryKey(pk);
			instance.setStatusKey(statusKey);
			rt = true;
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (FinderException e) {
			e.printStackTrace();
		}
		return rt;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getALLInstances()
	{
		try {
			return this.instanceDAO.getInstances();
		} catch (DAOException e) {
			e.printStackTrace();
			return null;
		}
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public InstanceDTO getInstance(String instanceName)
	{
		try {
			return this.instanceDAO.getInstance(instanceName);
		} catch (DAOException e) {
			e.printStackTrace();
			return null;
		}
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getPRInstances(ID requestId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getRInstances(ID requestId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getNSRInstances(ID requestId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getPMInstances(ID managerId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getCMInstances(ID managerId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getSMInstances(ID managerId)
	{
		return null;
	}
	/**
	 * @ejb.interface-method
	 *	view-type="both" 
	**/
	public Collection getNSMInstances(ID managerId)
	{
		return null;
	}
}

⌨️ 快捷键说明

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