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