Examples of CalendarException


Examples of com.peusoft.widget.calendar.error.CalendarException

                cal_srv = ICalendarServiceFactory.createInstance(
                        getIcalUrl());
            } catch (ICalendarServiceException e) {
                LOGGER.error("Can't get the instance of ICalendarService.", e);
                if (!e.getErrCode().equals(ICalendarServiceException.ERR_OUT_OF_PERIOD)) {
                    throw new CalendarException(e);
                }
            }
        }

        int sm = getModel().getSelectedMonth();
        Calendar cal = Calendar.getInstance(getLocale());
        cal.set(Calendar.MONTH, sm);
        cal.set(Calendar.YEAR,
                getModel().getSelectedYear());
        cal.set(Calendar.DAY_OF_MONTH, 1);

        int day_of_week = cal.get(Calendar.DAY_OF_WEEK);
        int day_of_week_idx = ((Integer) dayOrderMap.get(new Integer(day_of_week))).intValue();
        cal.add(Calendar.DAY_OF_YEAR, -day_of_week_idx);

        for (int i = 0; i < MAX_NUMBER_OF_WEEKS; i++) {

            int w = cal.get(Calendar.WEEK_OF_YEAR);
            weekNumbers[i].setText("" + w);

            for (int j = 0; j < MAX_NUMBER_OF_DAYS; j++) {

                days[i][j].setText("" + cal.get(Calendar.DAY_OF_MONTH));

                if (compareCalendar(
                        getModel().getSelectedDate(),
                        cal)) {
                    days[i][j].setBackground(
                            getSelectedDateBackground());
                    days[i][j].setFont(
                            days[i][j].getFont().deriveFont(Font.BOLD));
                    days[i][j].setSelected(true);
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("Day: selected " + days[i][j].getText());
                    }

                } else {
                    days[i][j].setBackground(
                            getNotSelectedDateBackground());
                    days[i][j].setFont(
                            days[i][j].getFont().deriveFont(Font.PLAIN));
                    days[i][j].setSelected(false);
                }

                int d = cal.get(Calendar.DAY_OF_WEEK);
                int m = cal.get(Calendar.MONTH);
                boolean out_of_month = m != sm;
                days[i][j].setOutOfMonth(out_of_month);
                if (out_of_month) {
                    days[i][j].setForeground(
                            getOutOfMonthDateForeground());
                } else if (d == Calendar.SUNDAY || d == Calendar.SATURDAY) {
                    days[i][j].setForeground(
                            getWeForeground());
                } else {
                    days[i][j].setForeground(
                            getDateForeground());
                }

                String hi = "";
                if (getIcalUrl() != null) {
                    List<String> l = new ArrayList<String>();
                    try {
                        if (cal_srv != null && cal_srv.isHoliday(cal, l)) {
                            hi = cal_srv.getHolidayName(cal, l);
                        }
                    } catch (ICalendarServiceException e) {
                        LOGGER.error("Can't check holidays.", e);
                        if (!e.getErrCode().equals(ICalendarServiceException.ERR_OUT_OF_PERIOD)) {
                            throw new CalendarException(e);
                        }
                    }
                }
                if (hi.length() > 0
                        || d == Calendar.SATURDAY
View Full Code Here

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

                CalendarExceptionTypeColor.DEFAULT, true);
        return result;
    }

    public static void addChristmasAsExceptionDay(BaseCalendar calendar) {
        CalendarException christmasDay = CalendarException.create(
                CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(),
                createCalendarExceptionType());

        calendar.addExceptionDay(christmasDay);
    }
View Full Code Here

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

    @Test
    public void testCapacityOnDerivedBasicCalendarWithException() {
        BaseCalendar calendar = createBasicCalendar().newDerivedCalendar();

        CalendarException day = CalendarException.create(WEDNESDAY_LOCAL_DATE,
                hours(4), createCalendarExceptionType());
        calendar.addExceptionDay(day);

        EffortDuration mondayHours = calendar
                .getCapacityOn(wholeDay(MONDAY_LOCAL_DATE));
View Full Code Here

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

    @Test
    public void testCapacityOnDerivedChristmasCalendarRedefiningExceptionDay() {
        BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar();

        CalendarException day = CalendarException.create(
                CHRISTMAS_DAY_LOCAL_DATE, hours(4),
                createCalendarExceptionType());
        calendar.addExceptionDay(day);

        EffortDuration hours = calendar
View Full Code Here

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

    @Test(expected = IllegalArgumentException.class)
    public void testAddTwoExceptionDaysInTheSameDate() {
        BaseCalendar calendar = createBasicCalendar();

        CalendarException day = CalendarException.create(MONDAY_LOCAL_DATE,
                hours(8), createCalendarExceptionType());
        calendar.addExceptionDay(day);

        CalendarException day2 = CalendarException.create(MONDAY_LOCAL_DATE,
                hours(4), createCalendarExceptionType());
        calendar.addExceptionDay(day2);
    }
View Full Code Here

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

    }

    @Test
    public void testCapacityOnNewVersionFromChristmasCalendar() {
        BaseCalendar calendar = createChristmasCalendar();
        CalendarException day = CalendarException.create(
                CHRISTMAS_DAY_LOCAL_DATE.plusYears(1), EffortDuration.zero(),
                createCalendarExceptionType());
        calendar.addExceptionDay(day);

        calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE.plusDays(1));
View Full Code Here

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

    public void testAddExceptionToNewVersionCalendar() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE
                .plusDays(1));

        CalendarException day = CalendarException.create(
                CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(),
                createCalendarExceptionType());
        calendar.addExceptionDay(day);

        assertThat(calendar.getExceptions().size(), equalTo(1));
View Full Code Here

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

    @Test
    public void testAllowCreateExceptionsInThePast() {
        BaseCalendar calendar = createBasicCalendar();

        LocalDate pastMonth = (new LocalDate()).minusMonths(1);
        CalendarException exceptionDay = CalendarException.create(pastMonth,
                zero(),
                createCalendarExceptionType());

        calendar.addExceptionDay(exceptionDay);
    }
View Full Code Here

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

    @Test
    public void testAllowRemoveExceptionsInThePast() {
        BaseCalendar calendar = createBasicCalendar();

        LocalDate pastMonth = (new LocalDate()).minusMonths(1);
        CalendarException exceptionDay = CalendarException.create(pastMonth,
                zero(), createCalendarExceptionType());

        calendar.addExceptionDay(exceptionDay);
        calendar.removeExceptionDay(pastMonth);
    }
View Full Code Here

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

    public void testCreateExceptionDayWithDate() {
        LocalDate date = new LocalDate();
        CalendarExceptionType type = BaseCalendarTest
                .createCalendarExceptionType();

        CalendarException day = CalendarException.create(date,
                EffortDuration.hours(8), type);

        assertThat(day.getDate(), equalTo(new LocalDate(date)));
        assertThat(day.getDuration(), equalTo(EffortDuration.hours(8)));
        assertThat(day.getType(), equalTo(type));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.