This post shows how to query task related information from BPEDB .
String whereClause = "TASK_TEMPL.NAME='RequestTask' AND TASK_TEMPL.NAMESPACE="http://ToDoTask/bpc/samples";
//Add "TASK.STATE = TASK.STATE.STATE_READY" to retrieve only those tasks which are in ready state.
QueryResultSet instances = taskManager.query(selectClause, whereClause, null, null, null, null);
To retrieve all the participating task templates :
String whereClause = "TASK_TEMPL.KIND = TASK_TEMPL.KIND.KIND_PARTICIPATING";
TaskTemplate[] templates = taskManager.queryTaskTemplates(whereClause, null, null, null);
System.out.println( " No of templates :" + templates.length);
System.out.println("***** Displaying TaskTemplateInfo ***** ");
for (int i = 0;i<templates.length;i++){
System.out.println(" Task Template Name :" + templates[i].getName());
System.out.println(" Task NameSpace :" + templates[i].getNamespace());
}
To retrieve all Escalation instances of ready tasks :
QueryResultSet escInstances = taskManager.query("DISTINCT ESCALATION.ESIID, ESCALATION.TKIID","TASK.STATE = TASK.STATE.STATE_READY ",(String)null, (Integer)null, (TimeZone)null );
QueryResultSet instances = taskManager.query (" DISTINCT TASK.TKIID, TASK_CPROP.NAME, TASK_CPROP.STRING_VALUE",
"TASK_TEMPL.NAME = 'MyTask'",
String)null, (Integer)null, null );
while(instances.next()){ // looping thru all the rows
TKIID tkiid = (TKIID) instances.getOID(1);
System.out.println("TKIID "+tkiid);
System.out.println(instances.size()); // No of Rows
System.out.println(instances.getColumnDisplayName(1)); // TKIID
System.out.println(instances.getColumnDisplayName(2)); // NAME
System.out.println( instances .getColumnDisplayName(3)); // STRING_VALUE
System.out.println( instances .getString(2)); // Custom Property Name
System.out.println( instances .getString(3)); // Custom Property Value
Note : By executing escInstances.next()we shift to the next tuple(Row).
To retrieve task instances of a particular task template :
String selectClause = "DISTINCT TASK.TKIID";String whereClause = "TASK_TEMPL.NAME='RequestTask' AND TASK_TEMPL.NAMESPACE="http://ToDoTask/bpc/samples";
//Add "TASK.STATE = TASK.STATE.STATE_READY" to retrieve only those tasks which are in ready state.
QueryResultSet instances = taskManager.query(selectClause, whereClause, null, null, null, null);
boolean b = instances.first();
b = instances.next();
TKIID tkiid = (TKIID) instances.getOID(1);
Task task = taskManager.getTask(tkiid);To retrieve all the participating task templates :
String whereClause = "TASK_TEMPL.KIND = TASK_TEMPL.KIND.KIND_PARTICIPATING";
TaskTemplate[] templates = taskManager.queryTaskTemplates(whereClause, null, null, null);
System.out.println( " No of templates :" + templates.length);
System.out.println("***** Displaying TaskTemplateInfo ***** ");
for (int i = 0;i<templates.length;i++){
System.out.println(" Task Template Name :" + templates[i].getName());
System.out.println(" Task NameSpace :" + templates[i].getNamespace());
}
To retrieve all Escalation instances of ready tasks :
QueryResultSet escInstances = taskManager.query("DISTINCT ESCALATION.ESIID, ESCALATION.TKIID","TASK.STATE = TASK.STATE.STATE_READY ",(String)null, (Integer)null, (TimeZone)null );
System.out.println("No of Instances :"+escInstances.size());
boolean b2 = escInstances.first();
b2 = escInstances.next();
ESIID esiid = (ESIID) escInstances.getOID(1);
Escalation esc = taskManager.getEscalation(esiid);
System.out.println("Escalation Name :"+esc.getName());
System.out.println("DurationUntilEscalated :"+esc.getDurationUntilEscalated());
To retrieve task instances with custom property name/value :
"TASK_TEMPL.NAME = 'MyTask'",
String)null, (Integer)null, null );
while(instances.next()){ // looping thru all the rows
TKIID tkiid = (TKIID) instances.getOID(1);
System.out.println("TKIID "+tkiid);
System.out.println(instances.size()); // No of Rows
System.out.println(instances.getColumnDisplayName(1)); // TKIID
System.out.println(instances.getColumnDisplayName(2)); // NAME
System.out.println( instances .getColumnDisplayName(3)); // STRING_VALUE
System.out.println( instances .getString(2)); // Custom Property Name
System.out.println( instances .getString(3)); // Custom Property Value
}