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.lm.leaveplan;
017
018 import java.sql.Date;
019 import java.text.ParseException;
020 import java.text.SimpleDateFormat;
021 import java.util.Map;
022
023 import org.apache.commons.lang.StringUtils;
024 import org.kuali.hr.time.service.base.TkServiceLocator;
025 import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
026 import org.kuali.rice.krad.bo.BusinessObject;
027
028 public class LeavePlanInquirableImpl extends KualiInquirableImpl {
029
030 @Override
031 public BusinessObject getBusinessObject(Map fieldValues) {
032
033 LeavePlan lp = null;
034 if(StringUtils.isNotBlank((String)fieldValues.get("lmLeavePlanId"))) {
035 lp = TkServiceLocator.getLeavePlanService().getLeavePlan((String)fieldValues.get("lmLeavePlanId"));
036
037 } else if(StringUtils.isNotBlank((String)fieldValues.get("leavePlan"))
038 && StringUtils.isNotBlank((String)fieldValues.get("effectiveDate"))) {
039 java.util.Date uDate = null;
040 try {
041 uDate = new SimpleDateFormat("MM/dd/yyyy").parse(fieldValues.get("effectiveDate").toString());
042
043 Date effdt = new java.sql.Date(uDate.getTime());
044 lp = TkServiceLocator.getLeavePlanService().getLeavePlan((String)fieldValues.get("leavePlan"), effdt);
045 } catch (ParseException e) {
046 e.printStackTrace();
047 }
048
049 } else {
050 lp = (LeavePlan) super.getBusinessObject(fieldValues);
051 }
052
053 return lp;
054 }
055
056 }