1 /* 2 * Copyright 2007-2010 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 java.util.ArrayList; 19 import java.util.Collection; 20 import java.util.List; 21 import java.util.Map; 22 23 import org.kuali.rice.kns.authorization.BusinessObjectRestrictions; 24 import org.kuali.rice.kns.bo.BusinessObject; 25 import org.kuali.rice.kns.service.BusinessObjectDictionaryService; 26 import org.kuali.rice.kns.service.DataDictionaryService; 27 import org.kuali.rice.kns.service.KNSServiceLocator; 28 import org.kuali.rice.kns.web.struts.form.LookupForm; 29 import org.kuali.rice.kns.web.ui.Field; 30 import org.kuali.rice.kns.web.ui.Row; 31 32 /** 33 * Mock lookupable helper service for the LookupResultsService test 34 * 35 * @author Kuali Rice Team (rice.collab@kuali.org) 36 * 37 */ 38 public class LookupResultsDDBoLookupableHelperServiceImpl implements LookupableHelperService { 39 40 /** 41 * Just sends back whatever someValue was sent in - or "A" as some value if nothing else was out there 42 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getSearchResults(java.util.Map) 43 */ 44 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { 45 final String valueToPopulate = (fieldValues.containsKey("someValue")) ? fieldValues.get("someValue") : "A"; 46 final LookupResultsDDBo result = new LookupResultsDDBo(valueToPopulate); 47 List<LookupResultsDDBo> results = new ArrayList<LookupResultsDDBo>(); 48 results.add(result); 49 return results; 50 } 51 52 /** 53 * Always return false 54 * 55 * @see org.kuali.rice.kns.lookup.LookupableHelperService#allowsMaintenanceNewOrCopyAction() 56 */ 57 public boolean allowsMaintenanceNewOrCopyAction() { 58 return false; 59 } 60 61 /** 62 * Always return false 63 * 64 * @see org.kuali.rice.kns.lookup.LookupableHelperService#allowsNewOrCopyAction(java.lang.String) 65 */ 66 public boolean allowsNewOrCopyAction(String documentTypeName) { 67 return false; 68 } 69 70 /** 71 * Don't do anything 72 * 73 * @see org.kuali.rice.kns.lookup.LookupableHelperService#applyFieldAuthorizationsFromNestedLookups(org.kuali.rice.kns.web.ui.Field) 74 */ 75 public void applyFieldAuthorizationsFromNestedLookups(Field field) {} 76 77 /** 78 * Always returns false 79 * 80 * @see org.kuali.rice.kns.lookup.LookupableHelperService#checkForAdditionalFields(java.util.Map) 81 */ 82 public boolean checkForAdditionalFields(Map fieldValues) { 83 return false; 84 } 85 86 /** 87 * Always returns a blank String 88 * 89 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getActionUrls(org.kuali.rice.kns.bo.BusinessObject, java.util.List, org.kuali.rice.kns.authorization.BusinessObjectRestrictions) 90 */ 91 public String getActionUrls(BusinessObject businessObject, List pkNames, BusinessObjectRestrictions businessObjectRestrictions) { 92 return ""; 93 } 94 95 /** 96 * Always returns blank String 97 * 98 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getBackLocation() 99 */ 100 public String getBackLocation() { 101 return ""; 102 } 103 104 /** 105 * Always returns the class of LookupResultsDDBo 106 * 107 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getBusinessObjectClass() 108 */ 109 public Class getBusinessObjectClass() { 110 return LookupResultsDDBo.class; 111 } 112 113 /** 114 * Gets the class from the KNSServiceLocator 115 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getBusinessObjectDictionaryService() 116 */ 117 public BusinessObjectDictionaryService getBusinessObjectDictionaryService() { 118 return KNSServiceLocator.getBusinessObjectDictionaryService(); 119 } 120 121 /** 122 * Always returns null 123 * 124 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getColumns() 125 */ 126 public List getColumns() { 127 return null; 128 } 129 130 /** 131 * Always returns null 132 * 133 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getCustomActionUrls(org.kuali.rice.kns.bo.BusinessObject, java.util.List) 134 */ 135 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) { 136 return null; 137 } 138 139 /** 140 * Returns DataDictionaryService from KNSServiceLocator 141 * 142 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getDataDictionaryService() 143 */ 144 public DataDictionaryService getDataDictionaryService() { 145 return KNSServiceLocator.getDataDictionaryService(); 146 } 147 148 /** 149 * Always returns null 150 * 151 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getDefaultSortColumns() 152 */ 153 public List getDefaultSortColumns() { 154 return null; 155 } 156 157 /** 158 * Always returns an empty String 159 * 160 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getDocFormKey() 161 */ 162 public String getDocFormKey() { 163 return ""; 164 } 165 166 /** 167 * Always returns empty String 168 * 169 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getDocNum() 170 */ 171 public String getDocNum() { 172 return ""; 173 } 174 175 /** 176 * Always returns null 177 * 178 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getExtraField() 179 */ 180 public Field getExtraField() { 181 return null; 182 } 183 184 /** 185 * Always returns null 186 * 187 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject, java.lang.String) 188 */ 189 public HtmlData getInquiryUrl(BusinessObject businessObject, String propertyName) { 190 return null; 191 } 192 193 /** 194 * Always returns null 195 * 196 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getMaintenanceUrl(org.kuali.rice.kns.bo.BusinessObject, org.kuali.rice.kns.lookup.HtmlData, java.util.List, org.kuali.rice.kns.authorization.BusinessObjectRestrictions) 197 */ 198 public String getMaintenanceUrl(BusinessObject businessObject, HtmlData htmlData, List pkNames, BusinessObjectRestrictions businessObjectRestrictions) { 199 return null; 200 } 201 202 /** 203 * Always returns null 204 * 205 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getParameters() 206 */ 207 public Map getParameters() { 208 return null; 209 } 210 211 /** 212 * Returns an incredibly sophisticated puzzle that would require the smartest genius on earth years to disentangle. It only appears to return null 213 * 214 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getPrimaryKeyFieldLabels() 215 */ 216 public String getPrimaryKeyFieldLabels() { 217 return null; 218 } 219 220 /** 221 * Isn't this class exciting? 222 * 223 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getReadOnlyFieldsList() 224 */ 225 public List<String> getReadOnlyFieldsList() { 226 return null; 227 } 228 229 /** 230 * It does ever so much work 231 * 232 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getReturnKeys() 233 */ 234 public List getReturnKeys() { 235 return null; 236 } 237 238 /** 239 * Returns null for everything 240 * 241 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getReturnLocation() 242 */ 243 public String getReturnLocation() { 244 return null; 245 } 246 247 /** 248 * Yeah, this too 249 * 250 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getReturnUrl(org.kuali.rice.kns.bo.BusinessObject, org.kuali.rice.kns.web.struts.form.LookupForm, java.util.List, org.kuali.rice.kns.authorization.BusinessObjectRestrictions) 251 */ 252 public HtmlData getReturnUrl(BusinessObject businessObject, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions) { 253 return null; 254 } 255 256 /** 257 * Why am I doing all of this? 258 * 259 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getReturnUrl(org.kuali.rice.kns.bo.BusinessObject, java.util.Map, java.lang.String, java.util.List, org.kuali.rice.kns.authorization.BusinessObjectRestrictions) 260 */ 261 public HtmlData getReturnUrl(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions) { 262 return null; 263 } 264 265 /** 266 * Why not just extend AbstractLookupableHelperServiceImpl? 267 * 268 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getRows() 269 */ 270 public List<Row> getRows() { 271 return null; 272 } 273 274 /** 275 * Oh, trust me... 276 * 277 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map) 278 */ 279 public List getSearchResultsUnbounded(Map<String, String> fieldValues) { 280 return null; 281 } 282 283 /** 284 * There's a story there 285 * 286 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSupplementalMenuBar() 287 */ 288 public String getSupplementalMenuBar() { 289 return null; 290 } 291 292 /** 293 * At any rate, my unit test works 294 * 295 * @see org.kuali.rice.kns.lookup.LookupableHelperService#getTitle() 296 */ 297 public String getTitle() { 298 return null; 299 } 300 301 /** 302 * And I just have a lot of dead methods 303 * 304 * @see org.kuali.rice.kns.lookup.LookupableHelperService#isResultReturnable(org.kuali.rice.kns.bo.BusinessObject) 305 */ 306 public boolean isResultReturnable(BusinessObject object) { 307 return false; 308 } 309 310 /** 311 * I'm not injecting dependencies 312 * 313 * @see org.kuali.rice.kns.lookup.LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues() 314 */ 315 public boolean isSearchUsingOnlyPrimaryKeyValues() { 316 return false; 317 } 318 319 /** 320 * This method found it hard pressed to do anything... 321 * 322 * @see org.kuali.rice.kns.lookup.LookupableHelperService#performClear(org.kuali.rice.kns.web.struts.form.LookupForm) 323 */ 324 public void performClear(LookupForm lookupForm) {} 325 326 /** 327 * Always returns false 328 * 329 * @see org.kuali.rice.kns.lookup.LookupableHelperService#performCustomAction(boolean) 330 */ 331 public boolean performCustomAction(boolean ignoreErrors) { 332 return false; 333 } 334 335 /** 336 * Always returns null 337 * 338 * @see org.kuali.rice.kns.lookup.LookupableHelperService#performLookup(org.kuali.rice.kns.web.struts.form.LookupForm, java.util.Collection, boolean) 339 */ 340 public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) { 341 return null; 342 } 343 344 /** 345 * Ignores the passed in value 346 * 347 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setBackLocation(java.lang.String) 348 */ 349 public void setBackLocation(String backLocation) {} 350 351 /** 352 * Throws the passed in value away 353 * 354 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setBusinessObjectClass(java.lang.Class) 355 */ 356 public void setBusinessObjectClass(Class businessObjectClass) {} 357 358 /** 359 * Did you actually want this mock service to save this information? I think not... 360 * 361 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setDocFormKey(java.lang.String) 362 */ 363 public void setDocFormKey(String docFormKey) {} 364 365 /** 366 * Does nothing 367 * 368 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setDocNum(java.lang.String) 369 */ 370 public void setDocNum(String docNum) {} 371 372 /** 373 * Doesn't do a thing 374 * 375 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setFieldConversions(java.util.Map) 376 */ 377 public void setFieldConversions(Map fieldConversions) {} 378 379 /** 380 * Doesn't set anything 381 * 382 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setParameters(java.util.Map) 383 */ 384 public void setParameters(Map parameters) {} 385 386 /** 387 * doesn't set anything 388 * 389 * @see org.kuali.rice.kns.lookup.LookupableHelperService#setReadOnlyFieldsList(java.util.List) 390 */ 391 public void setReadOnlyFieldsList(List<String> readOnlyFieldsList) {} 392 393 /** 394 * Always returns true, so that James isn't completely bored 395 * 396 * @see org.kuali.rice.kns.lookup.LookupableHelperService#shouldDisplayHeaderNonMaintActions() 397 */ 398 public boolean shouldDisplayHeaderNonMaintActions() { 399 return true; 400 } 401 402 /** 403 * Flips a coin to determine whether to return true or false 404 * 405 * @see org.kuali.rice.kns.lookup.LookupableHelperService#shouldDisplayLookupCriteria() 406 */ 407 public boolean shouldDisplayLookupCriteria() { 408 java.util.Random r = new java.util.Random(); 409 double value = r.nextDouble(); 410 return (value < 0.5); 411 } 412 413 /** 414 * Everything's valid, trust us 415 * 416 * @see org.kuali.rice.kns.lookup.LookupableHelperService#validateSearchParameters(java.util.Map) 417 */ 418 public void validateSearchParameters(Map fieldValues) {} 419 420 /** 421 * @see org.kuali.rice.kns.lookup.LookupableHelperService#applyConditionalLogicForFieldDisplay() 422 */ 423 public void applyConditionalLogicForFieldDisplay() { 424 425 } 426 427 }