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 @@
-
+
+
+
+