Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CocValuesFinder |
|
| 10.0;10 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.rice.student.lookup.keyvalues; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.List; | |
20 | ||
21 | import org.apache.commons.lang.StringUtils; | |
22 | import org.kuali.rice.core.util.KeyLabelPair; | |
23 | import org.kuali.student.common.search.dto.SearchRequest; | |
24 | import org.kuali.student.common.search.dto.SearchResult; | |
25 | import org.kuali.student.common.search.dto.SearchResultCell; | |
26 | import org.kuali.student.common.search.dto.SearchResultRow; | |
27 | ||
28 | 0 | public abstract class CocValuesFinder extends StudentKeyValuesBase { |
29 | ||
30 | /** | |
31 | * Find the curriculum committee Orgs with specified orgType. | |
32 | * Each org should have a kuali.org.CurriculumParent relationship with | |
33 | * an org with kuali.org.COC type. | |
34 | * | |
35 | * @param orgType | |
36 | * @return | |
37 | */ | |
38 | public static List<KeyLabelPair> findCocOrgs(String orgType) { | |
39 | 0 | List<KeyLabelPair> orgEntities = new ArrayList<KeyLabelPair>(); |
40 | ||
41 | 0 | SearchRequest searchRequest = new SearchRequest("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType"); |
42 | 0 | searchRequest.addParam("org.queryParam.relationType","kuali.org.CurriculumParent"); |
43 | 0 | searchRequest.addParam("org.queryParam.orgType",orgType); |
44 | 0 | searchRequest.addParam("org.queryParam.relatedOrgType","kuali.org.COC"); |
45 | ||
46 | try { | |
47 | 0 | SearchResult results = getOrganizationService().search(searchRequest); |
48 | ||
49 | 0 | for (SearchResultRow result : results.getRows()) { |
50 | 0 | String orgId = ""; |
51 | 0 | String orgShortName = ""; |
52 | 0 | String orgLongName = ""; |
53 | 0 | for (SearchResultCell resultCell : result.getCells()) { |
54 | 0 | if ("org.resultColumn.orgId".equals(resultCell.getKey())) { |
55 | 0 | orgId = resultCell.getValue(); |
56 | 0 | } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { |
57 | 0 | orgShortName = resultCell.getValue(); |
58 | 0 | } else if("org.resultColumn.orgLongName".equals(resultCell.getKey())){ |
59 | 0 | orgLongName = resultCell.getValue(); |
60 | } | |
61 | } | |
62 | 0 | if (StringUtils.isBlank(orgLongName)) { |
63 | //use shortName when longName is blank | |
64 | 0 | orgEntities.add(buildKeyLabelPair(orgId, orgShortName, null, null)); |
65 | } | |
66 | else { | |
67 | /* | |
68 | * The requirement is that in the RICE portal, when we add a principal to a role | |
69 | * the drop-down list for DepartmentCoC or DivisionCoC should display the full/long | |
70 | * names instead of short names. | |
71 | */ | |
72 | 0 | orgEntities.add(new KeyLabelPair(orgId, orgLongName)); |
73 | } | |
74 | 0 | } |
75 | ||
76 | 0 | return orgEntities; |
77 | 0 | } catch (Exception e) { |
78 | 0 | throw new RuntimeException(e); |
79 | } | |
80 | } | |
81 | } |