ItEr33S14CUCreacionUnidadesPlanificacion: The init date of order elements is taking into account for setting the initial start constraint for tasks
This commit is contained in:
parent
fb92e39e2d
commit
3094db9989
5 changed files with 82 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
import org.hibernate.validator.AssertTrue;
|
||||
import org.navalplanner.business.planner.entities.DayAssignment;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.planner.entities.TaskGroup;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
|
@ -158,4 +159,9 @@ public class Order extends OrderLineGroup {
|
|||
return resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyStartConstraintTo(Task task) {
|
||||
// the initDate of order don't imply a start constraint at a task
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.navalplanner.business.advance.exceptions.DuplicateAdvanceAssignmentFo
|
|||
import org.navalplanner.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.requirements.entities.CriterionRequirement;
|
||||
import org.navalplanner.business.requirements.entities.IndirectCriterionRequirement;
|
||||
|
|
@ -348,4 +349,19 @@ public abstract class OrderElement extends BaseEntity {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void updateStartConstraintIfNeeded(Task task) {
|
||||
if (getInitDate() != null) {
|
||||
applyStartConstraintTo(task);
|
||||
return;
|
||||
}
|
||||
OrderLineGroup parent = getParent();
|
||||
if (parent != null) {
|
||||
parent.updateStartConstraintIfNeeded(task);
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyStartConstraintTo(Task task) {
|
||||
task.getStartConstraint().notEarlierThan(this.getInitDate());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,4 +53,10 @@ public class TaskStartConstraint {
|
|||
: null;
|
||||
}
|
||||
|
||||
public void notEarlierThan(Date date) {
|
||||
Validate.notNull(date);
|
||||
this.constraintDate = date;
|
||||
this.startConstraintType = StartConstraintType.START_NOT_EARLIER_THAN;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,6 +339,9 @@ public class OrderModel implements IOrderModel {
|
|||
if (order.getDeadline() != null) {
|
||||
result.setDeadline(new LocalDate(order.getDeadline()));
|
||||
}
|
||||
if (result instanceof Task) {
|
||||
order.updateStartConstraintIfNeeded(((Task) result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
|||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -57,6 +58,7 @@ import org.navalplanner.business.orders.entities.Order;
|
|||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLine;
|
||||
import org.navalplanner.business.orders.entities.OrderLineGroup;
|
||||
import org.navalplanner.business.planner.entities.StartConstraintType;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.planner.entities.TaskGroup;
|
||||
|
|
@ -503,11 +505,58 @@ public class OrderModelTest {
|
|||
HoursGroup hoursGroup = createHoursGroup(hours);
|
||||
orderLine.addHoursGroup(hoursGroup);
|
||||
orderLine.setDeadline(year(2007));
|
||||
TaskElement task = orderModel
|
||||
.convertToInitialSchedule(orderLine);
|
||||
TaskElement task = orderModel.convertToInitialSchedule(orderLine);
|
||||
assertThat(task.getDeadline(), equalTo(new LocalDate(year(2007))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifNoParentWithStartDateTheStartConstraintIsSoonAsPossible() {
|
||||
OrderLine orderLine = OrderLine.create();
|
||||
orderLine.setName("bla");
|
||||
orderLine.setCode("000000000");
|
||||
HoursGroup hoursGroup = createHoursGroup(30);
|
||||
orderLine.addHoursGroup(hoursGroup);
|
||||
Task task = (Task) orderModel
|
||||
.convertToInitialSchedule(orderLine);
|
||||
assertThat(task.getStartConstraint().getStartConstraintType(),
|
||||
equalTo(StartConstraintType.AS_SOON_AS_POSSIBLE));
|
||||
assertThat(task.getStartConstraint().getConstraintDate(), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifSomeParentHasInitDateTheStartConstraintIsNotEarlierThan() {
|
||||
OrderLine orderLine = OrderLine.create();
|
||||
orderLine.setName("bla");
|
||||
orderLine.setCode("000000000");
|
||||
final Date initDate = year(2008);
|
||||
orderLine.setInitDate(initDate);
|
||||
HoursGroup hoursGroup = createHoursGroup(30);
|
||||
orderLine.addHoursGroup(hoursGroup);
|
||||
Task task = (Task) orderModel
|
||||
.convertToInitialSchedule(orderLine);
|
||||
assertThat(task.getStartConstraint().getStartConstraintType(),
|
||||
equalTo(StartConstraintType.START_NOT_EARLIER_THAN));
|
||||
assertThat(task.getStartConstraint().getConstraintDate(),
|
||||
equalTo(initDate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unlessTheOnlyParentWithInitDateNotNullIsTheOrder() {
|
||||
Order order = Order.create();
|
||||
final Date initDate = year(2008);
|
||||
order.setInitDate(initDate);
|
||||
OrderLine orderLine = OrderLine.create();
|
||||
order.add(orderLine);
|
||||
orderLine.setName("bla");
|
||||
orderLine.setCode("000000000");
|
||||
HoursGroup hoursGroup = createHoursGroup(30);
|
||||
orderLine.addHoursGroup(hoursGroup);
|
||||
Task task = (Task) orderModel.convertToInitialSchedule(orderLine);
|
||||
assertThat(task.getStartConstraint().getStartConstraintType(),
|
||||
equalTo(StartConstraintType.AS_SOON_AS_POSSIBLE));
|
||||
assertThat(task.getStartConstraint().getConstraintDate(), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theSublinesOfAnOrderLineGroupAreConverted() {
|
||||
OrderLineGroup orderLineGroup = OrderLineGroup.create();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue