ItEr60S08CUAsignacionRecursosLimitantesItEr59S08: Add a LimitingResourceQueueElement to the ValidAllocationAttempt.
This commit is contained in:
parent
b8bef91385
commit
d3fcbde23c
2 changed files with 31 additions and 5 deletions
|
|
@ -40,9 +40,11 @@ public abstract class AllocationAttempt {
|
|||
return new InvalidAllocationAttempt(gap);
|
||||
}
|
||||
|
||||
public static AllocationAttempt validOn(GapOnQueue gap, DateAndHour start,
|
||||
public static AllocationAttempt validOn(
|
||||
LimitingResourceQueueElement element, GapOnQueue gap,
|
||||
DateAndHour start,
|
||||
DateAndHour endExclusive, int[] assignableHours) {
|
||||
return new ValidAllocationAttempt(gap, start, endExclusive,
|
||||
return new ValidAllocationAttempt(element, gap, start, endExclusive,
|
||||
assignableHours);
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +61,9 @@ public abstract class AllocationAttempt {
|
|||
ResourceAllocation<?> allocation, Resource resource)
|
||||
throws IllegalStateException;
|
||||
|
||||
public abstract LimitingResourceQueueElement getElement()
|
||||
throws IllegalStateException;
|
||||
|
||||
public abstract DateAndHour getStartInclusive()
|
||||
throws IllegalStateException;
|
||||
|
||||
|
|
@ -92,6 +97,12 @@ class InvalidAllocationAttempt extends AllocationAttempt {
|
|||
throw new IllegalStateException(INVALID_ALLOCATION_ON_GAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitingResourceQueueElement getElement()
|
||||
throws IllegalStateException {
|
||||
throw new IllegalStateException(INVALID_ALLOCATION_ON_GAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateAndHour getEndExclusive() throws IllegalStateException {
|
||||
throw new IllegalStateException(INVALID_ALLOCATION_ON_GAP);
|
||||
|
|
@ -105,17 +116,21 @@ class InvalidAllocationAttempt extends AllocationAttempt {
|
|||
|
||||
class ValidAllocationAttempt extends AllocationAttempt {
|
||||
|
||||
private final LimitingResourceQueueElement element;
|
||||
private final DateAndHour start;
|
||||
private final DateAndHour end;
|
||||
private final int[] assignableHours;
|
||||
|
||||
public ValidAllocationAttempt(GapOnQueue gap, DateAndHour startInclusive,
|
||||
public ValidAllocationAttempt(LimitingResourceQueueElement element,
|
||||
GapOnQueue gap, DateAndHour startInclusive,
|
||||
DateAndHour endExclusive, int[] assignableHours) {
|
||||
super(gap);
|
||||
Validate.notNull(element);
|
||||
Validate.notNull(startInclusive);
|
||||
Validate.notNull(endExclusive);
|
||||
Validate.notNull(assignableHours);
|
||||
Validate.isTrue(endExclusive.isAfter(startInclusive));
|
||||
this.element = element;
|
||||
this.start = startInclusive;
|
||||
this.end = endExclusive;
|
||||
Validate.isTrue(assignableHours.length == toFiniteList(
|
||||
|
|
@ -170,6 +185,11 @@ class ValidAllocationAttempt extends AllocationAttempt {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitingResourceQueueElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateAndHour getEndExclusive() throws IllegalStateException {
|
||||
return end;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ public class InsertionRequirements {
|
|||
return DateAndHour.from(LocalDate.fromDateFields(date));
|
||||
}
|
||||
|
||||
public static InsertionRequirements create(
|
||||
LimitingResourceQueueElement element,
|
||||
DateAndHour start, DateAndHour end) {
|
||||
return new InsertionRequirements(element, start, end);
|
||||
}
|
||||
|
||||
private InsertionRequirements(LimitingResourceQueueElement element,
|
||||
DateAndHour earliestPossibleStart, DateAndHour earliestPossibleEnd) {
|
||||
Validate.notNull(element);
|
||||
|
|
@ -126,8 +132,8 @@ public class InsertionRequirements {
|
|||
private AllocationAttempt validAllocation(GapOnQueue gap,
|
||||
DateAndHour realStart,
|
||||
List<Integer> hours) {
|
||||
return AllocationAttempt.validOn(gap, realStart, calculateEnd(realStart,
|
||||
hours), asArray(hours));
|
||||
return AllocationAttempt.validOn(element, gap, realStart, calculateEnd(
|
||||
realStart, hours), asArray(hours));
|
||||
}
|
||||
|
||||
private DateAndHour calculateEnd(DateAndHour realStart, List<Integer> hours) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue