1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar.service;
17
18 import java.sql.Time;
19 import java.text.ParseException;
20 import java.text.SimpleDateFormat;
21 import java.util.Iterator;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Properties;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.kuali.hr.time.calendar.Calendar;
28 import org.kuali.rice.kns.lookup.HtmlData;
29 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
30 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
31 import org.kuali.rice.krad.bo.BusinessObject;
32 import org.kuali.rice.krad.util.KRADConstants;
33 import org.kuali.rice.krad.util.UrlFactory;
34
35 public class CalendarLookupableHelper extends KualiLookupableHelperServiceImpl {
36
37 private static final long serialVersionUID = 2324703412211619217L;
38
39 @Override
40 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
42
43 Calendar calendar = (Calendar) businessObject;
44 String hrCalendarId = calendar.getHrCalendarId();
45
46 Properties params = new Properties();
47 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
48 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
49 params.put("hrCalendarId", hrCalendarId);
50 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
51 viewUrl.setDisplayText("view");
52 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
53 customActionUrls.add(viewUrl);
54
55 return customActionUrls;
56 }
57
58 @Override
59 public List<? extends BusinessObject> getSearchResults(
60 Map<String, String> fieldValues) {
61 String flsaTime = null;
62 if(fieldValues.containsKey("flsaBeginTime")){
63 flsaTime = fieldValues.get("flsaBeginTime");
64 fieldValues.remove("flsaBeginTime");
65 }
66 List<? extends BusinessObject> objectList = super.getSearchResults(fieldValues);
67 if(!objectList.isEmpty() && flsaTime != null && StringUtils.isNotBlank(flsaTime)){
68 SimpleDateFormat sdFormat = new SimpleDateFormat("hh:mm aa");
69 Time flsaBeginTime = null;
70 try {
71 flsaBeginTime = new Time(sdFormat.parse(flsaTime).getTime());
72 Iterator itr = objectList.iterator();
73 while(itr.hasNext()){
74 Calendar pc = (Calendar)itr.next();
75 if(pc.getFlsaBeginTime()!= null && !pc.getFlsaBeginTime().equals(flsaBeginTime)){
76 itr.remove();
77 }
78 }
79 } catch (ParseException e) {
80 }
81 }
82 return objectList;
83 }
84
85 }