Coverage Report - org.kuali.rice.student.lookup.keyvalues.CocValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
CocValuesFinder
0%
0/36
0%
0/10
9
 
 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
                 List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2);
 43  0
                 SearchParam qpOrgType = new SearchParam();
 44  0
                 qpOrgType.setKey("org.queryParam.relationType");
 45  0
                 qpOrgType.setValue("kuali.org.CurriculumParent");
 46  0
                 queryParamValues.add(qpOrgType);
 47  
                 
 48  0
                 qpOrgType = new SearchParam();
 49  0
         qpOrgType.setKey("org.queryParam.orgType");
 50  0
         qpOrgType.setValue(orgType);
 51  0
                 queryParamValues.add(qpOrgType);
 52  
                 
 53  0
                 qpOrgType = new SearchParam();
 54  0
                 qpOrgType.setKey("org.queryParam.relatedOrgType");
 55  0
                 qpOrgType.setValue("kuali.org.COC");
 56  0
                 queryParamValues.add(qpOrgType);
 57  
                 
 58  0
                 SearchRequest searchRequest = new SearchRequest();
 59  0
                 searchRequest.setParams(queryParamValues);
 60  0
         searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType");
 61  
 
 62  
                 try {
 63  0
                         SearchResult results = getOrganizationService().search(searchRequest);
 64  
 
 65  0
                         for (SearchResultRow result : results.getRows()) {
 66  0
                                 String orgId = "";
 67  0
                                 String orgShortName = "";
 68  0
                                 String orgLongName = "";
 69  0
                                 for (SearchResultCell resultCell : result.getCells()) {
 70  0
                                         if ("org.resultColumn.orgId".equals(resultCell
 71  
                                                         .getKey())) {
 72  0
                                                 orgId = resultCell.getValue();
 73  0
                                                 orgLongName = getOrganizationService().getOrganization(orgId).getLongName();
 74  0
                                         } else if ("org.resultColumn.orgShortName"
 75  
                                                         .equals(resultCell.getKey())) {
 76  0
                                                 orgShortName = resultCell.getValue();
 77  
                                         }                                        
 78  
                                 }
 79  0
                         if (StringUtils.isBlank(orgLongName)) {
 80  
                            //use shortName when longName is blank
 81  0
                             orgEntities.add(buildKeyLabelPair(orgId, orgShortName, null, null));
 82  
                         }
 83  
                         else {
 84  
                             /*
 85  
                              * The requirement is that in the RICE portal, when we add a principal to a role
 86  
                              * the drop-down list for DepartmentCoC or DivisionCoC should display the full/long 
 87  
                              * names instead of short names.
 88  
                              */
 89  0
                             orgEntities.add(new KeyLabelPair(orgId, orgLongName));
 90  
                         }
 91  
 //                        orgEntities.add(buildKeyLabelPair(orgId, null, orgLongName, null));
 92  0
                         }
 93  
 
 94  0
                         return orgEntities;
 95  0
                 } catch (Exception e) {
 96  0
                         throw new RuntimeException(e);
 97  
                 }
 98  
         }
 99  
 }