Coverage Report - org.kuali.rice.location.impl.campus.CampusServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CampusServiceImpl
0%
0/27
0%
0/8
1.857
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.location.impl.campus;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 20  
 import org.kuali.rice.krad.service.BusinessObjectService;
 21  
 import org.kuali.rice.location.api.campus.Campus;
 22  
 import org.kuali.rice.location.api.campus.CampusService;
 23  
 import org.kuali.rice.location.api.campus.CampusType;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.Collections;
 27  
 import java.util.List;
 28  
 
 29  
 import static java.util.Collections.singletonMap;
 30  
 
 31  0
 public class CampusServiceImpl implements CampusService {
 32  
 
 33  
         private BusinessObjectService boService;
 34  
         
 35  
         /**
 36  
      * @see org.kuali.rice.location.api.campus.CampusService#getCampus(String code)
 37  
      */
 38  
         @Override
 39  
         public Campus getCampus(String code) {
 40  0
                 if (StringUtils.isBlank(code)) {
 41  0
             throw new RiceIllegalArgumentException("code is blank");
 42  
         }
 43  
 
 44  0
         CampusBo campusBo = boService.findByPrimaryKey(CampusBo.class, singletonMap("code", code));
 45  
 
 46  0
         return CampusBo.to(campusBo);
 47  
         }
 48  
 
 49  
         /**
 50  
      * @see org.kuali.rice.location.api.campus.CampusService#findAllCampuses
 51  
      */
 52  
         @Override
 53  
         public List<Campus> findAllCampuses() {
 54  0
                 List<CampusBo> campusBos = (List<CampusBo>) boService.findMatching(CampusBo.class, singletonMap("active", "true"));
 55  
 
 56  0
         return this.convertListOfCampusBosToImmutables(campusBos);
 57  
         }
 58  
 
 59  
         /**
 60  
      * @see org.kuali.rice.location.api.campus.CampusService#getCampusType(String code)
 61  
      */
 62  
         @Override
 63  
         public CampusType getCampusType(String code) {
 64  0
                 if (StringUtils.isBlank(code)) {
 65  0
             throw new RiceIllegalArgumentException("code is blank");
 66  
         }
 67  
 
 68  0
                 CampusTypeBo campusTypeBo = boService.findByPrimaryKey(CampusTypeBo.class, singletonMap("code", code));
 69  
 
 70  0
         return CampusTypeBo.to(campusTypeBo);
 71  
         }
 72  
 
 73  
         /**
 74  
      * @see org.kuali.rice.location.api.campus.CampusService#findAllCampusTypes
 75  
      */
 76  
         @Override
 77  
         public List<CampusType> findAllCampusTypes() {
 78  0
                 List<CampusTypeBo> campusTypeBos = (List<CampusTypeBo>)boService.findMatching(CampusTypeBo.class, singletonMap("active", "true"));
 79  0
                 return this.convertListOfCampusTypesBosToImmutables(campusTypeBos);
 80  
         }
 81  
     
 82  
     public void setBusinessObjectService(BusinessObjectService boService) {
 83  0
         this.boService = boService;
 84  0
     }
 85  
 
 86  
     private List<Campus> convertListOfCampusBosToImmutables(List<CampusBo> campusBos) {
 87  0
         ArrayList<Campus> campuses = new ArrayList<Campus>();
 88  0
         for (CampusBo bo : campusBos) {
 89  0
             Campus campus = CampusBo.to(bo);
 90  0
             campuses.add(campus) ;
 91  0
         }
 92  0
         return Collections.unmodifiableList(campuses);
 93  
     }
 94  
     
 95  
     private List<CampusType> convertListOfCampusTypesBosToImmutables(List<CampusTypeBo> campusTypeBos) {
 96  0
         ArrayList<CampusType> campusTypes = new ArrayList<CampusType>();
 97  0
         for (CampusTypeBo bo : campusTypeBos) {
 98  0
             CampusType campusType = CampusTypeBo.to(bo);
 99  0
             campusTypes.add(campusType) ;
 100  0
         }
 101  0
         return Collections.unmodifiableList(campusTypes);
 102  
     }
 103  
 }