Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Prenotazione {
- private int id;
- private Date data;
- private Cliente cliente;
- private Mezzo mezzo;
- private int numPostiOccupati;
- private Stazione partenza;
- private Stazione arrivo;
- private Localita localita;
- //getters and setters
- }
- public class PrenotazioneDAO implements IPrenotazioneDAO {
- @Override
- public Prenotazione findById(int id) {
- Prenotazione p = null;
- ArrayList<String[]> res = DbConnection.getInstance().eseguiQuery("SELECT * FROM prenotazione WHERE idprenotazione =" + id + ";");
- if (res.size() == 1) {
- String[] riga = res.get(0);
- p.setId(Integer.parseInt(riga[0]));
- p.setNumPostiOccupati(Integer.parseInt(riga[4]));
- p.setData(DateUtil.dateTimeFromString(riga[1]));
- ILocalitaDAO lDao = new LocalitaDAO();
- IStazioneDAO sDao = new StazioneDAO();
- IClienteDAO cDao = new ClienteDAO();
- IMezzoDAO mDao = new MezzoDAO();
- Localita l = lDao.findById(Integer.parseInt(riga[7]));
- Stazione partenza = sDao.findById(Integer.parseInt(riga[5]));
- Stazione arrivo = sDao.findById(Integer.parseInt(riga[6]));
- Cliente cliente = cDao.findById(Integer.parseInt(riga[2]));
- Mezzo mezzo = mDao.findById(Integer.parseInt(riga[3]));
- p.setLocalita(l);
- p.setArrivo(arrivo);
- p.setPartenza(partenza);
- p.setMezzo(mezzo);
- p.setCliente(cliente);
- //dobbiamo fare i DAO di stazione
- }
- return p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement