<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/TR/REC-html40/strict.dtd">
<%@ page import="java.util.*" %>
<%@ page import="org.huihoo.workflow.localclient.*" %>
<%@ page import="org.huihoo.workflow.localclient.factory.*" %>
<%@ page import="org.huihoo.workflow.localclient.model.*" %>
<%@ page import="org.huihoo.workflow.store.*" %>
<%@ page import="org.huihoo.workflow.store.persistent.*" %>
<%@ page import="org.huihoo.workflow.usermodel.*" %>
<%@ page import="org.huihoo.workflow.xpdl.*" %>
<%@ page import="org.huihoo.workflow.runtime.*" %>

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title><%= application.getServerInfo() %></title>
    <style type="text/css">
      <!--
        body {
            color: #000000;
            background-color: #FFFFFF;
            font-family: Arial, "Times New Roman", Times;
            font-size: 16px;
        }

        A:link {
            color: blue
        }

        A:visited {
            color: blue
        }

        td {
            color: #000000;
            font-family: Arial, "Times New Roman", Times;
            font-size: 16px;
        }

        .code {
            color: #000000;
            font-family: "Courier New", Courier;
            font-size: 16px;
        }
      -->
    </style>
</head>

<body>
<p>
<% 
    Hashtable env=new Hashtable();
		env.put(InitialLocalClient.INITIAL_CLIENT_FACTORY,"org.huihoo.willow.client.ObjectClientFactoryImpl");
		env.put(InitialLocalClient.PROVIDER_URL,"local://examples-tomcat");
		env.put(InitialLocalClient.SECURITY_PRINCIPAL,"zosatapo");
		env.put(InitialLocalClient.SECURITY_CREDENTIALS,"zosatapo");
		
		InitialLocalClient localClient=new InitialLocalClient(env);
		
		String package_id="willow-or-join";
		
		LocalService localService=localClient.findService("examples-tomcat");
		
		out.println("-----------------------------------------------"+"<BR>");
		out.println("org.huihoo.workflow="+localService.getName()+"<BR>");
			
		LocalUserDatabase userDatabase=localService.getUserDatabase();	
		WorkflowParticipant zosatapo=userDatabase.findParticipant("zosatapo");
		LocalCaseDatabase caseDatabase=localService.getCaseDatabase();
		WorkflowSession wfSession=localClient.getSession();
		
		WorkflowPackage localPackage=localService.findPackage(package_id);
		out.println("localPackage : "+localPackage+"<BR>");
		
		WorkflowProcess localProcess=localPackage.getMainProcess();
		
		out.println("localProcess : "+localProcess+"<BR>");
		out.println("caseDatabase : "+caseDatabase+"<BR>");
		out.println("maxInactiveInterval : "+wfSession.getMaxInactiveInterval()+" [s] "+"<BR>");
		String caseId=caseDatabase.createWorkflowCase(localProcess,zosatapo,new Date(),"first case"," "," ");
		
		WorkflowCase localCase=caseDatabase.findWorkflowCase(localProcess,caseId);			
		WorkflowWork localWork=(WorkflowWork)caseDatabase.getWorkflowWorkList(localProcess,localCase,zosatapo,Constants.WORK_STATUS_ACCEPTED).get(0);
		caseDatabase.dispatch(localWork);
		localClient.disconnect();
		
		out.println("-------org.huihoo.workflow execution completed--------------"+"<BR>");
%>
</p>
</body>

</html>
