View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not
3    * use this file except in compliance with the License. You may obtain a copy of the License at
4    *
5    * http://www.osedu.org/licenses/ECL-2.0
6    *
7    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
9    * governing permissions and limitations under the License.
10   *
11   */
12  package org.kuali.student.enrollment.state.service.impl;
13  
14  import java.util.Map;
15  import javax.xml.namespace.QName;
16  import org.apache.log4j.Logger;
17  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
18  import org.kuali.rice.krad.inquiry.InquirableImpl;
19  import org.kuali.student.enrollment.common.util.ContextBuilder;
20  import org.kuali.student.r2.common.dto.ContextInfo;
21  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
22  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
23  import org.kuali.student.r2.common.exceptions.MissingParameterException;
24  import org.kuali.student.r2.common.exceptions.OperationFailedException;
25  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
26  import org.kuali.student.r2.core.constants.StateServiceConstants;
27  import org.kuali.student.r2.core.class1.state.dto.LifecycleInfo;
28  import org.kuali.student.r2.core.class1.state.service.StateService;
29  
30  /**
31   * This class 
32   *
33   * @author Kuali Student Team
34   */
35  public class LifecycleInfoAdminInquirableImpl
36          extends InquirableImpl {
37  
38      private final static String KEY = "key";
39      private transient StateService stateService;
40      final Logger logger = Logger.getLogger(LifecycleInfoAdminInquirableImpl.class);
41  
42      @Override
43      public LifecycleInfo retrieveDataObject(Map<String, String> parameters) {
44          try {
45              return getStateService().getLifecycle(parameters.get(KEY), getContextInfo());
46          } catch (DoesNotExistException ex) {
47              throw new RuntimeException (ex);
48          } catch (InvalidParameterException ex) {
49              throw new RuntimeException (ex);
50          } catch (MissingParameterException ex) {
51              throw new RuntimeException (ex);
52          } catch (OperationFailedException ex) {
53              throw new RuntimeException (ex);
54          } catch (PermissionDeniedException ex) {
55              throw new RuntimeException (ex);
56          }
57      }
58  
59      public void setStateService(StateService stateService) {
60          this.stateService = stateService;
61      }
62  
63      public StateService getStateService() {
64          if (stateService == null) {
65              stateService = (StateService) GlobalResourceLoader.getService(new QName(StateServiceConstants.NAMESPACE,
66                      StateServiceConstants.SERVICE_NAME_LOCAL_PART));
67          }
68          return this.stateService;
69      }
70  
71      private ContextInfo getContextInfo() {
72          return ContextBuilder.loadContextInfo();
73      }
74  }