use of org.apache.openmeetings.db.entity.calendar.MeetingMember 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.MeetingMember 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.MeetingMember in project openmeetings by apache.
the class IcalUtils method addVEventpropsfromAppointment.
/**
* Adds the Appointment Properties to the given VEvent
*
* @param appointment Appointment whose properties are taken
* @param meeting VEvent of the Appointment
* @return Updated VEvent
*/
private static VEvent addVEventpropsfromAppointment(Appointment appointment, VEvent meeting) {
if (appointment.getLocation() != null) {
meeting.getProperties().add(new Location(appointment.getLocation()));
}
meeting.getProperties().add(new Description(appointment.getDescription()));
meeting.getProperties().add(new Sequence(0));
meeting.getProperties().add(Transp.OPAQUE);
String uid = appointment.getIcalId();
Uid ui;
if (uid == null || uid.length() < 1) {
UUID uuid = UUID.randomUUID();
appointment.setIcalId(uuid.toString());
ui = new Uid(uuid.toString());
} else {
ui = new Uid(uid);
}
meeting.getProperties().add(ui);
if (appointment.getMeetingMembers() != null) {
for (MeetingMember meetingMember : appointment.getMeetingMembers()) {
Attendee attendee = new Attendee(URI.create("mailto:" + meetingMember.getUser().getAddress().getEmail()));
attendee.getParameters().add(Role.REQ_PARTICIPANT);
attendee.getParameters().add(new Cn(meetingMember.getUser().getLogin()));
meeting.getProperties().add(attendee);
}
}
URI orgUri = URI.create("mailto:" + appointment.getOwner().getAddress().getEmail());
Attendee orgAtt = new Attendee(orgUri);
orgAtt.getParameters().add(Role.CHAIR);
Cn orgCn = new Cn(appointment.getOwner().getLogin());
orgAtt.getParameters().add(orgCn);
meeting.getProperties().add(orgAtt);
Organizer organizer = new Organizer(orgUri);
organizer.getParameters().add(orgCn);
meeting.getProperties().add(organizer);
return meeting;
}
use of org.apache.openmeetings.db.entity.calendar.MeetingMember in project openmeetings by apache.
the class IcalUtils method addVEventPropertiestoAppointment.
/**
* Add properties from the Given VEvent Component to the Appointment
*
* @param a Appointment to which the properties are to be added
* @param event VEvent to parse properties from.
* @return Updated Appointment
*/
private Appointment addVEventPropertiestoAppointment(Appointment a, CalendarComponent event) {
DateProperty dtstart = (DateProperty) event.getProperty(Property.DTSTART), dtend = (DateProperty) event.getProperty(Property.DTEND), dtstamp = (DateProperty) event.getProperty(Property.DTSTAMP), lastmod = (DateProperty) event.getProperty(Property.LAST_MODIFIED);
Property uid = event.getProperty(Property.UID), description = event.getProperty(Property.DESCRIPTION), summary = event.getProperty(Property.SUMMARY), location = event.getProperty(Property.LOCATION), organizer = event.getProperty(Property.ORGANIZER), recur = event.getProperty(Property.RRULE);
PropertyList<Attendee> attendees = event.getProperties(Property.ATTENDEE);
if (uid != null) {
a.setIcalId(uid.getValue());
}
Date d = dtstart.getDate();
a.setStart(d);
if (dtend == null) {
a.setEnd(addTimetoDate(d, java.util.Calendar.HOUR_OF_DAY, 1));
} else {
a.setEnd(dtend.getDate());
}
a.setInserted(dtstamp.getDate());
if (lastmod != null) {
a.setUpdated(lastmod.getDate());
}
if (description != null) {
a.setDescription(description.getValue());
}
if (summary != null) {
a.setTitle(summary.getValue());
}
if (location != null) {
a.setLocation(location.getValue());
}
if (recur != null) {
Parameter freq = recur.getParameter("FREQ");
if (freq != null) {
if (freq.getValue().equals(Recur.DAILY)) {
a.setIsDaily(true);
} else if (freq.getValue().equals(Recur.WEEKLY)) {
a.setIsWeekly(true);
} else if (freq.getValue().equals(Recur.MONTHLY)) {
a.setIsMonthly(true);
} else if (freq.getValue().equals(Recur.YEARLY)) {
a.setIsYearly(true);
}
}
}
List<MeetingMember> attList = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers();
// Note this value can be repeated in attendees as well.
if (organizer != null) {
URI uri = URI.create(organizer.getValue());
// If the value of the organizer is an email
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
// Contact or exist and owner
User org = userDao.getByEmail(email);
if (org == null) {
org = userDao.getContact(email, a.getOwner());
attList.add(createMeetingMember(a, org));
} else if (!org.getId().equals(a.getOwner().getId())) {
attList.add(createMeetingMember(a, org));
}
}
}
if (attendees != null && !attendees.isEmpty()) {
for (Property attendee : attendees) {
URI uri = URI.create(attendee.getValue());
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
User u = userDao.getByEmail(email);
if (u == null) {
u = userDao.getContact(email, a.getOwner());
}
attList.add(createMeetingMember(a, u));
}
}
}
a.setMeetingMembers(attList.isEmpty() ? null : attList);
return a;
}
use of org.apache.openmeetings.db.entity.calendar.MeetingMember in project openmeetings by apache.
the class TestAppointmentAddAppointment method testCreate.
@Test
public void testCreate() {
Appointment a = new Appointment();
a.setTitle("Test title");
setTime(a);
a.setReminder(Reminder.ical);
a.setMeetingMembers(new ArrayList<>());
User owner = userDao.get(1L);
a.setOwner(owner);
a.setRoom(new Room());
a.getRoom().setAppointment(true);
a.getRoom().setType(Room.Type.conference);
for (int i = 0; i < 3; ++i) {
MeetingMember mm = new MeetingMember();
mm.setUser(getContact(UUID.randomUUID().toString(), owner.getId()));
a.getMeetingMembers().add(mm);
}
a = appointmentDao.update(a, owner.getId());
assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
assertEquals("Saved appointment should have corect count of guests: ", 3, a.getMeetingMembers().size());
for (MeetingMember mm : a.getMeetingMembers()) {
assertNotNull("Saved guest should have valid id: ", mm.getId());
assertNotNull("Saved guest should have valid invitation: ", mm.getInvitation());
assertNotNull("Saved guest should have invitation with ID: ", mm.getInvitation().getId());
}
WebSession ws = WebSession.get();
Appointment a1 = appointmentDao.get(a.getId());
ws.checkHashes(StringValue.valueOf(""), StringValue.valueOf(a1.getMeetingMembers().get(0).getInvitation().getHash()));
assertTrue("Login via secure hash should be successful", ws.isSignedIn());
}
Aggregations