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.krad.uif.util;
17  
18  import java.lang.reflect.InvocationTargetException;
19  import java.util.Collection;
20  import java.util.Collections;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.kuali.rice.core.api.uif.RemotableQuickFinder.Builder;
25  import org.kuali.rice.krad.bo.BusinessObject;
26  import org.kuali.rice.krad.bo.DataObjectRelationship;
27  import org.kuali.rice.krad.bo.PersistableBusinessObject;
28  import org.kuali.rice.krad.bo.PersistableBusinessObjectExtension;
29  import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
30  import org.kuali.rice.krad.document.Document;
31  import org.kuali.rice.krad.service.LegacyDataAdapter;
32  import org.kuali.rice.krad.util.ForeignKeyFieldsPopulationState;
33  
34  /**
35   * Mock implementation of {@link LegacyDataAdapter} for supporting UIF unit tests.
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  public class MockLegacyDataAdapter implements LegacyDataAdapter {
40  
41      /**
42       * @see org.kuali.rice.krad.service.LegacyDataAdapter#save(java.lang.Object)
43       */
44      @Override
45      public <T> T save(T dataObject) {
46          return dataObject;
47      }
48  
49      /**
50       * @see org.kuali.rice.krad.service.LegacyDataAdapter#linkAndSave(java.lang.Object)
51       */
52      @Override
53      public <T> T linkAndSave(T dataObject) {
54          return dataObject;
55      }
56  
57      /**
58       * @see org.kuali.rice.krad.service.LegacyDataAdapter#saveDocument(java.lang.Object)
59       */
60      @Override
61      public <T> T saveDocument(T document) {
62          return document;
63      }
64  
65      /**
66       * @see org.kuali.rice.krad.service.LegacyDataAdapter#findBySinglePrimaryKey(java.lang.Class, java.lang.Object)
67       */
68      @Override
69      public <T> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey) {
70          return null;
71      }
72  
73      /**
74       * @see org.kuali.rice.krad.service.LegacyDataAdapter#findByPrimaryKey(java.lang.Class, java.util.Map)
75       */
76      @Override
77      public <T> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys) {
78          return null;
79      }
80  
81      /**
82       * @see org.kuali.rice.krad.service.LegacyDataAdapter#delete(java.lang.Object)
83       */
84      @Override
85      public void delete(Object dataObject) {
86      }
87  
88      /**
89       * @see org.kuali.rice.krad.service.LegacyDataAdapter#deleteMatching(java.lang.Class, java.util.Map)
90       */
91      @Override
92      public void deleteMatching(Class<?> clazz, Map<String, ?> fieldValues) {
93      }
94  
95      /**
96       * @see org.kuali.rice.krad.service.LegacyDataAdapter#retrieve(java.lang.Object)
97       */
98      @Override
99      public <T> T retrieve(T dataObject) {
100         return dataObject;
101     }
102 
103     /**
104      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findAll(java.lang.Class)
105      */
106     @Override
107     public <T> Collection<T> findAll(Class<T> clazz) {
108         return Collections.emptyList();
109     }
110 
111     /**
112      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findMatching(java.lang.Class, java.util.Map)
113      */
114     @Override
115     public <T> Collection<T> findMatching(Class<T> clazz, Map<String, ?> fieldValues) {
116         return Collections.emptyList();
117     }
118 
119     /**
120      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findMatchingOrderBy(java.lang.Class, java.util.Map,
121      * java.lang.String, boolean)
122      */
123     @Override
124     public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField,
125             boolean sortAscending) {
126         return Collections.emptyList();
127     }
128 
129     /**
130      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getPrimaryKeyFieldValues(java.lang.Object)
131      */
132     @Override
133     public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject) {
134         return Collections.emptyMap();
135     }
136 
137     /**
138      * @see org.kuali.rice.krad.service.LegacyDataAdapter#retrieveNonKeyFields(java.lang.Object)
139      */
140     @Override
141     public void retrieveNonKeyFields(Object persistableObject) {
142     }
143 
144     /**
145      * @see org.kuali.rice.krad.service.LegacyDataAdapter#retrieveReferenceObject(java.lang.Object, java.lang.String)
146      */
147     @Override
148     public void retrieveReferenceObject(Object persistableObject, String referenceObjectName) {
149     }
150 
151     /**
152      * @see org.kuali.rice.krad.service.LegacyDataAdapter#refreshAllNonUpdatingReferences(java.lang.Object)
153      */
154     @Override
155     public void refreshAllNonUpdatingReferences(Object persistableObject) {
156     }
157 
158     /**
159      * @see org.kuali.rice.krad.service.LegacyDataAdapter#resolveProxy(java.lang.Object)
160      */
161     @Override
162     public Object resolveProxy(Object o) {
163         return o;
164     }
165 
166     /**
167      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isProxied(java.lang.Object)
168      */
169     @Override
170     public boolean isProxied(Object object) {
171         return false;
172     }
173 
174     /**
175      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findCollectionBySearchHelper(java.lang.Class, java.util.Map,
176      * boolean, boolean, java.lang.Integer)
177      */
178     @Override
179     public <T> Collection<T> findCollectionBySearchHelper(Class<T> clazz, Map<String, String> formProps,
180             boolean unbounded, boolean allPrimaryKeyValuesPresentAndNotWildcard, Integer searchResultsLimit) {
181         return Collections.emptyList();
182     }
183 
184     /**
185      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findCollectionBySearchHelper(java.lang.Class, java.util.Map,
186      * java.util.List, boolean, boolean, java.lang.Integer)
187      */
188     @Override
189     public <T> Collection<T> findCollectionBySearchHelper(Class<T> clazz, Map<String, String> formProps,
190             List<String> wildcardAsLiteralPropertyNames, boolean unbounded,
191             boolean allPrimaryKeyValuesPresentAndNotWildcard, Integer searchResultsLimit) {
192         return Collections.emptyList();
193     }
194 
195     /**
196      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findObjectBySearch(java.lang.Class, java.util.Map)
197      */
198     @Override
199     public <T> T findObjectBySearch(Class<T> clazz, Map<String, String> formProps) {
200         return null;
201     }
202 
203     /**
204      * @see org.kuali.rice.krad.service.LegacyDataAdapter#allPrimaryKeyValuesPresentAndNotWildcard(java.lang.Class,
205      * java.util.Map)
206      */
207     @Override
208     public boolean allPrimaryKeyValuesPresentAndNotWildcard(Class<?> boClass, Map<String, String> formProps) {
209         return false;
210     }
211 
212     /**
213      * @see org.kuali.rice.krad.service.LegacyDataAdapter#listPrimaryKeyFieldNames(java.lang.Class)
214      */
215     @Override
216     public List<String> listPrimaryKeyFieldNames(Class<?> clazz) {
217         return Collections.emptyList();
218     }
219 
220     /**
221      * @see org.kuali.rice.krad.service.LegacyDataAdapter#determineCollectionObjectType(java.lang.Class,
222      * java.lang.String)
223      */
224     @Override
225     public Class<?> determineCollectionObjectType(Class<?> containingClass, String collectionPropertyName) {
226         return null;
227     }
228 
229     /**
230      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getForeignKeyFieldsPopulationState(java.lang.Object,
231      * java.lang.String)
232      */
233     @Override
234     public ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(Object bo, String referenceName) {
235         return null;
236     }
237 
238     /**
239      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getForeignKeysForReference(java.lang.Class, java.lang.String)
240      */
241     @Override
242     public Map<String, String> getForeignKeysForReference(Class<?> clazz, String attributeName) {
243         return Collections.emptyMap();
244     }
245 
246     /**
247      * @see org.kuali.rice.krad.service.LegacyDataAdapter#hasPrimaryKeyFieldValues(java.lang.Object)
248      */
249     @Override
250     public boolean hasPrimaryKeyFieldValues(Object persistableObject) {
251         return false;
252     }
253 
254     /**
255      * @see org.kuali.rice.krad.service.LegacyDataAdapter#hasReference(java.lang.Class, java.lang.String)
256      */
257     @Override
258     public boolean hasReference(Class<?> boClass, String referenceName) {
259         return false;
260     }
261 
262     /**
263      * @see org.kuali.rice.krad.service.LegacyDataAdapter#hasCollection(java.lang.Class, java.lang.String)
264      */
265     @Override
266     public boolean hasCollection(Class<?> boClass, String collectionName) {
267         return false;
268     }
269 
270     /**
271      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isExtensionAttribute(java.lang.Class, java.lang.String,
272      * java.lang.Class)
273      */
274     @Override
275     public boolean isExtensionAttribute(Class<?> boClass, String attributePropertyName, Class<?> propertyType) {
276         return false;
277     }
278 
279     /**
280      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getExtensionAttributeClass(java.lang.Class, java.lang.String)
281      */
282     @Override
283     public Class<?> getExtensionAttributeClass(Class<?> boClass, String attributePropertyName) {
284         return null;
285     }
286 
287     /**
288      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getPrimaryKeyFieldValuesDOMDS(java.lang.Object)
289      */
290     @Override
291     public Map<String, ?> getPrimaryKeyFieldValuesDOMDS(Object dataObject) {
292         return null;
293     }
294 
295     /**
296      * @see org.kuali.rice.krad.service.LegacyDataAdapter#equalsByPrimaryKeys(java.lang.Object, java.lang.Object)
297      */
298     @Override
299     public boolean equalsByPrimaryKeys(Object do1, Object do2) {
300         return false;
301     }
302 
303     /**
304      * @see org.kuali.rice.krad.service.LegacyDataAdapter#toPersistableBusinessObject(java.lang.Object)
305      */
306     @Override
307     public PersistableBusinessObject toPersistableBusinessObject(Object object) {
308         return null;
309     }
310 
311     /**
312      * @see org.kuali.rice.krad.service.LegacyDataAdapter#materializeAllSubObjects(java.lang.Object)
313      */
314     @Override
315     public void materializeAllSubObjects(Object object) {
316     }
317 
318     /**
319      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getPropertyType(java.lang.Object, java.lang.String)
320      */
321     @Override
322     public Class<?> getPropertyType(Object object, String propertyName) {
323         return null;
324     }
325 
326     /**
327      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getExtension(java.lang.Class)
328      */
329     @Override
330     public PersistableBusinessObjectExtension getExtension(
331             Class<? extends PersistableBusinessObject> businessObjectClass) throws InstantiationException, IllegalAccessException {
332         return null;
333     }
334 
335     /**
336      * @see org.kuali.rice.krad.service.LegacyDataAdapter#refreshReferenceObject(org.kuali.rice.krad.bo.PersistableBusinessObject,
337      * java.lang.String)
338      */
339     @Override
340     public void refreshReferenceObject(PersistableBusinessObject businessObject, String referenceObjectName) {
341     }
342 
343     /**
344      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isLockable(java.lang.Object)
345      */
346     @Override
347     public boolean isLockable(Object object) {
348         return false;
349     }
350 
351     /**
352      * @see org.kuali.rice.krad.service.LegacyDataAdapter#verifyVersionNumber(java.lang.Object)
353      */
354     @Override
355     public void verifyVersionNumber(Object dataObject) {
356     }
357 
358     /**
359      * @see org.kuali.rice.krad.service.LegacyDataAdapter#createQuickFinder(java.lang.Class, java.lang.String)
360      */
361     @Override
362     public Builder createQuickFinder(Class<?> containingClass, String attributeName) {
363         return null;
364     }
365 
366     /**
367      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isReferenceUpdatable(java.lang.Class, java.lang.String)
368      */
369     @Override
370     public boolean isReferenceUpdatable(Class<?> boClass, String referenceName) {
371         return false;
372     }
373 
374     /**
375      * @see org.kuali.rice.krad.service.LegacyDataAdapter#listReferenceObjectFields(java.lang.Class)
376      */
377     @Override
378     public Map<String, Class> listReferenceObjectFields(Class<?> boClass) {
379         return null;
380     }
381 
382     /**
383      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isCollectionUpdatable(java.lang.Class, java.lang.String)
384      */
385     @Override
386     public boolean isCollectionUpdatable(Class<?> boClass, String collectionName) {
387         return false;
388     }
389 
390     /**
391      * @see org.kuali.rice.krad.service.LegacyDataAdapter#listCollectionObjectTypes(java.lang.Class)
392      */
393     @Override
394     public Map<String, Class> listCollectionObjectTypes(Class<?> boClass) {
395         return null;
396     }
397 
398     /**
399      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getReferenceIfExists(java.lang.Object, java.lang.String)
400      */
401     @Override
402     public BusinessObject getReferenceIfExists(Object bo, String referenceName) {
403         return null;
404     }
405 
406     /**
407      * @see org.kuali.rice.krad.service.LegacyDataAdapter#allForeignKeyValuesPopulatedForReference(java.lang.Object,
408      * java.lang.String)
409      */
410     @Override
411     public boolean allForeignKeyValuesPopulatedForReference(Object bo, String referenceName) {
412         return false;
413     }
414 
415     /**
416      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getDictionaryRelationship(java.lang.Class, java.lang.String)
417      */
418     @Override
419     public RelationshipDefinition getDictionaryRelationship(Class<?> c, String attributeName) {
420         return null;
421     }
422 
423     /**
424      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getTitleAttribute(java.lang.Class)
425      */
426     @Override
427     public String getTitleAttribute(Class<?> dataObjectClass) {
428         return null;
429     }
430 
431     /**
432      * @see org.kuali.rice.krad.service.LegacyDataAdapter#areNotesSupported(java.lang.Class)
433      */
434     @Override
435     public boolean areNotesSupported(Class<?> dataObjectClass) {
436         return false;
437     }
438 
439     /**
440      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getDataObjectIdentifierString(java.lang.Object)
441      */
442     @Override
443     public String getDataObjectIdentifierString(Object dataObject) {
444         return null;
445     }
446 
447     /**
448      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getInquiryObjectClassIfNotTitle(java.lang.Object,
449      * java.lang.String)
450      */
451     @Override
452     public Class<?> getInquiryObjectClassIfNotTitle(Object dataObject, String propertyName) {
453         return null;
454     }
455 
456     /**
457      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getInquiryParameters(java.lang.Object, java.util.List,
458      * java.lang.String)
459      */
460     @Override
461     public Map<String, String> getInquiryParameters(Object dataObject, List<String> keys, String propertyName) {
462         return Collections.emptyMap();
463     }
464 
465     /**
466      * @see org.kuali.rice.krad.service.LegacyDataAdapter#hasLocalLookup(java.lang.Class)
467      */
468     @Override
469     public boolean hasLocalLookup(Class<?> dataObjectClass) {
470         return false;
471     }
472 
473     /**
474      * @see org.kuali.rice.krad.service.LegacyDataAdapter#hasLocalInquiry(java.lang.Class)
475      */
476     @Override
477     public boolean hasLocalInquiry(Class<?> dataObjectClass) {
478         return false;
479     }
480 
481     /**
482      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getDataObjectRelationship(java.lang.Object, java.lang.Class,
483      * java.lang.String, java.lang.String, boolean, boolean, boolean)
484      */
485     @Override
486     public DataObjectRelationship getDataObjectRelationship(Object dataObject, Class<?> dataObjectClass,
487             String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup,
488             boolean supportsInquiry) {
489         return null;
490     }
491 
492     /**
493      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isPersistable(java.lang.Class)
494      */
495     @Override
496     public boolean isPersistable(Class<?> dataObjectClass) {
497         return false;
498     }
499 
500     /**
501      * @see org.kuali.rice.krad.service.LegacyDataAdapter#setObjectPropertyDeep(java.lang.Object, java.lang.String,
502      * java.lang.Class, java.lang.Object)
503      */
504     @Override
505     public void setObjectPropertyDeep(Object bo, String propertyName, Class<?> type,
506             Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
507     }
508 
509     /**
510      * @see org.kuali.rice.krad.service.LegacyDataAdapter#materializeClassForProxiedObject(java.lang.Object)
511      */
512     @Override
513     public Class<?> materializeClassForProxiedObject(Object object) {
514         return null;
515     }
516 
517     /**
518      * @see org.kuali.rice.krad.service.LegacyDataAdapter#getNestedValue(java.lang.Object, java.lang.String)
519      */
520     @Override
521     public Object getNestedValue(Object bo, String fieldName) {
522         return null;
523     }
524 
525     /**
526      * @see org.kuali.rice.krad.service.LegacyDataAdapter#createNewObjectFromClass(java.lang.Class)
527      */
528     @Override
529     public Object createNewObjectFromClass(Class clazz) {
530         Object object = null;
531 
532         try {
533             object = clazz.newInstance();
534         } catch (InstantiationException e) {
535             // do nothing
536         } catch (IllegalAccessException e) {
537             // do nothing
538         }
539 
540         return object;
541     }
542 
543     /**
544      * @see org.kuali.rice.krad.service.LegacyDataAdapter#isNull(java.lang.Object)
545      */
546     @Override
547     public boolean isNull(Object object) {
548         return false;
549     }
550 
551     /**
552      * @see org.kuali.rice.krad.service.LegacyDataAdapter#setObjectProperty(java.lang.Object, java.lang.String,
553      * java.lang.Class, java.lang.Object)
554      */
555     @Override
556     public void setObjectProperty(Object bo, String propertyName, Class propertyType,
557             Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
558     }
559 
560     /**
561      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findByDocumentHeaderId(java.lang.Class, java.lang.String)
562      */
563     @Override
564     public <T extends Document> T findByDocumentHeaderId(Class<T> documentClass, String id) {
565         return null;
566     }
567 
568     /**
569      * @see org.kuali.rice.krad.service.LegacyDataAdapter#findByDocumentHeaderIds(java.lang.Class, java.util.List)
570      */
571     @Override
572     public <T extends Document> List<T> findByDocumentHeaderIds(Class<T> documentClass, List<String> ids) {
573         return Collections.emptyList();
574     }
575 
576 }