Search in sources :

Example 1 with Appointment

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

the class AppointmentDao method getInRange.

public List<Appointment> getInRange(Long userId, Date start, Date end) {
    log.debug("Start " + start + " End " + end);
    TypedQuery<Appointment> query = em.createNamedQuery("appointmentsInRange", Appointment.class);
    query.setParameter("start", start);
    query.setParameter("end", end);
    query.setParameter(PARAM_USER_ID, userId);
    List<Appointment> listAppoints = new ArrayList<>(query.getResultList());
    TypedQuery<Appointment> q1 = em.createNamedQuery("joinedAppointmentsInRange", Appointment.class);
    q1.setParameter("start", start);
    q1.setParameter("end", end);
    q1.setParameter(PARAM_USER_ID, userId);
    for (Appointment a : q1.getResultList()) {
        a.setConnectedEvent(true);
        listAppoints.add(a);
    }
    return listAppoints;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) ArrayList(java.util.ArrayList)

Example 2 with Appointment

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

the class MessageDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    PrivateMessage m = getModelObject();
    m.setInserted(new Date());
    User owner = userDao.get(getUserId());
    if (m.isBookedRoom()) {
        Room r = m.getRoom();
        r.setName(m.getSubject());
        r.setComment("");
        r.setCapacity(100L);
        r.setAppointment(true);
        r.setAllowUserQuestions(true);
        r = roomDao.update(r, getUserId());
        Appointment a = new Appointment();
        a.setTitle(m.getSubject());
        a.setDescription(m.getMessage());
        a.setRoom(r);
        a.setStart(CalendarWebHelper.getDate(start.getModelObject()));
        a.setEnd(CalendarWebHelper.getDate(end.getModelObject()));
        List<MeetingMember> attendees = new ArrayList<>();
        for (User to : modelTo.getObject()) {
            MeetingMember mm = new MeetingMember();
            mm.setUser(to);
            mm.setDeleted(false);
            mm.setInserted(a.getInserted());
            mm.setUpdated(a.getUpdated());
            mm.setAppointment(a);
            attendees.add(mm);
        }
        a.setOwner(owner);
        a.setMeetingMembers(attendees);
        apptDao.update(a, getUserId(), false);
        m.setRoom(r);
    } else {
        m.setRoom(null);
    }
    for (User to : modelTo.getObject()) {
        if (to.getId() == null) {
            userDao.update(to, getUserId());
        }
        // to send
        PrivateMessage p = new PrivateMessage(m);
        p.setTo(to);
        p.setFolderId(SENT_FOLDER_ID);
        msgDao.update(p, getUserId());
        // to inbox
        p = new PrivateMessage(m);
        p.setOwner(to);
        p.setFolderId(INBOX_FOLDER_ID);
        msgDao.update(p, getUserId());
        if (to.getAddress() != null) {
            String aLinkHTML = (isPrivate && to.getType() == Type.user) ? "<br/><br/>" + "<a href='" + getContactsLink() + "'>" + Application.getString("1302", to.getLanguageId()) + "</a><br/>" : "";
            String invitationLink = "";
            if (p.isBookedRoom()) {
                Invitation i = inviteManager.getInvitation(to, p.getRoom(), false, null, Valid.Period, owner, to.getLanguageId(), CalendarHelper.getDate(start.getModelObject(), to.getTimeZoneId()), CalendarHelper.getDate(end.getModelObject(), to.getTimeZoneId()), null);
                invitationLink = getInvitationLink(i, WebSession.get().getExtendedProperties().getBaseUrl());
                if (invitationLink == null) {
                    invitationLink = "";
                } else {
                    invitationLink = // 
                    "<br/>" + Application.getString("503", to.getLanguageId()) + "<br/><a href='" + invitationLink + "'>" + Application.getString("504", to.getLanguageId()) + "</a><br/>";
                }
            }
            String subj = p.getSubject() == null ? "" : p.getSubject();
            handler.send(to.getAddress().getEmail(), Application.getString("1301", to.getLanguageId()) + subj, (p.getMessage() == null ? "" : p.getMessage().replaceAll("\\<.*?>", "")) + aLinkHTML + invitationLink);
        }
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) ArrayList(java.util.ArrayList) Invitation(org.apache.openmeetings.db.entity.room.Invitation) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Room(org.apache.openmeetings.db.entity.room.Room) Date(java.util.Date)

