ItEr59S08CUAsignacionRecursosLimitantesItEr58S10: Rename class so it has a simpler name

This commit is contained in:
Óscar González Fernández 2010-06-05 19:41:15 +02:00
parent 3a1159f6bf
commit 2b5c5edc26
4 changed files with 63 additions and 63 deletions

View file

@ -29,7 +29,7 @@ import org.navalplanner.business.resources.entities.Resource;
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class LimitingResourceQueueElementGap implements Comparable<LimitingResourceQueueElementGap> {
public class Gap implements Comparable<Gap> {
private DateAndHour startTime;
@ -37,7 +37,7 @@ public class LimitingResourceQueueElementGap implements Comparable<LimitingResou
private Integer hoursInGap;
public LimitingResourceQueueElementGap(Resource resource, DateAndHour startTime,
public Gap(Resource resource, DateAndHour startTime,
DateAndHour endTime) {
this.startTime = startTime;
this.endTime = endTime;
@ -69,9 +69,9 @@ public class LimitingResourceQueueElementGap implements Comparable<LimitingResou
}
}
public static LimitingResourceQueueElementGap create(Resource resource, DateAndHour startTime,
public static Gap create(Resource resource, DateAndHour startTime,
DateAndHour endTime) {
return new LimitingResourceQueueElementGap(resource, startTime, endTime);
return new Gap(resource, startTime, endTime);
}
public DateAndHour getStartTime() {
@ -117,14 +117,14 @@ public class LimitingResourceQueueElementGap implements Comparable<LimitingResou
}
@Override
public int compareTo(LimitingResourceQueueElementGap o) {
public int compareTo(Gap o) {
if (o == null) {
return 1;
}
return this.getStartTime().compareTo(o.getStartTime());
}
public boolean isBefore(LimitingResourceQueueElementGap gap) {
public boolean isBefore(Gap gap) {
return (compareTo(gap) < 0);
}

View file

@ -72,7 +72,7 @@ public class LimitingResourceAllocator {
* @param element element to fit into queue
* @return
*/
public static LimitingResourceQueueElementGap getFirstValidGap(
public static Gap getFirstValidGap(
LimitingResourceQueue queue, LimitingResourceQueueElement element) {
final Resource resource = queue.getResource();
@ -85,11 +85,11 @@ public class LimitingResourceAllocator {
// Iterate through queue elements
while (pos <= size) {
LimitingResourceQueueElementGap gap = getGapInQueueAtPosition(
Gap gap = getGapInQueueAtPosition(
resource, elements, startTime, pos++);
if (gap != null) {
List<LimitingResourceQueueElementGap> subgaps = getFittingSubgaps(
List<Gap> subgaps = getFittingSubgaps(
element, gap, resource);
if (!subgaps.isEmpty()) {
return subgaps.get(0);
@ -102,18 +102,18 @@ public class LimitingResourceAllocator {
return null;
}
private static List<LimitingResourceQueueElementGap> getFittingSubgaps(
private static List<Gap> getFittingSubgaps(
LimitingResourceQueueElement element,
final LimitingResourceQueueElementGap gap, final Resource resource) {
final Gap gap, final Resource resource) {
List<LimitingResourceQueueElementGap> result = new ArrayList<LimitingResourceQueueElementGap>();
List<Gap> result = new ArrayList<Gap>();
if (isSpecific(element) && gap.canFit(element)) {
result.add(gap);
} else if (isGeneric(element)) {
final List<LimitingResourceQueueElementGap> gaps = splitIntoGapsSatisfyingCriteria(
final List<Gap> gaps = splitIntoGapsSatisfyingCriteria(
resource, getCriteria(element), gap);
for (LimitingResourceQueueElementGap subgap : gaps) {
for (Gap subgap : gaps) {
if (subgap.canFit(element)) {
result.add(subgap);
}
@ -122,18 +122,18 @@ public class LimitingResourceAllocator {
return result;
}
public static LimitingResourceQueueElementGap getFirstValidGapSince(
public static Gap getFirstValidGapSince(
LimitingResourceQueueElement element, LimitingResourceQueue queue,
DateAndHour since) {
List<LimitingResourceQueueElementGap> gaps = getValidGapsForElementSince(element, queue, since);
List<Gap> gaps = getValidGapsForElementSince(element, queue, since);
return (!gaps.isEmpty()) ? gaps.get(0) : null;
}
public static List<LimitingResourceQueueElementGap> getValidGapsForElementSince(
public static List<Gap> getValidGapsForElementSince(
LimitingResourceQueueElement element, LimitingResourceQueue queue,
DateAndHour since) {
List<LimitingResourceQueueElementGap> result = new ArrayList<LimitingResourceQueueElementGap>();
List<Gap> result = new ArrayList<Gap>();
final Resource resource = queue.getResource();
final List<LimitingResourceQueueElement> elements = new LinkedList<LimitingResourceQueueElement>(
@ -144,13 +144,13 @@ public class LimitingResourceAllocator {
// Iterate through queue elements
while (pos <= size) {
LimitingResourceQueueElementGap gap = getGapInQueueAtPosition(
Gap gap = getGapInQueueAtPosition(
resource, elements, since, pos++);
// The queue cannot hold this element (queue.resource
// doesn't meet element.criteria)
if (gap != null) {
List<LimitingResourceQueueElementGap> subgaps = getFittingSubgaps(
List<Gap> subgaps = getFittingSubgaps(
element, gap, resource);
result.addAll(subgaps);
}
@ -200,13 +200,13 @@ public class LimitingResourceAllocator {
return date != null ? date.toDateTimeAtStartOfDay().toDate() : null;
}
private static List<LimitingResourceQueueElementGap> splitIntoGapsSatisfyingCriteria(
Resource resource, Set<Criterion> criteria, LimitingResourceQueueElementGap gap) {
private static List<Gap> splitIntoGapsSatisfyingCriteria(
Resource resource, Set<Criterion> criteria, Gap gap) {
return splitIntoGapsSatisfyingCriteria(resource, criteria, gap.getStartTime(), gap.getEndTime());
}
/**
* Returns a set of {@link LimitingResourceQueueElementGap} composed by those gaps
* Returns a set of {@link Gap} composed by those gaps
* which satisfy <em>criteria</em> within the period: <em>gapStartTime</em> till <em>gapEndTime</em>
*
* @param resource
@ -218,7 +218,7 @@ public class LimitingResourceAllocator {
* end time of gap
* @return
*/
private static List<LimitingResourceQueueElementGap> splitIntoGapsSatisfyingCriteria(
private static List<Gap> splitIntoGapsSatisfyingCriteria(
Resource resource, Set<Criterion> criteria, DateAndHour gapStartTime,
DateAndHour gapEndTime) {
@ -231,7 +231,7 @@ public class LimitingResourceAllocator {
: gapStartTime.getDate().plusYears(10);
final LocalDate gapStartDate = gapStartTime.getDate();
List<LimitingResourceQueueElementGap> result = new ArrayList<LimitingResourceQueueElementGap>();
List<Gap> result = new ArrayList<Gap>();
LocalDate date = gapStartDate;
boolean open = compositedCriterion.isSatisfiedBy(resource, toDate(date));
@ -248,13 +248,13 @@ public class LimitingResourceAllocator {
}
if (open == true && !compositedCriterion.isSatisfiedBy(resource, toDate(date))) {
endTime = new DateAndHour(date, 0);
result.add(LimitingResourceQueueElementGap.create(resource,
result.add(Gap.create(resource,
startTime, endTime));
open = false;
}
date = date.plusDays(1);
}
result.add(LimitingResourceQueueElementGap.create(resource, startTime, gapEndTime));
result.add(Gap.create(resource, startTime, gapEndTime));
return result;
}
@ -269,7 +269,7 @@ public class LimitingResourceAllocator {
return new DateAndHour(end.getDay(), end.getHours());
}
private static LimitingResourceQueueElementGap getGapInQueueAtPosition(
private static Gap getGapInQueueAtPosition(
Resource resource, List<LimitingResourceQueueElement> elements,
DateAndHour startTimeBecauseOfGantt, int pos) {
@ -291,14 +291,14 @@ public class LimitingResourceAllocator {
if (pos == 0
&& startTimeBecauseOfGantt.getDate().isBefore(
next.getStartDate())) {
return LimitingResourceQueueElementGap.create(resource,
return Gap.create(resource,
startTimeBecauseOfGantt, next.getStartTime());
}
// In the middle of two elements
if (pos > 0) {
LimitingResourceQueueElement previous = elements.get(pos - 1);
return LimitingResourceQueueElementGap.create(resource, DateAndHour
return Gap.create(resource, DateAndHour
.Max(previous.getEndTime(), startTimeBecauseOfGantt), next
.getStartTime());
}
@ -310,14 +310,14 @@ public class LimitingResourceAllocator {
return new DateAndHour(new LocalDate(element.getEarlierStartDateBecauseOfGantt()), 0);
}
private static LimitingResourceQueueElementGap createLastGap(
private static Gap createLastGap(
DateAndHour _startTime, LimitingResourceQueueElement lastElement,
Resource resource) {
final DateAndHour queueEndTime = (lastElement != null) ? lastElement
.getEndTime() : null;
DateAndHour startTime = DateAndHour.Max(_startTime, queueEndTime);
return LimitingResourceQueueElementGap
return Gap
.create(resource, startTime, null);
}
@ -447,7 +447,7 @@ public class LimitingResourceAllocator {
public static DateAndHour startTimeToAllocateStartingFromEnd(
ResourceAllocation<?> resourceAllocation, Resource resource,
LimitingResourceQueueElementGap gap) {
Gap gap) {
// Last element, time is end of last element (gap.starttime)
if (gap.getEndTime() == null) {

View file

@ -58,7 +58,7 @@ import org.navalplanner.business.planner.limiting.entities.DateAndHour;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceAllocator;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueueDependency;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueueElement;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueueElementGap;
import org.navalplanner.business.planner.limiting.entities.Gap;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.CriterionSatisfaction;
import org.navalplanner.business.resources.entities.LimitingResourceQueue;
@ -403,16 +403,16 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
// Retrieve queue
queue = queuesState.getQueueFor(queueElement.getResource());
// Set start time
final LimitingResourceQueueElementGap firstGap = LimitingResourceAllocator
final Gap firstGap = LimitingResourceAllocator
.getFirstValidGap(queue, queueElement);
startTime = firstGap.getStartTime();
} else if (resourceAllocation instanceof GenericResourceAllocation) {
// Get the first gap for all the queues that can allocate the
// element during a certain interval of time
Map<LimitingResourceQueueElementGap, LimitingResourceQueue> firstGapsForQueues = findFirstGapsInAllQueues(
Map<Gap, LimitingResourceQueue> firstGapsForQueues = findFirstGapsInAllQueues(
queuesState.getQueues(), element);
// Among those queues, get the earliest gap
LimitingResourceQueueElementGap earliestGap = findEarliestGap(firstGapsForQueues
Gap earliestGap = findEarliestGap(firstGapsForQueues
.keySet());
if (earliestGap == null) {
return false;
@ -466,9 +466,9 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
return startTime.getDate().equals(endTime.getDate());
}
private LimitingResourceQueueElementGap findEarliestGap(Set<LimitingResourceQueueElementGap> gaps) {
LimitingResourceQueueElementGap earliestGap = null;
for (LimitingResourceQueueElementGap each: gaps) {
private Gap findEarliestGap(Set<Gap> gaps) {
Gap earliestGap = null;
for (Gap each: gaps) {
if (earliestGap == null || each.isBefore(earliestGap)) {
earliestGap = each;
}
@ -476,14 +476,14 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
return earliestGap;
}
private Map<LimitingResourceQueueElementGap, LimitingResourceQueue> findFirstGapsInAllQueues(
private Map<Gap, LimitingResourceQueue> findFirstGapsInAllQueues(
List<LimitingResourceQueue> queues,
LimitingResourceQueueElement element) {
Map<LimitingResourceQueueElementGap, LimitingResourceQueue> result = new HashMap<LimitingResourceQueueElementGap, LimitingResourceQueue>();
Map<Gap, LimitingResourceQueue> result = new HashMap<Gap, LimitingResourceQueue>();
for (LimitingResourceQueue each : queues) {
LimitingResourceQueueElementGap gap = LimitingResourceAllocator
Gap gap = LimitingResourceAllocator
.getFirstValidGap(each, element);
if (gap != null) {
result.put(gap, each);
@ -498,9 +498,9 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
}
}
public LimitingResourceQueueElementGap createGap(Resource resource, DateAndHour startTime,
public Gap createGap(Resource resource, DateAndHour startTime,
DateAndHour endTime) {
return LimitingResourceQueueElementGap.create(resource, startTime, endTime);
return Gap.create(resource, startTime, endTime);
}
private void updateStartAndEndTimes(LimitingResourceQueueElement element,
@ -716,7 +716,7 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
List<LimitingResourceQueueElement> unscheduledElements = new ArrayList<LimitingResourceQueueElement>();
LimitingResourceQueueElementGap gap;
Gap gap;
do {
gap = LimitingResourceAllocator.getFirstValidGapSince(element, queue, allocationTime);

View file

@ -33,7 +33,7 @@ import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.limiting.entities.DateAndHour;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceAllocator;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueueElement;
import org.navalplanner.business.planner.limiting.entities.LimitingResourceQueueElementGap;
import org.navalplanner.business.planner.limiting.entities.Gap;
import org.navalplanner.business.resources.entities.LimitingResourceQueue;
import org.navalplanner.business.resources.entities.Resource;
import org.springframework.beans.factory.config.BeanDefinition;
@ -84,7 +84,7 @@ public class ManualAllocationController extends GenericForwardComposer {
private Checkbox cbAllocationType;
private Map<LimitingResourceQueueElementGap, DateAndHour> endAllocationDates = new HashMap<LimitingResourceQueueElementGap, DateAndHour>();
private Map<Gap, DateAndHour> endAllocationDates = new HashMap<Gap, DateAndHour>();
private final QueueRenderer queueRenderer = new QueueRenderer();
@ -131,7 +131,7 @@ public class ManualAllocationController extends GenericForwardComposer {
}
private void feedValidGapsSince(LimitingResourceQueueElement element, LimitingResourceQueue queue, DateAndHour since) {
List<LimitingResourceQueueElementGap> gaps = LimitingResourceAllocator.getValidGapsForElementSince(element, queue, since);
List<Gap> gaps = LimitingResourceAllocator.getValidGapsForElementSince(element, queue, since);
endAllocationDates = calculateEndAllocationDates(element.getResourceAllocation(), queue.getResource(), gaps);
listCandidateGaps.setModel(new SimpleListModel(gaps));
@ -181,12 +181,12 @@ public class ManualAllocationController extends GenericForwardComposer {
startAllocationDate.setValue(date);
}
private Map<LimitingResourceQueueElementGap, DateAndHour> calculateEndAllocationDates(
private Map<Gap, DateAndHour> calculateEndAllocationDates(
ResourceAllocation<?> resourceAllocation, Resource resource,
List<LimitingResourceQueueElementGap> gaps) {
List<Gap> gaps) {
Map<LimitingResourceQueueElementGap, DateAndHour> result = new HashMap<LimitingResourceQueueElementGap, DateAndHour>();
for (LimitingResourceQueueElementGap each: gaps) {
Map<Gap, DateAndHour> result = new HashMap<Gap, DateAndHour>();
for (Gap each: gaps) {
result.put(each, calculateEndAllocationDate(resourceAllocation, resource, each));
}
return result;
@ -194,7 +194,7 @@ public class ManualAllocationController extends GenericForwardComposer {
private DateAndHour calculateEndAllocationDate(
ResourceAllocation<?> resourceAllocation, Resource resource,
LimitingResourceQueueElementGap gap) {
Gap gap) {
if (gap.getEndTime() != null) {
return LimitingResourceAllocator.startTimeToAllocateStartingFromEnd(resourceAllocation, resource, gap);
@ -279,7 +279,7 @@ public class ManualAllocationController extends GenericForwardComposer {
}
private DateAndHour getSelectedAllocationTime() {
final LimitingResourceQueueElementGap selectedGap = getSelectedGap();
final Gap selectedGap = getSelectedGap();
int index = radioAllocationDate.getSelectedIndex();
// Earliest date
@ -308,12 +308,12 @@ public class ManualAllocationController extends GenericForwardComposer {
return null;
}
private DateAndHour getEarliestTime(LimitingResourceQueueElementGap gap) {
private DateAndHour getEarliestTime(Gap gap) {
Validate.notNull(gap);
return gap.getStartTime();
}
private DateAndHour getLatestTime(LimitingResourceQueueElementGap gap) {
private DateAndHour getLatestTime(Gap gap) {
Validate.notNull(gap);
LimitingResourceQueueElement element = getLimitingResourceQueueModel().getLimitingResourceQueueElement();
LimitingResourceQueue queue = getSelectedQueue();
@ -321,10 +321,10 @@ public class ManualAllocationController extends GenericForwardComposer {
element.getResourceAllocation(), queue.getResource(), gap);
}
private LimitingResourceQueueElementGap getSelectedGap() {
private Gap getSelectedGap() {
Listitem item = listCandidateGaps.getSelectedItem();
if (item != null) {
return (LimitingResourceQueueElementGap) item.getValue();
return (Gap) item.getValue();
}
return null;
}
@ -340,7 +340,7 @@ public class ManualAllocationController extends GenericForwardComposer {
* @param gap
* @return
*/
private DateAndHour getValidDayInGap(LocalDate date, LimitingResourceQueueElementGap gap) {
private DateAndHour getValidDayInGap(LocalDate date, Gap gap) {
final DateAndHour endAllocationDate = endAllocationDates.get(gap);
final LocalDate start = gap.getStartTime().getDate();
final LocalDate end = endAllocationDate != null ? endAllocationDate.getDate() : null;
@ -402,7 +402,7 @@ public class ManualAllocationController extends GenericForwardComposer {
* @param uuid
* @param gap
*/
public void highlightDaysInGap(String uuid, LimitingResourceQueueElementGap gap) {
public void highlightDaysInGap(String uuid, Gap gap) {
final LocalDate start = gap.getStartTime().getDate();
final LocalDate end = getEndAllocationDate(gap);
@ -427,7 +427,7 @@ public class ManualAllocationController extends GenericForwardComposer {
Clients.evalJavaScript(jsCall);
}
private LocalDate getEndAllocationDate(LimitingResourceQueueElementGap gap) {
private LocalDate getEndAllocationDate(Gap gap) {
final DateAndHour endTime = endAllocationDates.get(gap);
return endTime != null ? endTime.getDate() : null;
}
@ -460,7 +460,7 @@ public class ManualAllocationController extends GenericForwardComposer {
@Override
public void render(Listitem item, Object data) throws Exception {
LimitingResourceQueueElementGap gap = (LimitingResourceQueueElementGap) data;
Gap gap = (Gap) data;
item.setValue(gap);
item.appendChild(cell(gap.getStartTime()));