Now workableDays is persistent

It is used to calculate the new end when it exists. If the calcualted
value is END_DATE it is null.

FEA: ItEr61OTS04PlanificacionHaciaAtras
This commit is contained in:
Óscar González Fernández 2010-11-11 16:30:00 +01:00
parent 1a6125a7b7
commit 6b93954ec4
3 changed files with 19 additions and 3 deletions

View file

@ -361,7 +361,8 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
List<ModifiedAllocation> modifications,
Collection<? extends ResourceAllocation<?>> toRemove) {
this.calculatedValue = calculatedValue;
this.workableDays = newWorkableDays;
this.workableDays = calculatedValue == CalculatedValue.END_DATE ? null
: newWorkableDays;
setIntraDayStartDate(start);
setIntraDayEndDate(end);
for (ModifiedAllocation pair : modifications) {
@ -455,6 +456,10 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
@Override
protected IntraDayDate calculateNewEndGiven(IntraDayDate newStartDate) {
if (workableDays != null) {
return IntraDayDate.startOfDay(calculateEndGivenWorkableDays(
newStartDate.getDate(), workableDays));
}
return calculateEndKeepingLength(newStartDate);
}
@ -687,13 +692,16 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
return workableDays;
}
public Integer getDaysBetweenDates() {
Days daysBetween = Days.daysBetween(getStartAsLocalDate(),
getIntraDayEndDate().asExclusiveEnd());
return daysBetween.getDays();
}
public Integer getSpecifiedWorkableDays() {
return workableDays;
}
private Integer getWorkableDaysBetweenDates() {
LocalDate end = getIntraDayEndDate().asExclusiveEnd();
return getWorkableDaysUntil(end);
@ -713,6 +721,12 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
public LocalDate calculateEndGivenWorkableDays(int workableDays) {
LocalDate result = getIntraDayStartDate().getDate();
return calculateEndGivenWorkableDays(result, workableDays);
}
private LocalDate calculateEndGivenWorkableDays(LocalDate start,
int workableDays) {
LocalDate result = start;
for (int i = 0; i < workableDays; result = result.plusDays(1)) {
if (isWorkable(result)) {
i++;

View file

@ -67,6 +67,8 @@
<property name="constraintDate" type="org.joda.time.contrib.hibernate.PersistentLocalDate"/>
</component>
<property name="workableDays" column="WORKABLE_DAYS" />
<one-to-one name="consolidation" class="org.navalplanner.business.planner.entities.consolidations.Consolidation"
cascade="all"/>

View file

@ -70,7 +70,7 @@ public class AllocationResult {
scenario, resourceAllocations);
AggregateOfResourceAllocations aggregate = new AggregateOfResourceAllocations(
ModifiedAllocation.modified(modifiedAllocations));
return new AllocationResult(task, task.getWorkableDays(),
return new AllocationResult(task, task.getSpecifiedWorkableDays(),
task.getCalculatedValue(), aggregate,
Collections.<ResourceAllocation<?>> emptyList(),
modifiedAllocations);