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