View Javadoc

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