/*
 * Created on 2004-6-29
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.huihoo.willow.client;

import java.rmi.RemoteException;

import workflow.live.LiveService;
import workflow.live.store.LiveCaseDatabase;
import workflow.live.store.LiveDispatcher;
import workflow.live.store.LiveUserDatabase;
import workflow.live.xpdl.LivePackage;
import workflow.services.WorkflowService;
import workflow.wfmc.xpdl.WorkflowPackage;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class LiveServiceImpl extends LiveRemoteObject implements LiveService
{
	private transient LiveCaseDatabase   liveCaseDatabase;
	private transient LiveUserDatabase   liveUserDatabase;
	
	private transient LiveDispatcher     liveWorkflowWD;
	private transient String             name;
	
	private transient WorkflowService workflowService;
	
	public LiveServiceImpl(WorkflowService workflowService)throws RemoteException
	{
		super();
		
		this.name=workflowService.getName();
		
		this.liveCaseDatabase=new LiveCaseDatabaseImpl(workflowService);
		this.liveUserDatabase=new LiveUserDatabaseImpl(workflowService);
		this.liveWorkflowWD=new LiveDispatcherImpl(workflowService);			
		
		this.workflowService=workflowService;
	}
	
	public LivePackage  findLivePackage(String packageID) throws RemoteException
	{
		WorkflowPackage workflowPackage=workflowService.findWorkflowPackage(packageID);
		if(workflowPackage!=null)
		{
			return new LivePackage(workflowPackage);
		}
		
		return null;
	}
	public LiveCaseDatabase          getCaseDatabase() throws RemoteException
	{
		return this.liveCaseDatabase;
	} 
	public LiveUserDatabase          getUserDatabase() throws RemoteException
	{
		return liveUserDatabase;
	}
	public LiveDispatcher        getLiveDispatcher() throws RemoteException
	{
		return liveWorkflowWD;
	}
	public String                   getName()throws RemoteException
	{
		return name;
	}
}
