Package org.opencustomer.db.dao.calendar

Examples of org.opencustomer.db.dao.calendar.EventDAO


        try {
            if(log.isDebugEnabled()) {
                log.debug("delete event: "+event);
            }
           
            new EventDAO().delete(event);           
        } catch (HibernateException e) {
            log.error("could not delete event", e);
           
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.couldNotDeleteEntity", panel.getEntity().getId()));
        }  
View Full Code Here


           
            if (event.getId() == null)
            {
                if (log.isDebugEnabled())
                    log.debug("create event");
                new EventDAO().insert(event);
            }
            else
            {
                if (log.isDebugEnabled())
                    log.debug("save event (ID:" + event.getId() + ")");
                new EventDAO().update(event);
            }
           
            HibernateContext.commitTransaction();
        }
        catch (HibernateException e)
View Full Code Here

       
        readEvents();
    }
   
    private void readEvents() {
        List<EventVO> events = new EventDAO().getByTimePeriod(calendar, startDate, endDate, user, withReminderDate);
       
        eventBeans = calculateEventBeans(events);
    }
View Full Code Here

    }
   
    @Override
    public void loadEntity(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        try {
            EventVO event = new EventDAO().getById(form.getId());
            Hibernate.initialize(event.getEventCalendars());
            Hibernate.initialize(event.getEventPersons());
           
            attributes.put("event", event);
        } catch (Exception e) {
View Full Code Here

     * @throws ParseException
     * @throws AccessDeniedException thown if there is no write access for this user to the calendar or event.
     */
    public void importIcal(InputStream ical, CalendarVO calendar, UserVO user, EventHandling handling) throws IOException, ParserException, ParseException, AccessDeniedException
    {
        EventDAO eventdao = new EventDAO();
        EventCalendarDAO eventcalendardao = new EventCalendarDAO();

        List<EventVO> events = IcalParser.getInstance().fromIcal(ical);
        List<EventVO> insertList = new ArrayList<EventVO>();
        for(EventVO event : events)
        {
            if(log.isDebugEnabled())
                log.debug("start import: " + event);
           
            if(event.getId() != null// parser found oc id
            {    
                EventVO event2 = eventdao.getById(event.getId());
                if(event2 != null)
                {
                    EventCalendarVO hostEventCalendar = null;
                    EventCalendarVO myEventCalendar = null;
                   
                    for(EventCalendarVO eventCalendar : event2.getEventCalendars()) { // search for myEventCalendar
                        if(calendar.equals(eventCalendar.getCalendar())) {
                            myEventCalendar = eventCalendar;
                        }
                    }
                   
                    for(EventCalendarVO eventCalendar : event2.getEventCalendars()) { // search for the hostEventCalendar entity
                        if(EventCalendarVO.ParticipiantType.HOST.equals(eventCalendar.getParticipiantType())) {
                            hostEventCalendar = eventCalendar;
                        }
                    }
                   
                    if(EntityAccessUtility.isAccessGranted(user,myEventCalendar,Access.WRITE)
                            && EntityAccessUtility.isAccessGranted(calendar.getUser(),hostEventCalendar,Access.WRITE)) // write access ?
                    {
                        event2.setDescription(event.getDescription());
                        event2.setTitle(event.getTitle());
                        event2.setAllDay(event.isAllDay());
                        event2.setEndDate(event.getEndDate());
                        event2.setStartDate(event.getStartDate());
                        event2.setRecurrenceCycle(event.getRecurrenceCycle());
                        event2.setRecurrenceCycleUnit(event.getRecurrenceCycleUnit());
                        event2.setRecurrenceEndDate(event.getRecurrenceEndDate());
                        event2.setRecurrenceStartDate(event.getRecurrenceStartDate());
                        event2.setRecurrenceInMonth(event.getRecurrenceInMonth());
                        event2.setRecurrenceInWeek(event.getRecurrenceInWeek());
                        event2.setRecurrenceNumberOfTimes(event.getRecurrenceNumberOfTimes());
                        event2.setRecurrenceType(event.getRecurrenceType());
                        event2.setRecurrenceUntilDate(event.getRecurrenceUntilDate());
                                              
                        if(log.isDebugEnabled())
                            log.debug("event updated: " + event2);
                       
                        eventdao.update(event2);
                        insertList.add(event2);
                    }
                    else
                    {
                        if(log.isDebugEnabled())
                            log.debug("event update denied: " + event2);
                        insertList.add(event2);
                        throw new AccessDeniedException(calendar.getName(),user.getUserName(),"WRITE");
                    }
                }
                else
                {
                    if(log.isInfoEnabled())
                        log.info("event " + event.getId() + " not found, id incorrect?");
                }
            }
            else
            {     
                // create new Event, no eventid found
                if(EntityAccessUtility.isAccessGranted(user,calendar,Access.WRITE))
                {
                    EventCalendarVO ecvo = new EventCalendarVO(event,calendar);
                    ecvo.setParticipiantType(ParticipiantType.HOST);
                    ecvo.setInvitationStatus(InvitationStatus.ACCEPTED);
                   
                    ecvo.setOwnerUser(calendar.getOwnerUser());
                    ecvo.setOwnerGroup(calendar.getOwnerGroup());
                    ecvo.setAccessUser(calendar.getAccessUser());
                    ecvo.setAccessGroup(calendar.getAccessGroup());
                    ecvo.setAccessGlobal(calendar.getAccessGlobal());
                   
                    event.getEventCalendars().add(ecvo);
                   
                    if(log.isDebugEnabled())
                        log.debug("new event created: " + event);
                   
                    eventdao.insert(event);
                    insertList.add(event);
                                      
                }
                else
                {
                    if(log.isDebugEnabled())
                        log.debug("create event denied: " + event);
                   
                    insertList.add(event);
                    throw new AccessDeniedException(calendar.getName(),user.getUserName(),"WRITE");
                }   
            }     
        }
       
        if(handling == EventHandling.DELETE// deleting events not in insertList
        {
            List<EventCalendarVO> actualList = eventcalendardao.getByCalendar(calendar, true);
            for(EventCalendarVO eventCalendar : actualList)
            {
                if(!insertList.contains(eventCalendar.getEvent()))
                {
                    if(log.isDebugEnabled())
                        log.debug("deleting event: " + eventCalendar.getEvent());
                   
                    eventdao.delete(eventCalendar.getEvent());    
                }          
            }
        } 
    }
View Full Code Here

                   
                    try {
                        StatusEmail mail = new StatusEmail();
                        mail.addRecipient(user);
                        List<JobVO> jobs = new JobDAO().getByUser(user, startDate.getTime(), endDate.getTime());
                        List<EventVO> events = new EventDAO().getByTimePeriod(user.getCalendar(), startDate.getTime(), endDate.getTime(), user);
                        if(!jobs.isEmpty() || !events.isEmpty()) {
                            if(log.isDebugEnabled())
                                log.debug(jobs.size() + "jobs found");
                            for(JobVO job : jobs)
                                mail.addJobs(job);
View Full Code Here

TOP

Related Classes of org.opencustomer.db.dao.calendar.EventDAO

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.