Coverage Report - org.kuali.student.enrollment.class2.acal.keyvalue.AtpStateKeyValues
 
Classes in this File Line Coverage Branch Coverage Complexity
AtpStateKeyValues
0%
0/36
0%
0/16
3
 
 1  
 /**
 2  
  * Copyright 2012 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  
  * Created by Li Pan on 3/6/12
 16  
  */
 17  
 package org.kuali.student.enrollment.class2.acal.keyvalue;
 18  
 
 19  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 20  
 import org.kuali.rice.core.api.util.ConcreteKeyValue;
 21  
 import org.kuali.rice.core.api.util.KeyValue;
 22  
 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
 23  
 import org.kuali.rice.krad.uif.view.ViewModel;
 24  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 25  
 import org.kuali.student.enrollment.class2.acal.form.CalendarSearchForm;
 26  
 import org.kuali.student.enrollment.class2.acal.util.CalendarConstants;
 27  
 import org.kuali.student.mock.utilities.TestHelper;
 28  
 import org.kuali.student.r2.common.constants.CommonServiceConstants;
 29  
 import org.kuali.student.r2.common.dto.ContextInfo;
 30  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 31  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 32  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 33  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 34  
 import org.kuali.student.r2.core.state.dto.StateInfo;
 35  
 
 36  
 import javax.xml.namespace.QName;
 37  
 import java.io.Serializable;
 38  
 import java.util.ArrayList;
 39  
 import java.util.Collections;
 40  
 import java.util.List;
 41  
 
 42  
 /**
 43  
  * This class //TODO ...
 44  
  *
 45  
  * @author Kuali Student Team
 46  
  */
 47  
 //Core slice class.
 48  
 @Deprecated
 49  0
 public class AtpStateKeyValues extends UifKeyValuesFinderBase implements Serializable {
 50  
 
 51  
     private static final long serialVersionUID = 1L;
 52  
 
 53  
     private transient AcademicCalendarService acalService;
 54  
 
 55  
     private static List<StateInfo> holidayStates;
 56  
 
 57  
     private static List<StateInfo> acalStates;
 58  
 
 59  
     private static List<StateInfo> termStates;
 60  
 
 61  
 
 62  
     @Override
 63  
     public List<KeyValue> getKeyValues(ViewModel model) {
 64  0
         CalendarSearchForm form = (CalendarSearchForm)model;
 65  0
         String atpType = form.getCalendarType();
 66  
 
 67  0
         List<KeyValue> keyValues = new ArrayList<KeyValue>();
 68  
 
 69  
 
 70  
         try {
 71  0
             List<StateInfo> states = null;
 72  
 
 73  0
             if(atpType.equals(CalendarConstants.HOLIDAYCALENDER)){
 74  0
                 states = getHolidayStates();
 75  0
             }else if(atpType.equals(CalendarConstants.ACADEMICCALENDER)) {
 76  0
                 states = getAcalStates();
 77  0
             }else if(atpType.equals(CalendarConstants.TERM)){
 78  0
                 states = getTermStates();
 79  
             }
 80  
 
 81  0
             for (StateInfo state : states) {
 82  0
                 ConcreteKeyValue keyValue = new ConcreteKeyValue();
 83  0
                 keyValue.setKey(state.getKey());
 84  0
                 keyValue.setValue(state.getName());
 85  0
                 keyValues.add(keyValue);
 86  0
             }
 87  0
         } catch (Exception e) {
 88  0
             throw new RuntimeException(e);
 89  0
         }
 90  
 
 91  0
         return keyValues;
 92  
     }
 93  
 
 94  
     public List<StateInfo> getHolidayStates() throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException {
 95  0
         if(holidayStates == null) {
 96  
             //TODO:Build real context.
 97  0
             ContextInfo context = TestHelper.getContext1();
 98  
 
 99  0
             holidayStates = Collections.unmodifiableList(getAcalService().getHolidayCalendarStates(context));
 100  
         }
 101  0
         return holidayStates;
 102  
     }
 103  
 
 104  
     public List<StateInfo> getAcalStates() throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException {
 105  0
         if(acalStates == null) {
 106  
             //TODO:Build real context.
 107  0
             ContextInfo context = TestHelper.getContext1();
 108  
 
 109  0
             acalStates = Collections.unmodifiableList(getAcalService().getAcademicCalendarStates(context));
 110  
         }
 111  
 
 112  0
         return acalStates;
 113  
     }
 114  
 
 115  
     public List<StateInfo> getTermStates() throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException {
 116  0
         if(termStates == null) {
 117  
             //TODO:Build real context.
 118  0
             ContextInfo context = TestHelper.getContext1();
 119  
 
 120  0
             termStates = Collections.unmodifiableList(getAcalService().getTermStates(context));
 121  
         }
 122  0
         return termStates;
 123  
     }
 124  
 
 125  
     public AcademicCalendarService getAcalService() {
 126  0
         if(acalService == null) {
 127  0
             acalService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX + "acal", "AcademicCalendarService"));
 128  
         }
 129  0
         return this.acalService;
 130  
     }
 131  
 }