It's all about the answers!

Ask a question

JAVA API to Read/Get the RTC User Profile details?


praveen hanchinamani (2729) | asked Jun 29 '16, 7:00 a.m.
edited Jun 30 '16, 8:50 a.m. by Paul Slauenwhite (8.4k12)
Hello Everyone,

In RTC 6.0.1 Web UI I can get the details of the users in the user profile such as - 
1) Work location 
2) Work Days & 
3) Work Allocation.

I am interested to retrieve these information using the RTC Plain JAVA API.
Provided the user id, i want to retrieve the  above details through RTC 6.0.1 Plain JAVA APIs.

Could you please help me on this? any code snippet to reach till user profile.

Thanks & Regards,
Praveen S H 

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Jun 30 '16, 9:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Here is some work I have done. It helps locating the classes:

https://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/
This is from other customers: JAM – Jazz Workallocation Manager A lightweight Web client to manage the Workallocation of users or team within Jazz/RTC I provided them some code but had no time to blog about it.

Some hints:
com.ibm.team.apt.internal.client.resource.ResourcePlanningManager
        ResourcePlanningManager resourcePlanningManager = resourcePlanning
                .getResourcePlanningManager();
        IContributorInfo info = resourcePlanningManager.getContributorInfo(
                this.user, true, monitor);
        ItemCollection<IWorkResourceDetails> details = info
                .getWorkDetails(this.user);

            IWorkResourceDetailsHandle[] remove = toRemove
                    .toArray(new IWorkResourceDetailsHandle[toRemove.size()]);

            resourcePlanning.deleteWorkDetails(remove, monitor);

            IWorkResourceDetails[] save = toSave
                    .toArray(new IWorkResourceDetails[toSave.size()]);

            resourcePlanning.saveWorkDetails(save, monitor);


There are several challenges with the API and it is not public API, it is internal API.




praveen hanchinamani selected this answer as the correct answer

Comments
praveen hanchinamani commented Jul 01 '16, 1:16 a.m.

Thank you Ralph,

I was interested in retrieving the details about the work allocation. Your answer helped me achieve the goal.


praveen hanchinamani commented Jul 01 '16, 1:16 a.m. | edited Jul 01 '16, 1:18 a.m.


One other answer



permanent link
praveen hanchinamani (2729) | answered Jul 07 '16, 12:57 a.m.
To access work allocation details, please find the code snippet as below -

// Get the user to whom the work allocation has be to fetched.
IContributor inspectUser = teamRepository.contributorManager().fetchContributorByUserId(user, monitor);
// Get the resource planning client 
final IResourcePlanningClient resourcePlanning = (IResourcePlanningClient) teamRepository.getClientLibrary(IResourcePlanningClient.class);

// Get the contributor related planning information
IContributorInfo info = resourcePlanning.getResourcePlanningManager().getContributorInfo(inspectUser, true, monitor);
ItemCollection<IWorkResourceDetails> workDetails = info.getWorkDetails(inspectUser);

for (IWorkResourceDetails iWorkResourceDetails : workDetails) {
    if (iWorkResourceDetails != null) {
// The % of work allocated to (Particularly to the timeline which belongs to team/project area)
        int assignment = iWorkResourceDetails.getAssignment();

// The work allocation dates - both start date and end date. If dates are defaulss
// Start Date : 2000-01-01 17:30:00.0 & End Date : 3000-01-01 17:30:00.0 that means allocations dates is - "No Date restrictions"
        System.out.println("Start Date : " + iWorkResourceDetails.getStartDate());
        System.out.println("End Date : " + iWorkResourceDetails.getEndDate());
// Development line (Timeline) to which a user has been allocated
        List<IItemHandle> listOfHandles = new ArrayList<IItemHandle>();
        listOfHandles.add(developmentLine);
        IFetchResult fetchCompleteItemsPermissionAware =
            teamRepository.itemManager()
                .fetchCompleteItemsPermissionAware(listOfHandles, IItemManager.REFRESH, monitor);
        IDevelopmentLine completeItem = null;
        if (fetchCompleteItemsPermissionAware.getRetrievedItems().get(0) instanceof IDevelopmentLine) {
          completeItem = (IDevelopmentLine) fetchCompleteItemsPermissionAware.getRetrievedItems().get(0);
        }
completeItem.getName();
// Project/Team Area where this dev line belongs to
        IProjectAreaHandle projectAreaHandle = completeItem.getProjectArea();
        listOfHandles = new ArrayList<IItemHandle>();
        listOfHandles.add(projectAreaHandle);
        fetchCompleteItemsPermissionAware =
            teamRepository.itemManager()
                .fetchCompleteItemsPermissionAware(listOfHandles, IItemManager.REFRESH, monitor);
        IProjectArea projectArea = null;
        if (fetchCompleteItemsPermissionAware.getRetrievedItems().get(0) instanceof IProjectArea) {
          projectArea = (IProjectArea) fetchCompleteItemsPermissionAware.getRetrievedItems().get(0);
        }
projectArea.getName()
    }
}

Comments
Ahmed Omair commented Jul 30 '17, 9:49 a.m. | edited Jul 30 '17, 9:50 a.m.

 Hi @praveen hanchinamani  


Your code looks good. I am confused in the below code.

// Development line (Timeline) to which a user has been allocated
        List<IItemHandle> listOfHandles = new ArrayList<IItemHandle>();
        listOfHandles.add(developmentLine);
        IFetchResult fetchCompleteItemsPermissionAware =
            teamRepository.itemManager()
                .fetchCompleteItemsPermissionAware(listOfHandles, IItemManager.REFRESH, monitor);
From where did you get the developmentLine object in above code?

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.