1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.kuali.student.kim.identity.mock; |
16 |
|
|
17 |
|
import java.util.ArrayList; |
18 |
|
import java.util.List; |
19 |
|
import org.apache.log4j.Logger; |
20 |
|
import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo; |
21 |
|
import org.kuali.rice.kim.bo.entity.dto.KimEntityInfo; |
22 |
|
import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo; |
23 |
|
import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo; |
24 |
|
import org.kuali.rice.kns.datadictionary.validation.DataType; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@author |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 64 (64) |
Complexity: 14 |
Complexity Density: 0.31 |
|
30 |
|
public class DataProviderForKimEntityInfoImpl implements DataProviderForKimEntityInfoInfc { |
31 |
|
|
32 |
|
final static Logger LOG = Logger.getLogger(DataProviderForKimEntityInfoImpl.class); |
33 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
34 |
0
|
public DataProviderForKimEntityInfoImpl() {... |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 7 |
Complexity Density: 0.23 |
|
37 |
0
|
@Override... |
38 |
|
public List<Object> getValues(KimEntityInfo obj, String fieldKey) { |
39 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_FIRST_NAME)) { |
40 |
0
|
List<Object> dvs = new ArrayList(); |
41 |
0
|
for (KimEntityNameInfo nameInfo : obj.getNames()) { |
42 |
0
|
dvs.add(nameInfo.getFirstName()); |
43 |
|
} |
44 |
0
|
return dvs; |
45 |
|
} |
46 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_LAST_NAME)) { |
47 |
0
|
List<Object> dvs = new ArrayList(); |
48 |
0
|
for (KimEntityNameInfo nameInfo : obj.getNames()) { |
49 |
0
|
dvs.add(nameInfo.getLastName()); |
50 |
|
} |
51 |
0
|
return dvs; |
52 |
|
} |
53 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_MIDDLE_NAME)) { |
54 |
0
|
List<Object> dvs = new ArrayList(); |
55 |
0
|
for (KimEntityNameInfo nameInfo : obj.getNames()) { |
56 |
0
|
dvs.add(nameInfo.getMiddleName()); |
57 |
|
} |
58 |
0
|
return dvs; |
59 |
|
} |
60 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PRINCIPALS_PRINCIPALNAME)) { |
61 |
0
|
List<Object> dvs = new ArrayList(); |
62 |
0
|
for (KimPrincipalInfo prinInfo : obj.getPrincipals()) { |
63 |
0
|
dvs.add(prinInfo.getPrincipalName()); |
64 |
|
} |
65 |
0
|
return dvs; |
66 |
|
} |
67 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PRINCIPALS_PRINCIPALID)) { |
68 |
0
|
List<Object> dvs = new ArrayList(); |
69 |
0
|
for (KimPrincipalInfo prinInfo : obj.getPrincipals()) { |
70 |
0
|
dvs.add(prinInfo.getPrincipalId()); |
71 |
|
} |
72 |
0
|
return dvs; |
73 |
|
} |
74 |
0
|
if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_AFFILIATION_TYPE_CODE)) { |
75 |
0
|
List<Object> dvs = new ArrayList(); |
76 |
0
|
for (KimEntityAffiliationInfo affInfo : obj.getAffiliations()) { |
77 |
0
|
dvs.add(affInfo.getAffiliationTypeCode()); |
78 |
|
} |
79 |
0
|
return dvs; |
80 |
|
} |
81 |
0
|
throw new IllegalArgumentException("Search criteria " + fieldKey + " is not supported"); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
84 |
0
|
@Override... |
85 |
|
public DataType getDataType(String fieldKey) { |
86 |
0
|
for (String supportedKey : IdentityServiceConstants.SUPPORTED_SEARCH_FIELD_KEYS) { |
87 |
0
|
if (supportedKey.equals(fieldKey)) { |
88 |
0
|
return DataType.STRING; |
89 |
|
} |
90 |
|
} |
91 |
0
|
throw new IllegalArgumentException("Search criteria " + fieldKey + " is not supported"); |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
94 |
0
|
@Override... |
95 |
|
public boolean supportsField(String fieldKey) { |
96 |
0
|
try { |
97 |
0
|
getDataType(fieldKey); |
98 |
0
|
return true; |
99 |
|
} catch (IllegalArgumentException ex) { |
100 |
0
|
return false; |
101 |
|
} |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
104 |
0
|
@Override... |
105 |
|
public Object parseValue(String fieldKey, String value) throws IllegalArgumentException { |
106 |
0
|
DataType dt = this.getDataType(fieldKey); |
107 |
0
|
switch (dt) { |
108 |
0
|
case STRING: |
109 |
0
|
return value.toLowerCase(); |
110 |
0
|
default: |
111 |
0
|
throw new IllegalArgumentException("Search criteria " + fieldKey + " has a data type that is not supported"); |
112 |
|
} |
113 |
|
|
114 |
|
} |
115 |
|
} |