Instead of delegating call the inner object

FEA: ItEr66S04BugFixing
This commit is contained in:
Óscar González Fernández 2010-12-29 17:40:59 +01:00
parent 4d1c4bb293
commit 9a9afdc5c9
3 changed files with 22 additions and 29 deletions

View file

@ -271,16 +271,6 @@ public abstract class TaskElement extends BaseEntity {
getIntraDayStartDate());
}
/**
* Sets the startDate to newStartDate. It can update the endDate
*
* @param scenario
* @param newStartDate
*/
public void moveTo(Scenario scenario, IntraDayDate newStartDate) {
getDatesHandler(scenario).moveTo(newStartDate);
}
@NotNull
public Date getEndDate() {
return endDate != null ? endDate.toDateTimeAtStartOfDay().toDate()
@ -314,20 +304,7 @@ public abstract class TaskElement extends BaseEntity {
return endDate;
}
public void resizeTo(Scenario scenario, Date endDate) {
resizeTo(scenario,
IntraDayDate.startOfDay(LocalDate.fromDateFields(endDate)));
}
public void resizeTo(Scenario scenario, IntraDayDate endDate) {
getDatesHandler(scenario).resizeTo(endDate);
}
public void moveEndTo(Scenario scenario, IntraDayDate intraDay) {
getDatesHandler(scenario).moveEndTo(intraDay);
}
private IDatesHandler getDatesHandler(Scenario scenario) {
public IDatesHandler getDatesHandler(Scenario scenario) {
return noNullDates(createDatesHandler(scenario));
}
@ -358,6 +335,12 @@ public abstract class TaskElement extends BaseEntity {
public interface IDatesHandler {
/**
* Sets the startDate to newStartDate. It can update the endDate
*
* @param scenario
* @param newStartDate
*/
void moveTo(IntraDayDate newStartDate);
void moveEndTo(IntraDayDate newEnd);

View file

@ -10,6 +10,7 @@ import java.util.Set;
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.IDatesHandler;
import org.navalplanner.business.planner.entities.TaskElement.IDatesInterceptor;
import org.navalplanner.business.scenarios.entities.Scenario;
import org.navalplanner.business.workingday.IntraDayDate;
@ -134,12 +135,16 @@ public class TemplateModelAdapter implements
@Override
public void setEndDateFor(TaskElement task, GanttDate newEnd) {
task.moveEndTo(scenario, toIntraDay(newEnd));
getDatesHandler(task).moveEndTo(toIntraDay(newEnd));
}
@Override
public void setStartDateFor(TaskElement task, GanttDate newStart) {
task.moveTo(scenario, toIntraDay(newStart));
getDatesHandler(task).moveTo(toIntraDay(newStart));
}
private IDatesHandler getDatesHandler(TaskElement taskElement) {
return taskElement.getDatesHandler(scenario);
}
@Override

View file

@ -72,6 +72,7 @@ import org.navalplanner.business.planner.entities.ResourceAllocation.Direction;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskElement.IDatesHandler;
import org.navalplanner.business.planner.entities.TaskGroup;
import org.navalplanner.business.planner.entities.TaskPositionConstraint;
import org.navalplanner.business.resources.daos.ICriterionDAO;
@ -394,7 +395,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
@Override
public Void execute() {
stepsBeforePossibleReallocation();
taskElement.moveTo(currentScenario,
getDatesHandler(taskElement).moveTo(
toIntraDay(beginDate));
return null;
}
@ -413,7 +414,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
@Override
public Void execute() {
stepsBeforePossibleReallocation();
taskElement.moveEndTo(currentScenario,
getDatesHandler(taskElement).moveEndTo(
toIntraDay(endDate));
return null;
}
@ -428,13 +429,17 @@ public class TaskElementAdapter implements ITaskElementAdapter {
public Void execute() {
stepsBeforePossibleReallocation();
updateTaskPositionConstraint(endDate);
taskElement.resizeTo(currentScenario,
getDatesHandler(taskElement).resizeTo(
toIntraDay(endDate));
return null;
}
});
}
IDatesHandler getDatesHandler(TaskElement taskElement) {
return taskElement.getDatesHandler(currentScenario);
}
private void updateTaskPositionConstraint(GanttDate endDate) {
if (taskElement instanceof ITaskPositionConstrained) {
ITaskPositionConstrained task = (ITaskPositionConstrained) taskElement;