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.tklm.time.rules.lunch.sys.web;
17  
18  import java.util.List;
19  import java.util.Map;
20  import java.util.Properties;
21  
22  import org.kuali.kpme.core.lookup.KPMELookupableHelper;
23  import org.kuali.kpme.core.util.TKUtils;
24  import org.kuali.kpme.tklm.time.rules.lunch.sys.SystemLunchRule;
25  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
26  import org.kuali.rice.kns.lookup.HtmlData;
27  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
28  import org.kuali.rice.krad.bo.BusinessObject;
29  import org.kuali.rice.krad.util.KRADConstants;
30  import org.kuali.rice.krad.util.UrlFactory;
31  
32  @SuppressWarnings("deprecation")
33  public class SystemLunchRuleLookupableHelper extends KPMELookupableHelper {
34  
35  	private static final long serialVersionUID = 6752606867867978501L;
36  
37  	@Override
38  	@SuppressWarnings("rawtypes")
39  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
40  		List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
41  
42  		SystemLunchRule systemLunchRule = (SystemLunchRule) businessObject;
43  		String tkSystemLunchRuleId = systemLunchRule.getTkSystemLunchRuleId();
44  		
45  		Properties params = new Properties();
46  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
47  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
48  		params.put("tkSystemLunchRuleId", tkSystemLunchRuleId);
49  		AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
50  		viewUrl.setDisplayText("view");
51  		viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
52  		customActionUrls.add(viewUrl);
53  		
54  		return customActionUrls;
55  	}
56  
57      @Override
58      public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
59          String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
60          String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
61          String active = fieldValues.get("active");
62          String showHist = fieldValues.get("history");
63  
64          return TkServiceLocator.getSystemLunchRuleService().getSystemLunchRules(TKUtils.formatDateString(fromEffdt),
65                  TKUtils.formatDateString(toEffdt), active, showHist);
66      }
67      
68  }