@Override public DriverVO addDriver( long number, String name, TimePO birthday, String iD, String tel, String carunit, String sex, TimePO licensedate) { // TODO Auto-generated method stub voList = new ArrayList<DriverVO>(); long id = 1111111111; try { id = cd.findlast().getNumber() + 1; } catch (IOException e) { e.printStackTrace(); } DriverVO vo = new DriverVO(id, name, birthday, iD, tel, carunit, sex, licensedate); voList.add(vo); DriverPO po = new DriverPO(id, name, birthday, iD, tel, carunit, sex, licensedate); System.out.println(sex); try { cd.insert(po); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return vo; }
@Override public Iterator<DriverVO> findAll() { // TODO Auto-generated method stub cd = DataFactory.getDriverData(); ArrayList<DriverVO> voList = new ArrayList<DriverVO>(); ArrayList<DriverPO> poList = new ArrayList<DriverPO>(); try { poList = cd.findAll(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (int i = 0; i < poList.size(); i++) { DriverPO po = poList.get(i); DriverVO vo = new DriverVO( po.getNumber(), po.getName(), po.getBirthday(), po.getID(), po.getTel(), po.getCarunit(), po.getSex(), po.getLicensedate()); voList.add(vo); } return voList.iterator(); }
@Override public boolean Upate(ArrayList<DriverVO> voList) { // TODO Auto-generated method stub for (int i = 0; i < voList.size(); i++) { DriverVO vo = voList.get(i); DriverPO po = new DriverPO( vo.getNumber(), vo.getName(), vo.getBirthday(), vo.getID(), vo.getTel(), vo.getCarunit(), vo.getSex(), vo.getLicensedate()); // System.out.println(vo.getId()+" // "+vo.getPermission1().toString()+" "+vo.getUsername()+" // "+vo.getPassword()); try { cd.update(po); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return true; }
@Override public boolean deleteDriver(long number) { // TODO Auto-generated method stub try { cd.delete(number); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }