Coverage Report - org.kuali.student.enrollment.class2.acal.service.impl.HolidayCalendarWrapperInquiryViewHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
HolidayCalendarWrapperInquiryViewHelperServiceImpl
0%
0/57
0%
0/8
6.333
 
 1  
 package org.kuali.student.enrollment.class2.acal.service.impl;
 2  
 
 3  
 
 4  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 5  
 import org.kuali.rice.krad.inquiry.InquirableImpl;
 6  
 import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants;
 7  
 import org.kuali.student.enrollment.acal.dto.HolidayCalendarInfo;
 8  
 import org.kuali.student.enrollment.acal.dto.HolidayInfo;
 9  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 10  
 import org.kuali.student.enrollment.class2.acal.dto.HolidayCalendarWrapper;
 11  
 import org.kuali.student.enrollment.class2.acal.dto.HolidayWrapper;
 12  
 import org.kuali.student.r2.common.dto.ContextInfo;
 13  
 import org.kuali.student.r2.common.exceptions.*;
 14  
 import org.kuali.student.r2.core.state.dto.StateInfo;
 15  
 import org.kuali.student.r2.core.type.dto.TypeInfo;
 16  
 
 17  
 import javax.xml.namespace.QName;
 18  
 import java.util.ArrayList;
 19  
 import java.util.HashMap;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  0
 public class HolidayCalendarWrapperInquiryViewHelperServiceImpl extends InquirableImpl {
 24  
     //         public final static String ACADEMIC_CALENDAR_KEY = "academicCalendarInfo.key";
 25  
     public final static String HOLIDAY_CALENDAR_WRAPPER_KEY = "id";
 26  
     private transient AcademicCalendarService academicCalendarService;
 27  
 
 28  
     @Override
 29  
     public HolidayCalendarWrapper retrieveDataObject(Map<String, String> parameters) {
 30  0
         ContextInfo context = new ContextInfo();
 31  
 
 32  0
         HolidayCalendarWrapper holidayCalendarWrapper = new HolidayCalendarWrapper();
 33  0
         List<HolidayWrapper> holidays = new ArrayList<HolidayWrapper>();
 34  
         try{
 35  
             //need to retrieve HolidayCalendarInfo and all Holidays to form the HolidayCalendarWrapper.
 36  0
             String holidayCalendarKey = parameters.get(HOLIDAY_CALENDAR_WRAPPER_KEY);
 37  0
             if(holidayCalendarKey == null){
 38  0
                 System.out.println(">>>holidayCalendarKey is null");
 39  0
                 return null;
 40  
             }
 41  
             else {
 42  0
                 System.out.println(">>>holidayCalendarKey ="+holidayCalendarKey);
 43  
             }
 44  0
             HolidayCalendarInfo holidayCalendarInfo = getAcademicCalendarService().getHolidayCalendar(holidayCalendarKey, context);
 45  0
             holidayCalendarWrapper.setHolidayCalendarInfo(holidayCalendarInfo);
 46  0
             holidayCalendarWrapper.setId(holidayCalendarInfo.getId());
 47  0
             holidayCalendarWrapper.setAdminOrgName(getAdminOrgNameById(holidayCalendarInfo.getAdminOrgId()));
 48  0
             StateInfo hcState = getAcademicCalendarService().getHolidayCalendarState(holidayCalendarInfo.getStateKey(), context);
 49  0
             holidayCalendarWrapper.setStateName(hcState.getName());
 50  
 
 51  
             try {
 52  0
                 List<HolidayInfo> holidayInfoList = getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarInfo.getId(), context);
 53  0
                 for(HolidayInfo holidayInfo : holidayInfoList){
 54  0
                     HolidayWrapper holiday = new HolidayWrapper();
 55  0
                     holiday.setHolidayInfo(holidayInfo);
 56  0
                     TypeInfo typeInfo = getAcademicCalendarService().getHolidayType(holidayInfo.getTypeKey(), context);
 57  0
                     holiday.setTypeName(typeInfo.getName());
 58  0
                     holidays.add(holiday);
 59  0
                 }
 60  0
                 holidayCalendarWrapper.setHolidays(holidays);
 61  0
             }catch (DoesNotExistException dnee){
 62  0
                 System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get DoesNotExistException:  "+dnee.toString());
 63  0
             }catch (InvalidParameterException ipe){
 64  0
                 System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get InvalidParameterException:  "+ipe.toString());
 65  0
             }catch (MissingParameterException mpe){
 66  0
                 System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get MissingParameterException:  "+mpe.toString());
 67  0
             }catch (OperationFailedException ofe){
 68  0
                 System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get OperationFailedException:  "+ofe.toString());
 69  0
             }catch (PermissionDeniedException pde){
 70  0
                 System.out.println("call getAcademicCalendarService().getHolidaysForHolidayCalendar(holidayCalendarId, context), and get PermissionDeniedException:  "+pde.toString());
 71  0
             }
 72  0
             return holidayCalendarWrapper;
 73  
 
 74  0
         }catch (DoesNotExistException dnee){
 75  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendar(holidayCalendarId, context), and get DoesNotExistException:  "+dnee.toString());
 76  0
         }catch (InvalidParameterException ipe){
 77  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendar(holidayCalendarId, context), and get InvalidParameterException:  "+ipe.toString());
 78  0
         }catch (MissingParameterException mpe){
 79  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendar(holidayCalendarId, context), and get MissingParameterException:  "+mpe.toString());
 80  0
         }catch (OperationFailedException ofe){
 81  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendar(holidayCalendarId, context), and get OperationFailedException:  "+ofe.toString());
 82  0
         }catch (PermissionDeniedException pde){
 83  0
             System.out.println("call getAcademicCalendarService().getHolidayCalendar(holidayCalendarId, context), and get PermissionDeniedException:  "+pde.toString());
 84  0
         }
 85  0
         return null;
 86  
     }
 87  
 
 88  
     private String getAdminOrgNameById(String id){
 89  
         //TODO: hard-coded for now, going to call OrgService
 90  0
         String adminOrgName = null;
 91  0
         Map<String, String> allHcOrgs = new HashMap<String, String>();
 92  0
         allHcOrgs.put("102", "Registrar's Office");
 93  
 
 94  0
         if(allHcOrgs.containsKey(id)){
 95  0
             adminOrgName = allHcOrgs.get(id);
 96  
         }
 97  
 
 98  0
         return adminOrgName;
 99  
     }
 100  
 
 101  
     protected AcademicCalendarService getAcademicCalendarService() {
 102  0
         if(academicCalendarService == null) {
 103  0
             academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE, AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART));
 104  
         }
 105  
 
 106  0
         return academicCalendarService;
 107  
     }
 108  
 }