View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  
17  */
18  package org.bejug.javacareers.jobs.service;
19  
20  import org.bejug.javacareers.common.search.SearchCriteria;
21  import org.bejug.javacareers.common.search.SearchCriteriaService;
22  import org.bejug.javacareers.jobs.dao.OfferDao;
23  import org.bejug.javacareers.jobs.model.AcademicEducationOffer;
24  import org.bejug.javacareers.jobs.model.CommercialEducationOffer;
25  import org.bejug.javacareers.jobs.model.EducationOffer;
26  
27  import java.util.List;
28  
29  /***
30   * Concrete implementation of the educationservice.
31   *
32   * @author Bart Meyers (Last modified by $Author: stephan_janssen $)
33   * @version $Revision: 1.2 $ - $Date: 2005/10/11 09:09:14 $
34   */
35  public class EducationServiceImpl implements EducationService {
36  
37  	/***
38       * The SearchcriteriaService.
39       */
40      private SearchCriteriaService searchCriteriaService;
41      
42      /***
43       * the academiceducationofferdao.
44       */
45      private OfferDao academicEducationOfferDao = null;
46      
47      /***
48       * the commercialeducationofferdao.
49       */
50      private OfferDao commercialEducationOfferDao = null;
51  
52      /***
53       * Constructor.
54       * @param academicEducationOfferDao the needed academicEducationOfferDao.
55       * @param commercialEducationOfferDao the needed commercialEducationOfferDao.
56       * @param searchCriteriaService the searchCriteriaService.
57       */
58      public EducationServiceImpl(OfferDao academicEducationOfferDao,
59      		OfferDao commercialEducationOfferDao,
60      		SearchCriteriaService searchCriteriaService) {
61   
62      	this.searchCriteriaService = searchCriteriaService;
63      	this.academicEducationOfferDao = academicEducationOfferDao;
64      	this.commercialEducationOfferDao = commercialEducationOfferDao;
65      }
66     
67      /***
68       * set the academicEducationOfferDao.
69       * @param academicEducationOfferDao the dao to set.
70       */
71      public void setAcademicEducationOfferDao(OfferDao academicEducationOfferDao) {
72          this.academicEducationOfferDao = academicEducationOfferDao;
73      }
74      
75      /***
76       * set the commercialEducationOfferDao.
77       * @param commercialEducationOfferDao the dao to set
78       */
79      public void setCommercialEducationOfferDao(
80              OfferDao commercialEducationOfferDao) {
81          this.commercialEducationOfferDao = commercialEducationOfferDao;
82      }
83      
84      /***
85       * {@inheritDoc}
86       */
87      public void storeEducationOffer(EducationOffer offer) {
88          commercialEducationOfferDao.store(offer);
89      }
90  
91      /***
92       * {@inheritDoc}
93       */
94      public void deleteEducationOffer(EducationOffer offer) {
95      	commercialEducationOfferDao.deleteOffer(offer);
96      }
97  
98      /***
99       * {@inheritDoc}
100      */
101     public List getAcademicEducationOffers() {
102         return academicEducationOfferDao.getOffers();
103     }
104 
105     /***
106      * {@inheritDoc}
107      */
108     public List getCommercialEducationOffers() {
109         return commercialEducationOfferDao.getOffers();
110     }
111 
112     /***
113      * {@inheritDoc}
114      */
115     public AcademicEducationOffer getAcademicEducationOffer(Integer id) {
116         return (AcademicEducationOffer) 
117         	academicEducationOfferDao.getOffer(id);
118     }
119 
120     /***
121      * {@inheritDoc}
122      */
123     public CommercialEducationOffer getCommercialEducationOffer(Integer id) {
124         return (CommercialEducationOffer) 
125         	commercialEducationOfferDao.getOffer(id);
126     }
127 
128     /***
129      * {@inheritDoc}
130      */
131     public int getCommercialEducationsCount() {
132         return commercialEducationOfferDao.getOfferCount();
133     }
134 
135     /***
136      * {@inheritDoc}
137      */
138     public int getAcademicEducationsCount() {
139         return academicEducationOfferDao.getOfferCount();
140     }
141 
142     /***
143      * {@inheritDoc}
144      */
145     public int getEducationsCount() {
146         return commercialEducationOfferDao.getOfferCount() +
147         	academicEducationOfferDao.getOfferCount();
148     }
149 
150 
151     /***
152      * {@inheritDoc}
153      */
154     public void setSearchCriteriaService(
155             SearchCriteriaService searchCriteriaService) {
156         this.searchCriteriaService = searchCriteriaService;
157     }
158 
159     /***
160      * {@inheritDoc}
161      */
162 	public List getCommercialEducationOffers(SearchCriteria searchCriteria)
163             throws IllegalArgumentException {
164 		if (searchCriteria.getClazz().equals(CommercialEducationOffer.class)) {
165             return searchCriteriaService.executeQuery(searchCriteria);
166         }
167         throw new IllegalArgumentException("invalid class type");
168 	}
169 
170     /***
171      * {@inheritDoc}
172      */
173 	public List getAcademicEducationOffers(SearchCriteria searchCriteria)
174              throws IllegalArgumentException {
175 		if (searchCriteria.getClazz().equals(AcademicEducationOffer.class)) {
176             return searchCriteriaService.executeQuery(searchCriteria);
177         }
178         throw new IllegalArgumentException("invalid class type");
179 	}
180 }
181 /***
182  * $Log: EducationServiceImpl.java,v $
183  * Revision 1.2  2005/10/11 09:09:14  stephan_janssen
184  * Code cleanup + CVS tags.
185  *
186  */