1 /** 2 * Copyright 2010 The Kuali Foundation Licensed under the 3 * Educational Community License, Version 2.0 (the "License"); you may 4 * not use this file except in compliance with the License. You may 5 * obtain a copy of the License at 6 * 7 * http://www.osedu.org/licenses/ECL-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, 10 * software distributed under the License is distributed on an "AS IS" 11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 * or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 /** 17 * 18 */ 19 package org.kuali.rice.student.lookup.keyvalues; 20 21 import javax.xml.namespace.QName; 22 23 import org.apache.commons.lang.StringUtils; 24 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 25 import org.kuali.rice.core.api.util.ConcreteKeyValue; 26 import org.kuali.rice.core.api.util.KeyValue; 27 import org.kuali.rice.krad.keyvalues.KeyValuesBase; 28 import org.kuali.student.r2.core.organization.service.OrganizationService; 29 /** 30 * Convenience class used to help out key values classes 31 * 32 */ 33 public abstract class StudentKeyValuesBase extends KeyValuesBase { 34 35 private static OrganizationService organizationService; 36 37 protected static OrganizationService getOrganizationService() { 38 if (organizationService == null) { 39 organizationService = (OrganizationService) GlobalResourceLoader 40 .getService(new QName("http://student.kuali.org/wsdl/organization","OrganizationService")); 41 } 42 return organizationService; 43 } 44 45 /** 46 * Builds a valid {@link KeyValue} object for use in Student system KeyValue classes. Will throw an {@link IllegalArgumentException} 47 * if the parameters needed are not passed. 48 * 49 * @param orgId 50 * @param orgShortName 51 * @param orgLongName 52 * @param orgType 53 * @return 54 */ 55 56 //** question from Bonnie: Why the input parameters have orgId, orgShortName, orgLongName and orgType, 57 //** but the output of KeyLabelPair is constructed with orgShortName for both key and label? 58 //** This looks weird for me. 59 protected static KeyValue buildKeyLabelPair(String orgId, String orgShortName, String orgLongName, String orgType) { 60 if (StringUtils.isBlank(orgShortName)) { 61 throw new IllegalArgumentException("Blank value for orgShortName is invalid."); 62 } 63 // return new KeyLabelPair(orgShortName, orgShortName); 64 return new ConcreteKeyValue(orgId, orgShortName); 65 } 66 67 }