Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.EffortDuration


            return getSumOfAssignedEffortCalculated();
        }
    }

    private EffortDuration getSumOfAssignedEffortCalculated() {
        EffortDuration result = EffortDuration.zero();
        for(ResourceAllocation<?> allocation : getAllResourceAllocations()) {
            result = result.plus(allocation.getAssignedEffort());
        }
        return result;
    }
View Full Code Here


    }

    public abstract EffortDuration getTheoreticalCompletedTimeUntilDate(Date date);

    public BigDecimal getTheoreticalAdvancePercentageUntilDate(Date date) {
        EffortDuration totalAllocatedTime = AggregateOfDayAssignments.create(
                this.getDayAssignments(FilterType.KEEP_ALL)).getTotalTime();
        EffortDuration totalTheoreticalCompletedTime = this.getTheoreticalCompletedTimeUntilDate(date);
        if (totalAllocatedTime.isZero() || totalTheoreticalCompletedTime.isZero()) {
            return BigDecimal.ZERO;
        }
        Validate.isTrue(totalTheoreticalCompletedTime.getSeconds() <= totalAllocatedTime.getSeconds());
        return totalTheoreticalCompletedTime.dividedByAndResultAsBigDecimal(totalAllocatedTime);
    }
View Full Code Here

        return new Max(calendars);
    }

    @Override
    public EffortDuration getCapacityOn(PartialDay day) {
        EffortDuration current = null;
        for (ICalendar workHour : calendars) {
            current = current == null ? workHour.getCapacityOn(day)
                    : updateCapacity(current, workHour.getCapacityOn(day));
        }
        return current;
View Full Code Here

        return current;
    }

    @Override
    public EffortDuration asDurationOn(PartialDay day, ResourcesPerDay amount) {
        EffortDuration result = null;
        for (ICalendar each : calendars) {
            result = result == null ? each.asDurationOn(day, amount)
                    : updateDuration(result, each.asDurationOn(day, amount));
        }
        return result;
View Full Code Here

        return start;
    }

    public static EffortDuration sum(
            Collection<? extends DayAssignment> assignments) {
        EffortDuration result = zero();
        for (DayAssignment each : assignments) {
            result = result.plus(each.getDuration());
        }
        return result;
    }
View Full Code Here

    }

    private static CapacityResult thereIsCapacityOn(ICalendar calendar,
            EffortDuration effortToAllocate,
            ResourcesPerDay resourcesPerDay, List<Interval> validPeriods) {
        EffortDuration sum = zero();
        for (Interval each : validPeriods) {
            FixedPoint start = (FixedPoint) each.getStart();
            FixedPoint end = (FixedPoint) each.getEnd();
            EffortDuration pending = effortToAllocate.minus(sum);
            sum = sum.plus(sumDurationUntil(calendar, pending,
                    resourcesPerDay, start.getDate(), end.getDate()));
            if (sum.compareTo(effortToAllocate) >= 0) {
                return new CapacityAvailable();
            }
View Full Code Here

    }

    private static EffortDuration sunDurationUntil(ICalendar calendar,
            EffortDuration maximum, ResourcesPerDay resourcesPerDay,
            IntraDayDate start, IntraDayDate end) {
        EffortDuration result = zero();
        for (PartialDay current : start.daysUntil(end)) {
            result = result.plus(calendar.asDurationOn(current, resourcesPerDay));
            if (result.compareTo(maximum) >= 0) {
                return maximum;
            }
        }
        return result;
    }
View Full Code Here

        assertThat(duration.toHoursAsDecimalWithScale(1), equalTo(new BigDecimal("1.5")));
    }

    @Test
    public void theScaleIsTheOneProvided() {
        EffortDuration duration = hours(1).and(30, Granularity.MINUTES);
        assertThat(duration.toHoursAsDecimalWithScale(1).scale(), equalTo(1));
        assertThat(duration.toHoursAsDecimalWithScale(2).scale(), equalTo(2));
        assertThat(duration.toHoursAsDecimalWithScale(3).scale(), equalTo(3));
    }
View Full Code Here

    }

    @Test
    public void anHalfUpRoundIsDone() {
        // 3601/3600 = 1.000277778
        EffortDuration duration = hours(1).and(1, Granularity.SECONDS);
        assertThat(duration.toHoursAsDecimalWithScale(6), equalTo(new BigDecimal(
                "1.000278")));
        assertThat(duration.toHoursAsDecimalWithScale(5),
                equalTo(new BigDecimal("1.00028")));
        assertThat(duration.toHoursAsDecimalWithScale(4),
                equalTo(new BigDecimal("1.0003")));
    }
View Full Code Here

    }

    private Map<Integer, Integer> asHours(Map<Integer, Capacity> capacities) {
        Map<Integer, Integer> result = new HashMap<Integer, Integer>();
        for (Entry<Integer, Capacity> each : capacities.entrySet()) {
            EffortDuration value = toDuration(each.getValue());
            result.put(each.getKey(), value == null ? null : value.getHours());
        }
        return result;
    }
View Full Code Here

TOP

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

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.