Coverage Report - org.kuali.student.enrollment.class2.acal.service.impl.HolidayCalendarWrapperLookupableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
HolidayCalendarWrapperLookupableImpl
0%
0/49
0%
0/8
8
 
 1  
 package org.kuali.student.enrollment.class2.acal.service.impl;
 2  
 
 3  
 import org.apache.commons.lang.StringUtils;
 4  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 5  
 import org.kuali.rice.krad.lookup.LookupableImpl;
 6  
 import org.kuali.rice.krad.web.form.LookupForm;
 7  
 import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants;
 8  
 import org.kuali.student.enrollment.acal.dto.HolidayCalendarInfo;
 9  
 import org.kuali.student.enrollment.acal.dto.HolidayInfo;
 10  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 11  
 import org.kuali.student.enrollment.class2.acal.dto.HolidayCalendarWrapper;
 12  
 import org.kuali.student.enrollment.class2.acal.dto.HolidayWrapper;
 13  
 import org.kuali.student.r2.common.dto.ContextInfo;
 14  
 import org.kuali.student.r2.common.exceptions.*;
 15  
 import org.kuali.student.r2.common.util.constants.AtpServiceConstants;
 16  
 import org.kuali.student.r2.core.type.dto.TypeInfo;
 17  
 
 18  
 import javax.xml.namespace.QName;
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  
 
 24  0
 public class HolidayCalendarWrapperLookupableImpl extends LookupableImpl {
 25  
 
 26  
     public final static String ACADEMIC_CALENDAR_START_YEAR_KEY = "acalStartYear";
 27  
     private transient AcademicCalendarService academicCalendarService;
 28  
 
 29  
 
 30  
     @Override
 31  
     protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
 32  
 
 33  0
         List<HolidayCalendarWrapper> holidayCalendarWrapperList = new ArrayList<HolidayCalendarWrapper>();
 34  0
         List<HolidayCalendarInfo> holidayCalendarInfoList = new ArrayList<HolidayCalendarInfo>();
 35  0
         List<HolidayWrapper> holidays = new ArrayList<HolidayWrapper>();
 36  
 
 37  0
         Integer theStartYear = new Integer(fieldValues.get(ACADEMIC_CALENDAR_START_YEAR_KEY));
 38  0
         ContextInfo context = new ContextInfo();
 39  
         try{
 40  0
             holidayCalendarInfoList = getAcademicCalendarService().getHolidayCalendarsByStartYear(theStartYear, context);
 41  0
             for(HolidayCalendarInfo holidayCalendarInfo:holidayCalendarInfoList){
 42  0
                 if (StringUtils.equals(holidayCalendarInfo.getStateKey(), AtpServiceConstants.ATP_OFFICIAL_STATE_KEY)){
 43  0
                     HolidayCalendarWrapper holidayCalendarWrapper = new HolidayCalendarWrapper();
 44  0
                     holidayCalendarWrapper.setHolidayCalendarInfo(holidayCalendarInfo);
 45  0
                     holidayCalendarWrapper.setId(holidayCalendarInfo.getId());
 46  0
                     holidayCalendarWrapper.setAcalStartYear(theStartYear.toString());
 47  
                     try {
 48  0
                         List<HolidayInfo> holidayInfoList = getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarInfo.getId(), context);
 49  0
                         for(HolidayInfo holidayInfo : holidayInfoList){
 50  0
                             HolidayWrapper holiday = new HolidayWrapper();
 51  0
                             holiday.setHolidayInfo(holidayInfo);
 52  0
                             TypeInfo typeInfo = getAcademicCalendarService().getHolidayType(holidayInfo.getTypeKey(), context);
 53  0
                             holiday.setTypeName(typeInfo.getName());
 54  0
                             holidays.add(holiday);
 55  0
                         }
 56  0
                         holidayCalendarWrapper.setHolidays(holidays);
 57  0
                     }catch (DoesNotExistException dnee){
 58  0
                         System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get DoesNotExistException:  "+dnee.toString());
 59  0
                     }catch (InvalidParameterException ipe){
 60  0
                         System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get InvalidParameterException:  "+ipe.toString());
 61  0
                     }catch (MissingParameterException mpe){
 62  0
                         System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get MissingParameterException:  "+mpe.toString());
 63  0
                     }catch (OperationFailedException ofe){
 64  0
                         System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get OperationFailedException:  "+ofe.toString());
 65  0
                     }catch (PermissionDeniedException pde){
 66  0
                         System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get PermissionDeniedException:  "+pde.toString());
 67  0
                     }
 68  0
                     holidayCalendarWrapperList.add(holidayCalendarWrapper);
 69  0
                 }
 70  
             }
 71  
             
 72  0
             return holidayCalendarWrapperList;
 73  
 
 74  0
         }catch (InvalidParameterException ipe){
 75  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendarsByStartYear(startYear, context), and get InvalidParameterException:  "+ipe.toString());
 76  0
         }catch (MissingParameterException mpe){
 77  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendarsByStartYear(startYear, context), and get MissingParameterException:  "+mpe.toString());
 78  0
         }catch (OperationFailedException ofe){
 79  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendarsByStartYear(startYear, context), and get OperationFailedException:  "+ofe.toString());
 80  0
         }catch (PermissionDeniedException pde){
 81  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendarsByStartYear(startYear, context), and get PermissionDeniedException:  "+pde.toString());
 82  0
         }
 83  0
         return null;
 84  
 
 85  
     }
 86  
 
 87  
     protected AcademicCalendarService getAcademicCalendarService() {
 88  0
         if(academicCalendarService == null) {
 89  0
             academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE, AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART));
 90  
         }
 91  0
         return academicCalendarService;
 92  
     }
 93  
 }
 94