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