1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.ldap;
17
18 import org.kuali.rice.kim.api.identity.CodedAttribute;
19 import org.kuali.rice.kim.api.identity.address.EntityAddress;
20 import org.springframework.ldap.core.DirContextOperations;
21
22
23
24
25
26 public class EntityAddressMapper extends BaseMapper<EntityAddress> {
27
28 @Override
29 EntityAddress mapDtoFromContext(DirContextOperations context) {
30 return mapDtoFromContext(context, false);
31 }
32
33 EntityAddress mapDtoFromContext(DirContextOperations context, boolean isdefault) {
34 EntityAddress.Builder builder = mapBuilderFromContext(context, isdefault);
35 return builder != null ? builder.build() : null;
36 }
37
38 EntityAddress.Builder mapBuilderFromContext(DirContextOperations context) {
39 return mapBuilderFromContext(context, false);
40 }
41
42 EntityAddress.Builder mapBuilderFromContext(DirContextOperations context, boolean isdefault) {
43 final EntityAddress.Builder builder = EntityAddress.Builder.create();
44 final String line1 = context.getStringAttribute("employeePrimaryDeptName");
45 final String line2 = context.getStringAttribute("employeePoBox");
46 final String city = context.getStringAttribute("employeeCity");
47 final String stateProvinceCode = context.getStringAttribute("employeeState");
48 final String postalCode = context.getStringAttribute("employeeZip");
49
50 builder.setAddressType(CodedAttribute.Builder.create("WORK"));
51 builder.setLine1(line1);
52 builder.setLine2(line2);
53 builder.setCity(city);
54 builder.setStateProvinceCode(stateProvinceCode);
55 builder.setPostalCode(postalCode);
56 builder.setDefaultValue(isdefault);
57 builder.setActive(true);
58 return builder;
59 }
60
61 }