%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
Query Properties Sample
<%@ page import="com.ibm.bpe.api.*"%>
<%@ page import="javax.naming.*"%>
<%@ page import="java.util.TimeZone"%>
Query Properties - Sample
<%
try {
// Get the customer id input
Object idInput = request.getParameter("idInput");
// Obtain the default initial JNDI context
Context initialContext = new InitialContext();
// Lookup the local home interface of the LocalBusinessFlowManager bean
Object resultLookup = initialContext.lookup("java:comp/env/ejb/LocalBusinessFlowManagerHome");
// Convert the lookup to the proper type
LocalBusinessFlowManagerHome processHome = (LocalBusinessFlowManagerHome)resultLookup;
// Create the EJB
LocalBusinessFlowManager flowManager = processHome.create();
// Check whether a customer ID was specified.
boolean customerIdGiven = (idInput != null && !((String)idInput).trim().equals(""));
// Create the query depending on whether a customer id was specified.
String selectClause = null;
String whereClause = null;
String orderByClause = null;
if (!customerIdGiven) {
// ALL TASKS
out.println("All insurance claim tasks:
");
selectClause =
"TASK.TKIID," +
"TASK.NAME," +
"TASK_DESC.DESCRIPTION," +
"PROCESS_INSTANCE.PIID," +
"PROCESS_INSTANCE.NAME," +
"QUERY_PROPERTY0.NUMBER_VALUE," +
"QUERY_PROPERTY1.STRING_VALUE," +
"QUERY_PROPERTY2.NUMBER_VALUE";
whereClause =
"TASK.STATE = TASK.STATE.STATE_READY AND " +
"TASK.KIND = TASK.KIND.KIND_PARTICIPATING AND " +
"WORK_ITEM.REASON = WORK_ITEM.REASON.REASON_POTENTIAL_OWNER AND " +
"TASK_DESC.LOCALE = 'default' AND " +
"QUERY_PROPERTY0.NAME = 'customerID' AND " +
"QUERY_PROPERTY1.NAME = 'claimDescription' AND " +
"QUERY_PROPERTY2.NAME = 'claimAmount'";
orderByClause =
"QUERY_PROPERTY2.NUMBER_VALUE DESC";
}
else {
// TASKS FOR GIVEN CUSTOMER ID
out.println("Insurance claim tasks for customer ID "+idInput+":
");
selectClause =
"TASK.TKIID," +
"TASK.NAME," +
"TASK_DESC.DESCRIPTION," +
"PROCESS_INSTANCE.PIID," +
"PROCESS_INSTANCE.NAME," +
"QUERY_PROPERTY1.STRING_VALUE," +
"QUERY_PROPERTY2.NUMBER_VALUE";
whereClause =
"TASK.STATE = TASK.STATE.STATE_READY AND " +
"TASK.KIND = TASK.KIND.KIND_PARTICIPATING AND " +
"WORK_ITEM.REASON = WORK_ITEM.REASON.REASON_POTENTIAL_OWNER AND " +
"TASK_DESC.LOCALE = 'default' AND " +
"QUERY_PROPERTY0.NAME = 'customerID' AND " +
"QUERY_PROPERTY0.NUMBER_VALUE = "+idInput+" AND " +
"QUERY_PROPERTY1.NAME ='claimDescription' AND " +
"QUERY_PROPERTY2.NAME ='claimAmount'";
orderByClause =
"QUERY_PROPERTY2.NUMBER_VALUE DESC";
}
// Process the query
QueryResultSet result = flowManager.query
(selectClause,
whereClause,
orderByClause,
(Integer)null,
(Integer)null,
(TimeZone)null );
// Create the tables with the query result data
int tableCounter = 0;
if (result.size() != 0) {
while (result.next()) {
tableCounter++;
out.println("Task Result No. "+tableCounter+"
");
out.println(
"");
out.println(
""+
"Task ID | "+
""+result.getOID(1)+" | "+
"
");
out.println(
""+
"Task Name | "+
""+result.getObject(2)+" | "+
"
");
out.println(
""+
"Task Description | "+
""+result.getObject(3)+" | "+
"
");
out.println(
""+
"Process ID | "+
""+result.getOID(4)+" | "+
"
");
out.println(
""+
"Process Name | "+
""+result.getObject(5)+" | "+
"
");
int customerIDOffest = 0;
if (!customerIdGiven) {
out.println(
""+
"Customer ID | "+
""+result.getObject(6)+" | "+
"
");
customerIDOffest = 1;
}
out.println(
""+
"Claim Description | "+
""+result.getObject(6+customerIDOffest)+" | "+
"
");
out.println(
""+
"Claim Amount | "+
""+result.getObject(7+customerIDOffest)+" | "+
"
");
out.println("
");
}
}
else {
out.println("Sorry, no claim handling tasks were found.
");
}
}
catch (Exception e) {
out.println("An exception occurred: "+e.getLocalizedMessage());
e.printStackTrace();
}
%>
Home