Prevent NPE in OrderElement::getSumChargedEffort()
Now SumChargeEffort objects are not created till some hours are reported, so it could be null in some cases. FEA: ItEr76S14ConcurrencyProblemWorkReports
This commit is contained in:
parent
abc0e0fe66
commit
dfb0090666
3 changed files with 5 additions and 2 deletions
|
|
@ -126,7 +126,8 @@ public class OrderLine extends OrderElement {
|
|||
if (!getMaterialAssignments().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!getSumChargedEffort().getDirectChargedEffort().isZero()) {
|
||||
if (getSumChargedEffort() != null
|
||||
&& !getSumChargedEffort().getDirectChargedEffort().isZero()) {
|
||||
return false;
|
||||
}
|
||||
if (!getTaskElements().isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import org.libreplan.business.orders.entities.Order;
|
|||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.orders.entities.OrderLine;
|
||||
import org.libreplan.business.orders.entities.OrderLineGroup;
|
||||
import org.libreplan.business.orders.entities.SumChargedEffort;
|
||||
import org.libreplan.business.qualityforms.daos.IQualityFormDAO;
|
||||
import org.libreplan.business.qualityforms.entities.QualityForm;
|
||||
import org.libreplan.business.qualityforms.entities.TaskQualityForm;
|
||||
|
|
@ -420,6 +421,7 @@ public class OrderElementDAOTest {
|
|||
@Test
|
||||
public void testSumChargedHoursRelation() throws InstanceNotFoundException {
|
||||
OrderLine orderLine = createValidOrderLine();
|
||||
orderLine.setSumChargedEffort(SumChargedEffort.create(orderLine));
|
||||
|
||||
orderLine.getSumChargedEffort().addDirectChargedEffort(
|
||||
EffortDuration.hours(8));
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class AssignedHoursToOrderElementModel implements
|
|||
|
||||
@Override
|
||||
public EffortDuration getTotalAssignedEffort() {
|
||||
if (orderElement == null) {
|
||||
if (orderElement == null || orderElement.getSumChargedEffort() == null) {
|
||||
return EffortDuration.zero();
|
||||
}
|
||||
return this.orderElement.getSumChargedEffort().getTotalChargedEffort();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue