Coverage Report - org.kuali.student.process.poc.ProcessPocIdentityServiceDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessPocIdentityServiceDecorator
0%
0/34
0%
0/4
1.75
 
 1  
 /*
 2  
  * To change this template, choose Tools | Templates
 3  
  * and open the template in the editor.
 4  
  */
 5  
 package org.kuali.student.process.poc;
 6  
 
 7  
 import java.util.Arrays;
 8  
 import org.kuali.rice.kim.api.identity.IdentityService;
 9  
 import org.kuali.rice.kim.api.identity.entity.Entity;
 10  
 import org.kuali.rice.kim.api.identity.name.EntityName;
 11  
 import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics;
 12  
 import org.kuali.student.kim.permission.mock.IdentityServiceDecorator;
 13  
 import org.kuali.student.r2.common.util.constants.KimIdentityServiceConstants;
 14  
 
 15  
 /**
 16  
  *
 17  
  * @author nwright
 18  
  */
 19  
 public class ProcessPocIdentityServiceDecorator extends IdentityServiceDecorator {
 20  
     
 21  0
     public ProcessPocIdentityServiceDecorator (IdentityService nextDecorator) {
 22  0
         this.setNextDecorator(nextDecorator);
 23  0
         this._initializeData ();
 24  0
     }
 25  
     
 26  
     private void _initializeData () {
 27  0
         for (ProcessPocPersonEnum person : ProcessPocPersonEnum.values()) {
 28  0
             _createPerson (person);
 29  
         }
 30  0
     }
 31  
     private void _createPerson (ProcessPocPersonEnum person) {
 32  0
         Entity.Builder entity = Entity.Builder.create();
 33  0
         entity.setId(person.getPersonId() + "");
 34  0
         entity.setActive(true);
 35  0
         EntityName.Builder name = EntityName.Builder.create();
 36  0
         name.setActive(true);
 37  0
         name.setDefaultValue(true);
 38  0
         name.setEntityId(person.getEntityId());
 39  0
         name.setFirstName(person.getFirstName());
 40  0
         name.setId(person.getEntityId());
 41  0
         name.setLastName(person.getLastName());
 42  0
         name.setMiddleName(person.getMiddleName());
 43  0
         name.setNamePrefix(person.getTitle());
 44  0
         name.setNameType(KimIdentityServiceConstants.PREFERRED_NAME_CODED_ATTRIBUTE);
 45  0
         name.setNameSuffix(person.getSuffix());
 46  0
         name.setVersionNumber(0l);
 47  0
         entity.setNames(Arrays.asList(name));
 48  0
         EntityBioDemographics.Builder bio = EntityBioDemographics.Builder.create(person.getEntityId(), person.getGender());
 49  0
         bio.setBirthDate(_nullIt (person.getBirthDate()));
 50  0
         bio.setDeceasedDate(_nullIt (person.getDeceasedDate()));
 51  0
         bio.setVersionNumber(0l);
 52  0
         entity.setBioDemographics(bio);
 53  0
         entity.setVersionNumber(0l);
 54  0
         this.createEntity(entity.build());
 55  0
     }
 56  
     
 57  
     private String _nullIt (String str) {
 58  0
         if (str.isEmpty()) {
 59  0
             return null;
 60  
         }
 61  0
         return str;
 62  
     }
 63  
 }