ItEr49S10CUVisualizacionResponsabilidadesTRaballoNaPlanificacionItEr48S10: Adding thereAreHoursOn method to IWorkHours.
This commit is contained in:
parent
aeef6f470b
commit
81278e4b4b
5 changed files with 42 additions and 4 deletions
|
|
@ -836,23 +836,30 @@ public class BaseCalendar extends BaseEntity implements IWorkHours {
|
|||
@Override
|
||||
public boolean thereAreAvailableHoursFrom(LocalDate start,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate) {
|
||||
AvailabilityTimeLine availability = getAvailabilityFrom(start);
|
||||
return thereAreHoursOn(availability, resourcesPerDay, hoursToAllocate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean thereAreHoursOn(AvailabilityTimeLine availability,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate) {
|
||||
if (hoursToAllocate == 0) {
|
||||
return true;
|
||||
}
|
||||
if (resourcesPerDay.isZero()) {
|
||||
return false;
|
||||
}
|
||||
AvailabilityTimeLine availability = getAvailabilityFrom(start);
|
||||
addInvaliditiesDerivedFromCalendar(availability);
|
||||
List<Interval> validPeriods = availability.getValidPeriods();
|
||||
if (validPeriods.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Interval last = getLast(validPeriods);
|
||||
Interval first = validPeriods.get(0);
|
||||
assert !first.getStart().equals(StartOfTime.create()) : "the start cannot be start of time,"
|
||||
+ " since a start is provided";
|
||||
final boolean isOpenEnded = last.getEnd().equals(EndOfTime.create())
|
||||
|| first.getStart().equals(StartOfTime.create());
|
||||
|
||||
boolean isOpenEnded = last.getEnd().equals(EndOfTime.create());
|
||||
return isOpenEnded
|
||||
|| thereAreHoursOn(hoursToAllocate, resourcesPerDay,
|
||||
validPeriods);
|
||||
|
|
|
|||
|
|
@ -84,6 +84,18 @@ public abstract class CombinedWorkHours implements IWorkHours {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean thereAreHoursOn(AvailabilityTimeLine availability,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate) {
|
||||
for (IWorkHours each : workHours) {
|
||||
if (!each.thereAreHoursOn(availability, resourcesPerDay,
|
||||
hoursToAllocate)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Min extends CombinedWorkHours {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ public interface IWorkHours {
|
|||
*/
|
||||
public Integer getCapacityAt(LocalDate date);
|
||||
|
||||
public boolean thereAreHoursOn(AvailabilityTimeLine availability,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate);
|
||||
|
||||
public boolean thereAreAvailableHoursFrom(LocalDate date,
|
||||
ResourcesPerDay resourcesPerDay, int hours);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,4 +56,9 @@ public class SameWorkHoursEveryDay implements IWorkHours {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean thereAreHoursOn(AvailabilityTimeLine availability,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import java.util.Map.Entry;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.calendars.entities.AvailabilityTimeLine;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.IWorkHours;
|
||||
import org.navalplanner.business.calendars.entities.SameWorkHoursEveryDay;
|
||||
|
|
@ -560,6 +561,16 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
return getTaskCalendar().thereAreAvailableHoursFrom(date,
|
||||
resourcesPerDay, hours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean thereAreHoursOn(AvailabilityTimeLine availability,
|
||||
ResourcesPerDay resourcesPerDay, int hoursToAllocate) {
|
||||
if (getTaskCalendar() == null) {
|
||||
return true;
|
||||
}
|
||||
return getTaskCalendar().thereAreHoursOn(availability,
|
||||
resourcesPerDay, hoursToAllocate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue