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.time.calendar.service; 017 018 import java.util.List; 019 import java.util.Map; 020 import java.util.Properties; 021 022 import org.kuali.hr.time.calendar.Calendar; 023 import org.kuali.hr.time.service.base.TkServiceLocator; 024 import org.kuali.rice.kns.lookup.HtmlData; 025 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; 026 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl; 027 import org.kuali.rice.krad.bo.BusinessObject; 028 import org.kuali.rice.krad.util.KRADConstants; 029 import org.kuali.rice.krad.util.UrlFactory; 030 031 public class CalendarLookupableHelper extends KualiLookupableHelperServiceImpl { 032 033 private static final long serialVersionUID = 2324703412211619217L; 034 035 @Override 036 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) { 037 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames); 038 039 Calendar calendar = (Calendar) businessObject; 040 String hrCalendarId = calendar.getHrCalendarId(); 041 042 Properties params = new Properties(); 043 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName()); 044 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL); 045 params.put("hrCalendarId", hrCalendarId); 046 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view"); 047 viewUrl.setDisplayText("view"); 048 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK); 049 customActionUrls.add(viewUrl); 050 051 return customActionUrls; 052 } 053 054 @Override 055 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { 056 String calendarName = fieldValues.get("calendarName"); 057 String calendarTypes = fieldValues.get("calendarTypes"); 058 String flsaBeginDay = fieldValues.get("flsaBeginDay"); 059 String flsaBeginTime = fieldValues.get("flsaBeginTime"); 060 061 return TkServiceLocator.getCalendarService().getCalendars(calendarName, calendarTypes, flsaBeginDay, flsaBeginTime); 062 // String flsaTime = null; 063 // if(fieldValues.containsKey("flsaBeginTime")){ 064 // flsaTime = fieldValues.get("flsaBeginTime"); 065 // fieldValues.remove("flsaBeginTime"); 066 // } 067 // List<? extends BusinessObject> objectList = super.getSearchResults(fieldValues); 068 // if(!objectList.isEmpty() && flsaTime != null && StringUtils.isNotBlank(flsaTime)){ 069 // SimpleDateFormat sdFormat = new SimpleDateFormat("hh:mm aa"); 070 // Time flsaBeginTime = null; 071 // try { 072 // flsaBeginTime = new Time(sdFormat.parse(flsaTime).getTime()); 073 // Iterator itr = objectList.iterator(); 074 // while(itr.hasNext()){ 075 // Calendar pc = (Calendar)itr.next(); 076 // if(pc.getFlsaBeginTime()!= null && !pc.getFlsaBeginTime().equals(flsaBeginTime)){ 077 // itr.remove(); 078 // } 079 // } 080 // } catch (ParseException e) { 081 // } 082 // } 083 // return objectList; 084 } 085 086 }