View Javadoc

1   package org.kuali.student.enrollment.class2.examoffering.krms.naturallanguage.context;
2   
3   import org.kuali.student.enrollment.class2.courseoffering.krms.naturallanguage.context.BasicContextImpl;
4   import org.kuali.student.r2.common.util.date.DateFormatters;
5   import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
6   
7   import java.util.Date;
8   import java.util.Map;
9   
10  /**
11   * Created with IntelliJ IDEA.
12   * User: SW Genis
13   * Date: 2013/09/04
14   * Time: 9:56 AM
15   * To change this template use File | Settings | File Templates.
16   */
17  public class FinalExamContextImpl extends BasicContextImpl {
18  
19      public final static String WEEKDAY_TOKEN = "weekdays";
20      public final static String STARTTIME_TOKEN = "startTime";
21      public final static String ENDTIME_TOKEN = "endTime";
22  
23      /**
24       * Creates the context map (template data) for the requirement component.
25       *
26       * @param parameters Requirement component
27       * @throws org.kuali.student.r2.common.exceptions.OperationFailedException
28       *          Creating context map fails
29       */
30      @Override
31      public Map<String, Object> createContextMap(Map<String, Object> parameters) {
32          Map<String, Object> contextMap = super.createContextMap(parameters);
33  
34          if(parameters.containsKey(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_WEEKDAY_STRING)) {
35              contextMap.put(WEEKDAY_TOKEN, parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_WEEKDAY_STRING));
36          }
37  
38          if(parameters.containsKey(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_START)) {
39              String timeInMillis = (String) parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_START);
40              Date timeForDisplay = new Date(Long.parseLong(timeInMillis));
41              contextMap.put(STARTTIME_TOKEN, DateFormatters.HOUR_MINUTE_AM_PM_TIME_FORMATTER.format(timeForDisplay));
42          }
43  
44          if(parameters.containsKey(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_END)) {
45              String timeInMillis = (String) parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_TIMESLOT_END);
46              Date timeForDisplay = new Date(Long.parseLong(timeInMillis));
47              contextMap.put(ENDTIME_TOKEN, DateFormatters.HOUR_MINUTE_AM_PM_TIME_FORMATTER.format(timeForDisplay));
48          }
49  
50          return contextMap;
51      }
52  }