Querying human task based on custom property using EJB API
Published August 22nd, 2008 in Websphere Process Server / Integration Developer
My last post talked about setting a custom attribute for a human task. Today I will be talking about querying the human task using EJB API based on the custom attribute. The complete code for querying the human task based on custom property is given below.
javax.naming.Context ctx = new javax.naming.InitialContext(); Object result = ctx.lookup("com/ibm/task/api/HumanTaskManagerHome"); com.ibm.task.api.HumanTaskManagerHome home = (com.ibm.task.api.HumanTaskManagerHome) javax.rmi.PortableRemoteObject.narrow(result,com.ibm.task.api.HumanTaskManagerHome.class); com.ibm.task.api.HumanTaskManager taskManager= home.create(); com.ibm.task.api.QueryResultSet rst = taskManager.queryAll("TASK.TKIID","TASK_CPROP1.NAME='id' AND TASK_CPROP1.STRING_VALUE='1'", null,null,null,null); while(rst.next()){ System.out.println("Got Task ID "+rst.getString(1)); }
In my code I have used the queryAll method for getting all the tasks for the user. The parameters for the queryAll method I used are, the select clause as the first parameter, where clause as the second parameter. Since I was selecting only Task Id, I used TASK.TKIID as my select clause. In the where clause TASK_CPROP1.NAME specifies the name of the custom attribute. For me the custom attribute name was id and TASK_CPROP1.STRING_VALUE specifies the value we are expecting for the custom property. When I created the task I entered 1 as the value for Id. The above query would return you the tasks with custom property name id and value 1.
Did you like this? If so, please about it, and subscribe to the blog RSS feed.If you enjoyed this post, make sure you subscribe to my RSS feed!



























Related Posts:
No Responses to “Querying human task based on custom property using EJB API”
Please Wait
Leave a Reply