From ef057267b968256c3d6a6300a0572e3b303aae54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Mon, 23 Jan 2012 13:55:45 +0100 Subject: [PATCH] Bug #1320: When asking a container for start constraints, return the leftmost of children's start-in-fixed-date constraints. Doing it, the dependencies of containers will be ensured to comply with the most restrictive start dependency of its children. FEA: ItEr76S04BugFixing --- .../web/planner/TaskElementAdapter.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java index aee8b0b43..544efda96 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java @@ -110,8 +110,41 @@ public class TaskElementAdapter { private static final Log LOG = LogFactory.getLog(TaskElementAdapter.class); + private static TaskPositionConstraint getLeftMostFixedDateConstraintAmongChildren( + TaskGroup container) { + + TaskPositionConstraint constraint = null; + for(TaskElement child : ((TaskGroup)container).getChildren()) { + TaskPositionConstraint currentConstraint = null; + if (child instanceof ITaskPositionConstrained) { + ITaskPositionConstrained task = (ITaskPositionConstrained) child; + currentConstraint = task.getPositionConstraint(); + } + else if (child instanceof TaskGroup) { + currentConstraint = getLeftMostFixedDateConstraintAmongChildren( + (TaskGroup) child); + } + if(currentConstraint != null && + currentConstraint.getConstraintType().equals( + PositionConstraintType.START_IN_FIXED_DATE) && + (constraint == null || currentConstraint.getConstraintDate(). + compareTo(constraint.getConstraintDate()) < 0)) { + constraint = currentConstraint; + } + } + return constraint; + } public static List> getStartConstraintsFor( TaskElement taskElement, LocalDate orderInitDate) { + if (taskElement instanceof TaskGroup) { + TaskPositionConstraint constraint = + getLeftMostFixedDateConstraintAmongChildren((TaskGroup) taskElement); + if(constraint == null) { + return Collections.emptyList(); + } + return Collections.singletonList(equalTo(toGantt( + constraint.getConstraintDate()))); + } if (taskElement instanceof ITaskPositionConstrained) { ITaskPositionConstrained task = (ITaskPositionConstrained) taskElement; TaskPositionConstraint startConstraint = task