Bug #1542: Fix bug getting project end date from children tasks
End date for root task is only updated while saving the project in the method: SaveCommand.updateRootTaskPosition. Now the end date is calculated checking the dates of the children tasks and getting the bigger one. FEA: ItEr77S04BugFixing
This commit is contained in:
parent
d4fa4017e5
commit
cf8482d878
3 changed files with 52 additions and 45 deletions
|
|
@ -793,4 +793,44 @@ public abstract class TaskElement extends BaseEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IntraDayDate maxDate(
|
||||||
|
Collection<? extends TaskElement> tasksToSave) {
|
||||||
|
List<IntraDayDate> endDates = toEndDates(tasksToSave);
|
||||||
|
return endDates.isEmpty() ? null : Collections.max(endDates);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<IntraDayDate> toEndDates(
|
||||||
|
Collection<? extends TaskElement> tasksToSave) {
|
||||||
|
List<IntraDayDate> result = new ArrayList<IntraDayDate>();
|
||||||
|
for (TaskElement taskElement : tasksToSave) {
|
||||||
|
IntraDayDate endDate = taskElement.getIntraDayEndDate();
|
||||||
|
if (endDate != null) {
|
||||||
|
result.add(endDate);
|
||||||
|
} else {
|
||||||
|
LOG.warn("the task" + taskElement + " has null end date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntraDayDate minDate(
|
||||||
|
Collection<? extends TaskElement> tasksToSave) {
|
||||||
|
List<IntraDayDate> startDates = toStartDates(tasksToSave);
|
||||||
|
return startDates.isEmpty() ? null : Collections.min(startDates);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<IntraDayDate> toStartDates(
|
||||||
|
Collection<? extends TaskElement> tasksToSave) {
|
||||||
|
List<IntraDayDate> result = new ArrayList<IntraDayDate>();
|
||||||
|
for (TaskElement taskElement : tasksToSave) {
|
||||||
|
IntraDayDate startDate = taskElement.getIntraDayStartDate();
|
||||||
|
if (startDate != null) {
|
||||||
|
result.add(startDate);
|
||||||
|
} else {
|
||||||
|
LOG.warn("the task" + taskElement + " has null start date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import org.libreplan.business.planner.entities.visitors.CalculateFinishedTasksEs
|
||||||
import org.libreplan.business.planner.entities.visitors.CalculateFinishedTasksLagInCompletionVisitor;
|
import org.libreplan.business.planner.entities.visitors.CalculateFinishedTasksLagInCompletionVisitor;
|
||||||
import org.libreplan.business.planner.entities.visitors.ResetTasksStatusVisitor;
|
import org.libreplan.business.planner.entities.visitors.ResetTasksStatusVisitor;
|
||||||
import org.libreplan.business.workingday.EffortDuration;
|
import org.libreplan.business.workingday.EffortDuration;
|
||||||
|
import org.libreplan.business.workingday.IntraDayDate;
|
||||||
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
|
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
|
@ -222,12 +223,14 @@ public class DashboardModel implements IDashboardModel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TaskGroup rootTask = getRootTask();
|
TaskGroup rootTask = getRootTask();
|
||||||
Days orderDuration = Days.daysBetween(rootTask.getStartAsLocalDate(),
|
IntraDayDate endDate = TaskElement.maxDate(rootTask.getChildren());
|
||||||
rootTask.getEndAsLocalDate().plusDays(1));
|
Days orderDuration = Days.daysBetween(
|
||||||
|
TaskElement.minDate(rootTask.getChildren()).getDate(),
|
||||||
|
endDate.asExclusiveEnd());
|
||||||
|
|
||||||
LocalDate deadLineAsLocalDate = LocalDate.fromDateFields(currentOrder
|
LocalDate deadLineAsLocalDate = LocalDate.fromDateFields(currentOrder
|
||||||
.getDeadline());
|
.getDeadline());
|
||||||
Days deadlineOffset = Days.daysBetween(rootTask.getEndAsLocalDate(),
|
Days deadlineOffset = Days.daysBetween(endDate.getDate(),
|
||||||
deadLineAsLocalDate);
|
deadLineAsLocalDate);
|
||||||
|
|
||||||
BigDecimal outcome = new BigDecimal(deadlineOffset.getDays(),
|
BigDecimal outcome = new BigDecimal(deadlineOffset.getDays(),
|
||||||
|
|
@ -253,7 +256,8 @@ public class DashboardModel implements IDashboardModel {
|
||||||
this.absoluteMarginWithDeadLine = null;
|
this.absoluteMarginWithDeadLine = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
absoluteMarginWithDeadLine = daysBetween(rootTask.getEndAsLocalDate(),
|
absoluteMarginWithDeadLine = daysBetween(
|
||||||
|
TaskElement.maxDate(rootTask.getChildren()).getDate(),
|
||||||
LocalDate.fromDateFields(deadline));
|
LocalDate.fromDateFields(deadline));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import static org.libreplan.web.I18nHelper._;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
@ -631,11 +630,13 @@ public class SaveCommandBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRootTaskPosition(TaskGroup rootTask) {
|
private void updateRootTaskPosition(TaskGroup rootTask) {
|
||||||
final IntraDayDate min = minDate(rootTask.getChildren());
|
final IntraDayDate min = TaskElement
|
||||||
|
.minDate(rootTask.getChildren());
|
||||||
if (min != null) {
|
if (min != null) {
|
||||||
rootTask.setIntraDayStartDate(min);
|
rootTask.setIntraDayStartDate(min);
|
||||||
}
|
}
|
||||||
final IntraDayDate max = maxDate(rootTask.getChildren());
|
final IntraDayDate max = TaskElement
|
||||||
|
.maxDate(rootTask.getChildren());
|
||||||
if (max != null) {
|
if (max != null) {
|
||||||
rootTask.setIntraDayEndDate(max);
|
rootTask.setIntraDayEndDate(max);
|
||||||
}
|
}
|
||||||
|
|
@ -867,44 +868,6 @@ public class SaveCommandBuilder {
|
||||||
taskElement.getDependenciesWithThisDestination().size();
|
taskElement.getDependenciesWithThisDestination().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntraDayDate maxDate(Collection<? extends TaskElement> tasksToSave) {
|
|
||||||
List<IntraDayDate> endDates = toEndDates(tasksToSave);
|
|
||||||
return endDates.isEmpty() ? null : Collections.max(endDates);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<IntraDayDate> toEndDates(
|
|
||||||
Collection<? extends TaskElement> tasksToSave) {
|
|
||||||
List<IntraDayDate> result = new ArrayList<IntraDayDate>();
|
|
||||||
for (TaskElement taskElement : tasksToSave) {
|
|
||||||
IntraDayDate endDate = taskElement.getIntraDayEndDate();
|
|
||||||
if (endDate != null) {
|
|
||||||
result.add(endDate);
|
|
||||||
} else {
|
|
||||||
LOG.warn("the task" + taskElement + " has null end date");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntraDayDate minDate(Collection<? extends TaskElement> tasksToSave) {
|
|
||||||
List<IntraDayDate> startDates = toStartDates(tasksToSave);
|
|
||||||
return startDates.isEmpty() ? null : Collections.min(startDates);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<IntraDayDate> toStartDates(
|
|
||||||
Collection<? extends TaskElement> tasksToSave) {
|
|
||||||
List<IntraDayDate> result = new ArrayList<IntraDayDate>();
|
|
||||||
for (TaskElement taskElement : tasksToSave) {
|
|
||||||
IntraDayDate startDate = taskElement.getIntraDayStartDate();
|
|
||||||
if (startDate != null) {
|
|
||||||
result.add(startDate);
|
|
||||||
} else {
|
|
||||||
LOG.warn("the task" + taskElement + " has null start date");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _("Save");
|
return _("Save");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue