Make the methods for creating and adding exceptions receive Capacity
FEA: ItEr68OTS05IntroducionLimiteSobreasignacionCalendarios
This commit is contained in:
parent
21c77f04b3
commit
691218a617
6 changed files with 43 additions and 28 deletions
|
|
@ -42,8 +42,8 @@ import org.navalplanner.business.common.IntegrationEntity;
|
|||
import org.navalplanner.business.common.entities.EntitySequence;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
import org.navalplanner.business.workingday.ResourcesPerDay;
|
||||
import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
||||
import org.navalplanner.business.workingday.ResourcesPerDay;
|
||||
|
||||
/**
|
||||
* Represents a calendar with some exception days. A calendar is valid till the
|
||||
|
|
@ -255,15 +255,15 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar {
|
|||
exceptions.remove(day);
|
||||
}
|
||||
|
||||
public void updateExceptionDay(Date date, EffortDuration duration,
|
||||
public void updateExceptionDay(Date date, Capacity capacity,
|
||||
CalendarExceptionType type) throws IllegalArgumentException {
|
||||
updateExceptionDay(new LocalDate(date), duration, type);
|
||||
updateExceptionDay(new LocalDate(date), capacity, type);
|
||||
}
|
||||
|
||||
public void updateExceptionDay(LocalDate date, EffortDuration duration,
|
||||
public void updateExceptionDay(LocalDate date, Capacity capacity,
|
||||
CalendarExceptionType type) throws IllegalArgumentException {
|
||||
removeExceptionDay(date);
|
||||
CalendarException day = CalendarException.create(date, duration, type);
|
||||
CalendarException day = CalendarException.create(date, capacity, type);
|
||||
addExceptionDay(day);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,17 +47,26 @@ public class CalendarException extends IntegrationEntity {
|
|||
}
|
||||
|
||||
public static CalendarException create(LocalDate date,
|
||||
EffortDuration duration,
|
||||
CalendarExceptionType type) {
|
||||
EffortDuration duration, CalendarExceptionType type) {
|
||||
return create(new CalendarException(date, from(duration, type), type));
|
||||
}
|
||||
|
||||
public static CalendarException create(LocalDate date, Capacity capacity,
|
||||
CalendarExceptionType type) {
|
||||
return create(new CalendarException(date, capacity, type));
|
||||
}
|
||||
|
||||
public static CalendarException create(String code, LocalDate date,
|
||||
EffortDuration duration, CalendarExceptionType type) {
|
||||
return create(new CalendarException(date, from(duration, type), type),
|
||||
code);
|
||||
}
|
||||
|
||||
public static CalendarException create(String code, LocalDate date,
|
||||
Capacity capacity, CalendarExceptionType type) {
|
||||
return create(new CalendarException(date, capacity, type), code);
|
||||
}
|
||||
|
||||
private static Capacity from(EffortDuration duration,
|
||||
CalendarExceptionType type) {
|
||||
return type.getCapacity().withStandardEffort(duration);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.navalplanner.business.calendars.entities.BaseCalendar.DayType;
|
|||
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||
import org.navalplanner.business.calendars.entities.CalendarExceptionType;
|
||||
import org.navalplanner.business.calendars.entities.Capacity;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
|
||||
/**
|
||||
|
|
@ -382,9 +383,10 @@ public class BaseCalendarTest {
|
|||
|
||||
calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE.plusDays(1));
|
||||
|
||||
CalendarExceptionType type = createCalendarExceptionType();
|
||||
calendar.updateExceptionDay(CHRISTMAS_DAY_LOCAL_DATE.plusYears(1),
|
||||
hours(8),
|
||||
createCalendarExceptionType());
|
||||
Capacity.create(hours(8)).extraEffort(
|
||||
type.getCapacity().getAllowedExtraEffort()), type);
|
||||
|
||||
assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE
|
||||
.plusYears(1))), equalTo(hours(8)));
|
||||
|
|
|
|||
|
|
@ -572,7 +572,9 @@ public abstract class BaseCalendarEditionController extends
|
|||
}
|
||||
|
||||
EffortDuration duration = exceptionDurationPicker.getValue();
|
||||
baseCalendarModel.createException(type, startDate, endDate, duration);
|
||||
baseCalendarModel.createException(type,
|
||||
LocalDate.fromDateFields(startDate),
|
||||
LocalDate.fromDateFields(endDate), Capacity.create(duration));
|
||||
reloadDayInformation();
|
||||
}
|
||||
|
||||
|
|
@ -1033,7 +1035,9 @@ public abstract class BaseCalendarEditionController extends
|
|||
}
|
||||
|
||||
EffortDuration duration = exceptionDurationPicker.getValue();
|
||||
baseCalendarModel.updateException(type, startDate, endDate, duration);
|
||||
baseCalendarModel.updateException(type,
|
||||
LocalDate.fromDateFields(startDate),
|
||||
LocalDate.fromDateFields(endDate), Capacity.create(duration));
|
||||
reloadDayInformation();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,14 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.navalplanner.business.calendars.daos.ICalendarExceptionTypeDAO;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar.DayType;
|
||||
import org.navalplanner.business.calendars.entities.CalendarAvailability;
|
||||
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||
import org.navalplanner.business.calendars.entities.CalendarExceptionType;
|
||||
import org.navalplanner.business.calendars.entities.Capacity;
|
||||
import org.navalplanner.business.calendars.entities.ResourceCalendar;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar.DayType;
|
||||
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.entities.Configuration;
|
||||
|
|
@ -280,17 +281,15 @@ public class BaseCalendarModel extends IntegrationEntityModel implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createException(CalendarExceptionType type, Date startDate,
|
||||
Date endDate, EffortDuration duration) {
|
||||
for (LocalDate date = new LocalDate(startDate); date
|
||||
.compareTo(new LocalDate(endDate)) <= 0; date = date
|
||||
public void createException(CalendarExceptionType type,
|
||||
LocalDate startDate, LocalDate endDate, Capacity capacity) {
|
||||
for (LocalDate date = startDate; date.compareTo(endDate) <= 0; date = date
|
||||
.plusDays(1)) {
|
||||
if (getTypeOfDay(date).equals(DayType.OWN_EXCEPTION)) {
|
||||
getBaseCalendar().updateExceptionDay(date, duration, type);
|
||||
getBaseCalendar().updateExceptionDay(date, capacity, type);
|
||||
} else {
|
||||
CalendarException day = CalendarException.create("", date,
|
||||
duration,
|
||||
type);
|
||||
capacity, type);
|
||||
getBaseCalendar().addExceptionDay(day);
|
||||
}
|
||||
}
|
||||
|
|
@ -591,8 +590,8 @@ public class BaseCalendarModel extends IntegrationEntityModel implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateException(CalendarExceptionType type, Date startDate,
|
||||
Date endDate, EffortDuration duration) {
|
||||
public void updateException(CalendarExceptionType type,
|
||||
LocalDate startDate, LocalDate endDate, Capacity capacity) {
|
||||
for (LocalDate date = new LocalDate(startDate); date
|
||||
.compareTo(new LocalDate(endDate)) <= 0; date = date
|
||||
.plusDays(1)) {
|
||||
|
|
@ -600,12 +599,12 @@ public class BaseCalendarModel extends IntegrationEntityModel implements
|
|||
if (type == null) {
|
||||
getBaseCalendar().removeExceptionDay(date);
|
||||
} else {
|
||||
getBaseCalendar().updateExceptionDay(date, duration, type);
|
||||
getBaseCalendar().updateExceptionDay(date, capacity, type);
|
||||
}
|
||||
} else {
|
||||
if (type != null) {
|
||||
CalendarException day = CalendarException.create(date,
|
||||
duration, type);
|
||||
capacity, type);
|
||||
getBaseCalendar().addExceptionDay(day);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.navalplanner.business.calendars.entities.CalendarData;
|
|||
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||
import org.navalplanner.business.calendars.entities.CalendarExceptionType;
|
||||
import org.navalplanner.business.calendars.entities.Capacity;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
import org.navalplanner.web.common.IIntegrationEntityModel;
|
||||
|
|
@ -112,8 +113,8 @@ public interface IBaseCalendarModel extends IIntegrationEntityModel {
|
|||
|
||||
EffortDuration getWorkableTime();
|
||||
|
||||
void createException(CalendarExceptionType type, Date startDate,
|
||||
Date endDate, EffortDuration duration);
|
||||
void createException(CalendarExceptionType type, LocalDate startDate,
|
||||
LocalDate endDate, Capacity capacity);
|
||||
|
||||
Boolean isDefault(Days day);
|
||||
|
||||
|
|
@ -163,8 +164,8 @@ public interface IBaseCalendarModel extends IIntegrationEntityModel {
|
|||
|
||||
CalendarExceptionType getCalendarExceptionType(LocalDate date);
|
||||
|
||||
void updateException(CalendarExceptionType type, Date startDate,
|
||||
Date endDate, EffortDuration duration);
|
||||
void updateException(CalendarExceptionType type, LocalDate startDate,
|
||||
LocalDate endDate, Capacity capacity);
|
||||
|
||||
void removeCalendarData(CalendarData calendarData);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue