Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.IntraDayDate


        IntraDayDate start = getIntraDayStartDate();
        return start != null ? start.getDate() : null;
    }

    private IntraDayDate getStartSpecifiedByTask() {
        IntraDayDate taskStart = task.getIntraDayStartDate();
        IntraDayDate firstDayNotConsolidated = getTask()
                .getFirstDayNotConsolidated();
        return IntraDayDate.max(taskStart, firstDayNotConsolidated);
    }
View Full Code Here


                .getFirstDayNotConsolidated();
        return IntraDayDate.max(taskStart, firstDayNotConsolidated);
    }

    public IntraDayDate getIntraDayStartDate() {
        IntraDayDate intraDayStart = getDayAssignmentsState()
                .getIntraDayStart();
        if (intraDayStart != null) {
            return intraDayStart;
        }
        return task.getIntraDayStartDate();
View Full Code Here

        }
        return task.getIntraDayStartDate();
    }

    public LocalDate getEndDate() {
        IntraDayDate intraDayEndDate = getIntraDayEndDate();
        return intraDayEndDate != null ? intraDayEndDate.asExclusiveEnd()
                : null;
    }
View Full Code Here

        return intraDayEndDate != null ? intraDayEndDate.asExclusiveEnd()
                : null;
    }

    public IntraDayDate getIntraDayEndDate() {
        IntraDayDate intraDayEnd = getDayAssignmentsState().getIntraDayEnd();
        if (intraDayEnd != null) {
            return intraDayEnd;
        }

        LocalDate l = getEndDateGiven(getAssignments());
View Full Code Here

        return getAssignedDuration(assignments, start, endExclusive);
    }

    @Override
    public EffortDuration getAssignedDurationAt(Resource resource, LocalDate day) {
        IntraDayDate start = IntraDayDate.startOfDay(day);
        return getAssignedEffort(resource, start, start.nextDayAtStart());
    }
View Full Code Here

    private EffortDuration getAssignedDuration(
            List<? extends DayAssignment> assignments,
            final IntraDayDate startInclusive, final IntraDayDate endExclusive) {

        final IntraDayDate allocationStart = getIntraDayStartDate();

        return EffortDuration.sum(assignments,
                new IEffortFrom<DayAssignment>() {

                    @Override
                    public EffortDuration from(DayAssignment value) {
                        PartialDay partial = getPartialDay(value,
                                startInclusive, endExclusive);
                        return partial.limitWorkingDay(value.getDuration());
                    }

                    private PartialDay getPartialDay(DayAssignment assignment,
                            IntraDayDate startInclusive,
                            IntraDayDate endExclusive) {

                        LocalDate assignmentDay = assignment.getDay();
                        LocalDate startDate = startInclusive.getDate();
                        LocalDate endDate = endExclusive.getDate();

                        PartialDay result = PartialDay.wholeDay(assignment
                                .getDay());
                        if (assignmentDay.equals(startDate)) {
                            result = new PartialDay(startInclusive, result
                                    .getEnd());
                        }
                        if (assignmentDay.equals(endDate)) {
                            result = new PartialDay(result.getStart(),
                                    endExclusive);
                        }
                        return adjustPartialDayToAllocationStart(result);
                    }

                    // if the start of the allocation is in the middle of a day,
                    // its work also starts later; so the PartialDay must be
                    // moved to earlier so it doesn't limit the duration more
                    // that it should
                    private PartialDay adjustPartialDayToAllocationStart(
                            PartialDay day) {
                        PartialDay result = day;
                        if (allocationStart.areSameDay(day.getDate())) {
                            EffortDuration substractingAtStart = day.getStart()
                                    .getEffortDuration();
                            EffortDuration newSubstractionAtStart = substractingAtStart
                                    .minus(EffortDuration
                                            .min(substractingAtStart,
                                                    allocationStart
                                                            .getEffortDuration()));
                            IntraDayDate newStart = IntraDayDate.create(
                                    day.getDate(), newSubstractionAtStart);
                            result = new PartialDay(newStart, day.getEnd());
                        }
                        return result;
                    }
View Full Code Here

                    allocationAttempt.getBeingModified().markAsUnsatisfied();
                    receiver.cantFulfill(allocationAttempt, capacityResult);
                }

            };
            IntraDayDate result = allocator.untilAllocating(toAllocate);
            if (result == null) {
                // allocation could not be done
                return direction == Direction.FORWARD ? task
                        .getIntraDayEndDate() : task.getIntraDayStartDate();
            }
View Full Code Here

            resultAssignments.put(r, new ArrayList<DayAssignment>());
        }
    }

    public IntraDayDate untilAllocating(EffortDuration effortToAllocate) {
        final IntraDayDate dateFromWhichToAllocate = direction
                .getDateFromWhichToAllocate(task);
        List<EffortPerAllocation> effortPerAllocation = effortPerAllocation(
                dateFromWhichToAllocate, effortToAllocate);
        if (effortPerAllocation.isEmpty()) {
            return null;
View Full Code Here

        return untilAllocating(dateFromWhichToAllocate, effortPerAllocation);
    }

    private IntraDayDate untilAllocating(final IntraDayDate dateFromWhichToAllocate,
            List<EffortPerAllocation> effortPerAllocation) {
        IntraDayDate currentResult = dateFromWhichToAllocate;
        for (EffortPerAllocation each : effortPerAllocation) {
            IntraDayDate candidate = untilAllocating(dateFromWhichToAllocate,
                    each.allocation, each.duration);
            currentResult = pickCurrentOrCandidate(currentResult, candidate);
        }
        setAssignmentsForEachAllocation(currentResult);
        return currentResult;
View Full Code Here

    private IntraDayDate untilAllocating(IntraDayDate dateFromWhichToAllocate,
            ResourcesPerDayModification resourcesPerDayModification,
            EffortDuration effortRemaining) {
        EffortDuration taken = zero();
        EffortDuration biggestLastAssignment = zero();
        IntraDayDate current = dateFromWhichToAllocate;
        IAssignmentsCreator assignmentsCreator = resourcesPerDayModification
                .createAssignmentsCreator();
        while (effortRemaining.compareTo(zero()) > 0) {
            PartialDay day = calculateDay(current);
            Pair<EffortDuration, EffortDuration> pair = assignForDay(
                    resourcesPerDayModification, assignmentsCreator, day,
                    effortRemaining);
            taken = pair.getFirst();
            biggestLastAssignment = pair.getSecond();
            effortRemaining = effortRemaining.minus(taken);

            if (effortRemaining.compareTo(zero()) > 0) {
                current = nextDay(current);
            }
        }
        IntraDayDate finish = adjustFinish(resourcesPerDayModification, taken,
                biggestLastAssignment, current);
        // We have to do it now, so the other allocations take it into account.
        // At the end it's done again with the right end date.
        setNewDataForAllocation(resourcesPerDayModification, resultAssignments
                .get(resourcesPerDayModification), finish);
View Full Code Here

TOP

Related Classes of org.libreplan.business.workingday.IntraDayDate

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.