Package org.opencustomer.db.vo.calendar

Examples of org.opencustomer.db.vo.calendar.EventCalendarVO


        Calendar calcStartDate = GregorianCalendar.getInstance();
        calcStartDate.setTime(event.getStartDate());
       
        int step = event.getRecurrenceCycle();

        EventCalendarVO eventCalendar = getEventCalendar(myCalendar, event);
       
        // handle days
        if(EventVO.RecurrenceUnit.DAY.equals(event.getRecurrenceCycleUnit()))
        {
            if(EventVO.RecurrenceType.NUMBER_OF_TIMES.equals(event.getRecurrenceType()))
            {
                for(int i=1; i<event.getRecurrenceNumberOfTimes(); i++)
                {
                    calcStartDate.add(Calendar.DAY_OF_MONTH, step);
                    list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                }
            }
            else
            {
                Date recurrenceEndDate = endDate;
                if(EventVO.RecurrenceType.UNTIL_DATE.equals(event.getRecurrenceType()))
                    recurrenceEndDate = event.getRecurrenceUntilDate();
               
                boolean searching = true;
                while(searching)
                {
                    calcStartDate.add(Calendar.DAY_OF_MONTH, step);
                    if(calcStartDate.getTime().before(recurrenceEndDate))
                        list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                    else
                        searching = false;
                       
                }
            }
        }
        else if(EventVO.RecurrenceUnit.WEEK.equals(event.getRecurrenceCycleUnit()))
        {
            if(log.isDebugEnabled())
                log.debug("recurrence unit is "+EventVO.RecurrenceUnit.WEEK);

            int[] day = new int[event.getRecurrenceInWeek().size()];
            int[] dayAdd = new int[event.getRecurrenceInWeek().size()];
           
            int week = DateUtility.getCalendar(event.getStartDate(), myCalendar.getFirstDayOfWeek().getDay()).get(Calendar.WEEK_OF_YEAR);
           
            Calendar calcDateWeek = GregorianCalendar.getInstance();
            calcDateWeek.setTime(event.getStartDate());
            calcDateWeek.add(Calendar.DAY_OF_WEEK, 1);

            // check days between recurrences (max 7 day in sum (-> week))
            int pos = 0;
            for(int i=0; i<7; i++)
            {
                RecurrenceInWeek inWeek = RecurrenceInWeek.getForDate(calcDateWeek.getTime());
               
                dayAdd[pos]++;
                day[pos] = inWeek.getCalendarValue();

                if(event.getRecurrenceInWeek().contains(inWeek)) {
                    pos++; // go to next position
                }
                if(pos >= dayAdd.length) {
                    pos = 0; // go to zero position
                }
                calcDateWeek.roll(Calendar.DAY_OF_WEEK, 1);
            }
           
            if(log.isDebugEnabled())
            {
                StringBuilder builder = new StringBuilder();
                for(int i=0; i<day.length; i++) {
                    if(i > 0)
                        builder.append(", ");
                    builder.append("[day:"+day[i]+"-add:"+dayAdd[i]+"]");
                }
               
                log.debug("day adds: size="+dayAdd.length+" / "+builder.toString());
            }
           
            if(EventVO.RecurrenceType.NUMBER_OF_TIMES.equals(event.getRecurrenceType()))
            {
                int run = 0;
                for(int i=1; i<event.getRecurrenceNumberOfTimes(); i++)
                {                   
                    if(run < dayAdd.length)
                    {
                        calcStartDate.add(Calendar.DAY_OF_WEEK, dayAdd[run]);
                       
                        run++;
                    }

                    if(step > 1) {
                        int newWeek = DateUtility.getCalendar(calcStartDate.getTime(), myCalendar.getFirstDayOfWeek().getDay()).get(Calendar.WEEK_OF_YEAR);
                       
                        if(newWeek != week)
                            calcStartDate.add(Calendar.DAY_OF_WEEK, 7*(step-1));
                       
                        week = DateUtility.getCalendar(calcStartDate.getTime(), myCalendar.getFirstDayOfWeek().getDay()).get(Calendar.WEEK_OF_YEAR);
                    }
                   
                    if(run >= dayAdd.length) {
                        run = 0;
                    }

                    list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                }
            }
            else
            {
                Date recurrenceEndDate = endDate;
                if(EventVO.RecurrenceType.UNTIL_DATE.equals(event.getRecurrenceType()))
                    recurrenceEndDate = event.getRecurrenceUntilDate();
               
                int run = 0;
                boolean searching = true;
               
                while(searching)
                {
                    if(run < dayAdd.length)
                    {
                        calcStartDate.add(Calendar.DAY_OF_WEEK, dayAdd[run]);
                        run++;
                    }

                    if(step > 1) {
                        int newWeek = DateUtility.getCalendar(calcStartDate.getTime(), myCalendar.getFirstDayOfWeek().getDay()).get(Calendar.WEEK_OF_YEAR);
                       
                        if(newWeek != week)
                            calcStartDate.add(Calendar.DAY_OF_WEEK, 7*(step-1));
                       
                        week = DateUtility.getCalendar(calcStartDate.getTime(), myCalendar.getFirstDayOfWeek().getDay()).get(Calendar.WEEK_OF_YEAR);
                    }
                   
                    if(run >= dayAdd.length) {
                        run = 0;
                    }
                   
                    if(calcStartDate.getTime().before(recurrenceEndDate))
                        list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                    else
                        searching = false;
                       
                }
            }
        }
        else if(EventVO.RecurrenceUnit.MONTH.equals(event.getRecurrenceCycleUnit()))
        {
            if(EventVO.RecurrenceType.NUMBER_OF_TIMES.equals(event.getRecurrenceType()))
            {
                for(int i=1; i<event.getRecurrenceNumberOfTimes(); i++)
                {
                    if(EventVO.RecurrenceInMonth.DAY_OF_MONTH.equals(event.getRecurrenceInMonth()))
                        calcStartDate.add(Calendar.MONTH, step);
                    else
                    {                     
                        int dayOfWeek = calcStartDate.get(Calendar.DAY_OF_WEEK);
                        int dayOfWeekInMonth = calcStartDate.get(Calendar.DAY_OF_WEEK_IN_MONTH);
                       
                        calcStartDate.add(Calendar.MONTH, step);
                       
                        calcStartDate.set(Calendar.DAY_OF_WEEK, dayOfWeek);
                        calcStartDate.set(Calendar.DAY_OF_WEEK_IN_MONTH, dayOfWeekInMonth);
                    }
                   
                    list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                }
            }
            else
            {
                Date recurrenceEndDate = endDate;
                if(EventVO.RecurrenceType.UNTIL_DATE.equals(event.getRecurrenceType()))
                    recurrenceEndDate = event.getRecurrenceUntilDate();
               
                boolean searching = true;
                while(searching)
                {
                    if(EventVO.RecurrenceInMonth.DAY_OF_MONTH.equals(event.getRecurrenceInMonth()))
                        calcStartDate.add(Calendar.MONTH, step);
                    else
                    {                     
                        int dayOfWeek = calcStartDate.get(Calendar.DAY_OF_WEEK);
                        int dayOfWeekInMonth = calcStartDate.get(Calendar.DAY_OF_WEEK_IN_MONTH);
                       
                        calcStartDate.add(Calendar.MONTH, step);
                       
                        calcStartDate.set(Calendar.DAY_OF_WEEK, dayOfWeek);
                        calcStartDate.set(Calendar.DAY_OF_WEEK_IN_MONTH, dayOfWeekInMonth);
                    }
                   
                    if(calcStartDate.getTime().before(recurrenceEndDate))
                        list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                    else
                        searching = false;
                       
                }
            }
        }
        else if(EventVO.RecurrenceUnit.YEAR.equals(event.getRecurrenceCycleUnit()))
        {
            if(EventVO.RecurrenceType.NUMBER_OF_TIMES.equals(event.getRecurrenceType()))
            {
                for(int i=1; i<event.getRecurrenceNumberOfTimes(); i++)
                {
                    calcStartDate.add(Calendar.YEAR, step);
                    list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                }
            }
            else
            {
                Date recurrenceEndDate = endDate;
                if(EventVO.RecurrenceType.UNTIL_DATE.equals(event.getRecurrenceType()))
                    recurrenceEndDate = event.getRecurrenceUntilDate();
               
                boolean searching = true;
                while(searching)
                {
                    calcStartDate.add(Calendar.YEAR, step);
                   
                    if(calcStartDate.getTime().before(recurrenceEndDate))
                        list.add(new EventBean(calcStartDate.getTime(), duration, list.size()+1, event, readable, eventCalendar.getParticipiantType(), eventCalendar.getInvitationStatus()));
                    else
                        searching = false;
                       
                }
            }
View Full Code Here


       
        return list;
    }
   
    private static EventCalendarVO getEventCalendar(CalendarVO calendar, EventVO event) {
        EventCalendarVO eventCalendarVO = null;
       
        for(EventCalendarVO vo : event.getEventCalendars()) {
            if(vo.getCalendar().equals(calendar)) {
                eventCalendarVO = vo;
                break;
View Full Code Here

        }
        else
        {
            EventVO event = (EventVO) panel.getEntity();
           
            EventCalendarVO eventCalendar = new EventCalendarVO();
            eventCalendar.setEvent(event);
            eventCalendar.setCalendar(user.getCalendar());
            eventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.NEW);
            eventCalendar.setParticipiantType(EventCalendarVO.ParticipiantType.GUEST);
           
            eventCalendar.setOwnerUser(user.getCalendar().getOwnerUser());
            eventCalendar.setOwnerGroup(user.getCalendar().getOwnerGroup());
            eventCalendar.setAccessUser(user.getCalendar().getAccessUser());
            eventCalendar.setAccessGroup(user.getCalendar().getAccessGroup());
            eventCalendar.setAccessGlobal(user.getCalendar().getAccessGlobal());
           
            if (!event.getEventCalendars().contains(eventCalendar))
                event.getEventCalendars().add(eventCalendar);
        }
    }
