Ejemplo n.º 1
0
 // HELPERS
 public SelectItem[] getDriverOptions() {
   List<Driver> drivers = dm.getFreeDrivers();
   List<Driver> freeDrivers = new ArrayList<Driver>();
   if (historiesForDate.isEmpty()) {
     SelectItem[] items = new SelectItem[drivers.size()];
     int i = 0;
     for (Driver d : drivers) {
       items[i++] = new SelectItem(d.getId().toString(), d.toString());
     }
     return items;
   } else {
     boolean isFree = true;
     for (Driver d : drivers) {
       for (History his : historiesForDate) {
         if (d.getId().equals(his.getDriver().getId())) {
           isFree = false;
           break;
         }
       }
       if (isFree) {
         freeDrivers.add(d);
       } else isFree = true;
     }
     SelectItem[] items = new SelectItem[freeDrivers.size()];
     int i = 0;
     for (Driver d : freeDrivers) {
       items[i++] = new SelectItem(d.getId().toString(), d.toString());
     }
     return items;
   }
 }
Ejemplo n.º 2
0
 public SelectItem[] getDriverAllOptions() {
   List<Driver> drivers = dm.getAllDrivers();
   SelectItem[] items = new SelectItem[drivers.size() + 1];
   items[0] = new SelectItem("");
   int i = 1;
   for (Driver d : drivers) {
     items[i++] = new SelectItem(d.getId().toString(), d.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";
 }