/*
 * Created on 2004-5-4
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.test;



/**
 * @author zosatapo
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class WorkflowTest
{
	public static void main(String[] args) throws Exception
	{   
//    try
//    {
//      SchemaContext schemaContext=new SchemaContext("D:\\project\\workflow\\conf\\workflow-schema.properties");
//      Store storeConfig=new Store("DriverManager","dbc:oracle:thin:@reic:1521:workflow","workflow","workflow","oracle.jdbc.driver.OracleDriver");
//      
//      LiveUserDatabase userDatabase=DatabaseUtil.getUserDatabase(storeConfig.getDriverClass()); 
//      userDatabase.setSchemaContext(schemaContext);
//      userDatabase.setStoreConfig(storeConfig);
//      userDatabase.open();
//      
      //FileInputStream fis =new FileInputStream("D:\\project\\workflow\\samples\\sample workflow process.xpdl");
     // XPDLParserFactory xpdlParserFactory=new XPDLParserFactoryImpl();
     // WorkflowPackage workflowPackage= xpdlParserFactory.newXPDLParser().parse(fis);
//      ((PackageImpl)workflowPackage).setUserDatabase(userDatabase);
//      
//      WorkflowProcess mainProcess=workflowPackage.getMainProcess();
//      mainProcess.setWorkDispatcher(new SpiWorkDispatcherImpl());
//      
//      LiveCaseDatabase caseDatabase=DatabaseUtil.getCaseDatabase(storeConfig.getDriverClass()); 
//      caseDatabase.setSchemaContext(schemaContext);
//      caseDatabase.setStoreConfig(storeConfig);
//      caseDatabase.setProcess(mainProcess);
//      caseDatabase.open();
//      
//      mainProcess.setCaseDatabase(caseDatabase);
//      
//      Participant zosatapo=userDatabase.findUser("zosatapo");
//      
//      String caseId=caseDatabase.createCase(zosatapo,new java.util.Date(),"zosatapo-jwz");
//      //System.err.println(java.sql.Date.valueOf("2004-05-04 00:00:00.0"));
//      //WorkflowCase workflowCase=caseDatabase.findCase(caseId);
//      
//      
//      List workList=caseDatabase.getWorkList(zosatapo,WorkflowWorkConstants.STATUS_ACCEPTED);
//      System.err.println("workList="+workList);
//      
//      WorkflowDispatcher workDispatcher=caseDatabase.getProcess().getWorkDispatcher();
//      
//      if(workList.size()>0)
//      {
//        WorkflowWork work=(WorkflowWork)workList.get(0);
//        workDispatcher.dispatch(work);
//      }      
//  
//    }
//    catch(WorkflowException ex)
//    {
//      ex.printStackTrace();
//      if(ex.getRootCause()!=null)
//      {
//        System.err.println("----------------------root cause------------------");
//        ex.getRootCause().printStackTrace();
//      }
//    }
//    catch(Exception ex)
//    {
//      ex.printStackTrace();
//    }
	}
}
