It's all about the answers!

Ask a question

How to write work allocation details using Java RTC API?

ast java (451246) | asked Sep 23 '16, 1:16 a.m.
edited Sep 23 '16, 5:01 a.m.
 Hi Team,

I would like to write the user work allocation details via java rtc api.

My code snippet for reading the data is,

 IContributorInfo info =
        resourcePlanning.getResourcePlanningManager().getContributorInfo(inspectUser, true, monitor);
    ItemCollection<IWorkResourceDetails> workDetails = info.getWorkDetails(inspectUser);

    for (IWorkResourceDetails iWorkResourceDetails : workDetails) {
int assignment = iWorkResourceDetails.getAssignment(); //To get percentage
 IAuditableHandle owner = iWorkResourceDetails.getOwner(); //To get the Project/Team area
 IDevelopmentLineHandle developmentLine = iWorkResourceDetails.getDevelopmentLine();//To get the timeline
 //And I can able to get the start & end dates.

Please let me know if any code snippet for the same.

Thanks in advance.

One answer

permanent link
Ralph Schoon (62.3k33643) | answered Sep 23 '16, 2:29 a.m.
This is all internal API. Here an example:

        ArrayList<IWorkResourceDetails> toSave = new ArrayList<IWorkResourceDetails>();
        for (IWorkAssignment workAssignment : allocations) {
        if (!toSave.isEmpty()) {
            this.dirty = true; // We want to reload after the safe, to be sure.
            final IResourcePlanningClient resourcePlanning = (IResourcePlanningClient) teamRepository

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

            resourcePlanning.saveWorkDetails(save, monitor);

There is much more around this e.g. how to work with timestamps etc. I explored this to some extent, but did not get around blogging about it. Good luck. See for some hints about the timestamp stuff.

ast java commented Sep 23 '16, 5:01 a.m.

  Hi Ralph,

Thanks for the response. 

I have few questions as below,
* In your code "allocations" refers list of "IWorkAssignment" - May I know how this has been updated? and which jar contains this "IWorkAssignment"  interface?
* From my code I can able to get the list of "IWorkResourceDetails", But If i want to edit the allocation percentage, default allocation , start & end date there are no methods are available. 
AND If I want to create a new iworkresourcedetails (with %, start & end date) how can I proceed?

From your code I am assuming that "allocations" list has been filled with the customized values and then adding into the RTC server.

I am interested on how it has been done.

I have updated my code snippet in the question.

Ralph Schoon commented Sep 23 '16, 5:31 a.m. | edited Sep 23 '16, 12:10 p.m.

IWorkAssignment is an interface the is defined in my code, so not in the plain java client libraries.

I have explored this long time ago and except some example code I don't have additional documentation. I basically read the data, changed something, read again, and tried the API to do the same. I think this is the only way.


ast java commented Sep 26 '16, 5:44 a.m.

 Ok. Thanks Ralph.

Is it possible to get the mutable copy of "IWorkResourceDetails". If 'yes' then which service is responsible for this?

Your answer

Register or to post your answer.