Coverage Report - org.kuali.rice.student.lookup.keyvalues.CocValuesFiinder
 
Classes in this File Line Coverage Branch Coverage Complexity
CocValuesFiinder
0%
0/32
0%
0/8
8
 
 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.core.search.dto.SearchParam;
 23  
 import org.kuali.student.core.search.dto.SearchRequest;
 24  
 import org.kuali.student.core.search.dto.SearchResult;
 25  
 import org.kuali.student.core.search.dto.SearchResultCell;
 26  
 import org.kuali.student.core.search.dto.SearchResultRow;
 27  
 
 28  
 /**
 29  
  * @author lindholm
 30  
  *
 31  
  */
 32  0
 public abstract class CocValuesFiinder extends StudentKeyValuesBase {
 33  
 
 34  
         /**
 35  
          * Find the curriculum committee Orgs of this orgType
 36  
          *
 37  
          * @param orgType
 38  
          * @return
 39  
          */
 40  
         public static List<KeyLabelPair> findCocOrgs(String orgType) {
 41  0
                 List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>();
 42  
 
 43  0
                 List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2);
 44  0
                 SearchParam qpOrgType = new SearchParam();
 45  0
                 qpOrgType.setKey("org.queryParam.relationType");
 46  0
                 qpOrgType.setValue("kuali.org.CurriculumChild");
 47  0
                 queryParamValues.add(qpOrgType);
 48  
                 
 49  0
                 qpOrgType = new SearchParam();
 50  0
                 qpOrgType.setKey("org.queryParam.orgType");
 51  0
                 qpOrgType.setValue(orgType);
 52  0
                 queryParamValues.add(qpOrgType);
 53  
                 
 54  0
                 qpOrgType = new SearchParam();
 55  0
                 qpOrgType.setKey("org.queryParam.relatedOrgType");
 56  0
                 qpOrgType.setValue("kuali.org.COC");
 57  0
                 queryParamValues.add(qpOrgType);
 58  
                 
 59  0
                 SearchRequest searchRequest = new SearchRequest();
 60  0
                 searchRequest.setParams(queryParamValues);
 61  0
                 searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType");
 62  
                 
 63  
                 try {
 64  0
                         SearchResult results = getOrganizationService().search(searchRequest);
 65  
 
 66  0
                         for (SearchResultRow result : results.getRows()) {
 67  0
                                 String orgId = "";
 68  0
                                 String orgShortName = "";
 69  0
                                 for (SearchResultCell resultCell : result.getCells()) {
 70  0
                                         if ("org.resultColumn.orgId".equals(resultCell
 71  
                                                         .getKey())) {
 72  0
                                                 orgId = resultCell.getValue();
 73  0
                                         } else if ("org.resultColumn.orgShortName"
 74  
                                                         .equals(resultCell.getKey())) {
 75  0
                                                 orgShortName = resultCell.getValue();
 76  
                                         }
 77  
                                 }
 78  0
                                 departments.add(buildKeyLabelPair(orgId, orgShortName, null, null));
 79  0
                         }
 80  
 
 81  0
                         return departments;
 82  0
                 } catch (Exception e) {
 83  0
                         throw new RuntimeException(e);
 84  
                 }
 85  
         }
 86  
 }