//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.coreImpl.store;

import org.huihoo.commons.jdbc.Store;
import org.huihoo.workflow.SchemaContext;
import org.huihoo.workflow.WorkflowException;
import org.huihoo.workflow.store.FactoryManager;
import org.huihoo.workflow.store.WorkflowTemplate;
import org.huihoo.workflow.store.WorkflowTemplateFactory;

public class WorkflowTemplateFactoryImpl implements WorkflowTemplateFactory
{
	public WorkflowTemplateFactoryImpl()
	{
		super();
		
		try
		{
			FactoryManager.registerFactory(this);
		}
		catch (WorkflowException e)
		{
			e.printStackTrace();
		}
	}

	public boolean acceptsStore(Store caseSTORE, Store userSTORE) throws WorkflowException
	{
		return true;
	}

	public WorkflowTemplate create(Store caseSTORE, Store userSTORE,SchemaContext schemaCONTEXT) throws WorkflowException
	{
		WorkflowTemplateImpl plugin = new WorkflowTemplateImpl();
		
		plugin.getCaseDatabase().setStore(caseSTORE);
		plugin.getCaseDatabase().setSchemaContext(schemaCONTEXT);

		plugin.getUserDatabase().setStore(userSTORE);
		plugin.getUserDatabase().setSchemaContext(schemaCONTEXT);
				
		return plugin ;
	}

	public int getMajorVersion()
	{
		return 1;
	}

	public int getMinorVersion()
	{
		return 0;
	}
}
