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 com.google.common.annotations.Beta; 19 import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType; 20 21 import java.util.Collection; 22 import java.util.List; 23 24 25 /** 26 * Metadata for a given data object type. 27 * 28 * <p> 29 * References the data object class and contains lists of all the attributes, collections, and relationships within 30 * the class. 31 * </p> 32 * 33 * @author Kuali Rice Team (rice.collab@kuali.org) 34 */ 35 public interface DataObjectMetadata extends MetadataCommon { 36 37 /** 38 * Gets metadata object type. 39 * 40 * <p> 41 * The type represented by this metadata object. Usually this will simply contain the class name created 42 * by the persistence layer when it is loaded from the database. 43 * </p> 44 * 45 * @return metadata object type. Will never return null. 46 */ 47 Class<?> getType(); 48 49 /** 50 * Gets attributes defined on the data object. 51 * 52 * <p> 53 * Gets all the attributes defined on the data object in the order given by the MetadataProvider. This may or may not 54 * be the same as the backing object's (table) and is most likely the order in which they appear in the source 55 * persistence metadata (XML or annotations). 56 * </p> 57 * 58 * @return Data object attributes. Will never return null. Will return an empty list if no attributes defined. 59 */ 60 List<DataObjectAttribute> getAttributes(); 61 62 /** 63 * Gets child collections. 64 * 65 * <p> 66 * Gets all the child collections defined on the data object in the order given by the MetadataProvider. 67 * </p> 68 * 69 * @return Child collections. Will never return null. Will return an empty list if no collections defined. 70 */ 71 List<DataObjectCollection> getCollections(); 72 73 /** 74 * Gets child relationships. 75 * 76 * <p> 77 * Gets all the child relationships defined on the data object in the order given by the MetadataProvider. 78 * </p> 79 * 80 * @return Child relationships. Will never return null. Will return an empty list if no relationships defined. 81 */ 82 List<DataObjectRelationship> getRelationships(); 83 84 /** 85 * Gets attribute metadata. 86 * 87 * <p> 88 * Get the named attribute's metadata from the data object. 89 * </p> 90 * 91 * @return <b>null</b> if the attributeName does not exist, the associated {@link DataObjectAttribute} otherwise. 92 */ 93 DataObjectAttribute getAttribute(String attributeName); 94 95 /** 96 * Gets the named collection's metadata from the data object. 97 * 98 * <p> 99 * The name is the property on the data object which holds 100 * the {@link Collection}. 101 * </p> 102 * 103 * @return <b>null</b> if the attributeName does not exist, the associated {@link DataObjectCollection} otherwise. 104 */ 105 DataObjectCollection getCollection(String collectionName); 106 107 /** 108 * Gets the named relationship's metadata from the data object. 109 * 110 * <p> 111 * The name is the property on the data object which holds the related business object's instance. 112 * </p> 113 * 114 * @return <b>null</b> if the attributeName does not exist, the associated {@link DataObjectRelationship} otherwise. 115 */ 116 DataObjectRelationship getRelationship(String relationshipName); 117 118 /** 119 * Gets attribute relationships. 120 * 121 * <p> 122 * Returns all relationships of which the given attribute is part of the foreign key relationship. 123 * </p> 124 * 125 * @return The list of relationship metadata objects or an empty list if none found. 126 */ 127 List<DataObjectRelationship> getRelationshipsInvolvingAttribute(String attributeName); 128 129 /** 130 * Gets relationship of last attribute. 131 * 132 * <p> 133 * Returns a single relationship for which the given attribute is the last in the foreign key relationship. 134 * </p> 135 * 136 * @return <b>null</b> if no relationship's foreign key set ends wit the given field. The 137 * {@link DataObjectRelationship} otherwise. 138 */ 139 DataObjectRelationship getRelationshipByLastAttributeInRelationship(String attributeName); 140 141 /** 142 * Get the list of primary key attribute names for this data object. 143 * 144 * @return primary key attribute names. 145 */ 146 List<String> getPrimaryKeyAttributeNames(); 147 148 /** 149 * List of attribute names which form a "user friendly" key. (As opposed to a sequence number as used by some parts 150 * of the system). 151 * 152 * <p> 153 * An example here would be the KIM Role object where the Role ID is the primary key, but the Namespace and Name 154 * properties form the user-visible and enterable key. 155 * </p> 156 * 157 * @return a list containing the business key attributes names for the data object. 158 */ 159 List<String> getBusinessKeyAttributeNames(); 160 161 /** 162 * Returns true if the list of primary key names and business key attribute names are different. 163 * 164 * @return true if the list of primary key names and business key attributes are different, false if they are the 165 * same. 166 */ 167 Boolean hasDistinctBusinessKey(); 168 169 /** 170 * Gets primary display attribute name 171 * 172 * <p> 173 * This is the field on the object which best represents it on displays. It will be used to build 174 * inquiry links and determine where to place quickfinder links. Usually this will be the the primary key 175 * or the last field of the primary key if there are multiple fields. 176 * </p> 177 * <p> 178 * If not specified by the provider, the base implementation will default it to the last attribute in the 179 * primaryKeyAttributeNames list. 180 * </p> 181 * 182 * @return the name of the attribute to use for primary display purposes. 183 */ 184 String getPrimaryDisplayAttributeName(); // KNS: titleAttribute 185 186 /** 187 * Determines whether optimistic locking is supported. 188 * 189 * <p> 190 * Returns true if the underlying ORM tool performs optimistic locking checks on this object before saving. Under 191 * the KNS, this was done via the versionNumber property and appropriate OJB configuration. In JPA, this is linked 192 * to the @Version annotation. 193 * </p> 194 * 195 * @return true if this data object is configured for optimistic locking. 196 */ 197 boolean isSupportsOptimisticLocking(); 198 199 /** 200 * BETA: Gets auto create uif view types. 201 * 202 * <p> 203 * Returns collections of uif view types that should be auto created. 204 * </p> 205 * 206 * @return collection of uif view types. 207 */ 208 @Beta 209 Collection<UifAutoCreateViewType> getAutoCreateUifViewTypes(); 210 211 /** 212 * BETA: Determines where view type should be auto created. 213 * 214 * <p> 215 * Determines whether the specified uif view type can be auto created. 216 * </p> 217 * 218 * @return true if this uif view type should be auto created. 219 */ 220 @Beta 221 boolean shouldAutoCreateUifViewOfType(UifAutoCreateViewType viewType); 222 }