From 74174533836e5b97773bb7ef30af77242672b6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Wed, 23 Sep 2009 01:57:50 +0200 Subject: [PATCH] ItEr27S06CUAsignacionGrupoRecursosAPlanificacionItEr26S07: The task stores now the calculatedValue --- .../business/planner/entities/Task.java | 18 +++++++++--------- .../business/planner/entities/Tasks.hbm.xml | 6 +++++- .../web/planner/EditTaskController.java | 8 +++++--- .../allocation/ResourceAllocationModel.java | 1 + .../ResourceAllocationsBeingEdited.java | 8 ++------ 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java index 1f5b995b0..cd7d53a14 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java @@ -29,7 +29,7 @@ public class Task extends TaskElement { @NotNull private HoursGroup hoursGroup; - private Boolean fixedDuration = false; + private CalculatedValue calculatedValue = CalculatedValue.END_DATE; private Set> resourceAllocations = new HashSet>(); @@ -89,16 +89,16 @@ public class Task extends TaskElement { resourceAllocations.remove(resourceAllocation); } - public Boolean getFixedDuration() { - return fixedDuration; + public CalculatedValue getCalculatedValue() { + if (calculatedValue == null) { + return CalculatedValue.END_DATE; + } + return calculatedValue; } - public void setFixedDuration(boolean fixedDuration) { - this.fixedDuration = fixedDuration; - } - - public boolean isFixedDuration() { - return fixedDuration != null && fixedDuration; + public void setCalculatedValue(CalculatedValue calculatedValue) { + Validate.notNull(calculatedValue); + this.calculatedValue = calculatedValue; } public void setDaysDuration(Integer duration) { diff --git a/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/Tasks.hbm.xml b/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/Tasks.hbm.xml index eda7e3f96..8f8979b04 100644 --- a/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/Tasks.hbm.xml +++ b/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/Tasks.hbm.xml @@ -35,7 +35,11 @@ - + + + org.navalplanner.business.planner.entities.CalculatedValue + + diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/EditTaskController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/EditTaskController.java index e5d2f2ac6..bc319a99e 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/EditTaskController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/EditTaskController.java @@ -1,5 +1,6 @@ package org.navalplanner.web.planner; +import org.navalplanner.business.planner.entities.CalculatedValue; import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.TaskElement; import org.springframework.beans.factory.config.BeanDefinition; @@ -54,9 +55,10 @@ public class EditTaskController extends GenericForwardComposer { duration.setValue(task.getDaysDuration()); // Disable some fields depending on fixedDuration value - duration.setDisabled(!task.isFixedDuration()); - ((Datebox) hours.getFellow("endDateBox")).setDisabled(!task - .isFixedDuration()); + duration + .setDisabled(task.getCalculatedValue() == CalculatedValue.END_DATE); + ((Datebox) hours.getFellow("endDateBox")).setDisabled(task + .getCalculatedValue() == CalculatedValue.END_DATE); } else { // If it's a TaskGroup // Hide fields diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java index a0fa296a4..076185fdf 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java @@ -101,6 +101,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { task.setDaysDuration(newDaysDuration); ganttTask.setEndDate(task.getEndDate()); } + task.setCalculatedValue(allocator.getCalculatedValue()); } private List getResourcesMatchingCriterions() { diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java index 23c65f3f5..61ea40883 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java @@ -58,15 +58,10 @@ public class ResourceAllocationsBeingEdited { this.modifyTask = modifyTask; this.currentAllocations = new ArrayList( initialAllocations); - this.calculatedValue = getCurrentCalculatedValue(task); + this.calculatedValue = task.getCalculatedValue(); this.daysDuration = task.getDaysDuration(); } - private CalculatedValue getCurrentCalculatedValue(Task task) { - return task.isFixedDuration() ? CalculatedValue.NUMBER_OF_HOURS - : CalculatedValue.END_DATE; - } - public void addSpecificResorceAllocationFor(Worker worker) { if (alreadyExistsAllocationFor(worker)) { throw new IllegalArgumentException(_( @@ -193,6 +188,7 @@ public class ResourceAllocationsBeingEdited { task, currentAllocations, resourceDAO, resourcesMatchingCriterions, true); result.formBinder = this.formBinder; + result.calculatedValue = this.calculatedValue; return result; }