KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rentacar > agency > services > statistics > AgencyStatisticsServiceImpl


1 package org.objectweb.rentacar.agency.services.statistics;
2
3 import java.util.Set JavaDoc;
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 /**
17  * This class expose web services that allow to do statistics on an agency
18  */

19 @WebService
20 public class AgencyStatisticsServiceImpl {
21
22     private static Logger logger = Logger.getLogger(AgencyStatisticsServiceImpl.class);
23
24     /**
25      * Retreive a central office
26      * @param centralofficeId
27      * @return central office
28      * @throws AgencyException
29      */

30     @WebMethod
31     public CentralOffice getCentralOffice(@WebParam(name = "centralofficeId")
32     String JavaDoc 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 JavaDoc<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