[Bug #804] Fix bug

The problem lied in that in advanced allocation perspective only the
task being modified was saved. Now the task's parents are updated and
saved too.

FEA: ItEr68S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-01-13 20:00:26 +01:00
parent 7aa159e391
commit affada5877
2 changed files with 17 additions and 1 deletions

View file

@ -216,6 +216,11 @@ public class TaskGroup extends TaskElement {
return false;
}
public void fitStartAndEndDatesToChildren() {
setIntraDayStartDate(getSmallestStartDateFromChildren());
setIntraDayEndDate(getBiggestEndDateFromChildren());
}
public IntraDayDate getSmallestStartDateFromChildren() {
return Collections.min(getChildrenStartDates());
}

View file

@ -46,18 +46,19 @@ import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskGroup;
import org.navalplanner.business.planner.entities.consolidations.Consolidation;
import org.navalplanner.business.resources.daos.IResourceDAO;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.scenarios.entities.Scenario;
import org.navalplanner.web.calendars.BaseCalendarModel;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController;
import org.navalplanner.web.planner.allocation.AllocationResult;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.AllocationInput;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IBack;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction;
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction.IRestrictionSource;
import org.navalplanner.web.planner.allocation.AllocationResult;
import org.navalplanner.web.planner.order.OrderPlanningModel;
import org.navalplanner.web.planner.tabs.CreatedOnDemandTab.IComponentCreator;
import org.zkoss.ganttz.extensions.ITab;
@ -188,6 +189,16 @@ public class AdvancedAllocationTabCreator {
taskElementDAO.reattach(task);
allocationResult.applyTo(currentScenario, task);
taskElementDAO.save(task);
updateParentsPositions(task);
}
private void updateParentsPositions(TaskElement task) {
TaskGroup current = task.getParent();
while (current != null) {
current.fitStartAndEndDatesToChildren();
taskElementDAO.save(current);
current = current.getParent();
}
}
}