Ejemplo n.º 1
0
 public SelectItem[] getBusOptions() {
   List<Bus> buses = bm.getWorkingBus();
   List<Bus> freeBuses = new ArrayList<Bus>();
   if (historiesForDate.isEmpty()) {
     SelectItem[] items = new SelectItem[buses.size()];
     int i = 0;
     for (Bus b : buses) {
       items[i++] = new SelectItem(b.getId().toString(), b.toString());
     }
     return items;
   } else {
     boolean isFree = true;
     for (Bus b : buses) {
       for (History his : historiesForDate) {
         if (b.getId().equals(his.getBus().getId())) {
           isFree = false;
           break;
         }
       }
       if (isFree) {
         freeBuses.add(b);
       } else isFree = true;
     }
     SelectItem[] items = new SelectItem[freeBuses.size()];
     int i = 0;
     for (Bus b : freeBuses) {
       items[i++] = new SelectItem(b.getId().toString(), b.toString());
     }
     return items;
   }
 }
Ejemplo n.º 2
0
 public SelectItem[] getBusAllOptions() {
   List<Bus> buses = bm.getAllBus();
   SelectItem[] items = new SelectItem[buses.size() + 1];
   items[0] = new SelectItem("");
   int i = 1;
   for (Bus b : buses) {
     items[i++] = new SelectItem(b.getId().toString(), b.toString());
   }
   return items;
 }
Ejemplo n.º 3
0
 public String addHistory() {
   history.setDriver(dm.getDriver(driverId));
   history.setBus(bm.getBus(busId));
   history.setRoute(rm.getRoute(routeId));
   history.setDate(date);
   hm.addHistory(history);
   history = new History();
   driverId = 0L;
   busId = 0L;
   routeId = 0L;
   historiesForDate = hm.getHistoryByDate(date);
   return "showLines?faces-redirect=true";
 }