Remove method from adapter

getSmallestBeginDateFromChildrenFor can be implemented in
GanttDiagramGraph. Thus there is less duplication.

FEA: ItEr64OTS03PlanificacionHaciaAtras
This commit is contained in:
Óscar González Fernández 2010-12-15 00:35:37 +01:00
parent 2f498a9070
commit 12a2dc372d
3 changed files with 13 additions and 32 deletions

View file

@ -99,8 +99,6 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
void setEndDateFor(V task, GanttDate newEnd);
GanttDate getSmallestBeginDateFromChildrenFor(V container);
public List<Constraint<GanttDate>> getConstraints(
ConstraintCalculator<V> calculator, Set<D> withDependencies,
Point point);
@ -213,12 +211,6 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
return task.getEndConstraints();
}
@Override
public GanttDate getSmallestBeginDateFromChildrenFor(Task container) {
return ((TaskContainer) container)
.getSmallestBeginDateFromChildren();
}
@Override
public boolean isFixed(Task task) {
return task.isFixed();
@ -844,8 +836,7 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
boolean enforceParentShrinkage(V container) {
GanttDate oldBeginDate = adapter.getStartDate(container);
GanttDate firstStart = adapter
.getSmallestBeginDateFromChildrenFor(container);
GanttDate firstStart = getSmallestBeginDateFromChildrenFor(container);
GanttDate previousEnd = adapter.getEndDateFor(container);
if (firstStart.after(oldBeginDate)) {
adapter.setStartDateFor(container, firstStart);
@ -856,6 +847,18 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
}
}
private GanttDate getSmallestBeginDateFromChildrenFor(V container) {
List<V> children = adapter.getChildren(container);
if (children.isEmpty()) {
return adapter.getStartDate(container);
}
List<GanttDate> dates = new ArrayList<GanttDate>();
for (V each : children) {
dates.add(adapter.getStartDate(each));
}
return Collections.min(dates);
}
List<Recalculation> getRecalculationsNeededFrom(V task) {
List<Recalculation> result = new LinkedList<Recalculation>();
Set<Recalculation> parentRecalculationsAlreadyDone = new HashSet<Recalculation>();

View file

@ -87,21 +87,6 @@ public class TaskContainer extends Task {
return tasks;
}
public GanttDate getSmallestBeginDateFromChildren() {
if (tasks.isEmpty()) {
return getBeginDate();
}
return getSmallest(getStartDates());
}
private List<GanttDate> getStartDates() {
ArrayList<GanttDate> result = new ArrayList<GanttDate>();
for (Task task : tasks) {
result.add(task.getBeginDate());
}
return result;
}
private List<GanttDate> getEndDates() {
ArrayList<GanttDate> result = new ArrayList<GanttDate>();
for (Task task : tasks) {

View file

@ -11,7 +11,6 @@ import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskElement.IDatesInterceptor;
import org.navalplanner.business.planner.entities.TaskGroup;
import org.navalplanner.business.scenarios.entities.Scenario;
import org.navalplanner.business.workingday.IntraDayDate;
import org.navalplanner.web.common.TemplateModel.DependencyWithVisibility;
@ -78,12 +77,6 @@ public class TemplateModelAdapter implements
return toGantt(task.getIntraDayEndDate());
}
@Override
public GanttDate getSmallestBeginDateFromChildrenFor(TaskElement container) {
TaskGroup taskGroup = (TaskGroup) container;
return toGantt(taskGroup.getSmallestStartDateFromChildren());
}
@Override
public TaskElement getSource(DependencyWithVisibility dependency) {
return dependency.getSource();