Coverage Report - org.kuali.rice.student.lookup.keyvalues.CocValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
CocValuesFinder
0%
0/25
0%
0/12
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.SearchParam;
 24  
 import org.kuali.student.common.search.dto.SearchRequest;
 25  
 import org.kuali.student.common.search.dto.SearchResult;
 26  
 import org.kuali.student.common.search.dto.SearchResultCell;
 27  
 import org.kuali.student.common.search.dto.SearchResultRow;
 28  
 
 29  0
 public abstract class CocValuesFinder extends StudentKeyValuesBase {
 30  
 
 31  
         /**
 32  
          * Find the curriculum committee Orgs with specified orgType.
 33  
          * Each org should have a kuali.org.CurriculumParent relationship with
 34  
          * an org with kuali.org.COC type.
 35  
          * 
 36  
          * @param orgType
 37  
          * @return
 38  
          */
 39  
         public static List<KeyLabelPair> findCocOrgs(String orgType) {
 40  0
                 List<KeyLabelPair> orgEntities = new ArrayList<KeyLabelPair>();
 41  
 
 42  0
                 SearchRequest searchRequest = new SearchRequest("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType");
 43  0
                 searchRequest.addParam("org.queryParam.relationType","kuali.org.CurriculumParent");
 44  0
                 searchRequest.addParam("org.queryParam.orgType",orgType);
 45  0
                 searchRequest.addParam("org.queryParam.relatedOrgType","kuali.org.COC");
 46  
 
 47  
                 try {
 48  0
                         SearchResult results = getOrganizationService().search(searchRequest);
 49  
 
 50  0
                         for (SearchResultRow result : results.getRows()) {
 51  0
                                 String orgId = "";
 52  0
                                 String orgShortName = "";
 53  0
                                 String orgLongName = "";
 54  0
                                 for (SearchResultCell resultCell : result.getCells()) {
 55  0
                                         if ("org.resultColumn.orgId".equals(resultCell.getKey())) {
 56  0
                                                 orgId = resultCell.getValue();
 57  0
                                         } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) {
 58  0
                                                 orgShortName = resultCell.getValue();
 59  0
                                         } else if("org.resultColumn.orgLongName".equals(resultCell.getKey())){
 60  0
                                                 orgLongName = resultCell.getValue();
 61  
                                         }
 62  
                                 }
 63  0
                         if (StringUtils.isBlank(orgLongName)) {
 64  
                            //use shortName when longName is blank
 65  0
                             orgEntities.add(buildKeyLabelPair(orgId, orgShortName, null, null));
 66  
                         }
 67  
                         else {
 68  
                             /*
 69  
                              * The requirement is that in the RICE portal, when we add a principal to a role
 70  
                              * the drop-down list for DepartmentCoC or DivisionCoC should display the full/long 
 71  
                              * names instead of short names.
 72  
                              */
 73  0
                             orgEntities.add(new KeyLabelPair(orgId, orgLongName));
 74  
                         }
 75  0
                         }
 76  
 
 77  0
                         return orgEntities;
 78  0
                 } catch (Exception e) {
 79  0
                         throw new RuntimeException(e);
 80  
                 }
 81  
         }
 82  
 }