View Javadoc

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  package org.kuali.student.enrollment.class2.courseoffering.service.impl;
16  
17  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
18  import org.kuali.rice.krad.inquiry.InquirableImpl;
19  import org.kuali.rice.krad.util.GlobalVariables;
20  import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader;
21  import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
22  import org.kuali.student.r2.common.dto.ContextInfo;
23  import org.kuali.student.r2.common.dto.LocaleInfo;
24  import org.kuali.student.r2.core.constants.FeeServiceConstants;
25  import org.kuali.student.r2.core.fee.dto.EnrollmentFeeInfo;
26  import org.kuali.student.r2.core.fee.service.FeeService;
27  
28  import javax.xml.namespace.QName;
29  import java.util.Locale;
30  import java.util.Map;
31  
32  /**
33   * This class //TODO ...
34   *
35   * @author Kuali Student Team
36   */
37  public class EnrollmentFeeInfoInquirableImpl extends InquirableImpl {
38  
39      private FeeService feeService;
40      private ContextInfo contextInfo;
41  
42      @Override
43      public EnrollmentFeeInfo retrieveDataObject(Map<String, String> parameters) {
44  
45          EnrollmentFeeInfo efiRet = null;
46  
47          try {
48              String id = parameters.get("id");
49  
50              if(id != null && !"".equals(id)){
51                  efiRet = getFeeService().getFee(id,getContextInfo() );
52              }
53          } catch (Exception e) {
54              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
55          }
56          return efiRet;
57      }
58  
59      public FeeService getFeeService() {
60          if (feeService == null) {
61              this.feeService = (FeeService) GlobalResourceLoader.getService(new QName(FeeServiceConstants.NAMESPACE, FeeServiceConstants.SERVICE_NAME_LOCAL_PART));
62          }
63          return this.feeService;
64      }
65  
66      public void setFeeService(FeeService feeService) {
67          this.feeService = feeService;
68      }
69  
70      public CourseOfferingService getCourseOfferingService() {
71          return CourseOfferingResourceLoader.loadCourseOfferingService();
72      }
73  
74      public ContextInfo getContextInfo() {
75          if (null == contextInfo) {
76              contextInfo = new ContextInfo();
77              contextInfo.setAuthenticatedPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
78              contextInfo.setPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
79              LocaleInfo localeInfo = new LocaleInfo();
80              localeInfo.setLocaleLanguage(Locale.getDefault().getLanguage());
81              localeInfo.setLocaleRegion(Locale.getDefault().getCountry());
82              contextInfo.setLocale(localeInfo);
83          }
84          return contextInfo;
85      }
86  
87  
88  }
89