View Javadoc
1   /**
2    * Copyright 2005-2016 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.data.metadata;
17  
18  import java.util.List;
19  
20  /**
21  * Non-top-level metadata object
22  *
23  * <p>
24  * Interface shared by all non-top-level metadata objects which link to other persistable objects. This is used as the
25  * base interface for 1:1/M:1 Relationships and 1:M/N:M Collections.
26  * </p>
27  *
28  * @author Kuali Rice Team (rice.collab@kuali.org)
29  */
30  public interface MetadataChild extends MetadataCommon {
31  
32      /**
33      * Gets the type of related object
34      *
35      * <p>
36      * This is the type of the object referenced by this relationship or contained in this collection.
37      * </p>
38      *
39      * @return type of related object
40      */
41  	Class<?> getRelatedType();
42  
43      /**
44      * Gets the parent-child related fields
45      *
46      * <p>
47      * Returns the related fields between the parent and child objects.
48      * </p>
49      *
50      * @return related fields. List must not be empty. There always must be at least one related field.
51      */
52  	List<DataObjectAttributeRelationship> getAttributeRelationships();
53  
54      /**
55      * Gets bi-directional relationship
56      *
57      * <p>
58      * If this metadata element is part of a bi-directional relationship, this method returns the other side of the
59      * bi-directional relationship.
60      * </p>
61      *
62      * @return the inverse of this relationship if it is bi-directional, false otherwise
63      */
64      MetadataChild getInverseRelationship();
65  
66      /**
67      * Determines whether object automatically saved
68      *
69      * <p>
70      * For related objects, whether this object will be automatically saved when the containing object is persisted.
71      * </p>
72      *
73      * @return whether object is automatically saved
74      */
75  	boolean isSavedWithParent();
76  
77      /**
78      * Determines whether this object will be automatically deleted when the containing object is deleted.
79      *
80      * <p>
81      * This is a special case of the {@link #isSavedWithParent()} method. It probably would never be true if the
82      * {@link #isSavedWithParent()} returns false.
83      * </p>
84      *
85      * @return whether automatically deleted
86      */
87  	boolean isDeletedWithParent();
88  
89      /**
90      * Determines whether object will be loaded with parent
91      *
92      * <p>
93      * For related objects, whether this related object will be loaded from the persistence layer at the same time as
94      * the parent object.
95      * </p>
96      * <p>
97      * If false, the object will be loaded upon demand, either via automatic lazy-loading provided by the infrastructure
98      * or by explicit request.
99      * </p>
100     *
101     * @return whether object
102     */
103 	boolean isLoadedAtParentLoadTime();
104 
105     /**
106     * Determines whether the object is reloaded automatically with parent
107     *
108     * <p>
109     * For related objects, whether this related object will be loaded from the persistence layer automatically when it
110     * is accessed by client code.
111     * </p>
112     * <p>
113     * If false, then the object must be refreshed manually by client code. (Though such a refresh may be possible by
114     * requesting the refresh from the persistence provider.)
115     * </p>
116     *
117     * @return whether object loaded automatically with parent
118     */
119 	boolean isLoadedDynamicallyUponUse();
120 
121     /**
122     * Gets foreign key attribute from parent.
123     *
124     * <p>
125     * For a given child key attribute, return the matching foreign key attribute on the parent object.
126     * </p>
127     *
128     * @return null if the attribute name given is not part of the key relationship.
129     */
130 	String getParentAttributeNameRelatedToChildAttributeName(String childAttribute);
131 }