Coverage Report - org.kuali.rice.student.lookup.keyvalues.OrgsOfTypeValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
OrgsOfTypeValuesFinder
0%
0/20
0%
0/8
8
 
 1  
 package org.kuali.rice.student.lookup.keyvalues;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.apache.commons.lang.StringUtils;
 7  
 import org.kuali.rice.core.util.KeyLabelPair;
 8  
 import org.kuali.student.common.search.dto.SearchRequest;
 9  
 import org.kuali.student.common.search.dto.SearchResult;
 10  
 import org.kuali.student.common.search.dto.SearchResultCell;
 11  
 import org.kuali.student.common.search.dto.SearchResultRow;
 12  
 import org.kuali.student.common.search.dto.SortDirection;
 13  
 
 14  0
 public abstract class OrgsOfTypeValuesFinder extends StudentKeyValuesBase {
 15  
 
 16  
         /**
 17  
          * Find the Orgs with specified orgType.
 18  
          * 
 19  
          * @param orgType
 20  
          * @return
 21  
          */
 22  
         public static List<KeyLabelPair> findOrgs(String orgType) {
 23  0
                 List<KeyLabelPair> orgEntities = new ArrayList<KeyLabelPair>();
 24  
 
 25  0
                 SearchRequest searchRequest = new SearchRequest("org.search.generic");
 26  0
                 searchRequest.addParam("org.queryParam.orgOptionalType",orgType);
 27  0
                 searchRequest.setSortColumn("org.resultColumn.orgOptionalLongName");
 28  0
                 searchRequest.setSortDirection(SortDirection.ASC);
 29  
                 try {
 30  0
                         SearchResult results = getOrganizationService().search(searchRequest);
 31  
 
 32  0
                         for (SearchResultRow result : results.getRows()) {
 33  0
                                 String orgId = "";
 34  0
                                 String orgLongName = "";
 35  0
                                 for (SearchResultCell resultCell : result.getCells()) {
 36  0
                                         if ("org.resultColumn.orgId".equals(resultCell.getKey())) {
 37  0
                                                 orgId = resultCell.getValue();
 38  0
                                         } else if("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())){
 39  0
                                                 orgLongName = resultCell.getValue();
 40  
                                         }
 41  
                                 }
 42  
                     /*
 43  
                      * The requirement is that in the RICE portal, when we add a principal to a role
 44  
                      * the drop-down list for Department or Division should display the full/long 
 45  
                      * names instead of short names.
 46  
                      */
 47  0
                     orgEntities.add(new KeyLabelPair(orgId, orgLongName));
 48  0
                         }
 49  
 
 50  0
                         return orgEntities;
 51  0
                 } catch (Exception e) {
 52  0
                         throw new RuntimeException(e);
 53  
                 }
 54  
         }
 55  
 }