1 |
|
package org.kuali.student.lum.bo.options; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
import java.util.List; |
5 |
|
|
6 |
|
import javax.xml.namespace.QName; |
7 |
|
|
8 |
|
import org.apache.commons.lang.StringUtils; |
9 |
|
import org.apache.log4j.Logger; |
10 |
|
import org.kuali.rice.core.resourceloader.GlobalResourceLoader; |
11 |
|
import org.kuali.rice.core.util.KeyLabelPair; |
12 |
|
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesBase; |
13 |
|
import org.kuali.student.common.search.dto.SearchRequest; |
14 |
|
import org.kuali.student.common.search.dto.SearchResultCell; |
15 |
|
import org.kuali.student.common.search.dto.SearchResultRow; |
16 |
|
import org.kuali.student.core.organization.service.OrganizationService; |
17 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 11 |
Complexity Density: 0.41 |
|
18 |
|
public class RemoteOrganizationValuesFinder extends KeyValuesBase { |
19 |
|
|
20 |
|
private static final Logger LOG = Logger.getLogger(RemoteOrganizationValuesFinder.class); |
21 |
|
|
22 |
|
private OrganizationService organizationService; |
23 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 6 |
Complexity Density: 0.29 |
|
24 |
0
|
@Override... |
25 |
|
public List<KeyLabelPair> getKeyValues() { |
26 |
0
|
List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>(); |
27 |
|
|
28 |
0
|
SearchRequest searchRequest = new SearchRequest(); |
29 |
0
|
searchRequest.setSearchKey("org.search.generic"); |
30 |
|
|
31 |
0
|
try { |
32 |
0
|
for (SearchResultRow result : getOrganizationService().search(searchRequest).getRows()) { |
33 |
0
|
String orgId = ""; |
34 |
0
|
String orgShortName = ""; |
35 |
0
|
String orgOptionalLongName = ""; |
36 |
0
|
String orgType = ""; |
37 |
0
|
for (SearchResultCell resultCell : result.getCells()) { |
38 |
0
|
if ("org.resultColumn.orgId".equals(resultCell.getKey())) { |
39 |
0
|
orgId = resultCell.getValue(); |
40 |
0
|
} else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { |
41 |
0
|
orgShortName = resultCell.getValue(); |
42 |
0
|
} else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { |
43 |
0
|
orgOptionalLongName = resultCell.getValue(); |
44 |
0
|
} else if ("org.resultColumn.orgType".equals(resultCell.getKey())) { |
45 |
0
|
orgType = resultCell.getValue(); |
46 |
|
} |
47 |
|
} |
48 |
0
|
departments.add(buildKeyLabelPair(orgId, orgShortName, orgOptionalLongName, orgType)); |
49 |
|
} |
50 |
|
|
51 |
|
} catch (Exception e) { |
52 |
0
|
LOG.error("Error building KeyValues List", e); |
53 |
|
|
54 |
|
|
55 |
|
} |
56 |
|
|
57 |
0
|
return departments; |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
60 |
0
|
protected OrganizationService getOrganizationService() {... |
61 |
0
|
if (organizationService == null) { |
62 |
0
|
organizationService = (OrganizationService) GlobalResourceLoader |
63 |
|
.getService(new QName("http://student.kuali.org/wsdl/organization","OrganizationService")); |
64 |
|
} |
65 |
0
|
return organizationService; |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
@link@link |
70 |
|
|
71 |
|
|
72 |
|
@param |
73 |
|
@param |
74 |
|
@param |
75 |
|
@param |
76 |
|
@return |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
78 |
0
|
protected KeyLabelPair buildKeyLabelPair(String orgId, String orgShortName, String orgLongName, String orgType) {... |
79 |
0
|
if (StringUtils.isBlank(orgShortName)) { |
80 |
0
|
throw new IllegalArgumentException("Blank value for orgShortName is invalid."); |
81 |
|
} |
82 |
|
|
83 |
0
|
return new KeyLabelPair(orgId, (StringUtils.isNotBlank(orgLongName) ? orgLongName : orgShortName) ); |
84 |
|
} |
85 |
|
|
86 |
|
} |