Package org.opencustomer.db.vo.calendar

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


   
    @Override
    protected void saveEntity(EditPanel panel, ActionMessages errors, HttpServletRequest request)
    {
        UserVO user         = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);       
        CalendarVO calendar = (CalendarVO) panel.getAttribute("calendar");

        try
        {
            if (log.isDebugEnabled())
                log.debug("save calendar (ID:" + calendar.getId() + ")");
           
            new CalendarDAO().update(calendar);
        }
        catch (HibernateException e)
        {
View Full Code Here


    @Override
    public EditPanel createPanel(ActionMessages errors, EditLoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        UserVO activeUser = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
       
        CalendarVO calendar = (CalendarVO)attributes.get("calendar");

        EditPanel panel = new EditPanel(Right.CALENDAR_CALENDAR_WRITE, calendar);
       
        String calendarName = MessageUtil.message(request, "module.calendar.personalCalendar");
        if(calendar.getUser() == null) {
            calendarName = calendar.getName();
        } else if(!calendar.getUser().equals(activeUser)) {
            calendarName = calendar.getUser().getUserName();
        }
       
        panel.setTitle(MessageUtil.message(request, "module.calendar.edit.headline", calendarName));
       
        panel.addAction(Action.Type.SAVE, "/calendar/edit/save");
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())) {
                myEventCalendar = eventCalendar;
            }
        }
       
        if(myEventCalendar != null) {
View Full Code Here

        }
    }
   
    @Override
    public void createEntity(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        CalendarVO calendar = (CalendarVO) Panel.getPanelStack(request).peek().getAttribute("calendar");
       
        // create event
        EventVO event = new EventVO();

        Date choosenDate = null;
        if(form.getDate() != null) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
                choosenDate = sdf.parse(form.getDate());
            } catch(ParseException e) {
                log.error("invalid date found ()", e);
            }
        }
        Calendar cal = GregorianCalendar.getInstance();
        if(choosenDate != null) {
            Calendar cal2 = GregorianCalendar.getInstance();
            cal2.setTime(choosenDate);
            cal.set(Calendar.DAY_OF_MONTH, cal2.get(Calendar.DAY_OF_MONTH));
            cal.set(Calendar.MONTH, cal2.get(Calendar.MONTH));
            cal.set(Calendar.YEAR, cal2.get(Calendar.YEAR));
        }
        event.setStartDate(cal.getTime());
        cal.add(Calendar.MINUTE, 30);
        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

    @Override
    protected boolean isEditable(EditPanel panel, HttpServletRequest request)
    {
        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;
            }
        }
       
        boolean participientCalendar = EntityAccessUtility.isAccessGranted(user, calendar, EntityAccess.Access.WRITE);
View Full Code Here

        UserVO user = (UserVO)panel.getEntity();
       
        // add/remove calendar
        if(form.getId() > 0) {
            try {
                CalendarVO calendar = new CalendarDAO().getById(form.getId());
               
                if(user.getCalendars().contains(calendar)) {
                    if(log.isDebugEnabled())
                        log.debug("remove calendar "+calendar);
                   
View Full Code Here

     * @return a RRule generated by the event
     * @throws ParseException
     */
    private RRule getRRule(EventVO event) throws ParseException
    {
        CalendarVO mainCalendar = null;
       
        for(EventCalendarVO vo : event.getEventCalendars()) {
            if(EventCalendarVO.ParticipiantType.HOST.equals(vo.getParticipiantType())) {
                mainCalendar = vo.getCalendar();
            }
        }
       
        Recur recur = new Recur("");
        if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.DAY)
            recur.setFrequency(Recur.DAILY);
        else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.WEEK)
            recur.setFrequency(Recur.WEEKLY);
        else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.MONTH)
            recur.setFrequency(Recur.MONTHLY);
        else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.YEAR)
            recur.setFrequency(Recur.YEARLY);
       
        if(event.getRecurrenceCycle() != null)
            recur.setInterval(event.getRecurrenceCycle());
       
        if(event.getRecurrenceType() == RecurrenceType.UNTIL_DATE)
            recur.setUntil(new Date(event.getRecurrenceEndDate()));
        else if(event.getRecurrenceType() == RecurrenceType.NUMBER_OF_TIMES)
            recur.setCount(event.getRecurrenceNumberOfTimes());
       
        for(RecurrenceInWeek day : event.getRecurrenceInWeek())
        {
            if (day.getCalendarValue() == java.util.Calendar.MONDAY)
                recur.getDayList().add(new WeekDay("MO"));
            if (day.getCalendarValue() == java.util.Calendar.TUESDAY)
                recur.getDayList().add(new WeekDay("TU"));
            if (day.getCalendarValue() == java.util.Calendar.WEDNESDAY)
                recur.getDayList().add(new WeekDay("WE"));
            if (day.getCalendarValue() == java.util.Calendar.THURSDAY)
                recur.getDayList().add(new WeekDay("TH"));
            if (day.getCalendarValue() == java.util.Calendar.FRIDAY)
                recur.getDayList().add(new WeekDay("FR"));
            if (day.getCalendarValue() == java.util.Calendar.SATURDAY)
                recur.getDayList().add(new WeekDay("SA"));
            if (day.getCalendarValue() == java.util.Calendar.SUNDAY)
                recur.getDayList().add(new WeekDay("SU"));
        }
        
        if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_MONTH)
        {
            java.util.Calendar cal = GregorianCalendar.getInstance();
            cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
            cal.setTime(event.getStartDate());
            recur.getMonthDayList().add(cal.get(java.util.Calendar.DAY_OF_MONTH));
        }
        else if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_WEEK)
        {
            java.util.Calendar cal = GregorianCalendar.getInstance();
            cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
            cal.setTime(event.getStartDate());
            int week = cal.get(java.util.Calendar.WEEK_OF_MONTH);
            int day = cal.get(java.util.Calendar.DAY_OF_WEEK);
            if (day== java.util.Calendar.MONDAY)
                recur.getDayList().add(new WeekDay(week + "MO"));
View Full Code Here

                user.setAccessGroup(Access.READ);
                user.setAccessGlobal(Access.READ);
                user.setPassword(SignatureUtility.getInstance().createSignature(new PasswordGenerator().generate()));
               
                new UserDAO().insert(user,adminUser);
                CalendarVO calendar = new CalendarVO();
                calendar.setUser(user);
                calendar.setAccessUser(EntityAccess.Access.WRITE_SYSTEM);
                calendar.setOwnerUser(user.getId());
                calendar.setAccessGroup(EntityAccess.Access.NONE);
                calendar.setOwnerGroup(user.getProfile().getDefaultUsergroup().getId());
                calendar.setAccessGlobal(EntityAccess.Access.NONE);
               
                new CalendarDAO().insert(calendar, user);
            }
            else
            {
View Full Code Here

TOP

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

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.