Coverage Report - org.kuali.rice.student.lookup.keyvalues.OrgCocValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
OrgCocValuesFinder
0%
0/39
0%
0/8
4.5
 
 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.kuali.rice.core.util.KeyLabelPair;
 22  
 import org.kuali.student.common.search.dto.SearchParam;
 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 class OrgCocValuesFinder extends StudentKeyValuesBase {
 29  0
         private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class);
 30  
 
 31  
         public static List<KeyLabelPair> findCocOrgs() {
 32  0
         List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>();
 33  
 
 34  0
         List<String> types = new ArrayList<String>();
 35  0
         types.add("kuali.org.College");
 36  0
         types.add("kuali.org.Department");
 37  0
         types.add("kuali.org.Division");
 38  
         
 39  0
         List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2);
 40  0
         SearchParam qpOrgType = new SearchParam();
 41  0
         qpOrgType.setKey("org.queryParam.relationType");
 42  0
         qpOrgType.setValue("kuali.org.CurriculumChild");
 43  0
         queryParamValues.add(qpOrgType);
 44  
         
 45  0
         qpOrgType = new SearchParam();
 46  0
         qpOrgType.setKey("org.queryParam.orgTypeList");
 47  0
         qpOrgType.setValue(types);
 48  0
         queryParamValues.add(qpOrgType);
 49  
         
 50  0
         qpOrgType = new SearchParam();
 51  0
         qpOrgType.setKey("org.queryParam.relatedOrgType");
 52  0
         qpOrgType.setValue("kuali.org.COC");
 53  0
         queryParamValues.add(qpOrgType);
 54  
 
 55  0
         SearchRequest searchRequest = new SearchRequest();
 56  0
         searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgTypeAltr");
 57  0
         searchRequest.setParams(queryParamValues);
 58  
         
 59  
         try {
 60  0
             SearchResult results = getOrganizationService().search(searchRequest);
 61  
 
 62  0
             for (SearchResultRow result : results.getRows()) {
 63  0
                 String orgId = "";
 64  0
                 String orgShortName = "";
 65  0
                 for (SearchResultCell resultCell : result.getCells()) {
 66  0
                     if ("org.resultColumn.orgId".equals(resultCell
 67  
                             .getKey())) {
 68  0
                         orgId = resultCell.getValue();
 69  0
                     } else if ("org.resultColumn.orgShortName"
 70  
                             .equals(resultCell.getKey())) {
 71  0
                         orgShortName = resultCell.getValue();
 72  
                     }
 73  
                 }
 74  0
                 departments.add(buildKeyLabelPair(orgId, orgShortName, null, null));
 75  0
             }
 76  
 
 77  0
             return departments;
 78  0
         } catch (Exception e) {
 79  0
                 LOG.error("Error building KeyValues List", e);
 80  0
             throw new RuntimeException(e);
 81  
         }
 82  
     }
 83  
 
 84  
     @Override
 85  
     public List getKeyValues() {
 86  
 
 87  0
         return findCocOrgs();
 88  
     }
 89  
 
 90  
 }