Package org.blync.client.calendar

Examples of org.blync.client.calendar.Day


    public void add(Appointment appointment) {
        String id = appointment.getId();
        delete(id);
        Vector days = new Vector();
        Vector recurrenceDays = new Vector();
        Day startDay = new Day(appointment.getStart());
        Day endDay = new Day(appointment.getEnd());
        for (int i = 0; i < 366; i++) {
            Day occurrence = startDay.add(i);
            if (occurrence.compare(endDay) > 0) {
                break;
            }
            days.addElement(new Integer(occurrence.toInt()));
        }
        if (appointment.getRecurrence() != null) {
            RecurrencePattern recurrence = appointment.getRecurrence();
            int type = recurrence.getType();
            Day repeatUntil = recurrence.getRepeatUntil();
            if (type == RecurrencePattern.REC_DAILY) {
                for (int i = 1; i <= 366; i++) {
                    Day occurrence = startDay.add(i);
                    if (repeatUntil != null && occurrence.compare(repeatUntil) > 0) {
                        break;
                    }
                    if (!recurrence.isException(occurrence)) {
                        recurrenceDays.addElement(new Integer(occurrence.toInt()));
                        days.addElement(new Integer(occurrence.toInt()));
                    }
                }
            }
            else if (type == RecurrencePattern.REC_WEEKLY) {
                for (int i = 1; i <= 105; i++) {
                    Day occurrence = startDay.add(i*7);
                    if (repeatUntil != null && occurrence.compare(repeatUntil) > 0) {
                        break;
                    }
                    if (!recurrence.isException(occurrence)) {
                        recurrenceDays.addElement(new Integer(occurrence.toInt()));
                        days.addElement(new Integer(occurrence.toInt()));
                    }
                }
            }
            else if (type == RecurrencePattern.REC_MONTHLY) {
                CalendarDate startDate = startDay.getCalendarDate();
                for (int i = 1; i <= 24; i++) {
                    Day occurrence = startDate.addMonths(i);
                    if (repeatUntil != null && occurrence.compare(repeatUntil) > 0) {
                        break;
                    }
                    if (!recurrence.isException(occurrence)) {
                        recurrenceDays.addElement(new Integer(occurrence.toInt()));
                        days.addElement(new Integer(occurrence.toInt()));
                    }
                }
            }
            else if (type == RecurrencePattern.REC_YEARLY) {
                CalendarDate startDate = startDay.getCalendarDate();
                for (int i = 1; i <= 5; i++) {
                    Day occurrence = startDate.addYears(i);
                    if (repeatUntil != null && occurrence.compare(repeatUntil) > 0) {
                        break;
                    }
                    if (!recurrence.isException(occurrence)) {
                        recurrenceDays.addElement(new Integer(occurrence.toInt()));
                        days.addElement(new Integer(occurrence.toInt()));
                    }
                }
            }
        }
        idToDaysMap.setValues(id, days);
        idToTitleMap.put(id, appointment.getTitle());
        idToLastModifiedMap.put(id, DateFormatter.dateToICal(new Date()));

        for (int i = 0; i < days.size(); i++) {
            Integer day = (Integer)days.elementAt(i);
            dayToIdsMap.add(day, id);
        }
        save();

        String appointmentId = appointment.getId();
//        alarmIndex.delete(appointmentId);
        if (appointment.getAlarmTime() != null) {
            int startDayNum = new Day(appointment.getStart()).toInt();
            Date alarmTime = appointment.getAlarmTime();
            alarmIndex.add(appointmentId, alarmTime);
            for (int rec = 0; rec < recurrenceDays.size(); rec++) {
                int recDayNum = ((Integer)recurrenceDays.elementAt(rec)).intValue();
                long offset = (recDayNum - startDayNum) * Day.MILISECONDS_IN_DAY;
 
View Full Code Here


*/
    public void addException(Appointment appointment) {
        String id = appointment.getId();

        Vector days = new Vector();
        Day startDay = new Day(appointment.getStart());
        Day endDay = new Day(appointment.getEnd());
        for (int i = 0; i < 366; i++) {
            Day occurrence = startDay.add(i);
            if (occurrence.compare(endDay) > 0) {
                break;
            }
            days.addElement(new Integer(occurrence.toInt()));
        }

        idToDaysMap.setValues(id, days);
        idToTitleMap.put(id, appointment.getTitle());
        idToLastModifiedMap.put(id, DateFormatter.dateToICal(new Date()));
View Full Code Here

            save();

            Date firstAlarmTime = appointment.getAlarmTime();
            if (firstAlarmTime != null) {
                Day firstDay = new Day(appointment.getStart());
                long offset = (selectedDay.toInt() - firstDay.toInt()) * Day.MILISECONDS_IN_DAY;
                Date alarmTime = new Date(firstAlarmTime.getTime() + offset);
                alarmIndex.delete(id, alarmTime);
            }
        }
    }
View Full Code Here

    public Occurrence searchItem(String searchName, boolean findAgain) {
        Occurrence occurrence = null;
        searchName = searchName.toLowerCase();
        if (searchDay.toInt() >= lastSearchDay.toInt()) {
            searchDay = new Day(0);
        }
        else if (!findAgain) {
            searchDay = Day.today();
        }
        Day currentSearchDay;
        for (currentSearchDay = searchDay;
             currentSearchDay.toInt() < lastSearchDay.toInt() && occurrence == null;
             currentSearchDay = currentSearchDay.add(1)) {
            Vector ids = getIdsForDay(currentSearchDay);
            for (int i = 0; i < ids.size() && occurrence == null; i++) {
                String id = (String)ids.elementAt(i);
                String title = ((String)idToTitleMap.get(id)).toLowerCase();
                if (title.indexOf(searchName) != -1) {
View Full Code Here

TOP

Related Classes of org.blync.client.calendar.Day

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.