示例#1
1
文件: Rental.java 项目: kiskit/stuff
 /**
  * The list of current rentals with who, what and when
  *
  * @return a list of all rentals with fields populated in the right fashion
  */
 public static List<Rental> getAllRentals() {
   List<Rental> rentals = new ArrayList<Rental>();
   List<Video> videos = Ebean.find(Video.class).where().isNotNull("rentedTo").findList();
   Ebean.sort(videos, "rentalDate asc");
   Rental rental = null;
   User user = null;
   for (Video v : videos) {
     rental = new Rental();
     rental.setWhatId(v.getId());
     rental.setWhat(v.getInputTitle());
     user = Ebean.find(User.class, v.getRentedTo());
     rental.setWho(user.getFullName());
     rental.setWhoId(v.getRentedTo());
     rental.setEmail(user.getEmail());
     rental.setWhen(v.getRentalDate());
     rentals.add(rental);
   }
   return rentals;
 }
示例#2
0
文件: Rental.java 项目: kiskit/stuff
 /**
  * Used to obtain a list of rentals for a specific user
  *
  * @param userId the user whose rentals we're interested into
  * @return the list of rentals for the user
  */
 public static List<Rental> getRentalsByUserId(Long userId) {
   List<Rental> rentals = new ArrayList<Rental>();
   List<Video> videos = Ebean.find(Video.class).where().eq("rentedTo", userId).findList();
   Rental rental = null;
   User user = null;
   for (Video v : videos) {
     rental = new Rental();
     rental.setWhatId(v.getId());
     rental.setWhat(v.getInputTitle());
     user = Ebean.find(User.class, v.getRentedTo());
     rental.setWho(user.getFullName());
     rental.setWhoId(v.getRentedTo());
     rental.setEmail(user.getEmail());
     rental.setWhen(v.getRentalDate());
     rentals.add(rental);
   }
   return rentals;
 }