001 /* 002 * Copyright 2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.osedu.org/licenses/ECL-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.student.ui.admin.atp; 017 018 019 import java.util.ArrayList; 020 import java.util.List; 021 import java.util.Map; 022 import javax.xml.namespace.QName; 023 import org.apache.log4j.Logger; 024 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 025 import org.kuali.rice.krad.inquiry.InquirableImpl; 026 import org.kuali.student.enrollment.common.util.ContextBuilder; 027 import org.kuali.student.r2.common.dto.ContextInfo; 028 import org.kuali.student.r2.core.atp.dto.AtpAtpRelationInfo; 029 import org.kuali.student.r2.core.atp.service.AtpService; 030 import org.kuali.student.r2.core.constants.AtpServiceConstants; 031 032 033 public class AtpAtpRelationInfoAdminInquirableImpl extends InquirableImpl 034 { 035 private static final Logger LOG = Logger.getLogger(AtpAtpRelationInfoAdminInquirableImpl.class); 036 private transient AtpService atpService; 037 private final static String PRIMARY_KEY = "id"; 038 private static final long serialVersionUID = 1L; 039 @Override 040 public AtpAtpRelationInfo retrieveDataObject(Map<String, String> parameters) 041 { 042 String key = parameters.get(PRIMARY_KEY); 043 try 044 { 045 AtpAtpRelationInfo info = this.getAtpService().getAtpAtpRelation(key, getContextInfo()); 046 return info; 047 } 048 catch (Exception ex) { 049 throw new RuntimeException(ex); 050 } 051 } 052 053 public void setAtpService(AtpService atpService) 054 { 055 this.atpService = atpService; 056 } 057 058 public AtpService getAtpService() 059 { 060 if (atpService == null) 061 { 062 QName qname = new QName(AtpServiceConstants.NAMESPACE,AtpServiceConstants.SERVICE_NAME_LOCAL_PART); 063 atpService = (AtpService) GlobalResourceLoader.getService(qname); 064 } 065 return this.atpService; 066 } 067 068 private ContextInfo getContextInfo() { 069 return ContextBuilder.loadContextInfo(); 070 } 071 } 072