Expand my Community achievements bar.

Can you retrieve a task list for a user without specifying that user's connection settings?

Avatar

Level 1

Hi

I would like to know if it is possible to obtain a list of workspace tasks for a user of my choice. In the following code, taken from the relevant quickstart, I am able to retrieve a list of tasks for "administrator" because it is the "administrator" settings specified in the connection properties when obtaining an instance of ServiceClientFactory. If I wanted to obtain a list of tasks for user "greg", for example, is there a way I can do this without having to specify the settings for "greg" in the connection properties? I tried to invoke the setUserId() method of the TaskFilter interface but no tasks are returned for user "greg" in that scenario. The aforesaid user has 3 tasks assigned to him. If I specify the user name and password for "greg" in connection settings, I am able to retrieve his list of tasks successfully. However, this is undesirable because I want to be able to retrieve a list of tasks for any user of my choice, by passing a parameter. Is that possible? Code follows:

//Start of code

import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

import com.adobe.idp.taskmanager.dsc.client.TaskManagerClientFactory;

import com.adobe.idp.taskmanager.dsc.client.TaskManagerQueryService;

import com.adobe.idp.taskmanager.dsc.client.query.StatusFilter;

import com.adobe.idp.taskmanager.dsc.client.query.TaskFilter;

import com.adobe.idp.taskmanager.dsc.client.query.TaskRow;

import java.util.Iterator;

import java.util.List;

import java.util.Properties;

public class RetrieveTaskInfo {

    public static void main(String[] args) {

        try {

            //Set connection properties required to invoke LiveCycle                                                                                                                       

            Properties connectionProps = new Properties();

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);          

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

            //Create a ServiceClientFactory object

            ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

            //Create a TaskManagerQueryService object    

            TaskManagerQueryService queryManager = TaskManagerClientFactory.getQueryManager(myFactory);

            //Define search criteria by performing a search on 

            //Assigned tasks (tasks assigned to the user specified

            //in connection properties) 

            TaskFilter filter = queryManager.newTaskFilter();

            StatusFilter sf = filter.newStatusFilter(); 

            sf.addStatus(StatusFilter.assigned); 

            filter.setStatusFiltering(sf);

            //Perform the search

            List result = queryManager.taskList(filter); 

            //Create an Iterator object and iterate through

            //the List object

            Iterator iter = result.iterator();

            while (iter.hasNext()) {

                TaskRow myTask = (TaskRow)iter.next();

                //Get the task identifier value

                long taskId = myTask.getTaskId();

                //Get the status of the task

                long taskStatus = myTask.getTaskStatus();

                

                //Get the name of process on which this task is based

                String processName = myTask.getProcessName();

                //Get the task description

                String taskDes = myTask.getDescription();

                System.out.println("The task identifier is " + taskId + "\n" +

                        "The status of the task is " + taskStatus + "\n" +

                        "The name of the process on which the task is based is " + processName + "\n" +

                        "The task description is " + taskDes);

            }

        } catch(Exception e) {

            e.printStackTrace();

        }

    }

   

}

//End of code

Thanks

Darren

0 Replies