<!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="workflow.services.*" %>
<%@ page import="workflow.store.*" %>
<%@ page import="workflow.client.*" %>
<%@ page import="workflow.client.factory.*" %>
<%@ page import="workflow.wfmc.xpdl.*" %>
<%@ page import="workflow.wfmc.rtm.*" %>
<%@ page import="workflow.wfmc.pm.*" %>

<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(MatrixClient.SECURITY_PRINCIPAL,"zosatapo");
  env.put(MatrixClient.SECURITY_CREDENTIALS,"zosatapo");
 
  WorkflowClient client=WorkflowClientRegistry.retrive(env,application);
  WorkflowSession workflowSession=client.getSession();
  WorkflowService workflowService=client.findService("examples");
  
  //WorkflowPackage workflowPackage=workflowService.findWorkflowPackage("examples");
  WorkflowPackage workflowPackage=workflowService.findWorkflowPackage("xor-join");
  WorkflowProcess workflowProcess=workflowPackage.getMainProcess();
  
  
  CaseDatabase caseDatabase=workflowService.getCaseDatabase();
  UserDatabase userDatabase=workflowService.getUserDatabase();
  Participant zosatapo=userDatabase.findParticipant("zosatapo");
  
	String caseId=caseDatabase.createWorkflowCase(workflowSession.getId(),workflowProcess,zosatapo,new Date(),"first case"," "," ");
	
	WorkflowCase workflowCase=caseDatabase.findWorkflowCase(workflowSession.getId(),workflowProcess,caseId);		
	System.err.println("workflowCase="+workflowCase);
	
	WorkflowWork workflowWork=(WorkflowWork)caseDatabase.getWorkflowWorkList(workflowSession.getId(),workflowProcess,workflowCase,zosatapo,Constants.WORK_STATUS_ACCEPTED).get(0);
	workflowService.getWorkflowDispatcher().dispatch(workflowSession.getId(),workflowWork);
	
  out.println(client.getSession());
  client.disconnect();
%>
</p>
</body>

</html>
