Package org.libreplan.business.planner.limiting.entities

Examples of org.libreplan.business.planner.limiting.entities.DateAndHour


    private List<GapOnQueueWithQueueElement> gapsWithQueueElementsFor(
            LimitingResourceQueue queue, DateAndHour allocationTime) {

        List<GapOnQueueWithQueueElement> result = new ArrayList<GapOnQueueWithQueueElement>();

        DateAndHour previousEnd = null;
        for (LimitingResourceQueueElement each : queue
                .getLimitingResourceQueueElements()) {
            DateAndHour startTime = each.getStartTime();
            if (!startTime.isBefore(allocationTime)) {
                if (previousEnd == null || startTime.isAfter(previousEnd)) {
                    Gap gap = Gap.create(queue.getResource(), previousEnd,
                            startTime);
                    result.add(GapOnQueueWithQueueElement.create(
                            gap.onQueue(queue), each));
                }
View Full Code Here


    private void feedValidGaps(LimitingResourceQueueElement element, LimitingResourceQueue queue) {
        feedValidGapsSince(element, queue, getStartDayBecauseOfGantt(element));
    }

    private DateAndHour getStartDayBecauseOfGantt(LimitingResourceQueueElement element) {
        return new DateAndHour(new LocalDate(element.getEarliestStartDateBecauseOfGantt()), 0);
    }
View Full Code Here

    }

    public void accept(Event e) {
        LimitingResourceQueueElement element = getBeingEditedElement();
        LimitingResourceQueue queue = getSelectedQueue();
        DateAndHour time = getSelectedAllocationTime();

        if (isAppropriative()) {
            appropriativeAllocation(element, queue, time);
        } else {
            nonAppropriativeAllocation(element, queue, time);
View Full Code Here

            if (isAppropriative()) {
                LimitingResourceQueueElement beingEdited = getBeingEditedElement();
                if (selectedDay.compareTo(new LocalDate(beingEdited.getEarliestStartDateBecauseOfGantt())) < 0) {
                    throw new WrongValueException(startAllocationDate, _("Day is not valid"));
                }
                return new DateAndHour(selectedDay, 0);
            } else {
                DateAndHour allocationTime = getValidDayInGap(selectedDay, getSelectedGap());
                if (allocationTime == null) {
                    throw new WrongValueException(startAllocationDate, _("Day is not valid"));
                }
                return allocationTime;
            }
View Full Code Here

     * @param date
     * @param gap
     * @return
     */
    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;

        if (start.equals(date)) {
            return gap.getStartTime();
        }
        if (end != null && end.equals(date)) {
            return endAllocationDate;
        }
        if ((start.compareTo(date) <= 0
                && (end == null || end.compareTo(date) >= 0))) {
            return new DateAndHour(date, 0);
        }

        return null;
    }
View Full Code Here

        return cachedGaps;
    }

    private List<GapOnQueue> calculateGaps() {
        List<Gap> result = new ArrayList<Gap>();
        DateAndHour previousEnd = null;
        ResourceCalendar calendar = resource.getCalendar();
        List<CalendarAvailability> activationPeriods = calendar.getCalendarAvailabilities();

        for (LimitingResourceQueueElement each : limitingResourceQueueElements) {
            DateAndHour startTime = each.getStartTime();
            if (previousEnd == null || startTime.isAfter(previousEnd)) {
                List<GapInterval> gapIntervals = GapInterval.
                        create(previousEnd, startTime).
                        delimitByActivationPeriods(activationPeriods);
                if (!gapIntervals.isEmpty()) {
                    result.addAll(GapInterval.gapsOn(gapIntervals, resource));
View Full Code Here

    private AllocationSpec getAllocationToBeDoneFor(
            DirectedGraph<LimitingResourceQueueElement, Edge> potentiallyAffectedByInsertion,
            Map<LimitingResourceQueueElement, AllocationSpec> allocationsToBeDoneByElement,
            LimitingResourceQueueElement current) {
        Validate.isTrue(!current.isDetached());
        DateAndHour newStart = current.getStartTime();
        DateAndHour newEnd = current.getEndTime();
        Map<LimitingResourceQueueElement, List<Edge>> incoming = bySource(potentiallyAffectedByInsertion
                .incomingEdgesOf(current));
        for (Entry<LimitingResourceQueueElement, List<Edge>> each : incoming
                .entrySet()) {
            AllocationSpec previous = allocationsToBeDoneByElement.get(each
View Full Code Here

        return result;
    }

    private DateAndHour getStartFrom(AllocationSpec previous,
            List<Edge> edges) {
        DateAndHour result = null;
        for (Edge each : edges) {
            result = DateAndHour.max(result,
                    calculateStart(previous, each.type));
        }
        return result;
View Full Code Here

        return type.calculateDateTargetFrom(previous.getStartInclusive(), previous
                .getEndExclusive());
    }

    private DateAndHour getEndFrom(AllocationSpec previous, List<Edge> edges) {
        DateAndHour result = null;
        for (Edge each : edges) {
            result = DateAndHour.max(result, calculateEnd(previous, each.type));
        }
        return result;
    }
View Full Code Here

     * @return
     */
    private AllocationSpec unscheduleElementsFor(
            LimitingResourceQueue queue, InsertionRequirements requirements,
            List<LimitingResourceQueueElement> result) {
        DateAndHour allocationTime = requirements.getEarliestPossibleStart();
        List<GapOnQueueWithQueueElement> gapsWithQueueElements = queuesState
                .getGapsWithQueueElementsOnQueueSince(queue, allocationTime);

        return unscheduleElementsFor(gapsWithQueueElements, requirements, result);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.limiting.entities.DateAndHour

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.