[jboss-user] [jBPM] - Re: Could not getting tasks for business administrators through task client
Maciej Swiderski
do-not-reply at jboss.com
Mon Nov 26 00:56:29 EST 2012
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion
"Re: Could not getting tasks for business administrators through task client"
To view the discussion, visit: https://community.jboss.org/message/778258#778258
--------------------------------------------------------------
No, it fact the problem was that you used getTasksAssignedAsPotentialOwner method instead of one dedicated to get tasks assigned as business user, see in bold:
> tom sebastian wrote:
>
> This was my class.
>
> public class BusinessAdminTest {
>
>
> private static final long DEFAULT_WAIT_TIME = 10000l;
> private TaskClient client;
> private WorkItemManager manager;
> private String ipAddress="192.168.1.111";
> private int port=9123;
>
> private void createClient() {
> if (client == null) {
> client = new TaskClient(new MinaTaskClientConnector("com.task.BusinessAdminTest",
> new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
> boolean connected = client.connect(ipAddress, port);
> if (!connected) {
> throw new IllegalArgumentException("Could not connect task client");
> }
> }
> }
> public void test() throws Throwable{
>
>
>
> // Create the task
> //assumed testGroup contain 'Mary','John' users
> Task task1 = createTask("TaskName", "Comment","Tom","testGroup");
> BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();
> client.addTask(task1, null, null);
>
>
> Thread.sleep(500);
>
> // Test if the task is successfully created
> BlockingTaskSummaryResponseHandler responseHandler = new BlockingTaskSummaryResponseHandler();
> client.getTasksAssignedAsPotentialOwner("Tom", "en-UK",
> responseHandler);
> responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
> List tasks = responseHandler.getResults();
> if(tasks!=null){
> System.out.println(tasks.size());
> TaskSummary summary=(TaskSummary) tasks.get(0);
> System.out.println(summary.getStatus().toString());//will be 'Ready'
>
> }
> //Try to get task as business administrator
> responseHandler = new BlockingTaskSummaryResponseHandler();
> * client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",*
> * responseHandler);*
> responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
> tasks = responseHandler.getResults();
> if(tasks!=null){// according to WS specification, we expect to get task
> System.out.println(tasks.size());
> TaskSummary summary=(TaskSummary) tasks.get(0);
> System.out.println(summary.getStatus().toString());
>
> }
>
> }
> public TaskClient getClient() {
> return client;
> }
> public void setClient(TaskClient client) {
> this.client = client;
> }
> private Task createTask(String taskName, String comment, String actorId,String groupId) {
> Task task = new Task();
> if (taskName != null) {
> List names = new ArrayList();
> names.add(new I18NText("en-UK", taskName));
> task.setNames(names);
> }
> if (comment != null) {
> List descriptions = new ArrayList();
> descriptions.add(new I18NText("en-UK", comment));
> task.setDescriptions(descriptions);
> List subjects = new ArrayList();
> subjects.add(new I18NText("en-UK", comment));
> task.setSubjects(subjects);
> }
> task.setPriority(10);
>
>
> TaskData taskData = new TaskData();
>
>
>
> PeopleAssignments assignments = new PeopleAssignments();
> List potentialOwners = new ArrayList();
>
>
> if (actorId != null && actorId.trim().length() > 0) {
>
> potentialOwners.add(new User(actorId.trim()));
> }
> if (groupId != null && groupId.trim().length() > 0) {
>
> potentialOwners.add(new Group(groupId.trim()));
>
> }
> // Set the first user as creator ID??? hmmm might be wrong
> if (potentialOwners.size() > 0) {
> taskData.setCreatedBy((User) potentialOwners.get(0));
> }
>
> assignments.setPotentialOwners(potentialOwners);
> List businessAdministrators = new ArrayList();
> businessAdministrators.add(new User("administrator"));
> assignments.setBusinessAdministrators(businessAdministrators);
> task.setPeopleAssignments(assignments);
>
> taskData.setSkipable(true);
>
> task.setTaskData(taskData);
>
> return task;
> }
>
> public void setManager(WorkItemManager manager) {
> this.manager = manager;
> }
> public WorkItemManager getManager() {
> return manager;
> }
>
> public static void main(String[] a){
> BusinessAdminTest baTest = new BusinessAdminTest();
> baTest.createClient();
> try {
> baTest.test();
> } catch (Throwable e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> }
>
>
>
>
>
>
> When i run this ,the output was(the first 2 lines indicate the number of tasks and its status as potential owner, while the remaining as business admin for the same task)
>
> 1
> Ready
> 0
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/778258#778258]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121126/53e98c10/attachment-0001.html
More information about the jboss-user
mailing list