Package org.libreplan.business.calendars.entities

Examples of org.libreplan.business.calendars.entities.Capacity


    public void testCreateAndSave() {
        int previous = baseCalendarModel.getBaseCalendars().size();
        baseCalendarModel.initCreate();
        BaseCalendar baseCalendar = baseCalendarModel.getBaseCalendar();
        baseCalendar.setName("Test");
        Capacity capacity = Capacity.create(hours(8));
        setCapacity(baseCalendar, capacity);
        baseCalendarModel.confirmSave();
        Map<Long, Set<BaseCalendar>> currentCalendars = BaseEntity
                .byId(baseCalendarModel.getBaseCalendars());
        assertThat(currentCalendars.size(), equalTo(previous + 1));
View Full Code Here


        }
    }

    @Test
    public void testEditAndSave() throws ValidationException {
        final Capacity capacity = Capacity.create(hours(4));
        doEditsSaveAndThenAsserts(new IOnExistentCalendar() {

            @Override
            public void onExistentCalendar(BaseCalendar calendar) {
                setCapacity(calendar, capacity);
View Full Code Here

    }

    @Test
    @Transactional
    public void testEditAndNewVersion() {
        final Capacity capacity = Capacity.create(hours(4));
        final LocalDate date = new LocalDate().plusWeeks(1);
        doEditsSaveAndThenAsserts(new IOnExistentCalendar() {

            @Override
            public void onExistentCalendar(BaseCalendar calendar) {
View Full Code Here

        calendar.setName("Default");
        calendar.setCode(entitySequenceDAO
                .getNextEntityCodeWithoutTransaction(EntityNameEnum.CALENDAR));
        calendar.setCodeAutogenerated(true);

        Capacity eightHours = Capacity.create(EffortDuration.hours(8))
                .overAssignableWithoutLimit();
        Capacity zeroCapacity = Capacity.zero().notOverAssignableWithoutLimit();
        calendar.setCapacityAt(Days.MONDAY, eightHours);
        calendar.setCapacityAt(Days.TUESDAY, eightHours);
        calendar.setCapacityAt(Days.WEDNESDAY, eightHours);
        calendar.setCapacityAt(Days.THURSDAY, eightHours);
        calendar.setCapacityAt(Days.FRIDAY, eightHours);
View Full Code Here

    private EffortDuration getMaxExtraEffort(Capacity[] capacities) {
        if (capacities.length == 0) {
            return null;
        }
        Capacity max = Collections.max(Arrays.asList(capacities), new Comparator<Capacity>(){

            @Override
            public int compare(Capacity o1, Capacity o2) {
                if (o1.getAllowedExtraEffort() == o2.getAllowedExtraEffort()) {
                    return 0;
                } else if (o1.getAllowedExtraEffort() == null) {
                    return -1;
                } else if (o2.getAllowedExtraEffort() == null) {
                    return 1;
                }
                return o1.getAllowedExtraEffort().compareTo(
                        o2.getAllowedExtraEffort());
            }
        });
        return max.getAllowedExtraEffort();

    }
View Full Code Here

                    _("Exception end date should be greater or equals than start date"));
        } else {
            Clients.closeErrorBox(dateboxEndDate);
        }

        Capacity capacity = capacityPicker.getValue();
        baseCalendarModel.createException(type, LocalDate
                .fromDateFields(startDate), LocalDate.fromDateFields(endDate),
                capacity);
        reloadDayInformation();
    }
View Full Code Here

                    _("Exception end date should be greater or equals than start date"));
        } else {
            Clients.closeErrorBox(dateboxEndDate);
        }

        Capacity capacity = capacityPicker.getValue();
        baseCalendarModel.updateException(type,
                LocalDate.fromDateFields(startDate),
                LocalDate.fromDateFields(endDate), capacity);
        reloadDayInformation();
    }
View Full Code Here

        return createCalendar(klass, capacity, 1);
    }

    private <T extends BaseCalendar> T createCalendar(Class<T> klass,
            final Capacity capacity, int units) {
        final Capacity capacityMultipliedByUnits = capacity.multiplyBy(units);
        BaseCalendar baseCalendar = createNiceMock(klass);
        expect(baseCalendar.getCapacityOn(isA(PartialDay.class))).andAnswer(
                new IAnswer<EffortDuration>() {

                    @Override
                    public EffortDuration answer() throws Throwable {
                        PartialDay day = (PartialDay) getCurrentArguments()[0];
                        return day.limitWorkingDay(capacityMultipliedByUnits
                                .getStandardEffort());
                    }
                }).anyTimes();
        expect(baseCalendar.isActive(isA(LocalDate.class))).andReturn(true)
                .anyTimes();
        expect(baseCalendar.canWorkOn(isA(LocalDate.class))).andReturn(true)
                .anyTimes();
        expect(baseCalendar.getAvailability()).andReturn(
                AvailabilityTimeLine.allValid()).anyTimes();
        IAnswer<EffortDuration> durationAnswer = new IAnswer<EffortDuration>() {
            @Override
            public EffortDuration answer() throws Throwable {
                PartialDay day = (PartialDay) getCurrentArguments()[0];
                ResourcesPerDay resourcesPerDay = (ResourcesPerDay) getCurrentArguments()[1];
                return capacityMultipliedByUnits.limitDuration(resourcesPerDay
                        .asDurationGivenWorkingDayOf(day.limitWorkingDay(capacity
                                .getStandardEffort())));
            }
        };
        expect(
View Full Code Here

        LocalDate start = new LocalDate(2006, 10, 5);
        givenTaskWithStartAndEnd(toInterval(start,
                Period.days(TASK_DURATION_DAYS)));
        givenGenericResourceAllocationForTask(task);

        Capacity workingDay = Capacity.create(hours(8));
        Capacity with2ExtraHours = workingDay
                .withAllowedExtraEffort(hours(2));
        givenCalendarsForResources(with2ExtraHours, with2ExtraHours,
                workingDay.overAssignableWithoutLimit());
        givenWorkersWithLoads(0, 0, 0);
View Full Code Here

        if (hoursPerDayDTOs != null) {
            for (HoursPerDayDTO hoursPerDayDTO : hoursPerDayDTOs) {
                try {
                    Integer day = CalendarData.Days.valueOf(hoursPerDayDTO.day)
                        .ordinal();
                    Capacity capacity = Capacity.create(
                            EffortDuration.hours(hoursPerDayDTO.hours))
                            .overAssignableWithoutLimit();
                    result.put(day, capacity);
                } catch (IllegalArgumentException e) {
                    throw new ValidationException("a day is not valid");
View Full Code Here

TOP

Related Classes of org.libreplan.business.calendars.entities.Capacity

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.