001package org.kuali.ole.deliver.lookup; 002 003import org.apache.commons.lang.StringUtils; 004import org.kuali.ole.OLEConstants; 005import org.kuali.ole.deliver.bo.OleCirculationDesk; 006import org.kuali.rice.krad.lookup.LookupableImpl; 007import org.kuali.rice.krad.uif.UifConstants; 008import org.kuali.rice.krad.uif.UifParameters; 009import org.kuali.rice.krad.uif.view.LookupView; 010import org.kuali.rice.krad.util.GlobalVariables; 011import org.kuali.rice.krad.util.KRADConstants; 012import org.kuali.rice.krad.util.KRADUtils; 013import org.kuali.rice.krad.util.UrlFactory; 014import org.kuali.rice.krad.web.form.LookupForm; 015 016import java.util.ArrayList; 017import java.util.List; 018import java.util.Map; 019import java.util.Properties; 020 021/** 022 * OleLicenseRequestLookupableImpl is the view helper service class for Ole License Request Document 023 */ 024public class OleCirculationDeskLocationLookupableImpl extends LookupableImpl { 025 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleCirculationDeskLocationLookupableImpl.class); 026 027 /** 028 * This method returns action URL as oleLicenseRequest. 029 * 030 * @param lookupForm 031 * @param dataObject 032 * @param methodToCall 033 * @param pkNames 034 * @return String 035 */ 036 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, 037 List<String> pkNames) { 038 LOG.debug("Inside getActionUrlHref()"); 039 LookupView lookupView = (LookupView) lookupForm.getView(); 040 041 Properties props = new Properties(); 042 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall); 043 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject); 044 for (String primaryKey : primaryKeyValues.keySet()) { 045 String primaryKeyValue = primaryKeyValues.get(primaryKey); 046 047 props.put(primaryKey, primaryKeyValue); 048 } 049 050 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) { 051 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation()); 052 } 053 054 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OleCirculationDesk.class.getName()); 055 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name()); 056 057 String maintenanceMapping = "oleCirculationDeskMaintenance"; 058 059 return UrlFactory.parameterizeUrl(maintenanceMapping, props); 060 } 061 062 @Override 063 protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) { 064 065 List<?> searchResults; 066 List<OleCirculationDesk> finalSearchResult = new ArrayList<OleCirculationDesk>(); 067 List<OleCirculationDesk> oleCirculationDesk = new ArrayList<OleCirculationDesk>(); 068 069 oleCirculationDesk = (List<OleCirculationDesk>) super.getSearchResults(form, searchCriteria, unbounded); 070 finalSearchResult.addAll(oleCirculationDesk); 071 072 searchResults = finalSearchResult; 073 if (searchResults.size() == 0) { 074 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.NO_RECORD_FOUND); 075 } 076 sortSearchResults(form, searchResults); 077 return searchResults; 078 } 079 080 081}