Search in sources :

Example 16 with Appointment

use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.

the class AbstractJUnitDefaults method getAppointment.

public static Appointment getAppointment(User owner, Room r, Date start, Date end) {
    // add new appointment
    Appointment ap = new Appointment();
    ap.setTitle("appointmentName");
    ap.setLocation("appointmentLocation");
    ap.setStart(start);
    ap.setEnd(end);
    ap.setDescription("appointmentDescription");
    ap.setInserted(new Date());
    ap.setDeleted(false);
    ap.setIsDaily(false);
    ap.setIsWeekly(false);
    ap.setIsMonthly(false);
    ap.setIsYearly(false);
    ap.setPasswordProtected(false);
    ap.setOwner(owner);
    ap.setConnectedEvent(false);
    if (ap.getReminder() == null) {
        ap.setReminder(Appointment.Reminder.none);
    }
    if (r == null) {
        r = new Room();
        r.setType(Room.Type.conference);
        r.setAppointment(true);
    }
    ap.setRoom(r);
    return ap;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Room(org.apache.openmeetings.db.entity.room.Room) Date(java.util.Date)

Example 17 with Appointment

use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.

the class AppointmentDao method update.

public Appointment update(Appointment a, Long userId, boolean sendmails) {
    Room r = a.getRoom();
    if (r.getId() == null) {
        r.setName(a.getTitle());
        r.setCapacity(cfgDao.getLong(CONFIG_CALENDAR_ROOM_CAPACITY, 50L));
    }
    a.setRoom(roomDao.update(r, userId));
    if (sendmails) {
        Set<Long> mmIds = a.getId() == null ? new HashSet<>() : meetingMemberDao.getMeetingMemberIdsByAppointment(a.getId());
        // update meeting members
        Appointment a0 = a.getId() == null ? null : get(a.getId());
        boolean sendMail = a0 == null || !a0.getTitle().equals(a.getTitle()) || !(a0.getDescription() != null ? a0.getDescription().equals(a.getDescription()) : true) || !(a0.getLocation() != null ? a0.getLocation().equals(a.getLocation()) : true) || !a0.getStart().equals(a.getStart()) || !a0.getEnd().equals(a.getEnd());
        List<MeetingMember> mmList = a.getMeetingMembers();
        if (mmList != null) {
            for (MeetingMember mm : mmList) {
                if (mm.getId() == null || !mmIds.contains(mm.getId())) {
                    invitationManager.processInvitation(a, mm, MessageType.Create);
                } else {
                    mmIds.remove(mm.getId());
                    invitationManager.processInvitation(a, mm, MessageType.Update, sendMail);
                }
            }
        }
        for (long id : mmIds) {
            invitationManager.processInvitation(a, meetingMemberDao.get(id), MessageType.Cancel);
        }
        // notify owner
        MeetingMember owner = new MeetingMember();
        owner.setUser(a.getOwner());
        if (a.getId() == null) {
            invitationManager.processInvitation(a, owner, MessageType.Create);
        } else if (a.isDeleted()) {
            invitationManager.processInvitation(a, owner, MessageType.Cancel);
        } else if (sendMail) {
            invitationManager.processInvitation(a, owner, MessageType.Update, sendMail);
        }
    }
    if (a.getId() == null) {
        a.setInserted(new Date());
        em.persist(a);
    } else {
        a.setUpdated(new Date());
        a = em.merge(a);
    }
    return a;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Room(org.apache.openmeetings.db.entity.room.Room) Date(java.util.Date)

Example 18 with Appointment

use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.

the class AppointmentDao method getByRoom.

public Appointment getByRoom(Long roomId) {
    List<Appointment> list = em.createNamedQuery("getAppointmentByRoomId", Appointment.class).setParameter("roomId", roomId).getResultList();
    Appointment a = list.isEmpty() ? null : list.get(0);
    if (a != null && !a.getRoom().isAppointment()) {
        throw new RuntimeException("Room " + a.getRoom().getName() + " isnt part of an appointed meeting");
    }
    return a;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment)

Example 19 with Appointment

use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.

the class CalendarPanel method onInitialize.

@Override
protected void onInitialize() {
    final Form<Date> form = new Form<>("form");
    add(form);
    dialog = new AppointmentDialog("appointment", this, new CompoundPropertyModel<>(getDefault()));
    add(dialog);
    boolean isRtl = isRtl();
    Options options = new Options();
    options.set("isRTL", isRtl);
    options.set("header", isRtl ? "{left: 'agendaDay,agendaWeek,month', center: 'title', right: 'today nextYear,next,prev,prevYear'}" : "{left: 'prevYear,prev,next,nextYear today', center: 'title', right: 'month,agendaWeek,agendaDay'}");
    options.set("allDaySlot", false);
    options.set("axisFormat", Options.asString("H(:mm)"));
    options.set("defaultEventMinutes", 60);
    options.set("timeFormat", Options.asString("H(:mm)"));
    options.set("buttonText", new JSONObject().put("month", getString("801")).put("week", getString("800")).put("day", getString("799")).put("today", getString("1555")).toString());
    JSONArray monthes = new JSONArray();
    JSONArray shortMonthes = new JSONArray();
    JSONArray days = new JSONArray();
    JSONArray shortDays = new JSONArray();
    // first week day must be Sunday
    days.put(0, getString("466"));
    shortDays.put(0, getString("459"));
    for (int i = 0; i < 12; i++) {
        monthes.put(i, getString(String.valueOf(469 + i)));
        shortMonthes.put(i, getString(String.valueOf(1556 + i)));
        if (i + 1 < 7) {
            days.put(i + 1, getString(String.valueOf(460 + i)));
            shortDays.put(i + 1, getString(String.valueOf(453 + i)));
        }
    }
    options.set("monthNames", monthes.toString());
    options.set("monthNamesShort", shortMonthes.toString());
    options.set("dayNames", days.toString());
    options.set("dayNamesShort", shortDays.toString());
    options.set("firstDay", cfgDao.getInt(CONFIG_CALENDAR_FIRST_DAY, 0));
    calendar = new Calendar("calendar", new AppointmentModel(), options) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onInitialize() {
            super.onInitialize();
            add(new CalendarFunctionsBehavior(getMarkupId()));
        }

        @Override
        public boolean isSelectable() {
            return true;
        }

        @Override
        public boolean isDayClickEnabled() {
            return true;
        }

        @Override
        public boolean isEventClickEnabled() {
            return true;
        }

        @Override
        public boolean isEventDropEnabled() {
            return true;
        }

        @Override
        public boolean isEventResizeEnabled() {
            return true;
        }

        // no need to override onDayClick
        @Override
        public void onSelect(AjaxRequestTarget target, CalendarView view, LocalDateTime start, LocalDateTime end, boolean allDay) {
            Appointment a = getDefault();
            LocalDateTime s = start, e = end;
            if (CalendarView.month == view) {
                LocalDateTime now = ZonedDateTime.now(getZoneId()).toLocalDateTime();
                s = start.withHour(now.getHour()).withMinute(now.getMinute());
                e = s.plus(1, ChronoUnit.HOURS);
            }
            a.setStart(getDate(s));
            a.setEnd(getDate(e));
            dialog.setModelObjectWithAjaxTarget(a, target);
            dialog.open(target);
        }

        @Override
        public void onEventClick(AjaxRequestTarget target, CalendarView view, int eventId) {
            Appointment a = apptDao.get((long) eventId);
            dialog.setModelObjectWithAjaxTarget(a, target);
            dialog.open(target);
        }

        @Override
        public void onEventDrop(AjaxRequestTarget target, int eventId, long delta, boolean allDay) {
            Appointment a = apptDao.get((long) eventId);
            if (!AppointmentDialog.isOwner(a)) {
                return;
            }
            java.util.Calendar cal = WebSession.getCalendar();
            cal.setTime(a.getStart());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setStart(cal.getTime());
            cal.setTime(a.getEnd());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setEnd(cal.getTime());
            apptDao.update(a, getUserId());
            if (a.getCalendar() != null) {
                updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a);
            }
        }

        @Override
        public void onEventResize(AjaxRequestTarget target, int eventId, long delta) {
            Appointment a = apptDao.get((long) eventId);
            if (!AppointmentDialog.isOwner(a)) {
                return;
            }
            java.util.Calendar cal = WebSession.getCalendar();
            cal.setTime(a.getEnd());
            cal.add(java.util.Calendar.MILLISECOND, (int) delta);
            a.setEnd(cal.getTime());
            apptDao.update(a, getUserId());
            if (a.getCalendar() != null) {
                updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a);
            }
        }
    };
    form.add(calendar);
    populateGoogleCalendars();
    add(refreshTimer);
    add(syncTimer);
    calendarDialog = new CalendarDialog("calendarDialog", this, new CompoundPropertyModel<>(getDefaultCalendar()));
    add(calendarDialog);
    calendarListContainer.setOutputMarkupId(true);
    calendarListContainer.add(new ListView<OmCalendar>("items", new LoadableDetachableModel<List<OmCalendar>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<OmCalendar> load() {
            List<OmCalendar> cals = new ArrayList<>(apptManager.getCalendars(getUserId()));
            cals.addAll(apptManager.getGoogleCalendars(getUserId()));
            return cals;
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<OmCalendar> item) {
            item.setOutputMarkupId(true);
            final OmCalendar cal = item.getModelObject();
            item.add(new Button("item", new PropertyModel<String>(cal, "title")).add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    calendarDialog.open(target, CalendarDialog.DIALOG_TYPE.UPDATE_CALENDAR, cal);
                    target.add(calendarDialog);
                }
            }));
        }
    });
    add(new Button("syncCalendarButton").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            syncCalendar(target);
        }
    }));
    add(new Button("submitCalendar").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            calendarDialog.open(target, CalendarDialog.DIALOG_TYPE.UPDATE_CALENDAR, getDefaultCalendar());
            target.add(calendarDialog);
        }
    }));
    add(calendarListContainer);
    super.onInitialize();
}
Also used : LocalDateTime(java.time.LocalDateTime) Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Options(com.googlecode.wicket.jquery.core.Options) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) Button(com.googlecode.wicket.jquery.ui.form.button.Button) OmCalendar(org.apache.openmeetings.db.entity.calendar.OmCalendar) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) CalendarView(com.googlecode.wicket.jquery.ui.calendar.CalendarView) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) OmCalendar(org.apache.openmeetings.db.entity.calendar.OmCalendar) Calendar(com.googlecode.wicket.jquery.ui.calendar.Calendar) GoogleCalendar(com.googlecode.wicket.jquery.ui.calendar.EventSource.GoogleCalendar) JSONArray(com.github.openjson.JSONArray) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) Date(java.util.Date) CalendarWebHelper.getDate(org.apache.openmeetings.web.util.CalendarWebHelper.getDate) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) JSONObject(com.github.openjson.JSONObject) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel)

Example 20 with Appointment

use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.

the class CalendarPanel method getDefault.

private Appointment getDefault() {
    Appointment a = new Appointment();
    a.setReminder(Reminder.ical);
    a.setOwner(userDao.get(getUserId()));
    a.setTitle(getString("1444"));
    log.debug(" -- getDefault -- Current model " + a);
    return a;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment)

Aggregations

Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)34 User (org.apache.openmeetings.db.entity.user.User)10 ArrayList (java.util.ArrayList)9 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)9 Test (org.junit.Test)9 Date (java.util.Date)7 Calendar (java.util.Calendar)6 Room (org.apache.openmeetings.db.entity.room.Room)5 OmCalendar (org.apache.openmeetings.db.entity.calendar.OmCalendar)4 Calendar (net.fortuna.ical4j.model.Calendar)3 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)3 JSONObject (com.github.openjson.JSONObject)2 Map (java.util.Map)2 TimeZone (java.util.TimeZone)2 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 Invitation (org.apache.openmeetings.db.entity.room.Invitation)2 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)2 PrivateMessage (org.apache.openmeetings.db.entity.user.PrivateMessage)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2