001    /**
002     * Copyright 2004-2013 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.opensource.org/licenses/ecl2.php
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     */
016    package org.kuali.hr.paygrade.web;
017    
018    import org.apache.commons.lang3.StringUtils;
019    import org.kuali.hr.paygrade.PayGrade;
020    import org.kuali.hr.time.service.base.TkServiceLocator;
021    import org.kuali.hr.time.util.TKUtils;
022    import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
023    import org.kuali.rice.krad.bo.BusinessObject;
024    
025    import java.util.Map;
026    
027    public class PayGradeInquirableImpl extends KualiInquirableImpl {
028    
029            private static final long serialVersionUID = -4002061046745019065L;
030    
031            @Override
032            public BusinessObject getBusinessObject(Map fieldValues) {
033            PayGrade payGrade = null;
034            if (StringUtils.isNotBlank((String)fieldValues.get("hrPayGradeId"))) {
035                payGrade = TkServiceLocator.getPayGradeService().getPayGrade((String) fieldValues.get("hrPayGradeId"));
036            } else if (fieldValues.containsKey("payGrade")
037                    && fieldValues.containsKey("salGroup")
038                    && fieldValues.containsKey("effectiveDate")) {
039                String pg = (String)fieldValues.get("payGrade");
040                String sg = (String)fieldValues.get("salGroup");
041    
042                payGrade = TkServiceLocator.getPayGradeService().getPayGrade(pg, sg,
043                        new java.sql.Date(TKUtils.convertDateStringToTimestampNoTimezone((String) fieldValues.get("effectiveDate")).getTime()));
044            } else {
045                payGrade = (PayGrade) super.getBusinessObject(fieldValues);
046            }
047    
048    
049                    return payGrade;
050            }
051            
052    }