Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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 

0 votes


Accepted answer

Permanent link
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

1 vote

Comments

Thank you Ralph,

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



One other answer

Permanent link
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()
    }
}

1 vote

Comments

 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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,944
× 1,700
× 480

Question asked: Jun 29 '16, 7:00 a.m.

Question was seen: 5,508 times

Last updated: Jul 30 '17, 9:50 a.m.

Confirmation Cancel Confirm