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;
}
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);
}
}
}
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);
}
}
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);
}
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);
}
}
Aggregations