View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.workarea.web;
17  
18  import java.util.Map;
19  
20  import org.apache.commons.lang3.StringUtils;
21  import org.kuali.hr.time.service.base.TkServiceLocator;
22  import org.kuali.hr.time.util.TKUtils;
23  import org.kuali.hr.time.workarea.WorkArea;
24  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
25  import org.kuali.rice.krad.bo.BusinessObject;
26  
27  public class WorkAreaInquirableImpl extends KualiInquirableImpl {
28  
29  	private static final long serialVersionUID = -4002061046745019065L;
30  
31  	@Override
32  	public BusinessObject getBusinessObject(Map fieldValues) {
33          WorkArea workArea = null;
34          if (StringUtils.isNotBlank((String)fieldValues.get("tkWorkAreaId"))) {
35              workArea = TkServiceLocator.getWorkAreaService().getWorkArea((String)fieldValues.get("tkWorkAreaId"));
36          } else if (fieldValues.containsKey("workArea") && fieldValues.containsKey("effectiveDate")) {
37              String workAreaVal = (String)fieldValues.get("workArea");
38              Long wa = workAreaVal != null ? Long.parseLong(workAreaVal) : null;
39              workArea = TkServiceLocator.getWorkAreaService().getWorkArea(wa,
40                      new java.sql.Date(TKUtils.convertDateStringToTimestampNoTimezone((String)fieldValues.get("effectiveDate")).getTime()));
41          } else {
42  	    	 workArea = (WorkArea) super.getBusinessObject(fieldValues);
43          }
44  
45          if (workArea != null) {
46          	TkServiceLocator.getWorkAreaService().populateWorkAreaTasks(workArea);
47  		    TkServiceLocator.getWorkAreaService().populateWorkAreaRoles(workArea);
48          }
49  
50  		return workArea;
51  	}
52  	
53  }