| 1 | |
package org.kuali.student.enrollment.class2.acal.keyvalue; |
| 2 | |
|
| 3 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 4 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
| 5 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
| 6 | |
import org.kuali.student.enrollment.acal.service.AcademicCalendarService; |
| 7 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 8 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 9 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 10 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 11 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 12 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
| 13 | |
|
| 14 | |
import javax.xml.namespace.QName; |
| 15 | |
import java.io.Serializable; |
| 16 | |
import java.util.ArrayList; |
| 17 | |
import java.util.Collections; |
| 18 | |
import java.util.List; |
| 19 | |
|
| 20 | |
|
| 21 | |
@Deprecated |
| 22 | 0 | public class TermInfoTypeKeyValues extends KeyValuesBase implements Serializable{ |
| 23 | |
public static final String FALL_TERM_TYPE_KEY = "kuali.atp.type.Fall"; |
| 24 | |
public static final String WINTER_TERM_TYPE_KEY = "kuali.atp.type.Winter"; |
| 25 | |
public static final String SPRING_TERM_TYPE_KEY = "kuali.atp.type.Spring"; |
| 26 | |
public static final String SUMMER_TERM_TYPE_KEY = "kuali.atp.type.Summer"; |
| 27 | |
|
| 28 | |
private static final long serialVersionUID = 1L; |
| 29 | |
|
| 30 | |
private transient AcademicCalendarService academicCalendarService; |
| 31 | |
|
| 32 | |
private static List<TypeInfo> termTypes; |
| 33 | |
|
| 34 | |
public List getKeyValues() { |
| 35 | 0 | List <ConcreteKeyValue> keyValues = new ArrayList<ConcreteKeyValue>(); |
| 36 | |
|
| 37 | |
|
| 38 | |
try { |
| 39 | 0 | List<TypeInfo> typeInfoList = getTermTypes(); |
| 40 | 0 | for (TypeInfo typeInfo : typeInfoList){ |
| 41 | 0 | String typeKey = typeInfo.getKey(); |
| 42 | 0 | if (typeKey.equalsIgnoreCase(FALL_TERM_TYPE_KEY)){ |
| 43 | 0 | keyValues.add(new ConcreteKeyValue(typeKey, typeInfo.getName())); |
| 44 | |
} |
| 45 | 0 | else if(typeKey.equalsIgnoreCase(WINTER_TERM_TYPE_KEY)){ |
| 46 | 0 | keyValues.add(new ConcreteKeyValue(typeKey, typeInfo.getName())); |
| 47 | |
} |
| 48 | 0 | else if (typeKey.equalsIgnoreCase(SPRING_TERM_TYPE_KEY)){ |
| 49 | 0 | keyValues.add(new ConcreteKeyValue(typeKey, typeInfo.getName())); |
| 50 | |
} |
| 51 | 0 | else if (typeKey.equalsIgnoreCase(SUMMER_TERM_TYPE_KEY)){ |
| 52 | 0 | keyValues.add(new ConcreteKeyValue(typeKey, typeInfo.getName())); |
| 53 | |
} |
| 54 | 0 | } |
| 55 | |
|
| 56 | 0 | }catch (InvalidParameterException ipe){ |
| 57 | 0 | throw new RuntimeException(ipe); |
| 58 | 0 | }catch (MissingParameterException mpe){ |
| 59 | 0 | throw new RuntimeException(mpe); |
| 60 | 0 | }catch (OperationFailedException ofe){ |
| 61 | 0 | throw new RuntimeException(ofe); |
| 62 | 0 | }catch (PermissionDeniedException pde){ |
| 63 | 0 | throw new RuntimeException(pde); |
| 64 | 0 | } |
| 65 | |
|
| 66 | 0 | return keyValues; |
| 67 | |
} |
| 68 | |
|
| 69 | |
private List<TypeInfo> getTermTypes() throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException { |
| 70 | 0 | if(termTypes == null) { |
| 71 | 0 | termTypes = Collections.unmodifiableList(getAcademicCalendarService().getTermTypes(new ContextInfo())); |
| 72 | |
} |
| 73 | |
|
| 74 | 0 | return termTypes; |
| 75 | |
} |
| 76 | |
|
| 77 | |
protected AcademicCalendarService getAcademicCalendarService() { |
| 78 | 0 | if(academicCalendarService == null) { |
| 79 | 0 | academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/acal","AcademicCalendarService")); |
| 80 | |
} |
| 81 | |
|
| 82 | 0 | return academicCalendarService; |
| 83 | |
} |
| 84 | |
} |