View Full Code Here

            if (log.isDebugEnabled())
                log.debug("change status");
           
            UserVO user = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
            CalendarVO calendar = (CalendarVO)getPanel().getAttribute("calendar");
            EventCalendarVO userEventCalendar = null;
           
            List<EventCalendarVO> eventCalendars = (List<EventCalendarVO>)getPanel().getAttribute("eventCalendars");
            for(EventCalendarVO eventCalendar : eventCalendars) {
                if(calendar.equals(eventCalendar.getCalendar())
                        && !eventCalendar.getParticipiantType().equals(EventCalendarVO.ParticipiantType.HOST)) {
                    userEventCalendar = eventCalendar;
                    break;
                }
            }
           
            if(userEventCalendar != null) {
                if(form.getDoStatusNew().isSelected())
                    userEventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.NEW);
                else if(form.getDoStatusAccept().isSelected())
                    userEventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.ACCEPTED);
                else if(form.getDoStatusReject().isSelected())
                    userEventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.REJECTED);
                else if(form.getDoStatusDelete().isSelected())
                    userEventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.DELETED);
               
                if(!getPanel().isEditable()) {
                    if(log.isDebugEnabled())
                        log.debug("save changes to event calendar without requesting save: "+userEventCalendar);
                   
View Full Code Here

       
        EntityAccess testEntity = null;
        if (event.getId() == null)
            testEntity = calendar;
        else {
            EventCalendarVO myEventCalendar = null;
           
            for(EventCalendarVO eventCalendar : event.getEventCalendars()) {
                if(calendar.equals(eventCalendar.getCalendar())) {
                    testEntity = eventCalendar;
                    break;
View Full Code Here

        else
            return false;
    }

    private boolean isEventValid(EventVO event, CalendarVO calendar) {
        EventCalendarVO eventCalendar = null;
       
        for(EventCalendarVO ec : event.getEventCalendars()) {
            if(ec.getCalendar().equals(calendar)) {
                eventCalendar = ec;
                break;
            }
        }
       
        return eventCalendar.getInvitationStatus().equals(InvitationStatus.ACCEPTED)
            || eventCalendar.getInvitationStatus().equals(InvitationStatus.NEW);
    }
View Full Code Here

            mainBean.setStartDate(event.getStartDate());
            mainBean.setEndDate(event.getEndDate());
            mainBean.setReminderDate(event.getReminderDate());
            mainBean.setEvent(event);
           
            EventCalendarVO myEventCalendar = null;
            for(EventCalendarVO eventCalendar : event.getEventCalendars()) {
                if(calendar.equals(eventCalendar.getCalendar())) {
                    myEventCalendar = eventCalendar;
                }
            }
            mainBean.setType(myEventCalendar.getParticipiantType());
            mainBean.setStatus(myEventCalendar.getInvitationStatus());
           
            if(user != null) {
                if(myEventCalendar != null) {
                    mainBean.setReadable(EntityAccessUtility.isAccessGranted(user, myEventCalendar, EntityAccess.Access.READ));
                } else {
View Full Code Here

    @Override
    protected boolean validateAccess(HttpServletRequest request, EditPanel panel) {
        UserVO user = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
        CalendarVO calendar = (CalendarVO)panel.getAttribute("calendar");
       
        EventCalendarVO myEventCalendar = null;
       
        EventVO event = (EventVO)panel.getEntity();

        for(EventCalendarVO eventCalendar : event.getEventCalendars()) {
            if(calendar.equals(eventCalendar.getCalendar())) {
View Full Code Here

        event.setEndDate(cal.getTime());
        event.setRecurrenceType(EventVO.RecurrenceType.NONE);
        event.setOccupied(false);
       
        // create event calendar
        EventCalendarVO eventCalendar = new EventCalendarVO();
        eventCalendar.setCalendar(calendar);
        eventCalendar.setEvent(event);
        eventCalendar.setParticipiantType(EventCalendarVO.ParticipiantType.HOST);
        eventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.ACCEPTED);
        eventCalendar.setOwnerUser(calendar.getOwnerUser());
        eventCalendar.setOwnerGroup(calendar.getOwnerGroup());
        eventCalendar.setAccessUser(calendar.getAccessUser());
        eventCalendar.setAccessGroup(calendar.getAccessGroup());
        eventCalendar.setAccessGlobal(calendar.getAccessGlobal());
       
        event.getEventCalendars().add(eventCalendar);
       
        attributes.put("event", event);
    }
View Full Code Here

        UserVO user         = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
        EventVO event       = (EventVO)panel.getEntity();
        CalendarVO calendar = (CalendarVO)panel.getAttribute("calendar");

        // active event calendar
        EventCalendarVO activeEventCalendar = null;
        for(EventCalendarVO eventCalendar : event.getEventCalendars()) {
            if(calendar.equals(eventCalendar.getCalendar())) {
                activeEventCalendar = eventCalendar;
            }
        }
View Full Code Here

TOP

Related Classes of org.opencustomer.db.vo.calendar.EventCalendarVO

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.