001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.data.metadata;
017
018import java.util.List;
019
020/**
021* Non-top-level metadata object
022*
023* <p>
024* Interface shared by all non-top-level metadata objects which link to other persistable objects. This is used as the
025* base interface for 1:1/M:1 Relationships and 1:M/N:M Collections.
026* </p>
027*
028* @author Kuali Rice Team (rice.collab@kuali.org)
029*/
030public interface MetadataChild extends MetadataCommon {
031
032    /**
033    * Gets the type of related object
034    *
035    * <p>
036    * This is the type of the object referenced by this relationship or contained in this collection.
037    * </p>
038    *
039    * @return type of related object
040    */
041        Class<?> getRelatedType();
042
043    /**
044    * Gets the parent-child related fields
045    *
046    * <p>
047    * Returns the related fields between the parent and child objects.
048    * </p>
049    *
050    * @return related fields. List must not be empty. There always must be at least one related field.
051    */
052        List<DataObjectAttributeRelationship> getAttributeRelationships();
053
054    /**
055    * Gets bi-directional relationship
056    *
057    * <p>
058    * If this metadata element is part of a bi-directional relationship, this method returns the other side of the
059    * bi-directional relationship.
060    * </p>
061    *
062    * @return the inverse of this relationship if it is bi-directional, false otherwise
063    */
064    MetadataChild getInverseRelationship();
065
066    /**
067    * Determines whether object automatically saved
068    *
069    * <p>
070    * For related objects, whether this object will be automatically saved when the containing object is persisted.
071    * </p>
072    *
073    * @return whether object is automatically saved
074    */
075        boolean isSavedWithParent();
076
077    /**
078    * Determines whether this object will be automatically deleted when the containing object is deleted.
079    *
080    * <p>
081    * This is a special case of the {@link #isSavedWithParent()} method. It probably would never be true if the
082    * {@link #isSavedWithParent()} returns false.
083    * </p>
084    *
085    * @return whether automatically deleted
086    */
087        boolean isDeletedWithParent();
088
089    /**
090    * Determines whether object will be loaded with parent
091    *
092    * <p>
093    * For related objects, whether this related object will be loaded from the persistence layer at the same time as
094    * the parent object.
095    * </p>
096    * <p>
097    * If false, the object will be loaded upon demand, either via automatic lazy-loading provided by the infrastructure
098    * or by explicit request.
099    * </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}