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.atp;
17  
18  
19  import java.util.Map;
20  import javax.xml.namespace.QName;
21  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
22  import org.kuali.rice.krad.inquiry.InquirableImpl;
23  import org.kuali.student.common.util.ContextBuilder;
24  import org.kuali.student.r2.common.dto.ContextInfo;
25  import org.kuali.student.r2.core.atp.dto.AtpInfo;
26  import org.kuali.student.r2.core.atp.service.AtpService;
27  import org.kuali.student.r2.core.constants.AtpServiceConstants;
28  
29  
30  public class AtpInfoAdminInquirableImpl extends InquirableImpl
31  {
32  	private transient AtpService atpService;
33  	private final static String PRIMARY_KEY = "id";
34      private static final long serialVersionUID = 1L;
35  	@Override
36  	public AtpInfo retrieveDataObject(Map<String, String> parameters)
37  	{
38  		String key = parameters.get(PRIMARY_KEY);
39  		try
40  		{
41              return this.getAtpService().getAtp(key, getContextInfo());
42  		}
43  		catch (Exception ex) {
44  		    throw new RuntimeException(ex);
45  		}
46  	}
47  
48  	public void setAtpService(AtpService atpService)
49  	{
50  		    this.atpService = atpService;
51  	}
52  
53  	public AtpService getAtpService()
54  	{
55  		if (atpService == null)
56  		{
57  			QName qname = new QName(AtpServiceConstants.NAMESPACE,AtpServiceConstants.SERVICE_NAME_LOCAL_PART);
58  			atpService = (AtpService) GlobalResourceLoader.getService(qname);
59  		}
60  		return this.atpService;
61  	}
62  
63  	private ContextInfo getContextInfo() {
64  	    return ContextBuilder.loadContextInfo();
65  	}
66  }
67