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.location.web;
17  
18  
19  import java.util.Map;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.joda.time.LocalDate;
23  import org.kuali.kpme.core.api.location.LocationContract;
24  import org.kuali.kpme.core.location.LocationBo;
25  import org.kuali.kpme.core.service.HrServiceLocator;
26  import org.kuali.kpme.core.service.HrServiceLocatorInternal;
27  import org.kuali.kpme.core.util.TKUtils;
28  import org.kuali.kpme.core.util.ValidationUtils;
29  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
30  import org.kuali.rice.krad.inquiry.InquirableImpl;
31  
32  public class LocationInquirableImpl extends KualiInquirableImpl  {//InquirableImpl
33  	
34  	private static final long serialVersionUID = -828163766114475072L;
35  
36  	@Override
37      @SuppressWarnings("rawtypes")
38      public LocationContract retrieveDataObject(Map fieldValues) {
39      	LocationBo locationObj = null;
40  
41      	if (StringUtils.isNotBlank((String) fieldValues.get("hrLocationId"))) {
42  			locationObj = HrServiceLocatorInternal.getLocationInternalService().getLocationWithRoleData((String) fieldValues.get("hrLocationId"));
43          } else if (fieldValues.containsKey("location")) {
44              String location = (String) fieldValues.get("location");
45              String effDate = (String) fieldValues.get("effectiveDate");
46              LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now() : TKUtils.formatDateString(effDate);
47              
48              locationObj = HrServiceLocatorInternal.getLocationInternalService().getLocationWithRoleData(location, effectiveDate);
49          } else {
50         	 	if(fieldValues.get("location") != null && !ValidationUtils.isWildCard(fieldValues.get("location").toString())){
51         	 		locationObj = (LocationBo) super.retrieveDataObject(fieldValues);
52         	 	}
53         	}
54  
55          return locationObj;
56      	
57      }
58  
59  }