1 package org.objectweb.rentacar.persistance.dao; 2 3 import java.util.Set ; 4 5 import org.objectweb.rentacar.persistance.bo.Agency; 6 import org.objectweb.rentacar.persistance.bo.CentralOffice; 7 8 11 public class CentralOfficeDAO extends GenericDAO { 12 13 private static CentralOfficeDAO theInstance; 14 15 private CentralOfficeDAO() { 16 17 } 18 19 public static synchronized CentralOfficeDAO getInstance() { 20 if (null == theInstance) { 21 theInstance = new CentralOfficeDAO(); 22 } 23 return theInstance; 24 } 25 26 33 public void updateCentralOfficeAgencies(String centralOfficeId, Set <Agency> newAgencies) throws DAOException { 34 35 CentralOffice centralOffice = null; 36 37 centralOffice = (CentralOffice) retrieveById(CentralOffice.class, centralOfficeId); 38 39 centralOffice.getAgencies().clear(); 40 centralOffice.getAgencies().addAll(newAgencies); 41 42 update(centralOffice); 43 } 44 45 51 public CentralOffice getCentralOffice(String centralOfficeId) throws DAOException { 52 return (CentralOffice) retrieveById(CentralOffice.class, centralOfficeId); 53 } 54 55 } 56 | Popular Tags |