View Javadoc

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