configurable initialization of entities of list() methods
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / BeanInitializer.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.persistence.dao;
11
12 import java.util.List;
13
14 import eu.etaxonomy.cdm.model.taxon.Taxon;
15 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
16
17 /**
18 * @author a.kohlbecker
19 * @date 25.03.2009
20 *
21 */
22 public interface BeanInitializer {
23
24 /**
25 * Wildcard for initializing all *ToOne relations of a <code>bean</code>.
26 */
27 public static final String LOAD_2ONE_WILDCARD = "$";
28
29 /**
30 * Wildcard for initializing all *ToOne and all *ToMany relations of a <code>bean</code>.
31 */
32 public static final String LOAD_2ONE_2MANY_WILDCARD = "*";
33
34 /**
35 * Initializes all *ToOne relations of the <code>bean</code>.
36 *
37 * @param bean
38 */
39 public void load(Object bean);
40
41 /**
42 * Initializes all *ToOne and all *ToMany relations of the <code>bean</code>.
43 *
44 * @param bean
45 */
46 public void loadFully(Object bean);
47
48 /**
49 * Allows more fine grained initialization not only of the root bean
50 * identified by its <code>uuid</code> but also of specific paths of
51 * the object graph. The sub graph to initialize may be defined in the
52 * <code>propertyPaths</code> parameter as list of paths all starting at the
53 * root bean.
54 * <p>
55 * You can use wildcards <code>*</code> {@link LOAD_2ONE_2MANY_WILDCARD}
56 * and <code>$</code> {@link LOAD_2ONE_WILDCARD} for initializing
57 * all *ToOne and all *ToMany relations of a bean.
58 * NOTE: A wildcard subsequently terminates its property path.
59 * <p>
60 * <b>Example:</b> Assuming <code>cdmEntity</code> is a {@link Taxon}
61 * instance the following <code>propertyPaths</code> can be used for
62 * initializing bean properties of this instance. It is possible to
63 * initialized nested properties of properties with unlimited depth.
64 * <ul>
65 * <li><code>name</code>: initializes {@link Taxon#getName()}</li>
66 * <li><code>name.rank</code>: initializes {@link Taxon#getName()}.{@link TaxonNameBase#getRank() getRank()}</li>
67 * <li><code>name.$</code>: initializes all *ToOne relations of the {@link Taxon#getName()}</li>
68 * </ul>
69 *
70 * @param bean
71 * @param propertyPaths
72 * a List of property names
73 */
74 public void initialize(Object bean, List<String> propertyPaths);
75
76 public void initializeAll(List list, List<String> propertyPaths);
77
78
79 /*TODO implement:
80 public void loadBy(UUID uuid);
81 public void loadFullyByUuid(UUID uuid);*/
82
83 }