@Throws(Exception::class) fun execute( mapping: ActionMapping, form: ActionForm, request: HttpServletRequest, response: HttpServletResponse): ActionForward? { val editRoomDeptForm: EditRoomDeptForm = form as EditRoomDeptForm val rsc: MessageResources = getResources(request) val doit: String = editRoomDeptForm.getDoit() if (doit != null) { if (doit == rsc.getMessage("button.update")) { var errors = ActionMessages() errors = editRoomDeptForm.validate(mapping, request) if (errors.size() === 0) { doUpdate(editRoomDeptForm, request) return mapping.findForward("showRoomDetail") } else { saveErrors(request, errors) } } if (doit == rsc.getMessage("button.returnToRoomDetail")) { response.sendRedirect("roomDetail.do?id=" + editRoomDeptForm.getId()) return null } if (doit == rsc.getMessage("button.addRoomDept")) { if (editRoomDeptForm.getDept() == null || editRoomDeptForm.getDept() .length() === 0 ) { val errors = ActionMessages() errors.add("roomDept", ActionMessage("errors.required", "Department")) saveErrors(request, errors) } else if (editRoomDeptForm.getDepartmentIds() .contains(editRoomDeptForm.getDept()) ) { val errors = ActionMessages() errors.add("roomDept", ActionMessage("errors.alreadyPresent", "Department")) saveErrors(request, errors) } else { editRoomDeptForm.addDepartment(editRoomDeptForm.getDept()) } } if (doit == rsc.getMessage("button.removeRoomDept")) { if (editRoomDeptForm.getDept() == null || editRoomDeptForm.getDept() .length() === 0 ) { val errors = ActionMessages() errors.add("roomDept", ActionMessage("errors.required", "Department")) saveErrors(request, errors) } else if (!editRoomDeptForm.getDepartmentIds() .contains(editRoomDeptForm.getDept()) ) { val errors = ActionMessages() errors.add("roomDept", ActionMessage("errors.notPresent", "Department")) saveErrors(request, errors) } else { editRoomDeptForm.removeDepartment(editRoomDeptForm.getDept()) } } } val id: Long = java.lang.Long.valueOf(request.getParameter("id")) val ldao = LocationDAO()  val location: Location = ldao.get(id) sessionContext.checkPermission(location, Right.RoomEditAvailability) if (doit != null && doit == rsc.getMessage("button.modifyRoomDepts")) { val roomDepts = TreeSet(location.getRoomDepts()) val i: Iterator<*> = roomDepts.iterator() while (i.hasNext()) { val roomDept: RoomDept = i.next() as RoomDept editRoomDeptForm.addDepartment(roomDept.getDepartment().getUniqueId().toString()) } } val timeVertical: Boolean = CommonValues.VerticalGrid.eq(UserProperty.GridOrientation.get(sessionContext.getUser())) val rtt: RequiredTimeTable = location.getRoomSharingTable( sessionContext.getUser(), editRoomDeptForm.getDepartmentIds() ) rtt.getModel().setDefaultSelection(UserProperty.GridSize.get(sessionContext.getUser())) if (doit != null && (doit == rsc.getMessage("button.removeRoomDept") || doit == rsc.getMessage( "button.addRoomDept" )) ) { rtt.update(request) } editRoomDeptForm.setSharingTable(rtt.print(true, timeVertical)) if (location is Room) { val r: Room = location as Room editRoomDeptForm.setName(r.getLabel()) editRoomDeptForm.setNonUniv(false) } else if (location is NonUniversityLocation) { val nonUnivLocation: NonUniversityLocation = location as NonUniversityLocation editRoomDeptForm.setName(nonUnivLocation.getName()) editRoomDeptForm.setNonUniv(true) } else { val errors = ActionMessages() errors.add("editRoomDept", ActionMessage("errors.lookup.notFound", "Room Department")) saveErrors(request, errors) } setupDepartments(editRoomDeptForm, request, location) return mapping.findForward("showEditRoomDept") }
Method execute