//----------------------------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.FileWriter;
import java.io.IOException;

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.commons.jdbc.Store;

public class XPDLParserJDBCTest
{

	public static void main(String[] args) throws WorkflowException, IOException
	{
		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");
		store.setProperty(org.huihoo.workflow.WorkflowGlobals.PACKAGE_ID_KEY,"willow-xor-join");
		XPDLParserFactory xpdlParserFactory = new XPDLParserFactoryImpl();
		WorkflowPackage workflowPackage = xpdlParserFactory.newXPDLParser().parse(store);
		System.err.println("XPDLParser : "+workflowPackage);
		
		File xpOut = new File("D:\\project\\willow-xor-join.xpdl");
		XPDLSerializer serializer = new DefaultXPDLSerializer();
		FileWriter writer = new FileWriter(xpOut);
		System.err.println("XPDL OUT FILE : " + xpOut.getAbsolutePath());
		serializer.serialize(workflowPackage, writer);
		writer.close();
		System.err.println("XPDLSerializer : "+workflowPackage);
	}
}
