View Javadoc

1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.service.impl;
17  
18  import org.kuali.rice.core.api.criteria.QueryByCriteria;
19  import org.kuali.rice.kim.api.identity.IdentityArchiveService;
20  import org.kuali.rice.kim.api.identity.IdentityService;
21  import org.kuali.rice.kim.api.identity.Type;
22  import org.kuali.rice.kim.api.identity.address.EntityAddress;
23  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
24  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationType;
25  import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship;
26  import org.kuali.rice.kim.api.identity.email.EntityEmail;
27  import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
28  import org.kuali.rice.kim.api.identity.entity.Entity;
29  import org.kuali.rice.kim.api.identity.entity.EntityDefault;
30  import org.kuali.rice.kim.api.identity.entity.EntityDefaultQueryResults;
31  import org.kuali.rice.kim.api.identity.entity.EntityQueryResults;
32  import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier;
33  import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierType;
34  import org.kuali.rice.kim.api.identity.name.EntityName;
35  import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics;
36  import org.kuali.rice.kim.api.identity.personal.EntityEthnicity;
37  import org.kuali.rice.kim.api.identity.phone.EntityPhone;
38  import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
39  import org.kuali.rice.kim.api.identity.principal.Principal;
40  import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences;
41  import org.kuali.rice.kim.api.identity.residency.EntityResidency;
42  import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
43  import org.kuali.rice.kim.api.identity.visa.EntityVisa;
44  import org.kuali.rice.kim.util.KIMWebServiceConstants;
45  
46  import javax.jws.WebParam;
47  import javax.jws.WebService;
48  import java.util.List;
49  import java.util.Map;
50  
51  /**
52   * This IdentityService implementation is largely just a knee-jerk delegator, except for
53   * getters returning {@link EntityDefault} in which case the IdentityArchiveService
54   * will be invoked if the inner IndentityService impl returns null.
55   * 
56   * @author Kuali Rice Team (rice.collab@kuali.org)
57   */
58  
59  @WebService(endpointInterface = KIMWebServiceConstants.IdentityService.INTERFACE_CLASS, serviceName = KIMWebServiceConstants.IdentityService.WEB_SERVICE_NAME, portName = KIMWebServiceConstants.IdentityService.WEB_SERVICE_PORT, targetNamespace = KIMWebServiceConstants.MODULE_TARGET_NAMESPACE)
60  public class IdentityCurrentAndArchivedServiceImpl implements IdentityService {
61  
62  	private final IdentityArchiveService identityArchiveService;
63  	private final IdentityService innerIdentityService;
64  	
65  	/**
66  	 * This constructs a IdentityCurrentAndArchivedServiceImpl, injecting the
67  	 * needed services.
68  	 */
69  	public IdentityCurrentAndArchivedServiceImpl(IdentityService innerIdentityService, 
70  			IdentityArchiveService identityArchiveService) {
71  		this.innerIdentityService = innerIdentityService;
72  		this.identityArchiveService = identityArchiveService;
73  	}
74  	
75  	/**
76  	 * @see org.kuali.rice.kim.api.identity.IdentityService#getAddressType(java.lang.String)
77  	 */
78  	public Type getAddressType(String code) {
79  		return getInnerIdentityService().getAddressType(code);
80  	}
81  
82      /**
83  	 * @see org.kuali.rice.kim.api.identity.IdentityService#getAffiliationType(java.lang.String)
84  	 */
85  	public EntityAffiliationType getAffiliationType(String code) {
86  		return getInnerIdentityService().getAffiliationType(code);
87  	}
88  
89      /**
90  	 * @see org.kuali.rice.kim.api.identity.IdentityService#getCitizenshipStatus(java.lang.String)
91  	 */
92  	public Type getCitizenshipStatus(String code) {
93  		return Type.Builder.create(getInnerIdentityService().getCitizenshipStatus(code)).build();
94  	}
95  
96      /**
97  	 * @see org.kuali.rice.kim.api.identity.IdentityService#getDefaultNamesForEntityIds(java.util.List)
98  	 */
99  	public Map<String, EntityNamePrincipalName> getDefaultNamesForEntityIds(
100 			List<String> entityIds) {
101 		return getInnerIdentityService().getDefaultNamesForEntityIds(entityIds);
102 	}
103 
104     @Override
105     public EntityName addNameToEntity(EntityName name) {
106         return getInnerIdentityService().addNameToEntity(name);
107     }
108 
109     @Override
110     public EntityName updateName(EntityName name) {
111         return getInnerIdentityService().updateName(name);
112     }
113 
114     @Override
115     public EntityName inactivateName(String id) {
116         return getInnerIdentityService().inactivateName(id);
117     }
118 
119     @Override
120     public EntityEmployment addEmploymentToEntity(EntityEmployment employment) {
121         return getInnerIdentityService().addEmploymentToEntity(employment);
122     }
123 
124     @Override
125     public EntityEmployment updateEmployment(EntityEmployment employment) {
126         return getInnerIdentityService().updateEmployment(employment);
127     }
128 
129     @Override
130     public EntityEmployment inactivateEmployment(String id) {
131         return getInnerIdentityService().inactivateEmployment(id);
132     }
133 
134     @Override
135     public EntityBioDemographics addBioDemographicsToEntity(EntityBioDemographics bioDemographics) {
136         return getInnerIdentityService().addBioDemographicsToEntity(bioDemographics);
137     }
138 
139     @Override
140     public EntityBioDemographics updateBioDemographics(EntityBioDemographics bioDemographics) {
141         return getInnerIdentityService().updateBioDemographics(bioDemographics);
142     }
143 
144     /**
145 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getDefaultNamesForPrincipalIds(java.util.List)
146 	 */
147 	public Map<String, EntityNamePrincipalName> getDefaultNamesForPrincipalIds(
148 			List<String> principalIds) {
149 		return getInnerIdentityService().getDefaultNamesForPrincipalIds(principalIds);
150 	}
151 
152 	/**
153 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEmailType(java.lang.String)
154 	 */
155 	public Type getEmailType(String code) {
156 		return getInnerIdentityService().getEmailType(code);
157 	}
158 
159     /**
160 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEmploymentStatus(java.lang.String)
161 	 */
162 	public Type getEmploymentStatus(String code) {
163 		return getInnerIdentityService().getEmploymentStatus(code);
164 	}
165 
166 
167     /**
168 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEmploymentType(java.lang.String)
169 	 */
170 	public Type getEmploymentType(String code) {
171 		return getInnerIdentityService().getEmploymentType(code);
172 	}
173 
174 
175     /**
176 	 * This method first tries the inner IdentityService impl, and resorts to
177 	 * the IdentityArchiveService if need be.
178 	 * 
179 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityDefault(java.lang.String)
180 	 */
181 	public EntityDefault getEntityDefault(String entityId) {
182 		EntityDefault entity = getInnerIdentityService().getEntityDefault(entityId);
183     	if ( entity == null ) {
184     		entity = getIdentityArchiveService().getEntityDefaultFromArchive(entityId);
185     	} else {
186 			getIdentityArchiveService().saveEntityDefaultToArchive(entity);
187     	}
188 		return entity;
189 	}
190 
191 	/**
192 	 * This method first tries the inner IdentityService impl, and resorts to
193 	 * the IdentityArchiveService if need be.
194 	 * 
195 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityDefaultByPrincipalId(java.lang.String)
196 	 */
197 	public EntityDefault getEntityDefaultByPrincipalId(String principalId) {
198 		EntityDefault entity = getInnerIdentityService().getEntityDefaultByPrincipalId(principalId);
199     	if ( entity == null ) {
200     		entity = getIdentityArchiveService().getEntityDefaultFromArchiveByPrincipalId(principalId);
201     	} else {
202 			getIdentityArchiveService().saveEntityDefaultToArchive(entity);
203     	}
204     	return entity;
205 	}
206 
207 	/**
208 	 * This method first tries the inner IdentityService impl, and resorts to
209 	 * the IdentityArchiveService if need be.
210 	 * 
211 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityDefaultByPrincipalName(java.lang.String)
212 	 */
213 	public EntityDefault getEntityDefaultByPrincipalName(String principalName) {
214 		EntityDefault entity = getInnerIdentityService().getEntityDefaultByPrincipalName(principalName);
215     	if ( entity == null ) {
216     		entity = getIdentityArchiveService().getEntityDefaultFromArchiveByPrincipalName(principalName);
217     	} else {
218 			getIdentityArchiveService().saveEntityDefaultToArchive(entity);
219     	}
220     	return entity;
221 	}
222 
223     @Override
224     public EntityDefaultQueryResults findEntityDefaults(@WebParam(name = "query") QueryByCriteria queryByCriteria) {
225         return getInnerIdentityService().findEntityDefaults(queryByCriteria);
226     }
227 
228     @Override
229     public EntityQueryResults findEntities(@WebParam(name = "query") QueryByCriteria queryByCriteria) {
230         return getInnerIdentityService().findEntities(queryByCriteria);
231     }
232 
233     /**
234 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntity(java.lang.String)
235 	 */
236 	public Entity getEntity(String entityId) {
237 		return getInnerIdentityService().getEntity(entityId);
238 	}
239 
240 	/**
241 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityByPrincipalId(java.lang.String)
242 	 */
243 	public Entity getEntityByPrincipalId(String principalId) {
244 		return getInnerIdentityService().getEntityByPrincipalId(principalId);
245 	}
246 
247 	/**
248 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityByPrincipalName(java.lang.String)
249 	 */
250 	public Entity getEntityByPrincipalName(String principalName) {
251 		return getInnerIdentityService().getEntityByPrincipalName(principalName);
252 	}
253 
254 
255     @Override
256     public Entity createEntity(Entity entity) {
257         return getInnerIdentityService().createEntity(entity);
258     }
259 
260     @Override
261     public Entity updateEntity(Entity entity) {
262         return getInnerIdentityService().updateEntity(entity);
263     }
264 
265     @Override
266     public Entity inactivateEntity(String entityId) {
267         return getInnerIdentityService().inactivateEntity(entityId);
268     }
269 
270     /**
271 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getNameType(java.lang.String)
272 	 */
273 	public Type getNameType(String code) {
274 		return getInnerIdentityService().getNameType(code);
275 	}
276 
277     /**
278 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityPrivacyPreferences(java.lang.String)
279 	 */
280 	public EntityPrivacyPreferences getEntityPrivacyPreferences(
281 			String entityId) {
282 		return getInnerIdentityService().getEntityPrivacyPreferences(entityId);
283 	}
284 
285     @Override
286     public EntityPrivacyPreferences addPrivacyPreferencesToEntity(EntityPrivacyPreferences privacyPreferences) {
287         return getInnerIdentityService().addPrivacyPreferencesToEntity(privacyPreferences);
288     }
289 
290     @Override
291     public EntityPrivacyPreferences updatePrivacyPreferences(EntityPrivacyPreferences privacyPreferences) {
292         return getInnerIdentityService().updatePrivacyPreferences(privacyPreferences);
293     }
294 
295     @Override
296     public EntityCitizenship addCitizenshipToEntity(EntityCitizenship citizenship) {
297         return getInnerIdentityService().addCitizenshipToEntity(citizenship);
298     }
299 
300     @Override
301     public EntityCitizenship updateCitizenship(EntityCitizenship citizenship) {
302         return getInnerIdentityService().updateCitizenship(citizenship);
303     }
304 
305     @Override
306     public EntityCitizenship inactivateCitizenship(String id) {
307         return getInnerIdentityService().inactivateCitizenship(id);
308     }
309 
310     @Override
311     public EntityEthnicity addEthnicityToEntity(EntityEthnicity ethnicity) {
312         return getInnerIdentityService().addEthnicityToEntity(ethnicity);
313     }
314 
315     @Override
316     public EntityEthnicity updateEthnicity(EntityEthnicity ethnicity) {
317         return getInnerIdentityService().updateEthnicity(ethnicity);
318     }
319 
320     @Override
321     public EntityResidency addResidencyToEntity(EntityResidency residency) {
322         return getInnerIdentityService().addResidencyToEntity(residency);
323     }
324 
325     @Override
326     public EntityResidency updateResidency(EntityResidency residency) {
327         return getInnerIdentityService().updateResidency(residency);
328     }
329 
330     @Override
331     public EntityVisa addVisaToEntity(EntityVisa visa) {
332         return getInnerIdentityService().addVisaToEntity(visa);
333     }
334 
335     @Override
336     public EntityVisa updateVisa(EntityVisa visa) {
337         return getInnerIdentityService().updateVisa(visa);
338     }
339 
340     /**
341 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getEntityType(java.lang.String)
342 	 */
343 	public Type getEntityType(String code) {
344 		return getInnerIdentityService().getEntityType(code);
345 	}
346 
347     /**
348 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getExternalIdentifierType(java.lang.String)
349 	 */
350 	public EntityExternalIdentifierType getExternalIdentifierType(String code) {
351 		return getInnerIdentityService().getExternalIdentifierType(code);
352 	}
353 
354 
355 	/**
356 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getPhoneType(java.lang.String)
357 	 */
358 	public Type getPhoneType(String code) {
359 		return getInnerIdentityService().getPhoneType(code);
360 	}
361 
362     /**
363 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getPrincipal(java.lang.String)
364 	 */
365 	public Principal getPrincipal(String principalId) {
366 		return getInnerIdentityService().getPrincipal(principalId);
367 	}
368 
369 	/**
370 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getPrincipalByPrincipalName(java.lang.String)
371 	 */
372 	public Principal getPrincipalByPrincipalName(String principalName) {
373 		return getInnerIdentityService().getPrincipalByPrincipalName(principalName);
374 	}
375 
376 	/**
377 	 * @see org.kuali.rice.kim.api.identity.IdentityService#getPrincipalByPrincipalNameAndPassword(java.lang.String, java.lang.String)
378 	 */
379 	public Principal getPrincipalByPrincipalNameAndPassword(
380 			String principalName, String password) {
381 		return getInnerIdentityService().getPrincipalByPrincipalNameAndPassword(
382 				principalName, password);
383 	}
384 
385     @Override
386     public Principal addPrincipalToEntity(Principal principal) {
387         return getInnerIdentityService().addPrincipalToEntity(principal);
388     }
389 
390     @Override
391     public Principal updatePrincipal(Principal principal) {
392         return getInnerIdentityService().updatePrincipal(principal);
393     }
394 
395     @Override
396     public Principal inactivatePrincipal(String principalId) {
397         return getInnerIdentityService().inactivatePrincipal(principalId);
398     }
399 
400     @Override
401     public Principal inactivatePrincipalByName(String principalName) {
402         return getInnerIdentityService().inactivatePrincipalByName(principalName);
403     }
404 
405     @Override
406     public EntityTypeContactInfo addEntityTypeContactInfoToEntity(EntityTypeContactInfo entityTypeContactInfo) {
407         return getInnerIdentityService().addEntityTypeContactInfoToEntity(entityTypeContactInfo);
408     }
409 
410     @Override
411     public EntityTypeContactInfo updateEntityTypeContactInfo(EntityTypeContactInfo entityTypeContactInfo) {
412         return getInnerIdentityService().updateEntityTypeContactInfo(entityTypeContactInfo);
413     }
414 
415     @Override
416     public EntityTypeContactInfo inactivateEntityTypeContactInfo(String entityId, String entityTypeCode) {
417         return getInnerIdentityService().inactivateEntityTypeContactInfo(entityId, entityTypeCode);
418     }
419 
420     @Override
421     public EntityAddress addAddressToEntity(EntityAddress address) {
422         return getInnerIdentityService().addAddressToEntity(address);
423     }
424 
425     @Override
426     public EntityAddress updateAddress(EntityAddress address) {
427         return getInnerIdentityService().updateAddress(address);
428     }
429 
430     @Override
431     public EntityAddress inactivateAddress(String addressId) {
432         return getInnerIdentityService().inactivateAddress(addressId);
433     }
434 
435     @Override
436     public EntityEmail addEmailToEntity(EntityEmail email) {
437         return getInnerIdentityService().addEmailToEntity(email);
438     }
439 
440     @Override
441     public EntityEmail updateEmail(EntityEmail email) {
442         return getInnerIdentityService().updateEmail(email);
443     }
444 
445     @Override
446     public EntityEmail inactivateEmail(String emailId) {
447         return getInnerIdentityService().inactivateEmail(emailId);
448     }
449 
450     @Override
451     public EntityPhone addPhoneToEntity(EntityPhone phone) {
452         return getInnerIdentityService().addPhoneToEntity(phone);
453     }
454 
455     @Override
456     public EntityPhone updatePhone(EntityPhone phone) {
457         return getInnerIdentityService().updatePhone(phone);
458     }
459 
460     @Override
461     public EntityPhone inactivatePhone(String phoneId) {
462         return getInnerIdentityService().inactivatePhone(phoneId);
463     }
464 
465     @Override
466     public EntityExternalIdentifier addExternalIdentifierToEntity(EntityExternalIdentifier externalId) {
467         return getInnerIdentityService().addExternalIdentifierToEntity(externalId);
468     }
469 
470     @Override
471     public EntityExternalIdentifier updateExternalIdentifier(EntityExternalIdentifier externalId) {
472         return getInnerIdentityService().updateExternalIdentifier(externalId);
473     }
474 
475     @Override
476     public EntityAffiliation addAffiliationToEntity(EntityAffiliation affiliation) {
477         return getInnerIdentityService().addAffiliationToEntity(affiliation);
478     }
479 
480     @Override
481     public EntityAffiliation updateAffiliation(EntityAffiliation affiliation) {
482         return getInnerIdentityService().updateAffiliation(affiliation);
483     }
484 
485     @Override
486     public EntityAffiliation inactivateAffiliation(String id) {
487         return getInnerIdentityService().inactivateAffiliation(id);
488     }
489 
490 
491 	private IdentityService getInnerIdentityService() {
492 		return innerIdentityService;
493 	}
494 	
495 	private IdentityArchiveService getIdentityArchiveService() {
496 		return identityArchiveService;
497 	}
498 
499 }