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