Package org.libreplan.business.calendars.entities

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


    }

    private void doEditsSaveAndThenAsserts(final IOnExistentCalendar edits,
            final IOnExistentCalendar asserts) {
        final BaseCalendar baseCalendar = transactionService
                .runOnTransaction(new IOnTransaction<BaseCalendar>() {

                @Override
                    public BaseCalendar execute() {
                        return saveOneCalendar();
                    }
                });
        transactionService.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                baseCalendarModel.initEdit(baseCalendar);
                edits.onExistentCalendar(baseCalendarModel.getBaseCalendar());
                baseCalendarModel.confirmSave();
                return null;
            }
        });
        transactionService.runOnReadOnlyTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                BaseCalendar calendar = calendarDAO
                        .findExistingEntity(baseCalendar.getId());
                asserts.onExistentCalendar(calendar);
                return null;
            }
        });
View Full Code Here


    @Transactional
    public void testRemove() {
        int previous = baseCalendarModel.getBaseCalendars().size();
        saveOneCalendar();

        BaseCalendar baseCalendar = baseCalendarModel.getBaseCalendars().get(
                previous);
        baseCalendarModel.initRemove(baseCalendar);
        baseCalendarModel.confirmRemove(baseCalendar);
        assertThat(baseCalendarModel.getBaseCalendars().size(),
                equalTo(previous));
View Full Code Here

        baseCalendarModel.initCreate();
        baseCalendarModel.getBaseCalendar().setName("Test");
        setCapacity(baseCalendarModel.getBaseCalendar(),
                Capacity.create(hours(8)));
        BaseCalendar parent = baseCalendarModel.getBaseCalendar();
        baseCalendarModel.createNewVersion(new LocalDate().plusMonths(1), null,
                null);
        BaseCalendar parentNewVersion = baseCalendarModel.getBaseCalendar();
        baseCalendarModel.confirmSave();

        baseCalendarModel.initCreateDerived(parent);
        BaseCalendar child = baseCalendarModel.getBaseCalendar();
        baseCalendarModel.getBaseCalendar().setName("Derived");
        baseCalendarModel.confirmSave();

        baseCalendarModel.initEdit(child);
        List<BaseCalendar> possibleParentCalendars = baseCalendarModel
                .getPossibleParentCalendars();

        assertThat(possibleParentCalendars.size(), equalTo(previous + 1));
        BaseCalendar calendarComparison = null;
        for (BaseCalendar calendar : possibleParentCalendars)
            if (calendar.getId().equals(parentNewVersion.getId()))
                calendarComparison = calendar;
        assertThat(calendarComparison.getId(),
                equalTo(parentNewVersion.getId()));
        assertThat(calendarComparison.getCalendarDataVersions().size(),
                equalTo(2));
    }
View Full Code Here

        order.setDescription("description");
        order.setInitDate(year(2000));
        order.setName("name");
        order.setResponsible("responsible");
        order.setCode("code-" + UUID.randomUUID());
        BaseCalendar calendar = adHocTransaction
                .runOnReadOnlyTransaction(new IOnTransaction<BaseCalendar>() {

                    @Override
                    public BaseCalendar execute() {
                        BaseCalendar result = configurationDAO
                                .getConfigurationWithReadOnlyTransaction()
                                .getDefaultCalendar();
                        BaseCalendarModel.forceLoadBaseCalendar(result);
                        return result;
                    }
View Full Code Here

                .addBaseCalendars(baseCalendars).instanceConstraintViolationsList;

        assertTrue(instanceConstraintViolationsList.toString(),
                instanceConstraintViolationsList.size() == 0);

        BaseCalendar baseCalendar = baseCalendarDAO
                .findByCode(codeBaseCalendar);
        assertTrue(baseCalendar.getExceptions().isEmpty());
        assertTrue(baseCalendar.getCalendarDataVersions().size() == 2);

        CalendarData data = baseCalendar.getCalendarDataByCode("codeData");
        assertEquals(Capacity.create(EffortDuration.hours(4))
                .overAssignableWithoutLimit(),
                data.getCapacityOn(CalendarData.Days.FRIDAY));
        assertEquals(Capacity.create(EffortDuration.hours(4))
                .overAssignableWithoutLimit(true),
View Full Code Here

        IOnTransaction<BaseCalendar> find = new IOnTransaction<BaseCalendar>() {

            @Override
            public BaseCalendar execute() {
                BaseCalendar defaultCalendar = configurationDAO
                        .getConfiguration().getDefaultCalendar();
                defaultCalendar.getCode();
                return defaultCalendar;
            }
        };

        return transactionService.runOnAnotherTransaction(find);
View Full Code Here

    @Autowired
    private SessionFactory sessionFactory;

    private BaseCalendar givenBaseCalendarStored() {
        BaseCalendar calendar = BaseCalendar.createBasicCalendar();
        calendar.setName("calendar-name");

        baseCalendarDAO.save(calendar);
        baseCalendarDAO.flush();
        sessionFactory.getCurrentSession().evict(calendar);
        calendar.dontPoseAsTransientObjectAnymore();

        return calendar;
    }
View Full Code Here

    @Test
    @Transactional
    public void exportBaseCalendars2() {
        int previous = baseCalendarDAO.getBaseCalendars().size();

        BaseCalendar calendar = givenBaseCalendarStored();

        BaseCalendarListDTO baseCalendars = calendarService.getBaseCalendars();
        assertThat(baseCalendars.baseCalendars.size(), equalTo(previous + 1));

        for (BaseCalendarDTO calendarDTO : baseCalendars.baseCalendars)
            if (calendarDTO.code.equals(calendar.getCode())) {
                assertThat(calendarDTO.code, equalTo(calendar.getCode()));
                assertThat(calendarDTO.name, equalTo(calendar.getName()));
            }
    }
View Full Code Here

    @Test
    @Transactional
    public void testAddResourceWithSpecificCalendar() {

        /* Create a resource calendar DTO. */
        BaseCalendar baseCalendar = createBaseCalendar();
        ResourceCalendar resourceCalendar = baseCalendar
                .newDerivedResourceCalendar();
        ResourceCalendarDTO resourceCalendarDTO = ResourceConverter
                .toDTO(resourceCalendar);

        /* Create a machine DTO. */
        MachineDTO machineDTO = new MachineDTO("name", "desc");
        machineDTO.calendar = resourceCalendarDTO;

        /* Test. */
        assertNoConstraintViolations(resourceService
                .addResources(createResourceListDTO(machineDTO)));
        Machine machine = machineDAO.findExistingEntityByCode(machineDTO.code);
        assertEquals(baseCalendar.getId(), machine.getCalendar().getParent()
                .getId());

    }
View Full Code Here

        IOnTransaction<BaseCalendar> create = new IOnTransaction<BaseCalendar>() {

            @Override
            public BaseCalendar execute() {
                BaseCalendar baseCalendar = BaseCalendar.createBasicCalendar();
                baseCalendar.setName(getUniqueName());
                baseCalendarDAO.save(baseCalendar);
                return baseCalendar;
            }
        };
View Full Code Here

TOP

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

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.