[Bug #942] Added constraint to avoid storing calendars with zero hours.
FEA: ItEr73S04BugFixing
This commit is contained in:
parent
c93783d648
commit
3bb6687c0c
2 changed files with 28 additions and 5 deletions
|
|
@ -808,9 +808,13 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar {
|
|||
return calendarDataVersions.get(calendarDataVersions.size() - 1);
|
||||
}
|
||||
|
||||
public boolean onlyGivesZeroHours(Days each) {
|
||||
CalendarData last = lastCalendarData();
|
||||
return last.isEmptyFor(each);
|
||||
public boolean onlyGivesZeroHours(Days day) {
|
||||
for (CalendarData each : calendarDataVersions) {
|
||||
if (!each.isEmptyFor(day)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1015,4 +1019,16 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar {
|
|||
return lastSequenceCode;
|
||||
}
|
||||
|
||||
@AssertTrue(message = "calendars with zero hours are not allowed")
|
||||
public boolean checkConstraintZeroHours() {
|
||||
if ((calendarDataVersions != null) && (!calendarDataVersions.isEmpty())) {
|
||||
for (CalendarData each : calendarDataVersions) {
|
||||
if (!each.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,8 +196,15 @@ public class CalendarData extends IntegrationEntity {
|
|||
}
|
||||
|
||||
boolean isEmptyFor(Days day) {
|
||||
return !isDefault(day) && getCapacityOn(day).isZero() || isDefault(day)
|
||||
&& hasParent() && getParent().onlyGivesZeroHours(day);
|
||||
if (isDefault(day)) {
|
||||
if (hasParent()) {
|
||||
return getParent().onlyGivesZeroHours(day);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return getCapacityOn(day).isZero();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasParent() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue