| 1 |
|
package org.kuali.rice.student.lookup.keyvalues; |
| 2 |
|
|
| 3 |
|
import java.util.ArrayList; |
| 4 |
|
import java.util.List; |
| 5 |
|
|
| 6 |
|
import javax.xml.namespace.QName; |
| 7 |
|
|
| 8 |
|
import org.kuali.rice.core.resourceloader.GlobalResourceLoader; |
| 9 |
|
import org.kuali.rice.core.util.KeyLabelPair; |
| 10 |
|
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesBase; |
| 11 |
|
import org.kuali.student.common.search.dto.SearchRequest; |
| 12 |
|
import org.kuali.student.common.search.dto.SearchResult; |
| 13 |
|
import org.kuali.student.common.search.dto.SearchResultCell; |
| 14 |
|
import org.kuali.student.common.search.dto.SearchResultRow; |
| 15 |
|
import org.kuali.student.core.organization.service.OrganizationService; |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 6 |
Complexity Density: 0.23 |
|
| 17 |
|
public class DepartmentValuesFinder extends KeyValuesBase { |
| 18 |
|
private static OrganizationService organizationService; |
| 19 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 20 |
0
|
protected static OrganizationService getOrganizationService() {... |
| 21 |
0
|
if (organizationService == null) { |
| 22 |
0
|
organizationService = (OrganizationService) GlobalResourceLoader |
| 23 |
|
.getService(new QName( |
| 24 |
|
"http://student.kuali.org/wsdl/organization", |
| 25 |
|
"OrganizationService")); |
| 26 |
|
} |
| 27 |
0
|
return organizationService; |
| 28 |
|
} |
| 29 |
|
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 4 |
Complexity Density: 0.17 |
|
| 30 |
0
|
@Override... |
| 31 |
|
public List getKeyValues() { |
| 32 |
0
|
List<KeyLabelPair> orgEntities = new ArrayList<KeyLabelPair>(); |
| 33 |
|
|
| 34 |
0
|
SearchRequest searchRequest = new SearchRequest("org.search.generic"); |
| 35 |
0
|
List<String> orgTypes = new ArrayList<String>(); |
| 36 |
0
|
orgTypes.add("kuali.org.Department"); |
| 37 |
0
|
orgTypes.add("kuali.org.College"); |
| 38 |
0
|
orgTypes.add("kuali.org.Division"); |
| 39 |
0
|
orgTypes.add("kuali.org.Office"); |
| 40 |
0
|
orgTypes.add("kuali.org.School"); |
| 41 |
0
|
searchRequest.addParam("org.queryParam.orgOptionalType", orgTypes); |
| 42 |
0
|
searchRequest.setSortColumn("org.resultColumn.orgOptionalLongName"); |
| 43 |
0
|
try { |
| 44 |
0
|
SearchResult results = getOrganizationService().search(searchRequest); |
| 45 |
|
|
| 46 |
0
|
for (SearchResultRow result : results.getRows()) { |
| 47 |
0
|
String orgId = null; |
| 48 |
0
|
String orgLongName = null; |
| 49 |
0
|
for (SearchResultCell resultCell : result.getCells()) { |
| 50 |
0
|
if ("org.resultColumn.orgId".equals(resultCell.getKey())) { |
| 51 |
0
|
orgId = resultCell.getValue(); |
| 52 |
0
|
} else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { |
| 53 |
0
|
orgLongName = resultCell.getValue(); |
| 54 |
|
} |
| 55 |
|
} |
| 56 |
0
|
orgEntities.add(new KeyLabelPair(orgId, orgLongName)); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
0
|
return orgEntities; |
| 60 |
|
} catch (Exception e) { |
| 61 |
0
|
throw new RuntimeException(e); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
} |