Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.EffortDuration


            return new IAssignedEffortForResource() {

                @Override
                public EffortDuration getAssignedDurationAt(Resource resource,
                        LocalDate day) {
                    EffortDuration previouslyAssigned = assignedEffortForResource
                            .getAssignedDurationAt(resource, day);
                    ResourceWithAssignedDuration withDuration = byResource
                            .get(resource);
                    if (withDuration != null) {
                        return previouslyAssigned.plus(withDuration.duration);
                    }
                    return previouslyAssigned;
                }
            };
        }
View Full Code Here


            this.calendar = generateCalendarFor(resource);
        }

        ResourceWithAvailableCapacity withAvailableCapacityOn(PartialDay day,
                IAssignedEffortForResource assignedEffort) {
            EffortDuration allCapacityForDay = calendar
                    .getCapacityOn(PartialDay.wholeDay(day.getDate()));
            EffortDuration capacity = calendar.getCapacityOn(day);

            EffortDuration capacityForAlreadyAssigned = allCapacityForDay
                    .minus(capacity);

            EffortDuration assigned = assignedEffort.getAssignedDurationAt(
                    resource, day.getDate());
            EffortDuration assignedInterfering = assigned.minus(min(assigned,
                    capacityForAlreadyAssigned));

            EffortDuration available = capacity.minus(min(assignedInterfering,
                    capacity));
            return new ResourceWithAvailableCapacity(resource, available);
        }
View Full Code Here

        Capacity getAvailableCapacityOn(PartialDay day,
                IAssignedEffortForResource assignedEffort) {
            Capacity originalCapacity = day.limitCapacity(calendar
                    .getCapacityWithOvertime(day.getDate()));
            EffortDuration alreadyAssigned = assignedEffort
                    .getAssignedDurationAt(resource, day.getDate());
            return originalCapacity.minus(alreadyAssigned);
        }
View Full Code Here

    }

    @Override
    public EffortDuration asDurationOn(PartialDay day, ResourcesPerDay amount) {
        Capacity capacity = findCapacityAt(day.getDate());
        EffortDuration oneResourcePerDayWorkingDuration = day
                .limitWorkingDay(capacity.getStandardEffort());
        EffortDuration amountRequestedDuration = amount
                .asDurationGivenWorkingDayOf(oneResourcePerDayWorkingDuration);

        EffortDuration duration = multiplyByCalendarUnits(capacity)
                .limitDuration(amountRequestedDuration);
        return duration.atNearestMinute();
    }
View Full Code Here

public class EffortDurationTest {

    @Test
    public void itCanExpressTheDurationAsHoursMinutesAndSeconds() {
        EffortDuration duration = EffortDuration.hours(4);
        assertThat(duration.getHours(), equalTo(4));
        assertThat(duration.getMinutes(), equalTo(240));
        assertThat(duration.getSeconds(), equalTo(240 * 60));
    }
View Full Code Here

                equalTo(ninetyMinutes.hashCode()));
    }

    @Test
    public void anEffortDurationCanBeDecomposedIntoElements() {
        EffortDuration duration = hours(1).and(90, Granularity.MINUTES);
        EnumMap<Granularity, Integer> values = duration.decompose();
        assertThat(values.get(Granularity.HOURS), equalTo(2));
        assertThat(values.get(Granularity.MINUTES), equalTo(30));
        assertThat(values.get(Granularity.SECONDS), equalTo(0));
    }
View Full Code Here

        assertThat(values.get(Granularity.SECONDS), equalTo(0));
    }

    @Test
    public void anZeroDurationHasZeroElements() {
        EffortDuration duration = EffortDuration.zero();
        EnumMap<Granularity, Integer> values = duration.decompose();
        assertThat(values.get(Granularity.HOURS), equalTo(0));
        assertThat(values.get(Granularity.MINUTES), equalTo(0));
        assertThat(values.get(Granularity.SECONDS), equalTo(0));
    }
View Full Code Here

        assertThat(values.get(Granularity.SECONDS), equalTo(0));
    }

    @Test
    public void aZeroDurationIsZero() {
        EffortDuration duration = EffortDuration.zero();
        assertTrue(duration.isZero());
    }
View Full Code Here

    public void effortDurationImplementsComparable() {
        assertTrue(hours(3).compareTo(minutes(180)) == 0);
        assertTrue(hours(3).compareTo(minutes(178)) > 0);
        assertTrue(hours(3).compareTo(minutes(181)) < 0);
        assertTrue(hours(3).compareTo(minutes(190)) < 0);
        EffortDuration min = min(asList(hours(2), hours(3), seconds(10),
                seconds(5).and(1, Granularity.HOURS)));
        assertThat(min, equalTo(seconds(10)));
    }
View Full Code Here

        assertThat(min, equalTo(seconds(10)));
    }

    @Test
    public void effortDurationsCanBePlused() {
        EffortDuration a = EffortDuration.hours(1).and(30, Granularity.MINUTES);
        EffortDuration b = EffortDuration.minutes(30);
        assertThat(a.plus(b), equalTo(EffortDuration.hours(2)));
    }
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.