//----------------------------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.samples;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.SQLException;

import org.huihoo.workflow.WorkflowException;
import org.huihoo.workflow.coreImpl.xpdl.parser.XPDLParserFactoryImpl;
import org.huihoo.workflow.coreImpl.xpdl.serializer.DefaultXPDLSerializer;
import org.huihoo.workflow.xpdl.WorkflowPackage;
import org.huihoo.workflow.xpdl.parser.XPDLParserFactory;
import org.huihoo.workflow.xpdl.serializer.XPDLSerializer;
import org.huihoo.workflow.xpdl.serializer.XPDLSerializeException;

import org.huihoo.commons.jdbc.Store;

public class XPDLSerializerJDBCTest
{

	public static void main(String[] args) throws WorkflowException, XPDLSerializeException, IOException, SQLException
	{
		File xpIn = new File("D:\\project\\huihoo\\huihoo-samples\\examples-willow\\WEB-INF\\xpdl\\willow-xor-join.xpdl");

		System.err.println("XPDL IN FILE : " + xpIn.getAbsolutePath());

		FileInputStream fis = new FileInputStream(xpIn);
		XPDLParserFactory xpdlParserFactory = new XPDLParserFactoryImpl();
		WorkflowPackage workflowPackage = xpdlParserFactory.newXPDLParser().parse(fis);
		System.err.println("XPDLParser : "+workflowPackage);
		
		Store store = new Store();
		store.setDriverClass("com.mysql.jdbc.Driver");
		store.setUserName("root");
		store.setPassword("");
		store.setType(Store.DRIVERMANAGER_STORE);
		store.setURL("jdbc:mysql://localhost/workflow?useUnicode=true&characterEncoding=gb2312");
		XPDLSerializer serializer = new DefaultXPDLSerializer();
		serializer.serialize(workflowPackage,store);
	}
}
