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.springframework.ldap.core.DirContextOperations;
19 import org.springframework.ldap.core.support.AbstractContextMapper;
20
21 import org.kuali.rice.kim.api.identity.CodedAttribute;
22 import org.kuali.rice.kim.api.identity.address.EntityAddress;
23 import org.kuali.rice.kim.util.Constants;
24
25
26
27
28
29 public class EntityAddressMapper extends AbstractContextMapper {
30 private Constants constants;
31
32 public EntityAddress.Builder mapFromContext(DirContextOperations context, boolean isdefault) {
33 return (EntityAddress.Builder) doMapFromContext(context, isdefault);
34 }
35
36 public EntityAddress.Builder mapFromContext(DirContextOperations context) {
37 return mapFromContext(context, false);
38 }
39
40 public Object doMapFromContext(DirContextOperations context) {
41 return doMapFromContext(context, false);
42 }
43
44 protected Object doMapFromContext(DirContextOperations context, boolean isdefault) {
45 final EntityAddress.Builder builder = EntityAddress.Builder.create();
46 final String line1 = context.getStringAttribute("employeePrimaryDeptName");
47 final String line2 = context.getStringAttribute("employeePoBox");
48 final String city = context.getStringAttribute("employeeCity");
49 final String stateProvinceCode = context.getStringAttribute("employeeState");
50 final String postalCode = context.getStringAttribute("employeeZip");
51
52 builder.setAddressType(CodedAttribute.Builder.create("WORK"));
53 builder.setLine1(line1);
54 builder.setLine2(line2);
55 builder.setCity(city);
56 builder.setStateProvinceCode(stateProvinceCode);
57 builder.setPostalCode(postalCode);
58 builder.setDefaultValue(isdefault);
59 builder.setActive(true);
60 return builder;
61 }
62
63
64
65
66
67
68
69 public final Constants getConstants() {
70 return this.constants;
71 }
72
73
74
75
76
77
78 public final void setConstants(final Constants argConstants) {
79 this.constants = argConstants;
80 }
81 }