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