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