1 package org.objectweb.rentacar.agency.services.statistics; 2 3 import java.util.Set ; 4 5 import javax.jws.WebMethod; 6 import javax.jws.WebParam; 7 import javax.jws.WebService; 8 9 import org.apache.log4j.Logger; 10 import org.objectweb.rentacar.AgencyException; 11 import org.objectweb.rentacar.persistance.bo.Agency; 12 import org.objectweb.rentacar.persistance.bo.CentralOffice; 13 import org.objectweb.rentacar.persistance.dao.CentralOfficeDAO; 14 import org.objectweb.rentacar.persistance.dao.DAOException; 15 16 19 @WebService 20 public class AgencyStatisticsServiceImpl { 21 22 private static Logger logger = Logger.getLogger(AgencyStatisticsServiceImpl.class); 23 24 30 @WebMethod 31 public CentralOffice getCentralOffice(@WebParam(name = "centralofficeId") 32 String centralofficeId, @WebParam(name = "nbOffice") 33 int nbOffice) throws AgencyException { 34 logger.info("Agency . getCentralOffice : " + centralofficeId); 35 CentralOffice of = null; 36 try { 37 of = CentralOfficeDAO.getInstance().getCentralOffice(centralofficeId); 38 Set <Agency> agencies = of.getAgencies(); 39 Agency ag = (Agency) agencies.iterator().next(); 40 while (agencies.size() < nbOffice){ 41 ag.setAgencyId(ag.getAgencyId()+"1"); 42 agencies.add(ag); 43 } 44 of.setAgencies(agencies); 45 } 46 catch (DAOException e) { 47 logger.error("Error when retrieving central office", e); 48 throw new AgencyException("Error when retrieving central office", e); 49 } 50 return of; 51 } 52 53 } 54 | Popular Tags |