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

📄 wftemplatemgrdelegate.java

📁 这是一个工作流管理的后端EJB实现
💻 JAVA
字号:
package com.coshare.joyteam.projectMgr.businessDelegate;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Date;

import javax.ejb.Handle;
import javax.rmi.PortableRemoteObject;

import com.coshare.joyteam.projectMgr.dto.ActivityDTO;
import com.coshare.joyteam.projectMgr.dto.AssignmentDTO;
import com.coshare.joyteam.projectMgr.dto.TemplateDTO;
import com.coshare.joyteam.projectMgr.sessionFacade.WFTemplateMgr;
import com.coshare.joyteam.util.ID;
import com.coshare.joyteam.projectMgr.dto.ActivityRelDTO;


//测试添加的内容
import java.util.ArrayList;

public class WFTemplateMgrDelegate
{
	private WFTemplateMgr remote;
	private Handle handle;

	public WFTemplateMgrDelegate() throws DelegateException
	{
//		try
//		{
//			WFTemplateMgrHome home =
//				(WFTemplateMgrHome) EJBHomeFactory.getFactory().lookUpEJBHome(
//					WFTemplateMgrHome.class);
//
//			remote = home.create();
//			handle = remote.getHandle();
//		}
//		catch (Exception e)
//		{
//			throw new DelegateException(e);
//		}
	}

	private WFTemplateMgr getEJB() throws DelegateException
	{
		try
		{
			if (remote == null)
			{
				remote =
					(WFTemplateMgr) PortableRemoteObject.narrow(
						handle.getEJBObject(),
						WFTemplateMgr.class);
			}

			return remote;
		}
		catch (Exception e)
		{
			throw new DelegateException(e);
		}
	}

	public void remove() throws DelegateException
	{
//		try
//		{
//			getEJB().remove();
//		}
//		catch (Exception e)
//		{
//			throw new DelegateException(e);
//		}
	}

	/*
	 * Template
	 */
	public int addTemplate(TemplateDTO template) throws DelegateException
	{
//		try
//		{
//			return getEJB().addTemplate(template);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
	}

	public int delTemplate(String templateName, int version)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().delTemplate(templateName, version);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
	}

	public Collection getTemplates(String condition) throws DelegateException
	{
//		try
//		{
//			return getEJB().getTemplates(condition);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		
		ArrayList temp=new ArrayList();
		for( int i=0;i<20;i++ ){
			TemplateDTO tmpDto = new TemplateDTO();
			tmpDto.setCreatingTime(  new Date() );
			tmpDto.setCreator("创建者"+i);
			tmpDto.setCreatorType(i);
			tmpDto.setTemplateId(i);
			tmpDto.setTemplateName("模板名"+i);
			tmpDto.setTheDescription("描述"+i);
			tmpDto.setVersion(1);
			temp.add(tmpDto);
		}
			
	
		
		return temp;
		
	}

	public TemplateDTO getTemplate(String templateName, int version)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().getTemplate(templateName, version);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		TemplateDTO tmpDto = new TemplateDTO();
		tmpDto.setCreatingTime(  new Date() );
		tmpDto.setCreator("创建者");
		tmpDto.setCreatorType(2);
		tmpDto.setTemplateId(1);
		tmpDto.setTemplateName("模板名");
		tmpDto.setTheDescription("描述");
		tmpDto.setVersion(1);
		return tmpDto;
	}

	/*
	 *  Activity
	 */
	public int addActivity(ActivityDTO activity) throws DelegateException
	{
//		try
//		{
//			return getEJB().addActivity(activity);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
	}
	/**
	 * Add this activity after the activity who's ID is activityId
	 * @param <code>ActivityDTO</code> activity
	 * @param <code>ID</code> activityId
	 * @return the number of lines affected
	 * @throws DelegateException
	 */
	public int addActivityAfter(ActivityDTO activity,ID activityId) throws DelegateException
	{

		return 1;
	}
	/**
	 * Add this activity to the head of all the activities associated with a template
	 * @param  <code>ActivityDTO</code>  activity
	 * @return the number of lines affected
	 * @throws DelegateException
	 */
	public int addActivityAhead(ActivityDTO activity) throws DelegateException
	{

		return 1;
	}

	public int delActivity(
		ID templateId,
		String activityName,
		int activityType)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().delActivity(templateId, activityName, activityType);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
		
	}

	public int addActivityRel(ID preActId, ID sucActId)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().addActivityRel(preActId, sucActId);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
	}

	public int delActivityRel(ID preActId, ID sucActId)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().delActivityRel(preActId, sucActId);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		return 1;
	}

	public Collection  getActivitiesOfT(ID templateId) throws DelegateException
	{
//		try
//		{
//			return getEJB().getActivitiesOfT(templateId);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		ArrayList temp=new ArrayList();
		for( int i=0;i<4;i++ ){
			ActivityDTO tmpDto = new ActivityDTO();
			ID tId=TemplateDTO.intToID(i);
			tmpDto.setTemplateId(tId);
			tmpDto.setActivityId(i);
			tmpDto.setActivityName("活动名"+i);
			tmpDto.setTheDescription("描述"+i);
			tmpDto.setActivityType(2);
			
			temp.add(tmpDto);
		}
			
	
		
		return temp;
	}

	public ActivityDTO getActivity(ID activityId) throws DelegateException
	{
//		try
//		{
//			return getEJB().getActivity(activityId);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		ActivityDTO tmpDto = new ActivityDTO();
		
		tmpDto.setActivityId(222);
		tmpDto.setActivityName("活动名"+222);
		tmpDto.setTheDescription("描述"+222);
		tmpDto.setActivityType(2);
		return tmpDto;
	}

	public ActivityDTO getActivity(
		ID templateId,
		String activityName,
		int activityType)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().getActivity(templateId, activityName, activityType);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		ActivityDTO tmpDto = new ActivityDTO();
		
		tmpDto.setActivityId(222);
		tmpDto.setActivityName("活动名"+222);
		tmpDto.setTheDescription("描述"+222);
		tmpDto.setActivityType(2);
		return tmpDto;
	}

	public Object getActivityRel(ID activityId_1, ID activityId_2)
		throws DelegateException
	{
//		try
//		{
//			return getEJB().getActivityRel(activityId_1, activityId_2);
//		}
//		catch (RemoteException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
//		catch (DelegateException e)
//		{
//			e.printStackTrace();
//			throw new DelegateException(e);
//		}
		ActivityRelDTO arDto= new ActivityRelDTO();
		arDto.setActivityRelId(1);
		arDto.setPreActivity(1);
		arDto.setSucActivity(2);
		return arDto;
	}

	/*
	 *  Assignment
	 */
	public int addAssignment(AssignmentDTO assignment) throws DelegateException
	{
		try
		{
			return getEJB().addAssignment(assignment);
		}
		catch (RemoteException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
		catch (DelegateException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
	}

	public int delAssignment(AssignmentDTO assignment) throws DelegateException
	{
		try
		{
			return getEJB().delAssignment(assignment);
		}
		catch (RemoteException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
		catch (DelegateException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
	}

	public AssignmentDTO getAssignment(ID holderId) throws DelegateException
	{
		try
		{
			return getEJB().getAssignment(holderId);
		}
		catch (RemoteException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
		catch (DelegateException e)
		{
			e.printStackTrace();
			throw new DelegateException(e);
		}
	}
}

⌨️ 快捷键说明

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