View Javadoc

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