[Bug #729] Fix bug

The problem lies in that the startContraintDate was being written to
the start date of the task directly. So, the start date was set to the
specified date without the end date being recalculated. This could
leave the task in an inconsistent state, with an end date prior to the
start date.

The solution is to simply not update directly the task start date with
the constraint date.

FEA: ItEr63S03BugFixing
This commit is contained in:
Óscar González Fernández 2010-11-17 21:48:25 +01:00
parent 94e2987c86
commit 4e77db8965
3 changed files with 11 additions and 21 deletions

View file

@ -22,8 +22,6 @@ package org.navalplanner.web.planner.taskedition;
import static org.navalplanner.web.I18nHelper._;
import java.util.Date;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.exceptions.ValidationException;
@ -32,7 +30,6 @@ import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.ITaskLeafConstraint;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskStartConstraint;
import org.navalplanner.business.workingday.IntraDayDate;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.Level;
@ -447,24 +444,10 @@ public class EditTaskController extends GenericForwardComposer {
return isTask(taskElement);
}
public Date getStartConstraintDate() {
if ((taskElement == null) || (!isTaskLeafConstraint())) {
return null;
}
return ((ITaskLeafConstraint) taskElement).getStartConstraint()
.getConstraintDateAsDate();
}
private boolean isTaskLeafConstraint() {
return (taskElement != null && taskElement instanceof ITaskLeafConstraint);
}
public void setStartConstraintDate(Date date) {
if ((taskElement != null) && (isTask())) {
resourceAllocationController.setStartDate(date);
}
}
public void showNonPermitChangeResourceAllocationType() {
String message = _("The task has got advance consolidations.It must delete all consolidations to change the resource allocation type ");
try {

View file

@ -277,7 +277,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
StartConstraintType type = task.getStartConstraint()
.getStartConstraintType();
startConstraintTypes.setSelectedItemApi(findComboWithType(type));
startConstraintDate.setVisible(type.isAssociatedDateRequired());
updateStartConstraint(type);
}
private Comboitem findComboWithType(StartConstraintType type) {
@ -294,9 +294,17 @@ public class TaskPropertiesController extends GenericForwardComposer {
private void constraintTypeChoosen(WebStartConstraintType constraint) {
startConstraintDate.setVisible(constraint.isAssociatedDateRequired());
updateStartConstraint(constraint.getType());
}
private void updateStartConstraint(StartConstraintType type) {
TaskStartConstraint taskStartConstraint = currentTaskElementAsTaskLeafConstraint()
.getStartConstraint();
startConstraintDate.setValue(taskStartConstraint.getConstraintDateAsDate());
startConstraintDate.setVisible(type.isAssociatedDateRequired());
if (taskStartConstraint.getConstraintDateAsDate() != null) {
startConstraintDate.setValue(taskStartConstraint
.getConstraintDateAsDate());
}
}
private boolean saveConstraintChanges() {

View file

@ -61,8 +61,7 @@
<label value="${i18n:_('Constraint')}" />
<vbox>
<combobox id="startConstraintTypes" width="300px" />
<datebox id="startConstraintDate" constraint ="no empty"
value="@{editController.startConstraintDate}" />
<datebox id="startConstraintDate" constraint ="no empty"/>
</vbox>
</row>
<row id="resourceAllocationType" visible="@{editController.isTask}">