View Javadoc
1   /**
2    * Copyright 2004-2015 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.paygrade.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.paygrade.PayGrade;
24  import org.kuali.kpme.core.service.HrServiceLocator;
25  import org.kuali.kpme.core.util.TKUtils;
26  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
27  import org.kuali.rice.krad.bo.BusinessObject;
28  
29  public class PayGradeInquirableImpl extends KualiInquirableImpl {
30  
31  	private static final long serialVersionUID = -4002061046745019065L;
32  
33  	@Override
34  	public BusinessObject getBusinessObject(Map fieldValues) {
35          PayGrade payGrade = null;
36          if (StringUtils.isNotBlank((String) fieldValues.get("hrPayGradeId"))) {
37              payGrade = HrServiceLocator.getPayGradeService().getPayGrade((String) fieldValues.get("hrPayGradeId"));
38          } else if (fieldValues.containsKey("payGrade")
39                  && fieldValues.containsKey("salGroup")) {
40              String pg = (String)fieldValues.get("payGrade");
41              String sg = (String)fieldValues.get("salGroup");
42              String effDate = (String) fieldValues.get("effectiveDate");
43              LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now() : TKUtils.formatDateString(effDate);
44              
45              payGrade = HrServiceLocator.getPayGradeService().getPayGrade(pg, sg, effectiveDate);
46          } else {
47              payGrade = (PayGrade) super.getBusinessObject(fieldValues);
48          }
49  
50  
51  		return payGrade;
52  	}
53  	
54  }