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 package org.bejug.javacareers.jobs.service;
18
19 import java.util.List;
20 import java.util.Set;
21
22 import org.bejug.javacareers.common.exception.DuplicateUserNameException;
23 import org.bejug.javacareers.common.exception.LastAdminException;
24 import org.bejug.javacareers.jobs.dao.CountryDao;
25 import org.bejug.javacareers.jobs.dao.ParameterDao;
26 import org.bejug.javacareers.jobs.dao.RegionDao;
27 import org.bejug.javacareers.jobs.dao.UserDao;
28 import org.bejug.javacareers.jobs.model.Country;
29 import org.bejug.javacareers.jobs.model.OfferType;
30 import org.bejug.javacareers.jobs.model.OrganisationType;
31 import org.bejug.javacareers.jobs.model.Profile;
32 import org.bejug.javacareers.jobs.model.Region;
33 import org.bejug.javacareers.jobs.model.User;
34
35
36 /***
37 * The User service implementation which will be called by the view. This
38 * can be any view including RUI and/or HTML web clients.
39 *
40 * @author Sven Schauwvliege (Last modified by $Author: shally $)
41 * @version $Revision: 1.4 $ - $Date: 2005/12/09 10:46:56 $
42 */
43 public class AdminServiceImpl implements AdminService {
44
45
46 /***
47 * The user dao.
48 */
49 private UserDao userDao;
50
51 /***
52 * The organisationType dao.
53 */
54 private ParameterDao organisationTypeDao;
55
56 /***
57 * The offerType dao.
58 */
59 private ParameterDao offerTypeDao;
60
61 /***
62 * The country dao.
63 */
64 private CountryDao countryDao;
65
66 /***
67 * The region dao.
68 */
69 private RegionDao regionDao;
70
71
72 /***
73 * the profileDao
74 */
75 private ParameterDao profileDao;
76
77
78
79 /***
80 * Constructor. Parameters are inserted through constructor-injection.
81 * @param userDao the userDao.
82 * @param organisationTypeDao the organisationTypeDao.
83 * @param offerTypeDao the offerTypeDao.
84 * @param countryDao the countryDao.
85 * @param regionDao the regionDao.
86 * @param profileDao the profileDao.
87 */
88 public AdminServiceImpl(UserDao userDao, ParameterDao organisationTypeDao,
89 ParameterDao offerTypeDao, CountryDao countryDao,
90 RegionDao regionDao, ParameterDao profileDao) {
91 this.userDao = userDao;
92 this.organisationTypeDao = organisationTypeDao;
93 this.offerTypeDao = offerTypeDao;
94 this.countryDao = countryDao;
95 this.regionDao = regionDao;
96 this.profileDao = profileDao;
97 }
98
99 /***
100 * Sets the organisationType dao through Springs Ioc.
101 * @param organisationTypeDao the organisationType dao.
102 */
103 public void setOrganisationTypeDao(ParameterDao organisationTypeDao) {
104 this.organisationTypeDao = organisationTypeDao;
105 }
106
107 /***
108 * Sets the user dao through Springs Ioc.
109 * @param userDao the user dao.
110 */
111 public void setUserDao(UserDao userDao) {
112 this.userDao = userDao;
113 }
114
115 /***
116 * @param regionDao The regionDao to set.
117 */
118 public void setRegionDao(RegionDao regionDao) {
119 this.regionDao = regionDao;
120 }
121
122 /***
123 * @param profileDao the profileDao to set.
124 */
125 public void setProfileDao(ParameterDao profileDao) {
126 this.profileDao = profileDao;
127 }
128
129
130
131
132 /***
133 * {@inheritDoc}
134 */
135 public void storeUser(User user)
136 throws DuplicateUserNameException, LastAdminException {
137 userDao.store(user);
138 }
139
140 /***
141 * {@inheritDoc}
142 */
143 public void deleteUser(Integer userId) throws LastAdminException {
144 userDao.deleteUser(userId);
145 }
146
147 /***
148 * {@inheritDoc}
149 */
150 public List getUsers() {
151 return userDao.getUsers();
152 }
153
154 /***
155 * {@inheritDoc}
156 */
157 public User getUser(Integer id) {
158 return userDao.getUser(id);
159 }
160
161 /***
162 * {@inheritDoc}
163 */
164 public User getUserByUserName(String userName) {
165 return userDao.getUserByUserName(userName);
166 }
167
168 /***
169 * {@inheritDoc}
170 */
171 public void storeOrganisationType(OrganisationType organisationType) {
172
173 organisationTypeDao.store(organisationType);
174
175 }
176
177 /***
178 * {@inheritDoc}
179 */
180 public void deleteOrganisationType(Integer id) {
181 organisationTypeDao.deleteParameter(id);
182
183 }
184
185 /***
186 * {@inheritDoc}
187 */
188 public List getOrganisationTypes() {
189 return organisationTypeDao.getParameters();
190 }
191
192 /***
193 * {@inheritDoc}
194 */
195 public OrganisationType getOrganisationType(Integer id) {
196 return (OrganisationType) organisationTypeDao.getParameter(id);
197 }
198
199 /***
200 * {@inheritDoc}
201 */
202 public void deleteOfferType(Integer id) {
203 offerTypeDao.deleteParameter(id);
204
205 }
206
207 /***
208 * {@inheritDoc}
209 */
210 public void storeOfferType(OfferType offerType) {
211 offerTypeDao.store(offerType);
212
213 }
214
215 /***
216 * {@inheritDoc}
217 */
218 public List getOfferTypes() {
219 return offerTypeDao.getParameters();
220 }
221
222 /***
223 * {@inheritDoc}
224 */
225 public OfferType getOfferType(Integer id) {
226 return (OfferType) offerTypeDao.getParameter(id);
227 }
228
229 /***
230 * @param offerTypeDao The offerTypeDao to set.
231 */
232 public void setOfferTypeDao(ParameterDao offerTypeDao) {
233 this.offerTypeDao = offerTypeDao;
234 }
235
236 /***
237 * @param countryDao The countryDao to set.
238 */
239 public void setCountryDao(CountryDao countryDao) {
240 this.countryDao = countryDao;
241 }
242
243 /***
244 * {@inheritDoc}
245 */
246 public void deleteCountry(Integer id) {
247 countryDao.deleteCountry(id);
248
249 }
250
251 /***
252 * {@inheritDoc}
253 */
254 public void storeCountry(Country country) {
255 countryDao.store(country);
256
257 }
258
259 /***
260 * {@inheritDoc}
261 */
262 public List getCountries() {
263 return countryDao.getCountries();
264 }
265
266 /***
267 * {@inheritDoc}
268 */
269 public Country getCountry(Integer id) {
270 return countryDao.getCountry(id);
271 }
272
273 /***
274 * {@inheritDoc}
275 */
276 public Set getRegions(String country) {
277 Country countr = countryDao.getCountryByName(country);
278 if (countr != null){
279 return countr.getRegion();
280 }
281 return null;
282 }
283
284 /***
285 * {@inheritDoc}
286 */
287 public Region getRegionByName(String region) {
288 Region regio = regionDao.getRegionByName(region);
289 return regio;
290 }
291
292 /***
293 * {@inheritDoc}
294 */
295 public void storeProfile(Profile profile) {
296 profileDao.store(profile);
297 }
298
299 /***
300 * {@inheritDoc}
301 */
302 public List getProfiles() {
303 return profileDao.getParameters();
304 }
305
306 /***
307 * {@inheritDoc}
308 */
309 public void deleteProfile(Integer id) {
310 profileDao.deleteParameter(id);
311
312 }
313
314
315
316 }
317 /***
318 * $Log: AdminServiceImpl.java,v $
319 * Revision 1.4 2005/12/09 10:46:56 shally
320 * Opkuis voor checkstyle en PMD
321 *
322 * Revision 1.3 2005/09/06 13:21:44 schauwvliege
323 * Intro if interview
324 *
325 * Revision 1.2 2005/08/31 09:53:40 bavo_jcs
326 * Lucene delete fix
327 *
328 * Revision 1.1 2005/08/26 07:58:31 ge0ffrey
329 * split up the sources in service, serviceimpl and webclient
330 *
331 * Revision 1.16 2005/08/16 09:10:14 bme_jcs
332 * checkstyle errors resolved
333 *
334 * Revision 1.15 2005/08/12 11:56:43 bme_jcs
335 * spring-alike configuration of the caches
336 *
337 * Revision 1.14 2005/08/12 08:33:09 bme_jcs
338 * moved profile-methods from jobservice to adminservice
339 *
340 * Revision 1.13 2005/08/11 12:17:03 bavo_jcs
341 * Role change rule
342 *
343 * Revision 1.12 2005/08/10 14:04:27 bme_jcs
344 * refactoring of adminService
345 *
346 * Revision 1.11 2005/08/10 12:42:47 schauwvliege
347 * added getRegionByName
348 *
349 * Revision 1.6 2005/08/03 13:16:03 bme_jcs
350 * getDao's removed and storeObject renamed to store
351 *
352 * Revision 1.5 2005/07/13 14:19:27 bme_jcs
353 * introduction of constructor-injection
354 *
355 * Revision 1.4 2005/07/05 15:13:11 schauwvliege
356 * added person/contact and location to model
357 *
358 * Revision 1.3 2005/06/14 13:40:04 schauwvliege
359 * Renamed add to store
360 *
361 * Revision 1.2 2005/06/09 08:18:52 bejug_cc
362 * Fix initial import
363 *
364 * Revision 1.12 2005/06/07 12:12:56 ssc
365 * Delete last admin exception
366 *
367 * Revision 1.11 2005/06/06 10:02:24 ssc
368 * Offertype support
369 *
370 * Revision 1.10 2005/05/17 11:59:56 ssc
371 * Refactored User and Publisher class to User Class added cvAdded Boolean, added Address to user, Fixed test to work with this setup
372 *
373 * Revision 1.9 2005/05/12 08:23:55 ssc
374 * Checkstyle errors
375 *
376 * Revision 1.8 2005/05/11 17:21:18 sja
377 * corrected import of DuplicationUserNameException.
378 *
379 * Revision 1.7 2005/05/11 16:30:10 sja
380 * Added CVS last modified tag.
381 *
382 * Revision 1.6 2005/05/11 10:14:52 ssc
383 * Checstyle errors
384 *
385 * Revision 1.5 2005/05/10 14:38:06 ssc
386 * Deleted Salutation
387 *
388 * Revision 1.4 2005/05/10 11:59:33 ssc
389 * Duplicate user/user exception
390 *
391 * Revision 1.3 2005/05/09 13:28:35 bme
392 * updated for the introduction of the 'generalised' parameterhandling
393 *
394 * Revision 1.2 2005/05/03 13:18:05 ssc
395 * Added OrganisationType in AdminService
396 *
397 * Revision 1.1 2005/05/03 11:09:25 ssc
398 * Renamed User service to AdminService
399 *
400 * Revision 1.1 2005/05/02 13:36:15 ssc
401 * First release
402 *
403 *
404 */