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 */
016package org.kuali.student.ui.admin.atp;
017
018
019import java.util.Map;
020import javax.xml.namespace.QName;
021import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
022import org.kuali.rice.krad.inquiry.InquirableImpl;
023import org.kuali.student.common.util.ContextBuilder;
024import org.kuali.student.r2.common.dto.ContextInfo;
025import org.kuali.student.r2.core.atp.dto.AtpAtpRelationInfo;
026import org.kuali.student.r2.core.atp.service.AtpService;
027import org.kuali.student.r2.core.constants.AtpServiceConstants;
028
029public class AtpAtpRelationInfoAdminInquirableImpl extends InquirableImpl
030{
031        private transient AtpService atpService;
032        private final static String PRIMARY_KEY = "id";
033    private static final long serialVersionUID = 1L;
034        @Override
035        public AtpAtpRelationInfo retrieveDataObject(Map<String, String> parameters)
036        {
037                String key = parameters.get(PRIMARY_KEY);
038                try
039                {
040            return this.getAtpService().getAtpAtpRelation(key, getContextInfo());
041                }
042                catch (Exception ex) {
043                    throw new RuntimeException(ex);
044                }
045        }
046
047        public void setAtpService(AtpService atpService)
048        {
049                    this.atpService = atpService;
050        }
051
052        public AtpService getAtpService()
053        {
054                if (atpService == null)
055                {
056                        QName qname = new QName(AtpServiceConstants.NAMESPACE,AtpServiceConstants.SERVICE_NAME_LOCAL_PART);
057                        atpService = (AtpService) GlobalResourceLoader.getService(qname);
058                }
059                return this.atpService;
060        }
061
062        private ContextInfo getContextInfo() {
063            return ContextBuilder.loadContextInfo();
064        }
065}
066