Reimplemented getHoursAdvancePercentage() to avoid calling OrderElementDAO.getHoursAdvancePercentage().

The DAO method makes recursive calls over all the children of the order.
The reimplementation uses the pre-calculated data on the TaskElement to
prevent recursive calls.

FEA: ItEr61S03RFPerformanceCompanyView
This commit is contained in:
Jacobo Aragunde Pérez 2010-10-07 13:09:25 +02:00
parent 222c966f20
commit 79425a183f

View file

@ -337,11 +337,21 @@ public class TaskElementAdapter implements ITaskElementAdapter {
@Override
public BigDecimal getHoursAdvancePercentage() {
OrderElement orderElement = taskElement.getOrderElement();
if (orderElement != null) {
return orderElementDAO.getHoursAdvancePercentage(orderElement);
} else {
return new BigDecimal(0);
if (orderElement == null) {
return BigDecimal.ZERO;
}
Integer totalChargedHours = orderElement.getSumChargedHours() != null ? orderElement
.getSumChargedHours().getTotalChargedHours() : new Integer(0);
BigDecimal assignedHours = new BigDecimal(totalChargedHours).setScale(2);
BigDecimal estimatedHours = new BigDecimal(taskElement.getSumOfHoursAllocated())
.setScale(2);
if (estimatedHours.compareTo(BigDecimal.ZERO) <= 0) {
return BigDecimal.ZERO;
}
return assignedHours.divide(estimatedHours, RoundingMode.DOWN);
}
@Override