Coverage Report - org.kuali.rice.kim.ldap.EntityTypeContactInfoMapper
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityTypeContactInfoMapper
0%
0/28
N/A
1
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.ldap;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.springframework.ldap.core.ContextMapper;
 22  
 import org.springframework.ldap.core.DirContextOperations;
 23  
 import org.springframework.ldap.core.support.AbstractContextMapper;
 24  
 
 25  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 26  
 import org.kuali.rice.kim.api.identity.address.EntityAddress;
 27  
 import org.kuali.rice.kim.api.identity.email.EntityEmail;
 28  
 import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
 29  
 import org.kuali.rice.kim.api.identity.phone.EntityPhone;
 30  
 import org.kuali.rice.kim.util.Constants;
 31  
 
 32  
 import static org.kuali.rice.core.util.BufferedLogger.*;
 33  
 
 34  
 /**
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  0
 public class EntityTypeContactInfoMapper extends AbstractContextMapper {
 39  
     private Constants constants;
 40  
 
 41  
     private EntityAddressMapper addressMapper;
 42  
     private EntityPhoneMapper phoneMapper;
 43  
     private EntityEmailMapper emailMapper;;
 44  
 
 45  
     
 46  
     public Object doMapFromContext(DirContextOperations context) {
 47  0
         final String entityId       = (String) context.getStringAttribute(getConstants().getKimLdapIdProperty());
 48  0
         final String entityTypeCode = (String ) getConstants().getPersonEntityTypeCode();
 49  
 
 50  0
         final EntityTypeContactInfo.Builder builder = EntityTypeContactInfo.Builder.create(entityId, entityTypeCode); 
 51  0
         final EntityAddress.Builder address = getAddressMapper().mapFromContext(context);
 52  0
         final List<EntityAddress.Builder> addresses = new ArrayList<EntityAddress.Builder>();
 53  0
         addresses.add(address);
 54  0
         final List<EntityEmail.Builder> email = new ArrayList<EntityEmail.Builder>();
 55  0
         email.add(getEmailMapper().mapFromContext(context));
 56  0
         final List<EntityPhone.Builder> phone = new ArrayList<EntityPhone.Builder>();
 57  0
         phone.add(getPhoneMapper().mapFromContext(context));
 58  0
         builder.setAddresses(addresses);
 59  0
         builder.setEmailAddresses(email);
 60  0
         builder.setPhoneNumbers(phone);
 61  0
         debug("Created Entity Type with code ", builder.getEntityTypeCode());                
 62  
 
 63  0
         return builder;
 64  
     }
 65  
     
 66  
     /**
 67  
      * Gets the value of constants
 68  
      *
 69  
      * @return the value of constants
 70  
      */
 71  
     public final Constants getConstants() {
 72  0
         return this.constants;
 73  
     }
 74  
 
 75  
     /**
 76  
      * Sets the value of constants
 77  
      *
 78  
      * @param argConstants Value to assign to this.constants
 79  
      */
 80  
     public final void setConstants(final Constants argConstants) {
 81  0
         this.constants = argConstants;
 82  0
     }
 83  
 
 84  
     /**
 85  
      * Gets the value of addressMapper
 86  
      *
 87  
      * @return the value of addressMapper
 88  
      */
 89  
     public final EntityAddressMapper getAddressMapper() {
 90  0
         return this.addressMapper;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Sets the value of addressMapper
 95  
      *
 96  
      * @param argAddressMapper Value to assign to this.addressMapper
 97  
      */
 98  
     public final void setAddressMapper(final EntityAddressMapper argAddressMapper) {
 99  0
         this.addressMapper = argAddressMapper;
 100  0
     }
 101  
 
 102  
     /**
 103  
      * Gets the value of phoneMapper
 104  
      *
 105  
      * @return the value of phoneMapper
 106  
      */
 107  
     public final EntityPhoneMapper getPhoneMapper() {
 108  0
         return this.phoneMapper;
 109  
     }
 110  
 
 111  
     /**
 112  
      * Sets the value of phoneMapper
 113  
      *
 114  
      * @param argPhoneMapper Value to assign to this.phoneMapper
 115  
      */
 116  
     public final void setPhoneMapper(final EntityPhoneMapper argPhoneMapper) {
 117  0
         this.phoneMapper = argPhoneMapper;
 118  0
     }
 119  
 
 120  
     /**
 121  
      * Gets the value of emailMapper
 122  
      *
 123  
      * @return the value of emailMapper
 124  
      */
 125  
     public final EntityEmailMapper getEmailMapper() {
 126  0
         return this.emailMapper;
 127  
     }
 128  
 
 129  
     /**
 130  
      * Sets the value of emailMapper
 131  
      *
 132  
      * @param argEmailMapper Value to assign to this.emailMapper
 133  
      */
 134  
     public final void setEmailMapper(final EntityEmailMapper argEmailMapper) {
 135  0
         this.emailMapper = argEmailMapper;
 136  0
     }
 137  
 }