From db9a92fe516554179d8c95e76cc696483aec4d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Wed, 12 Jan 2011 13:02:30 +0100 Subject: [PATCH] Now CalendarException uses a Capacity instead of the field duration FEA: ItEr68OTS05IntroducionLimiteSobreasignacionCalendarios --- .../calendars/entities/CalendarException.java | 31 +++++++++++++------ .../src/main/resources/db.changelog-1.0.xml | 14 +++++++++ .../calendars/entities/Calendars.hbm.xml | 8 +++-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarException.java b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarException.java index f7a15c5f5..6d7aca536 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarException.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarException.java @@ -42,18 +42,25 @@ public class CalendarException extends IntegrationEntity { public static CalendarException create(Date date, EffortDuration duration, CalendarExceptionType type) { - return create(new CalendarException(new LocalDate(date), duration, type)); + return create(new CalendarException(new LocalDate(date), from(duration, + type), type)); } public static CalendarException create(LocalDate date, EffortDuration duration, CalendarExceptionType type) { - return create(new CalendarException(date, duration, type)); + return create(new CalendarException(date, from(duration, type), type)); } public static CalendarException create(String code, LocalDate date, EffortDuration duration, CalendarExceptionType type) { - return create(new CalendarException(date, duration, type), code); + return create(new CalendarException(date, from(duration, type), type), + code); + } + + private static Capacity from(EffortDuration duration, + CalendarExceptionType type) { + return type.getCapacity().withNormalDuration(duration); } private static EffortDuration fromHours(Integer hours) { @@ -67,7 +74,7 @@ public class CalendarException extends IntegrationEntity { } if (hours != null) { - this.duration = fromHours(hours); + this.capacity.withNormalDuration(fromHours(hours)); } if (type != null) { @@ -77,7 +84,7 @@ public class CalendarException extends IntegrationEntity { private LocalDate date; - private EffortDuration duration; + private Capacity capacity; private CalendarExceptionType type; @@ -88,11 +95,11 @@ public class CalendarException extends IntegrationEntity { } - private CalendarException(LocalDate date, EffortDuration duration, + private CalendarException(LocalDate date, Capacity capacity, CalendarExceptionType type) { - Validate.notNull(duration); + Validate.notNull(capacity); this.date = date; - this.duration = duration; + this.capacity = capacity; this.type = type; } @@ -101,9 +108,13 @@ public class CalendarException extends IntegrationEntity { return date; } - @NotNull public EffortDuration getDuration() { - return duration; + return capacity.getStandardEffort(); + } + + @NotNull + public Capacity getCapacity() { + return capacity; } @NotNull diff --git a/navalplanner-business/src/main/resources/db.changelog-1.0.xml b/navalplanner-business/src/main/resources/db.changelog-1.0.xml index d26566a54..82fc2ee6f 100644 --- a/navalplanner-business/src/main/resources/db.changelog-1.0.xml +++ b/navalplanner-business/src/main/resources/db.changelog-1.0.xml @@ -32,4 +32,18 @@ + + Convert from duration to capacity property for calendar exceptions + + + + + + update calendar_exception SET allowed_extra_effort = + (select allowed_extra_effort from calendar_exception_type + where calendar_exception_type.id = calendar_exception.calendar_exception_id) + + + diff --git a/navalplanner-business/src/main/resources/org/navalplanner/business/calendars/entities/Calendars.hbm.xml b/navalplanner-business/src/main/resources/org/navalplanner/business/calendars/entities/Calendars.hbm.xml index e3a4b81c6..fee4ffadc 100644 --- a/navalplanner-business/src/main/resources/org/navalplanner/business/calendars/entities/Calendars.hbm.xml +++ b/navalplanner-business/src/main/resources/org/navalplanner/business/calendars/entities/Calendars.hbm.xml @@ -65,8 +65,12 @@ - + + + +