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

public class XPDLSerializerIOTest
{

	public static void main(String[] args) throws WorkflowException, IOException
	{
		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);
		
		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);
	}
}