Example 3 with Appointment

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

the class AppointmentDialog method deleteAppointment.

protected void deleteAppointment(IPartialPageRequestHandler handler) {
    Appointment a = getModelObject();
    apptDao.delete(a, getUserId());
    calendarPanel.refresh(handler);
    if (a.getCalendar() != null && a.getHref() != null) {
        calendarPanel.updatedeleteAppointment(handler, CalendarDialog.DIALOG_TYPE.DELETE_APPOINTMENT, a);
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment)

Example 4 with Appointment

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

the class AppointmentDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    Appointment a = form.getModelObject();
    a.setRoom(form.createRoom ? form.appRoom : form.groom.getModelObject());
    final List<MeetingMember> mms = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers();
    Set<Long> currentIds = new HashSet<>();
    List<User> users = new ArrayList<>();
    if (InviteeType.group == rdi.getModelObject()) {
        // lets iterate through all group users
        for (Group g : groups.getModelObject()) {
            for (GroupUser gu : groupUserDao.get(g.getId(), 0, Integer.MAX_VALUE)) {
                User u = gu.getUser();
                if (!currentIds.contains(u.getId())) {
                    users.add(u);
                    currentIds.add(u.getId());
                }
            }
        }
    } else {
        users = new ArrayList<>(attendees.getModelObject());
        for (User u : users) {
            if (u.getId() != null) {
                currentIds.add(u.getId());
            }
        }
    }
    // remove users
    for (Iterator<MeetingMember> i = mms.iterator(); i.hasNext(); ) {
        MeetingMember m = i.next();
        if (!currentIds.contains(m.getUser().getId())) {
            i.remove();
        }
    }
    Set<Long> originalIds = new HashSet<>();
    for (MeetingMember m : mms) {
        originalIds.add(m.getUser().getId());
    }
    // add users
    for (User u : users) {
        if (u.getId() == null || !originalIds.contains(u.getId())) {
            MeetingMember mm = new MeetingMember();
            mm.setUser(u);
            mm.setDeleted(false);
            mm.setInserted(a.getInserted());
            mm.setUpdated(a.getUpdated());
            mm.setAppointment(a);
            mms.add(mm);
        }
    }
    a.setMeetingMembers(mms);
    a.setStart(getDate(form.start.getModelObject()));
    a.setEnd(getDate(form.end.getModelObject()));
    a.setCalendar(form.cals.getModelObject());
    apptDao.update(a, getUserId());
    if (a.getCalendar() != null) {
        calendarPanel.updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a);
    }
    target.add(feedback);
    calendarPanel.refresh(target);
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Group(org.apache.openmeetings.db.entity.user.Group) RadioGroup(org.apache.wicket.markup.html.form.RadioGroup) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 5 with Appointment

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

the class MessagesContactsPanel method selectMessage.

private void selectMessage(long id, AjaxRequestTarget target) {
    PrivateMessage msg = msgDao.get(id);
    selectedMessage.addOrReplace(new Label("from", msg == null ? "" : getEmail(msg.getFrom())));
    selectedMessage.addOrReplace(new Label("to", msg == null ? "" : getEmail(msg.getTo())));
    selectedMessage.addOrReplace(new Label("subj", msg == null ? "" : msg.getSubject()));
    selectedMessage.addOrReplace(new Label("body", msg == null ? "" : msg.getMessage()).setEscapeModelStrings(false));
    if (msg != null) {
        Room r = msg.getRoom();
        if (r != null) {
            Appointment a = apptDao.getByRoom(r.getId());
            roomContainer.addOrReplace(new Label("start", a == null ? "" : getDateFormat().format(a.getStart())));
            roomContainer.addOrReplace(new Label("end", a == null ? "" : getDateFormat().format(a.getEnd())));
            roomContainer.addOrReplace(new Button("enter").add(new RoomEnterBehavior(r.getId())));
        }
        roomContainer.setVisible(r != null);
    }
    if (target != null) {
        target.add(selectedMessage);
        updateControls(target);
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) RoomEnterBehavior(org.apache.openmeetings.web.user.rooms.RoomEnterBehavior) Button(org.apache.wicket.markup.html.form.Button) Label(org.apache.wicket.markup.html.basic.Label) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Room(org.apache.openmeetings.db.entity.room.Room)

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