How to write work allocation details using Java RTC API?
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);
System.out.println(workDetails.size());
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
This is all internal API. Here an example:
ArrayList<IWorkResourceDetails> toSave = new ArrayList<IWorkResourceDetails>();
for (IWorkAssignment workAssignment : allocations) {
printAssignment(workAssignment);
toSave.add(workAssignment.getWorkResourceDetails());
}
if (!toSave.isEmpty()) {
this.dirty = true; // We want to reload after the safe, to be sure.
final IResourcePlanningClient resourcePlanning = (IResourcePlanningClient) teamRepository
.getClientLibrary(IResourcePlanningClient.class);
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 https://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/ for some hints about the timestamp stuff.
ArrayList<IWorkResourceDetails> toSave = new ArrayList<IWorkResourceDetails>();
for (IWorkAssignment workAssignment : allocations) {
printAssignment(workAssignment);
toSave.add(workAssignment.getWorkResourceDetails());
}
if (!toSave.isEmpty()) {
this.dirty = true; // We want to reload after the safe, to be sure.
final IResourcePlanningClient resourcePlanning = (IResourcePlanningClient) teamRepository
.getClientLibrary(IResourcePlanningClient.class);
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 https://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/ for some hints about the timestamp stuff.
Comments
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.
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.
Sorry.
Ok. Thanks Ralph.
Is it possible to get the mutable copy of "IWorkResourceDetails". If 'yes' then which service is responsible for this?