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.kns.service;
017
018import org.kuali.rice.krad.bo.BusinessObject;
019import org.kuali.rice.krad.bo.DataObjectRelationship;
020import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
021import org.kuali.rice.krad.valuefinder.ValueFinder;
022import org.kuali.rice.krad.service.DataObjectMetaDataService;
023
024import java.util.Collection;
025import java.util.List;
026import java.util.Map;
027
028/**
029 * Provides Metadata about a specific BusinessObject. Depending on the circumstance or type
030 * of BO it will retrieve the data it needs from either the DataDictionary or through the
031 * PersistenceStructureService
032 * 
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 */
035public interface BusinessObjectMetaDataService extends DataObjectMetaDataService {
036
037        public DataObjectRelationship getBusinessObjectRelationship(RelationshipDefinition ddReference,
038                        BusinessObject bo, Class boClass, String attributeName, String attributePrefix, boolean keysOnly);
039
040        public RelationshipDefinition getBusinessObjectRelationshipDefinition(Class c, String attributeName);
041
042        public RelationshipDefinition getBusinessObjectRelationshipDefinition(BusinessObject bo, String attributeName);
043
044        /**
045         * 
046         * This method returns a list of inquirable field names
047         * 
048         * @param bo
049         * @return a collection of inquirable field names
050         */
051        public Collection<String> getInquirableFieldNames(Class boClass, String sectionTitle);
052
053        /**
054         * 
055         * This method returns a list of lookupable fields
056         * 
057         * @param bo
058         * @return a collection of lookupable fields
059         */
060        public List<String> getLookupableFieldNames(Class boClass);
061
062        /**
063         * 
064         * This method looks up the default value for a given attribute and returns
065         * it
066         * 
067         * @param businessObjectClass
068         * @param attributeName
069         * @return default value for an attribute
070         */
071        public String getLookupFieldDefaultValue(Class businessObjectClass, String attributeName);
072
073        /**
074         * 
075         * This method returns the value finder class for a given attribute
076         * 
077         * @param businessObjectClass
078         * @param attributeName
079         * @return value finder class
080         */
081        public Class getLookupFieldDefaultValueFinderClass(Class businessObjectClass, String attributeName);
082
083        /**
084         * 
085         * This method looks up the quickfinder parameter string for a given
086         * attribute and returns it. See
087         * {@link org.kuali.rice.kns.datadictionary.FieldDefinition#getQuickfinderParameterString()}.
088         * 
089         * @param businessObjectClass
090         * @param attributeName
091         * @return default values for attributes
092         */
093        public String getLookupFieldQuickfinderParameterString(Class businessObjectClass, String attributeName);
094
095        /**
096         * This method returns the quickfinder parameter string builder class for a
097         * given attribute. See
098         * {@link org.kuali.rice.kns.datadictionary.FieldDefinition#getQuickfinderParameterStringBuilderClass()}.
099         * 
100         * @param businessObjectClass
101         * @param attributeName
102         * @return value finder class
103         */
104        public Class<? extends ValueFinder> getLookupFieldQuickfinderParameterStringBuilderClass(Class businessObjectClass,
105                        String attributeName);
106
107        /**
108         * 
109         * This method returns a list of collection names a business object contains
110         * 
111         * @param bo
112         * @return
113         */
114        public Collection<String> getCollectionNames(BusinessObject bo);
115
116        /**
117         * 
118         * This method determines if a given field(attribute) is inquirable or not
119         * This handles both nested and non-nested attributes
120         * 
121         * @param bo
122         * @param attributeName
123         * @param sectionTitle
124         * @return true if field is inquirable
125         */
126        public boolean isAttributeInquirable(Class boClass, String attributeName, String sectionTitle);
127
128        /**
129         * 
130         * This method determines if a given business object is inquirable
131         * 
132         * @param bo
133         * @return true if bo is inquirable
134         */
135        public boolean isInquirable(Class boClass);
136
137        /**
138         * 
139         * This method determines if a given field(attribute) is lookupable or not
140         * This handles both nested and non-nested attributes
141         * 
142         * @param bo
143         * @param attributeName
144         * @return true if field is lookupable
145         */
146        public boolean isAttributeLookupable(Class boClass, String attributeName);
147
148        /**
149         * 
150         * This method determines if a given business object is lookupable
151         * 
152         * @param bo
153         * @return true if bo is lookupable
154         */
155        public boolean isLookupable(Class boClass);
156
157        /**
158         * 
159         * This method will return a class that is related to the parent BO (either
160         * through the DataDictionary or through the PersistenceStructureService)
161         * 
162         * @param bo
163         * @param attributes
164         * @return related class
165         */
166        @Deprecated
167        public DataObjectRelationship getBusinessObjectRelationship(BusinessObject bo, String attributeName);
168
169        @Deprecated
170        public DataObjectRelationship getBusinessObjectRelationship(BusinessObject bo, Class boClass,
171                        String attributeName, String attributePrefix, boolean keysOnly);
172
173
174
175        /**
176         * Get all the business object relationships for the given business object.
177         * These relationships may be defined at the ORM-layer or within the data
178         * dictionary.
179         */
180        @Deprecated
181        public List<DataObjectRelationship> getBusinessObjectRelationships(BusinessObject bo);
182
183        /**
184         * Get all the business object relationships for the given class. These
185         * relationships may be defined at the ORM-layer or within the data
186         * dictionary.
187         */
188        @Deprecated
189        public List<DataObjectRelationship> getBusinessObjectRelationships(Class<? extends BusinessObject> boClass);
190
191        /**
192         * This method accepts a business object and one of its foreign key
193         * attribute names. It returns a map that has a foreign key attribute name
194         * as a key and its respective related class as value. If the passed in
195         * attributeName is not a foreign key, this method will return an empty map.
196         * 
197         * @param BusinessObject
198         *            businessObject
199         * @param String
200         *            attributeName
201         * @return Map<String, Class>
202         */
203        @Deprecated
204        public Map<String, Class> getReferencesForForeignKey(BusinessObject businessObject, String attributeName);
205
206        /**
207         * 
208         * This method ...
209         * 
210         * @param businessObjectClass
211         * @param attributeName
212         * @param targetName
213         * @return
214         */
215        @Deprecated
216        public String getForeignKeyFieldName(Class businessObjectClass, String attributeName, String targetName);
217}