View Javadoc
1   /**
2    * Copyright 2004-2014 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.opensource.org/licenses/ecl2.php
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.kpme.core.institution.web;
17  
18  import java.util.Map;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.joda.time.LocalDate;
22  import org.kuali.kpme.core.api.institution.InstitutionContract;
23  import org.kuali.kpme.core.institution.InstitutionBo;
24  import org.kuali.kpme.core.service.HrServiceLocator;
25  import org.kuali.kpme.core.util.TKUtils;
26  import org.kuali.kpme.core.util.ValidationUtils;
27  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
28  import org.kuali.rice.krad.bo.BusinessObject;
29  
30  @SuppressWarnings("deprecation")
31  public class InstitutionInquirableImpl extends KualiInquirableImpl {
32  
33  	private static final long serialVersionUID = 7952001181052895833L;
34  
35  	@Override
36  	@SuppressWarnings("rawtypes")
37  	public BusinessObject getBusinessObject(Map fieldValues) {
38  		InstitutionBo institutionObj = null;
39  		if (StringUtils.isNotBlank((String) fieldValues.get("pmInstitutionId"))) {
40  			institutionObj = InstitutionBo.from(HrServiceLocator.getInstitutionService().getInstitutionById((String) fieldValues.get("pmInstitutionId")));
41          } else if (fieldValues.containsKey("institutionCode") && fieldValues.containsKey("effectiveDate")) {
42              String effDate = (String) fieldValues.get("effectiveDate");
43              LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now() : TKUtils.formatDateString(effDate);
44              
45              institutionObj = InstitutionBo.from(HrServiceLocator.getInstitutionService().getInstitution((String)fieldValues.get("institutionCode"), effectiveDate));
46          } else {
47         	 	if(fieldValues.get("institutionCode") != null && !ValidationUtils.isWildCard(fieldValues.get("institutionCode").toString())){
48         	 		institutionObj = (InstitutionBo) super.getBusinessObject(fieldValues);
49         	}
50  }
51  		return institutionObj;
52  	}
53  	
54  }