Search in sources :

Example 31 with Appointment

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

the class BackupExport method exportAppointment.

/*
	 * ##################### Backup Appointments
	 */
private void exportAppointment(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    List<Appointment> list = appointmentDao.get();
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(User.class, UserConverter.class);
    registry.bind(Appointment.Reminder.class, AppointmentReminderTypeConverter.class);
    registry.bind(Room.class, RoomConverter.class);
    bindDate(registry, list);
    writeList(serializer, zos, "appointements.xml", "appointments", list);
    progressHolder.setProgress(25);
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 32 with Appointment

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

the class AppointmentDTO method get.

public Appointment get(UserDao userDao, BaseFileItemDao fileDao, AppointmentDao appointmentDao, User u) {
    Appointment a = id == null ? new Appointment() : appointmentDao.get(id);
    a.setId(id);
    a.setTitle(title);
    a.setLocation(location);
    a.setStart(start.getTime());
    a.setEnd(end.getTime());
    a.setDescription(description);
    a.setOwner(owner == null ? u : userDao.get(owner.getId()));
    a.setInserted(inserted);
    a.setUpdated(updated);
    a.setDeleted(deleted);
    a.setReminder(reminder);
    a.setRoom(room.get(fileDao));
    a.setIcalId(icalId);
    List<MeetingMember> mml = new ArrayList<>();
    for (MeetingMemberDTO mm : meetingMembers) {
        MeetingMember m = null;
        if (mm.getId() != null) {
            // if ID is NOT null it should already be in the list
            for (MeetingMember m1 : a.getMeetingMembers()) {
                if (m1.getId().equals(mm.getId())) {
                    m = m1;
                    break;
                }
            }
            if (m == null) {
                throw new RuntimeException("Weird guest from different appointment is passed");
            }
        } else {
            m = mm.get(userDao, u);
            m.setAppointment(a);
        }
        mml.add(m);
    }
    a.setMeetingMembers(mml);
    a.setLanguageId(languageId);
    a.setPasswordProtected(passwordProtected);
    a.setConnectedEvent(connectedEvent);
    a.setReminderEmailSend(reminderEmailSend);
    return a;
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) ArrayList(java.util.ArrayList)

Example 33 with Appointment

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

the class CalendarWebService method save.

/**
 * Save an appointment
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param appointment
 *            calendar event
 *
 * @return - appointment saved
 */
@WebMethod
@POST
@Path("/")
public AppointmentDTO save(@QueryParam("sid") @WebParam(name = "sid") String sid, @FormParam("appointment") @WebParam(name = "appointment") AppointmentDTO appointment) {
    // Seems to be create
    log.debug("save SID: {}", sid);
    return performCall(sid, sd -> {
        User u = userDao.get(sd.getUserId());
        if (!AuthLevelUtil.hasUserLevel(u.getRights())) {
            log.error("save: not authorized");
            return false;
        }
        return AuthLevelUtil.hasWebServiceLevel(u.getRights()) || appointment.getOwner() == null || appointment.getOwner().getId().equals(u.getId());
    }, sd -> {
        User u = userDao.get(sd.getUserId());
        Appointment a = appointment.get(userDao, fileDao, dao, u);
        if (a.getRoom().getId() != null) {
            if (a.getRoom().isAppointment()) {
                a.getRoom().setIspublic(false);
            } else {
                a.setRoom(roomDao.get(a.getRoom().getId()));
            }
        }
        return new AppointmentDTO(dao.update(a, u.getId()));
    });
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 34 with Appointment

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

the class TestCalendar method testEventCreate.

@Test
public void testEventCreate() throws OmException {
    testArea(regularUsername, p -> {
        Menu menu = (Menu) p.get(PATH_MENU);
        Assert.assertNotNull(menu);
        tester.getRequest().setParameter("hash", menu.getItemList().get(0).getItems().get(1).getId());
        tester.executeBehavior((AbstractAjaxBehavior) menu.getBehaviorById(0));
        tester.assertComponent(PATH_CHILD, CalendarPanel.class);
        CalendarPanel cal = (CalendarPanel) p.get(PATH_CHILD);
        tester.executeAllTimerBehaviors(cal);
        User u = userDao.getByLogin(regularUsername, User.Type.user, null);
        // test create month
        tester.getRequest().setParameter("allDay", String.valueOf(false));
        tester.getRequest().setParameter("startDate", LocalDateTime.of(2017, 11, 13, 13, 13).toString());
        tester.getRequest().setParameter("endDate", LocalDateTime.of(2017, 11, 13, 13, 13).toString());
        tester.getRequest().setParameter("viewName", CalendarView.month.name());
        // select-event
        tester.executeBehavior((AbstractAjaxBehavior) cal.get("form:calendar").getBehaviorById(0));
        FormTester appTester = tester.newFormTester(PATH_APPOINTMENT_DLG_FRM);
        // check inviteeType:groupContainer:groups is invisible for regular user
        String title = String.format("title%s", UUID.randomUUID());
        appTester.setValue("title", title);
        ButtonAjaxBehavior save = getButtonBehavior(PATH_APPOINTMENT_DLG, "save");
        tester.executeBehavior(save);
        List<Appointment> appts = appointmentDao.searchByTitle(u.getId(), title);
        assertEquals("Appointment should be created", 1, appts.size());
        assertEquals("Appointment should be created", title, appts.get(0).getTitle());
    });
}
Also used : CalendarPanel(org.apache.openmeetings.web.user.calendar.CalendarPanel) Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) FormTester(org.apache.wicket.util.tester.FormTester) Menu(com.googlecode.wicket.jquery.ui.widget.menu.Menu) ButtonAjaxBehavior(com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior) Test(org.junit.Test)

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