use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class TestSubjTemplate method testTemplateGeneration.
@Test
public void testTemplateGeneration() {
Appointment a = getAppointment();
String[] ids = TimeZone.getAvailableIDs();
Recording rec = new Recording();
rec.setRoomId(5L);
for (User u : userDao.get(0, 100)) {
TimeZone tz = TimeZone.getTimeZone(ids[rnd.nextInt(ids.length)]);
checkTemplate(CreatedAppointmentTemplate.get(u, a, tz, u.getLogin()));
checkTemplate(CanceledAppointmentTemplate.get(u, a, tz, u.getLogin()));
checkTemplate(UpdatedAppointmentTemplate.get(u, a, tz, u.getLogin()));
checkTemplate(AppointmentReminderTemplate.get(u, a, tz));
checkTemplate(RecordingExpiringTemplate.get(u, rec, 1L));
}
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class TestSubjTemplate method testError.
@Test
public void testError() {
InvitedAppointmentTemplate t = new InvitedAppointmentTemplate(Locale.CHINA, new Appointment(), TimeZone.getDefault(), "TEST") {
private static final long serialVersionUID = 1L;
@Override
String getPrefix() {
return null;
}
};
checkTemplateError(t, tmp -> tmp.getSubject());
checkTemplateError(t, tmp -> tmp.getEmail());
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class TestDatabaseStructureGetAppointmentByRange method test.
@Test
public void test() {
log.debug("Test started");
Long userId = 1L;
Calendar now = Calendar.getInstance();
Calendar rangeStart = Calendar.getInstance();
rangeStart.setTime(now.getTime());
rangeStart.add(Calendar.DATE, -1);
Calendar rangeEnd = Calendar.getInstance();
rangeEnd.add(Calendar.DATE, 1);
rangeEnd.setTime(now.getTime());
Calendar a1End = Calendar.getInstance();
a1End.setTime(now.getTime());
a1End.add(Calendar.HOUR_OF_DAY, 1);
Appointment a1 = getAppointment(now.getTime(), a1End.getTime());
a1.setTitle("AppointmentByRange_a1");
Appointment a2 = getAppointment(now.getTime(), a1End.getTime());
a2.setTitle("AppointmentByRange_a2");
a2.setMeetingMembers(new ArrayList<MeetingMember>());
MeetingMember mm1 = new MeetingMember();
mm1.setUser(createUserContact(userId));
mm1.setAppointment(a2);
a2.getMeetingMembers().add(mm1);
Appointment a3 = getAppointment(now.getTime(), a1End.getTime());
a3.setTitle("AppointmentByRange_a3");
a3.setMeetingMembers(new ArrayList<MeetingMember>());
MeetingMember mm2 = new MeetingMember();
mm2.setUser(createUserContact(userId));
mm2.setAppointment(a3);
a3.getMeetingMembers().add(mm2);
MeetingMember mm3 = new MeetingMember();
mm3.setUser(createUserContact(userId));
mm3.setAppointment(a3);
a3.getMeetingMembers().add(mm3);
a1 = appointmentDao.update(a1, userId);
a2 = appointmentDao.update(a2, userId);
a3 = appointmentDao.update(a3, userId);
int a1found = 0, a2found = 0, a3found = 0;
for (Appointment a : appointmentDao.getInRange(userId, rangeStart.getTime(), rangeEnd.getTime())) {
int mmCount = a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size();
if (a.getId().equals(a1.getId())) {
assertEquals("Inapropriate MeetingMembers count", 0, mmCount);
a1found++;
}
if (a.getId().equals(a2.getId())) {
assertEquals("Inapropriate MeetingMembers count", 1, mmCount);
a2found++;
}
if (a.getId().equals(a3.getId())) {
assertEquals("Inapropriate MeetingMembers count", 2, mmCount);
a3found++;
}
}
assertEquals("Inappropriate count of appointments without members found", 1, a1found);
assertEquals("Inappropriate count of appointments with 1 member found", 1, a2found);
assertEquals("Inappropriate count of appointments with 2 members found", 1, a3found);
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class TestGetAppointment method testGetByRoom.
@Test
public void testGetByRoom() {
Date start = new Date();
Appointment a = createAppointment(getAppointment(userDao.get(1L), roomDao.get(5L), start, new Date(start.getTime() + ONE_HOUR)));
Appointment a1 = appointmentDao.getByRoom(1L, 5L);
assertNotNull("Created appointment should be found", a1);
assertEquals(a.getId(), a1.getId());
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class AppointmentLogic method doScheduledMeetingReminder.
/**
* Sending Reminder in Simple mail format 5 minutes before Meeting begins
*/
// ----------------------------------------------------------------------------------------------
public void doScheduledMeetingReminder() {
String baseUrl = getBaseUrl();
if (baseUrl == null || baseUrl.length() < 1) {
log.error("Error retrieving baseUrl for application");
return;
}
int minutesReminderSend = cfgDao.getInt(CONFIG_APPOINTMENT_REMINDER_MINUTES, DEFAULT_MINUTES_REMINDER_SEND);
if (minutesReminderSend == 0) {
log.warn("minutesReminderSend is 0, disabling reminder scheduler");
return;
}
long milliseconds = minutesReminderSend * 60 * 1000L;
Calendar start = Calendar.getInstance();
if (milliseconds < 0) {
start.setTimeInMillis(start.getTimeInMillis() + milliseconds);
}
Calendar end = Calendar.getInstance();
if (milliseconds > 0) {
end.setTimeInMillis(end.getTimeInMillis() + milliseconds);
}
for (Appointment a : appointmentDao.getInRange(start, end)) {
// very long to send each
if (a.isReminderEmailSend()) {
continue;
}
TimeZone ownerZone = getTimeZone(a.getOwner());
Calendar aNow = Calendar.getInstance(ownerZone);
Calendar aStart = a.startCalendar(ownerZone);
aStart.add(Calendar.MINUTE, -minutesReminderSend);
if (aStart.after(aNow)) {
// to early to send reminder
continue;
}
// Update Appointment to not send invitation twice
a.setReminderEmailSend(true);
appointmentDao.update(a, null, false);
List<MeetingMember> members = a.getMeetingMembers();
sendReminder(a.getOwner(), a);
if (members == null) {
log.debug("doScheduledMeetingReminder : no members in meeting!");
continue;
}
// Iterate through all MeetingMembers
for (MeetingMember mm : members) {
log.debug("doScheduledMeetingReminder : Member " + mm.getUser().getAddress().getEmail());
Invitation inv = mm.getInvitation();
sendReminder(mm.getUser(), a, inv);
}
}
}
Aggregations