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.department.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.department.DepartmentBo;
24  import org.kuali.kpme.core.service.HrServiceLocatorInternal;
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 DepartmentInquirableImpl extends KualiInquirableImpl {
30  
31      private static final long serialVersionUID = 8809785231041208573L;
32  
33      // This class shouldn't be used any more
34      @Override
35      @SuppressWarnings("rawtypes")
36      public BusinessObject getBusinessObject(Map fieldValues) {
37          DepartmentBo departmentObj = null;
38  
39          if (StringUtils.isNotBlank((String) fieldValues.get("hrDeptId"))) {
40              departmentObj = HrServiceLocatorInternal.getDepartmentInternalService().getDepartmentWithRoleData((String) fieldValues.get("hrDeptId"));
41          } else if (fieldValues.containsKey("dept") && fieldValues.containsKey("groupKeyCode") && fieldValues.containsKey("effectiveDate")) {
42              String department = (String) fieldValues.get("dept");
43              String groupKeyCode = (String) fieldValues.get("groupKeyCode");
44              String effDate = (String) fieldValues.get("effectiveDate");
45              LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now() : TKUtils.formatDateString(effDate);
46              departmentObj = HrServiceLocatorInternal.getDepartmentInternalService().getDepartmentWithRoleData(department, groupKeyCode, effectiveDate);
47          } else {
48              departmentObj = (DepartmentBo) super.getBusinessObject(fieldValues);
49          }
50  
51          return departmentObj;
52      }
53  }