Coverage Report - org.kuali.student.enrollment.class2.acal.service.TermLookupableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TermLookupableImpl
0%
0/36
0%
0/6
4
 
 1  
 package org.kuali.student.enrollment.class2.acal.service;
 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.uif.UifConstants;
 7  
 import org.kuali.rice.krad.uif.UifParameters;
 8  
 import org.kuali.rice.krad.util.KRADConstants;
 9  
 import org.kuali.rice.krad.util.KRADUtils;
 10  
 import org.kuali.rice.krad.util.UrlFactory;
 11  
 import org.kuali.rice.krad.web.form.LookupForm;
 12  
 import org.kuali.student.enrollment.acal.dto.TermInfo;
 13  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 14  
 import org.kuali.student.enrollment.class2.acal.dto.TermWrapper;
 15  
 import org.kuali.student.r2.common.dto.ContextInfo;
 16  
 import org.kuali.student.r2.common.exceptions.*;
 17  
 
 18  
 import javax.xml.namespace.QName;
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 import java.util.Properties;
 23  
 
 24  
 
 25  
 /**
 26  
  * Created by IntelliJ IDEA.
 27  
  * User: huangb
 28  
  */
 29  
 //Core slice class.
 30  
 @Deprecated
 31  0
 public class TermLookupableImpl extends LookupableImpl  {
 32  
     public final static String TERM_KEY = "key";
 33  
          private transient AcademicCalendarService academicCalendarService;
 34  
 
 35  
 
 36  
     @Override
 37  
     protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
 38  0
             TermInfo termInfo = null;
 39  0
             List<TermInfo> termInfoList = new ArrayList<TermInfo>();
 40  
 
 41  0
             String termKey = fieldValues.get(TERM_KEY);
 42  0
             ContextInfo context = new ContextInfo();
 43  
             try{
 44  0
                     termInfo = getAcademicCalendarService().getTerm(termKey, context);
 45  0
                     termInfoList.add(termInfo);
 46  0
                     return termInfoList;
 47  0
             }catch (DoesNotExistException dnee){
 48  0
             System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get DoesNotExistException:  "+dnee.toString());
 49  0
             }catch (InvalidParameterException ipe){
 50  0
             System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get InvalidParameterException:  "+ipe.toString());
 51  0
             }catch (MissingParameterException mpe){
 52  0
             System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get MissingParameterException:  "+mpe.toString());
 53  0
             }catch (OperationFailedException ofe){
 54  0
             System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get OperationFailedException:  "+ofe.toString());
 55  0
             }catch (PermissionDeniedException pde){
 56  0
             System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get PermissionDeniedException:  "+pde.toString());
 57  0
             }
 58  0
             return null;
 59  
 
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) {
 64  
 
 65  0
        Properties props = new Properties();
 66  0
        props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
 67  
 
 68  0
        Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
 69  0
        for (String primaryKey : primaryKeyValues.keySet()) {
 70  0
            String primaryKeyValue = primaryKeyValues.get(primaryKey);
 71  0
            props.put(primaryKey, primaryKeyValue);
 72  0
            props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
 73  0
        }
 74  
 
 75  0
        if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
 76  0
            props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
 77  
        }
 78  
 
 79  0
        props.put(UifParameters.DATA_OBJECT_CLASS_NAME, TermWrapper.class.getName());
 80  0
        props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE);
 81  
 
 82  0
        return UrlFactory.parameterizeUrl(KRADConstants.Maintenance.REQUEST_MAPPING_MAINTENANCE, props);
 83  
 
 84  
     }
 85  
 
 86  
     protected AcademicCalendarService getAcademicCalendarService() {
 87  0
         if(academicCalendarService == null) {
 88  0
                  academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/acal", "AcademicCalendarService"));
 89  
         }
 90  0
         return academicCalendarService;
 91  
     }
 92  
 
 93  
 
 94  
 
 95  
 
 96  
 }