Coverage Report - org.kuali.student.enrollment.class2.acal.service.AcademicCalendarWrapperLookupableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AcademicCalendarWrapperLookupableImpl
0%
0/52
0%
0/26
10
 
 1  
 package org.kuali.student.enrollment.class2.acal.service;
 2  
 
 3  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 4  
 import org.kuali.rice.krad.lookup.LookupableImpl;
 5  
 import org.kuali.rice.krad.web.form.LookupForm;
 6  
 import org.kuali.student.enrollment.acal.dto.AcademicCalendarInfo;
 7  
 import org.kuali.student.enrollment.acal.dto.KeyDateInfo;
 8  
 import org.kuali.student.enrollment.acal.dto.TermInfo;
 9  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 10  
 import org.kuali.student.enrollment.class2.acal.dto.AcademicCalendarWrapper;
 11  
 import org.kuali.student.enrollment.class2.acal.dto.TermWrapper;
 12  
 import org.kuali.student.r2.common.dto.ContextInfo;
 13  
 import org.kuali.student.r2.common.exceptions.*;
 14  
 import org.kuali.student.r2.common.util.constants.AtpServiceConstants;
 15  
 
 16  
 import javax.xml.namespace.QName;
 17  
 import java.util.ArrayList;
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 //Core slice class.
 22  
 @Deprecated
 23  0
 public class AcademicCalendarWrapperLookupableImpl extends LookupableImpl {
 24  
     public final static String CREDENTIAL_PROGRAM_TYPE_KEY = "academicCalendarInfo.credentialProgramTypeKey";
 25  
     public final static String ACADEMIC_CALENDAR_NAME = "academicCalendarInfo.name";
 26  
     public final static String ACADEMIC_CALENDAR_WRAPPER_KEY = "id";
 27  
          private transient AcademicCalendarService academicCalendarService;
 28  
          
 29  
 
 30  
     @Override
 31  
     protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
 32  0
             List<AcademicCalendarWrapper> academicCalendarWrapperList = new ArrayList<AcademicCalendarWrapper>();
 33  0
         List<AcademicCalendarInfo> academicCalendarInfoList = new ArrayList<AcademicCalendarInfo>();
 34  
 
 35  0
             String academicCalendarKey = fieldValues.get(ACADEMIC_CALENDAR_WRAPPER_KEY);
 36  0
         String academicCalendarName = fieldValues.get(ACADEMIC_CALENDAR_NAME);
 37  0
         String credentialProgramType =  fieldValues.get(CREDENTIAL_PROGRAM_TYPE_KEY);
 38  0
         System.out.println(">>>academicCalendarKey = "+academicCalendarKey);
 39  0
             ContextInfo context = new ContextInfo();
 40  
             try{
 41  0
             if(academicCalendarKey != null && !academicCalendarKey.trim().isEmpty()){
 42  0
                         AcademicCalendarInfo acal = getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context);
 43  0
                 if (acal != null) academicCalendarInfoList.add(acal);
 44  
             }
 45  
             else {
 46  
                 // TODO fix the search by Admin Org.  Switch from credential program to admin org cuased issues
 47  
                 /*
 48  
                 List<AcademicCalendarInfo> acals = getAcademicCalendarService().getAcademicCalendarsByCredentialProgramType(credentialProgramType, context);
 49  
                 if(!acals.isEmpty()){
 50  
                     if(academicCalendarName != null && !academicCalendarName.trim().isEmpty()){
 51  
                         for (AcademicCalendarInfo academicCalendarInfo : acals){
 52  
                             if(academicCalendarInfo.getName()!= null && academicCalendarInfo.getName().equals(academicCalendarName))
 53  
                                 academicCalendarInfoList.add(academicCalendarInfo);
 54  
                         }
 55  
                     }
 56  
                     else
 57  
                         academicCalendarInfoList = acals;
 58  
                 }
 59  
                 */
 60  
             }
 61  
 
 62  0
             if(!academicCalendarInfoList.isEmpty()){
 63  0
                 for(AcademicCalendarInfo academicCalendarInfo : academicCalendarInfoList){
 64  0
                     AcademicCalendarWrapper academicCalendarWrapper = new AcademicCalendarWrapper();
 65  0
                         List<TermWrapper> termWrapperList = academicCalendarWrapper.getTermWrapperList();
 66  
 
 67  0
                     academicCalendarWrapper.setAcademicCalendarInfo(academicCalendarInfo);
 68  0
                     List<TermInfo> terms = getAcademicCalendarService().getTermsForAcademicCalendar(academicCalendarInfo.getId(), context);
 69  0
                     for (TermInfo term : terms){
 70  0
                         TermWrapper termWrapper = new TermWrapper();
 71  0
                         termWrapper.setTermInfo(term);
 72  0
                         List<KeyDateInfo>  keyDateInfoList = getAcademicCalendarService().getKeyDatesForTerm(term.getId(), context);
 73  0
                         for (KeyDateInfo keyDateInfo : keyDateInfoList){
 74  0
                             if(AtpServiceConstants.MILESTONE_INSTRUCTIONAL_PERIOD_TYPE_KEY.equals(keyDateInfo.getTypeKey())){
 75  0
                                 termWrapper.setClassesMeetDates(keyDateInfo);
 76  
                             }
 77  0
                             else if(AtpServiceConstants.MILESTONE_REGISTRATION_PERIOD_TYPE_KEY.equals(keyDateInfo.getTypeKey())){
 78  0
                                 termWrapper.setRegistrationPeriod(keyDateInfo);
 79  
                             }
 80  0
                             else if(AtpServiceConstants.MILESTONE_DROP_DATE_TYPE_KEY.equals(keyDateInfo.getTypeKey())){
 81  0
                                 termWrapper.setDropPeriodEndsDate(keyDateInfo);
 82  
                             }
 83  0
                             else if(AtpServiceConstants.MILESTONE_FINAL_EXAM_PERIOD_TYPE_KEY.equals(keyDateInfo.getTypeKey())){
 84  0
                                 termWrapper.setFinalExaminationsDates(keyDateInfo);
 85  
                             }
 86  0
                             else if(AtpServiceConstants.MILESTONE_GRADES_DUE_TYPE_KEY.equals(keyDateInfo.getTypeKey())){
 87  0
                                 termWrapper.setGradesDueDate(keyDateInfo);
 88  
                             }
 89  
                         }
 90  0
                         termWrapperList.add(termWrapper);
 91  0
                     }
 92  0
                     academicCalendarWrapper.setTermWrapperList(termWrapperList);
 93  0
                     academicCalendarWrapperList.add(academicCalendarWrapper);
 94  0
                 }
 95  
             }
 96  
 
 97  0
         }catch (DoesNotExistException dnee){
 98  0
            System.out.println("call getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context), and get DoesNotExistException:  "+dnee.toString());
 99  0
             }catch (InvalidParameterException ipe){
 100  0
                         System.out.println("call getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context), and get InvalidParameterException:  "+ipe.toString());
 101  0
             }catch (MissingParameterException mpe){
 102  0
                 System.out.println("call getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context), and get MissingParameterException:  "+mpe.toString());
 103  0
             }catch (OperationFailedException ofe){
 104  0
                 System.out.println("call getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context), and get OperationFailedException:  "+ofe.toString());
 105  0
             }catch (PermissionDeniedException pde){
 106  0
                 System.out.println("call getAcademicCalendarService().getAcademicCalendar(academicCalendarKey, context), and get PermissionDeniedException:  "+pde.toString());
 107  0
             }
 108  0
             return academicCalendarWrapperList;
 109  
         
 110  
     }
 111  
     
 112  
     protected AcademicCalendarService getAcademicCalendarService() {
 113  0
         if(academicCalendarService == null) {
 114  0
                  academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/acal","AcademicCalendarService"));
 115  
         }
 116  0
         return academicCalendarService;
 117  
     }
 118  
 
 119  
 
 120  
 }