private void loadResourceAssignments(final Workpackage task,
final ResourceAssignmentCollection assignments,
final Map<Long, ProjectResource> allResourcesUniqueIdMap)
throws SystemAlertException {
LOG.info("Loading Resource Assignments... WP ID = " + task.getId());
for (com.aspose.tasks.ResourceAssignment assignment : assignments) {
if (assignment.get(Asn.RESOURCE).get(Rsc.UID) != null) {
ProjectResource resource = allResourcesUniqueIdMap.get(
assignment.get(Asn.RESOURCE).get(Rsc.UID).longValue());
ProjectWorker worker = new ProjectWorker();
worker.setWorkpackage(task);
worker.setProjectResource(resource);
com.aspose.tasks.Duration work = assignment.get(Asn.WORK);
if (work != null) {
worker.setEffortValue(work.toDouble());
worker.setEffortType(getEffortType(work.getTimeUnit()));
}
com.aspose.tasks.Duration remainingWork = assignment.get(Asn.REMAINING_WORK);
if (remainingWork != null) {
worker.setDone(remainingWork.toDouble() == 0);
}
List allocationMap = new ArrayList();
TimephasedDataCollection timePhasedDataList =
assignment.getTimephasedData(assignment.get(Asn.START),
assignment.get(Asn.FINISH), TimephasedDataType.AssignmentWork);
if (timePhasedDataList != null){
for (TimephasedData timePhasedData : timePhasedDataList) {
Date timePhaseDay = timePhasedData.getStart();
ProjectWorkerAllocation allocation =
checkIfAllocationMapContainsDayAllocation(allocationMap,
timePhaseDay);
// If specific day allocation doesn't exist create a new one
if (allocation == null) {
allocation = new ProjectWorkerAllocation();
allocation.setDate(timePhaseDay);
allocation.setProjectWorker(worker);
allocation.setRate(0D);
allocationMap.add(allocation);
}
// Save work per day in minutes
allocation.setAllocation(getDayAllocationInMinutes(
timePhasedData.getValue()));
}
worker.setAllocationMap(allocationMap);
}
projectDAO.persist(worker);
}
}
}
Hi Renata,
Thank you for writing to Aspose Support team.
We have looked into your sample code but, unfortunately, could not compile it due to missing references. Please share your sample running code along with your input MPP files with us so that we can further investigate the issue and assist you.
Thanks for you answer Kashif.
Hi Renata,
Project proj = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new Project(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Project.mpp”);
ChildTasksCollector collector = <span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:navy”>new
ChildTasksCollector(); <span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:gray”>//
Create a ChildTasksCollector instance
TaskUtils.apply(proj.getRootTask(),
collector, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>5); <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:gray”>// Collect all the tasks from RootTask using TaskUtils
<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>for (Task tsk : collector.getTasks())
{
System.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out.println(tsk.get(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>NAME));
<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>for (ResourceAssignment assn
: tsk.getAssignments())
{
TimephasedDataCollection coll =
tsk.getTimephasedData(assn.get(Asn.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>START), assn.get(Asn.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>FINISH), TimephasedDataType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>AssignmentWork);
<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>for (TimephasedData tm :
coll)
{
System.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out.print(tm.getStart());
System.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out.println(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>", " +
tm.getFinish());
}
}
}
Dear Kashif,
Hi Renata,