Search in sources :

Example 1 with RoomType

use of fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType in project pyramus by otavanopisto.

the class RoomTypeDAO method create.

public RoomType create(String name) {
    RoomType roomType = new RoomType();
    roomType.setName(name);
    return persist(roomType);
}
Also used : RoomType(fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType)

Example 2 with RoomType

use of fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType in project pyramus by otavanopisto.

the class CourseStudentDetailsDialogViewController method process.

public void process(PageRequestContext pageRequestContext) {
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    RoomTypeDAO roomTypeDAO = DAOFactory.getInstance().getRoomTypeDAO();
    RoomDAO roomDAO = DAOFactory.getInstance().getRoomDAO();
    Long courseStudentId = pageRequestContext.getLong("courseStudentId");
    if (courseStudentId == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Missing courseStudentId parameter");
    }
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    if (courseStudent == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Invalid courseStudentId parameter");
    }
    Map<RoomType, List<Room>> rooms = new TreeMap<>(new Comparator<RoomType>() {

        @Override
        public int compare(RoomType o1, RoomType o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    List<RoomType> roomTypes = roomTypeDAO.listAll();
    for (RoomType roomType : roomTypes) {
        List<Room> typeRooms = roomDAO.listByType(roomType);
        rooms.put(roomType, typeRooms);
    }
    // Support other currencies
    List<Currency> currencies = Arrays.asList(Currency.getInstance("EUR"));
    List<BillingDetails> existingBillingDetails = getExistingBillingDetails(courseStudent);
    pageRequestContext.getRequest().setAttribute("courseStudent", courseStudent);
    pageRequestContext.getRequest().setAttribute("rooms", rooms);
    pageRequestContext.getRequest().setAttribute("currencies", currencies);
    pageRequestContext.getRequest().setAttribute("existingBillingDetails", existingBillingDetails);
    pageRequestContext.setIncludeJSP("/templates/courses/studentdetailsdialog.jsp");
}
Also used : RoomDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) TreeMap(java.util.TreeMap) BillingDetails(fi.otavanopisto.pyramus.domainmodel.base.BillingDetails) RoomType(fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Currency(java.util.Currency) RoomTypeDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomTypeDAO) ArrayList(java.util.ArrayList) List(java.util.List) Room(fi.otavanopisto.pyramus.domainmodel.accommodation.Room)

Aggregations

RoomType (fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType)2 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)1 RoomDAO (fi.otavanopisto.pyramus.dao.accommodation.RoomDAO)1 RoomTypeDAO (fi.otavanopisto.pyramus.dao.accommodation.RoomTypeDAO)1 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)1 Room (fi.otavanopisto.pyramus.domainmodel.accommodation.Room)1 BillingDetails (fi.otavanopisto.pyramus.domainmodel.base.BillingDetails)1 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)1 ArrayList (java.util.ArrayList)1 Currency (java.util.Currency)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1