Search in sources :

Example 6 with MeetingMember

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

the class TestAppointmentAddAppointment method saveAppointment.

@Test
public void saveAppointment() throws Exception {
    log.debug("- saveAppointment");
    Calendar start = Calendar.getInstance();
    start.setTimeInMillis(start.getTimeInMillis() + 600000);
    Calendar end = Calendar.getInstance();
    end.setTimeInMillis(start.getTimeInMillis() + 600000);
    String appointmentName = "Test 01";
    String appointmentDescription = "Descr";
    Long userId = 1L;
    String appointmentLocation = "office";
    Boolean isMonthly = false;
    Boolean isDaily = false;
    Boolean isWeekly = false;
    String remind = Appointment.Reminder.ical.name();
    Boolean isYearly = false;
    String[] mmClient = new String[1];
    for (int i = 0; i < 1; i++) {
        mmClient[0] = createClientObj("firstname" + i, "lastname" + i, "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1");
    }
    Long languageId = 1L;
    Long roomType = 1L;
    Appointment a = new Appointment();
    a.setTitle(appointmentName);
    a.setLocation(appointmentLocation);
    a.setDescription(appointmentDescription);
    a.setStart(start.getTime());
    a.setEnd(end.getTime());
    a.setIsDaily(isDaily);
    a.setIsWeekly(isWeekly);
    a.setIsMonthly(isMonthly);
    a.setIsYearly(isYearly);
    a.setReminder(Reminder.valueOf(remind));
    a.setRoom(new Room());
    a.getRoom().setComment(appointmentDescription);
    a.getRoom().setName(appointmentName);
    a.getRoom().setType(Room.Type.get(roomType));
    a.getRoom().setAppointment(true);
    a.setOwner(userDao.get(userId));
    a.setPasswordProtected(false);
    a.setPassword("");
    a.setMeetingMembers(new ArrayList<MeetingMember>());
    for (String singleClient : mmClient) {
        if (Strings.isEmpty(singleClient)) {
            continue;
        }
        MeetingMember mm = getMeetingMember(userId, languageId, singleClient);
        mm.setAppointment(a);
        a.getMeetingMembers().add(mm);
    }
    a = appointmentDao.update(a, userId);
    Thread.sleep(3000);
    appointmentLogic.doScheduledMeetingReminder();
    Thread.sleep(3000);
    assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Calendar(java.util.Calendar) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Room(org.apache.openmeetings.db.entity.room.Room) Test(org.junit.Test)

Example 7 with MeetingMember

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

the class TestAppointmentAddAppointment method getMeetingMember.

public MeetingMember getMeetingMember(Long userId, Long langId, String str) {
    String[] params = str.split(",");
    try {
        return meetingMemberDao.get(Long.valueOf(params[0]));
    } catch (Exception e) {
    // no-op
    }
    MeetingMember mm = new MeetingMember();
    try {
        mm.setUser(userDao.get(Long.valueOf(params[4])));
    } catch (Exception e) {
    // no-op
    }
    if (mm.getUser() == null) {
        mm.setUser(userDao.getContact(params[3], params[1], params[2], langId, params[5], userId));
    }
    return mm;
}
Also used : MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember)

Example 8 with MeetingMember

use of org.apache.openmeetings.db.entity.calendar.MeetingMember 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 9 with MeetingMember

use of org.apache.openmeetings.db.entity.calendar.MeetingMember 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);
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) Calendar(java.util.Calendar) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Test(org.junit.Test)

Example 10 with MeetingMember

use of org.apache.openmeetings.db.entity.calendar.MeetingMember 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);
        }
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) TimeZone(java.util.TimeZone) TimezoneUtil.getTimeZone(org.apache.openmeetings.db.util.TimezoneUtil.getTimeZone) Calendar(java.util.Calendar) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Invitation(org.apache.openmeetings.db.entity.room.Invitation)

Aggregations

MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)16 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)9 User (org.apache.openmeetings.db.entity.user.User)7 ArrayList (java.util.ArrayList)4 Calendar (java.util.Calendar)4 Room (org.apache.openmeetings.db.entity.room.Room)4 Test (org.junit.Test)4 Date (java.util.Date)3 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)3 JSONObject (com.github.openjson.JSONObject)2 URI (java.net.URI)2 Attendee (net.fortuna.ical4j.model.property.Attendee)2 Invitation (org.apache.openmeetings.db.entity.room.Invitation)2 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 HashSet (java.util.HashSet)1 TimeZone (java.util.TimeZone)1 UUID (java.util.UUID)1