1 /** 2 * Copyright 2005-2015 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.rice.kns.lookup; 17 18 import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions; 19 import org.kuali.rice.kns.web.struts.form.LookupForm; 20 import org.kuali.rice.kns.web.ui.Column; 21 import org.kuali.rice.kns.web.ui.Field; 22 import org.kuali.rice.kns.web.ui.ResultRow; 23 import org.kuali.rice.kns.web.ui.Row; 24 import org.kuali.rice.krad.bo.BusinessObject; 25 import org.kuali.rice.kns.service.BusinessObjectDictionaryService; 26 import org.kuali.rice.krad.service.DataDictionaryService; 27 28 import java.io.Serializable; 29 import java.util.Collection; 30 import java.util.List; 31 import java.util.Map; 32 33 public interface LookupableHelperService extends Serializable{ 34 35 /** 36 * Initializes the lookup with a business object class. This is set 37 * via the LookupableHelperService's consumer, namely the Lookupable 38 * implementation (or in cases of nesting a wrapping LookupableHelperService). 39 * The Lookupable in turn receives this value from the UI via 40 * LookupForm population. 41 * 42 * @param businessObjectClass 43 */ 44 public void setBusinessObjectClass(Class businessObjectClass); 45 46 /** 47 * @return Returns the dataObjectClass this lookupable is representing 48 */ 49 // NOTE: used in exactly one place in RuleBaseValuesLookupableHelperServiceImpl to conditionally initialize 50 // an internal lookup helper service reference; this reference should in theory be a unique instance or prototype 51 // so the check should not be necessary 52 public Class getBusinessObjectClass(); 53 54 /** 55 * Initializes the lookup with the given Map of parameters. 56 * 57 * @param parameters 58 */ 59 public void setParameters(Map<String, String[]> parameters); 60 61 /** 62 * @return Returns the parameters passed to this lookup 63 */ 64 public Map<String, String[]> getParameters(); 65 66 /** 67 * @return String url for the location to return to after the lookup 68 */ 69 public String getReturnLocation(); 70 71 /** 72 * @return List of Column objects used to render the result table 73 */ 74 public List<Column> getColumns(); 75 76 /** 77 * Validates the values filled in as search criteria, also checks for required field values. 78 * 79 * @param fieldValues - Map of property/value pairs 80 */ 81 public void validateSearchParameters(Map<String, String> fieldValues); 82 83 /** 84 * Performs a search and returns result list. 85 * 86 * @param fieldValues - Map of property/value pairs 87 * @return List of business objects found by the search 88 * @throws Exception 89 */ 90 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues); 91 92 /** 93 * Similar to getSearchResults, but the number of returned rows is not bounded 94 * 95 * @param fieldValues 96 * @return 97 */ 98 public List<? extends BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues); 99 100 /** 101 * Determines if there should be more search fields rendered based on already entered search criteria. 102 * 103 * @param fieldValues - Map of property/value pairs 104 * @return boolean 105 */ 106 public boolean checkForAdditionalFields(Map<String, String> fieldValues); 107 108 /** 109 * Builds the return value url. 110 * 111 * @param businessObject - Instance of a business object containing the return values 112 * @param fieldConversions - Map of conversions mapping bo names to caller field names. 113 * @param lookupImpl - Current lookup impl name 114 * @param returnKeys - Keys to return 115 * @return String url called when selecting a row from the result set 116 */ 117 public HtmlData getReturnUrl(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions); 118 119 /** 120 * This method builds the return url 121 * 122 * @param businessObject 123 * @param lookupForm 124 * @param returnKeys 125 * @return 126 */ 127 public HtmlData getReturnUrl(BusinessObject businessObject, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions); 128 129 /** 130 * Builds string of action urls that can take place for a result row 131 * 132 * @param businessObject - Instance of a business object containing the return values 133 * @param pkNames - List of primary key names 134 * @return String rendered in actions column of result set 135 */ 136 public String getActionUrls(BusinessObject businessObject, List pkNames, BusinessObjectRestrictions businessObjectRestrictions); 137 138 /** 139 * 140 * This method is a template method that allows child classes to return their own custom action html data. 141 * 142 * @param businessObject 143 * @param pkNames 144 * @return 145 */ 146 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames); 147 148 /** 149 * Builds string an inquiry url for drill down on a result field 150 * 151 * @param businessObject - Instance of a business object containing the return values 152 * @param propertyName - Name of the property in the business object 153 * @return String url called on selection of the result field 154 */ 155 public HtmlData getInquiryUrl(BusinessObject businessObject, String propertyName); 156 157 /** 158 * Sets the requested fields conversions in the lookupable 159 * 160 * @param fieldConversions 161 */ 162 public void setFieldConversions(Map fieldConversions); 163 164 /** 165 * Gets the readOnlyFieldsList attribute. 166 * @return Returns the readOnlyFieldsList. 167 */ 168 public List<String> getReadOnlyFieldsList(); 169 170 /** 171 * Sets the requested read only fields list in the lookupable 172 * 173 * @param readOnlyFieldsList 174 */ 175 public void setReadOnlyFieldsList(List<String> readOnlyFieldsList); 176 177 /** 178 * This method is public because some unit tests depend on it. 179 * 180 * @return a List of the names of fields which are marked in data dictionary as return fields. 181 */ 182 public List<String> getReturnKeys(); 183 184 public String getDocFormKey(); 185 186 public void setDocFormKey(String docFormKey); 187 188 public String getDocNum(); 189 190 public void setDocNum(String docNum); 191 192 /** 193 * 194 * This method builds a maintenance url. 195 * 196 * @param businessObject 197 * @param htmlData 198 * @param pkNames 199 * @return 200 */ 201 public String getMaintenanceUrl(BusinessObject businessObject, HtmlData htmlData, List pkNames, BusinessObjectRestrictions businessObjectRestrictions); 202 203 /** 204 * Determines if underlying lookup bo has associated maintenance document that allows new or copy maintenance actions. 205 * 206 * @return true if bo has maint doc that allows new or copy actions 207 */ 208 public boolean allowsMaintenanceNewOrCopyAction(); 209 210 /** 211 * Determines if underlying lookup bo has associated document that allows new or copy maintenance actions. 212 * 213 * @return true if bo has doc that allows new or copy actions 214 */ 215 public boolean allowsNewOrCopyAction(String documentTypeName); 216 217 /** 218 * Returns a list of Row objects to be used to generate the search query screen 219 * 220 * Generally, setDataObjectClass needs to be called with a non-null value for proper operation 221 * @return 222 */ 223 public List<Row> getRows(); 224 225 /** 226 * This method returns the DataDictionaryService used to initialize this helper service and is used by Lookupable implementations to 227 * retrieve the proper service. 228 * 229 * @return 230 */ 231 public DataDictionaryService getDataDictionaryService(); 232 233 /** 234 * This method returns the BusinessObjectDictionaryService used to initialize this helper service and is used by Lookupable implementations to 235 * retrieve the proper service. 236 * 237 * @return 238 */ 239 public BusinessObjectDictionaryService getBusinessObjectDictionaryService(); 240 241 public void setBackLocation(String backLocation); 242 243 public String getBackLocation(); 244 245 /** 246 * 247 * This method performs the lookup and returns a collection of BO items 248 * @param lookupForm 249 * @param resultTable 250 * @param bounded 251 * @return the list of result BOs, possibly bounded 252 */ 253 public Collection<? extends BusinessObject> performLookup(LookupForm lookupForm, Collection<ResultRow> resultTable, boolean bounded); 254 255 /** 256 * This method returns a list of the default columns used to sort the result set. For multiple value lookups, 257 * this method does not change when different columns are sorted. 258 * 259 * @return 260 */ 261 public List<String> getDefaultSortColumns(); 262 263 /** 264 * This method returns whether the previously executed getSearchResults used the primary key values to search, ignoring all non key values 265 * 266 * @return 267 * @see LookupableHelperService#getPrimaryKeyFieldLabels() 268 */ 269 public boolean isSearchUsingOnlyPrimaryKeyValues(); 270 271 /** 272 * Returns a comma delimited list of primary key field labels, to be used on the UI to tell the user which fields were used to search 273 * 274 * @return 275 * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues() 276 */ 277 public String getPrimaryKeyFieldLabels(); 278 279 /** 280 * Determines whether a given BusinessObject that's returned as one of the lookup's results is considered returnable, which means that for 281 * single-value lookups, a "return value" link may be rendered, and for multiple value lookups, a checkbox is rendered. 282 * 283 * Note that this can be part of an authorization mechanism, but not the complete authorization mechanism. The component that invoked the lookup/ 284 * lookup caller (e.g. document, nesting lookup, etc.) needs to check that the object that was passed to it was returnable as well because there 285 * are ways around this method (e.g. crafting a custom return URL). 286 * 287 * @param object an object from the search result set 288 * @return 289 */ 290 public boolean isResultReturnable(BusinessObject object); 291 292 /** 293 * 294 * This method allows for overriding the clear behavior 295 * 296 */ 297 public void performClear(LookupForm lookupForm); 298 299 public boolean shouldDisplayHeaderNonMaintActions(); 300 301 public boolean shouldDisplayLookupCriteria(); 302 303 /** 304 * This method gets the supplemental lookup menu if any 305 * 306 * @return supplemental menu bar 307 */ 308 public String getSupplementalMenuBar(); 309 310 /** 311 * @return String displayed as title for the lookup 312 */ 313 public String getTitle(); 314 315 /** 316 * 317 * performs custom actions. return true to reperform search 318 * 319 * @param ignoreErrors 320 * @return boolean to reperform search 321 */ 322 public boolean performCustomAction(boolean ignoreErrors); 323 324 /** 325 * get an extra field 326 * @return 327 */ 328 public Field getExtraField(); 329 330 public void applyFieldAuthorizationsFromNestedLookups(Field field); 331 332 /** 333 * Performs conditional logic (based on current search values or other parameters) to 334 * override field hidden, read-only, and required attributes previously set. 335 */ 336 public void applyConditionalLogicForFieldDisplay(); 337 }