001/**
002 * Copyright 2005-2014 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.service;
017
018import org.kuali.rice.krad.bo.DataObjectRelationship;
019import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
020
021import java.util.List;
022import java.util.Map;
023
024/**
025 * Provides metadata such as relationships and key fields for data objects
026 *
027 * <p>
028 * Service provides a facade to the various services for retrieving metadata
029 * within the framework, such as the <code>DataDictionaryService</code> and
030 * the <code>PersistenceService</code>
031 * </p>
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 *
035 * @deprecated use {@link org.kuali.rice.krad.data.metadata.MetadataRepository} instead
036 */
037@Deprecated
038public interface DataObjectMetaDataService {
039
040    /**
041     * Checks the DataDictionary and OJB Repository File to determine the primary
042     * fields names for a given class.
043     *
044     * @param clazz - the Class to check for primary keys
045     * @return a list of the primary key field names or an empty list if none are found
046     *
047     * @deprecated use {@link org.kuali.rice.krad.data.metadata.DataObjectMetadata#getPrimaryKeyAttributeNames()}
048     */
049    @Deprecated
050    public List<String> listPrimaryKeyFieldNames(Class<?> clazz);
051
052    /**
053     * Determines the primary keys for the class of the given object, then for each
054     * key field retrieves the value from the object instance and populates the return
055     * map with the primary key name as the map key and the object value as the map value
056     *
057     * @param dataObject - object whose primary key field name,value pairs you want
058     * @return a Map containing the names and values of fields for the given class which
059     *         are designated as key fields in the OJB repository file or DataDictionary
060     * @throws IllegalArgumentException if the given Object is null
061     *
062     * @deprecated use {@link org.kuali.rice.krad.data.DataObjectWrapper#getPrimaryKeyValues()} instead
063     */
064    @Deprecated
065    public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject);
066
067    /**
068     * Determines the primary keys for the class of the given object, then for each
069     * key field retrieves the value from the object instance and populates the return
070     * map with the primary key name as the map key and the object value as the map value
071     *
072     * @param dataObject - object whose primary key field name,value pairs you want
073     * @param sortFieldNames - if true, the returned Map will iterate through its entries sorted by fieldName
074     * @return a Map containing the names and values of fields for the given class which
075     *         are designated as key fields in the OJB repository file or DataDictionary
076     * @throws IllegalArgumentException if the given Object is null
077
078     * @deprecated use {@link org.kuali.rice.krad.data.DataObjectWrapper#getPrimaryKeyValues()} instead, and sort manually if needed
079     */
080    @Deprecated
081    public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject, boolean sortFieldNames);
082
083    /**
084     * Compares two dataObject instances for equality of type and key values using toString()
085     * of each value for comparison purposes.
086     *
087     * @param do1
088     * @param do2
089     * @return boolean indicating whether the two objects are equal.
090     *
091     * @deprecated use {@link org.kuali.rice.krad.data.DataObjectWrapper#equalsByPrimaryKey(Object)}
092     */
093    @Deprecated
094    public boolean equalsByPrimaryKeys(Object do1, Object do2);
095
096    /**
097     * Attempts to find a relationship for the given attribute within the given
098     * data object
099     *
100     * <p>
101     * First the data dictionary is queried to find any relationship definitions
102     * setup that include the attribute, if found the
103     * <code>BusinessObjectRetationship</code> is build from that. If not and
104     * the data object class is persistent, relationships are retrieved from the
105     * persistence service. Nested attributes are handled in addition to
106     * external business objects. If multiple relationships are found, the one
107     * that contains the least amount of joining keys is returned
108     * </p>
109     *
110     * @param dataObject - data object instance that contains the attribute
111     * @param dataObjectClass - class for the data object that contains the attribute
112     * @param attributeName - property name for the attribute
113     * @param attributePrefix - property prefix for the attribute
114     * @param keysOnly - indicates whether only primary key fields should be returned
115     * in the relationship
116     * @param supportsLookup - indicates whether the relationship should support lookup
117     * @param supportsInquiry - indicates whether the relationship should support inquiry
118     * @return BusinessObjectRelationship for the attribute, or null if not
119     *         found
120     */
121    @Deprecated
122    public DataObjectRelationship getDataObjectRelationship(Object dataObject, Class<?> dataObjectClass,
123            String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup,
124            boolean supportsInquiry);
125
126    /**
127     * Attempts to find relationships for the given data object class
128     *
129     * <p>
130     * First the data dictionary is queried to find any relationship definitions
131     * <code>BusinessObjectRetationship</code> is build from that. If not and
132     * the data object class is persistent, relationships are retrieved from the
133     * persistence service. Nested attributes are handled in addition to
134     * external business objects. If multiple relationships are found, the one
135     * that contains the least amount of joining keys is returned
136     * </p>
137     *
138     * @param dataObjectClass - class for the data object that contains the attribute
139     * @return List of DataObjectRelationship for the class
140     */
141    @Deprecated
142    public List<DataObjectRelationship> getDataObjectRelationships(Class<?> dataObjectClass);
143
144    /**
145     * Fetches the RelationshipDefinition for the attribute with the given name within
146     * the given class
147     *
148     * @param dataObjectClass - data object class that contains the attribute
149     * @param attributeName - property name for the attribute
150     * @return RelationshipDefinition for the attribute, or null if not found
151     */
152    @Deprecated
153    public RelationshipDefinition getDictionaryRelationship(Class<?> dataObjectClass, String attributeName);
154
155    /**
156     * Returns the attribute to be associated with for object level markings.  This would
157     * be the field chosen for inquiry links etc.
158     *
159     * @param dataObjectClass - data object class to obtain title attribute of
160     * @return property name of title attribute or null if data object entry not found
161     * @throws IllegalArgumentException if the given Class is null
162     */
163    @Deprecated
164    public String getTitleAttribute(Class<?> dataObjectClass);
165
166    /**
167     * Indicates whether notes are supported by the given data object class, currently this
168     * can only be true for business objects
169     *
170     * @param dataObjectClass - class for data object to check
171     * @return boolean true if notes are supported for data object, false if notes are not supported
172     */
173    @Deprecated
174    public boolean areNotesSupported(Class<?> dataObjectClass);
175
176    /**
177     * Builds a string that uniquely identifiers the data object instance
178     *
179     * <p>
180     * Based on the metadata available for the class of the data object, the values for fields that uniquely
181     * identify an instance are concatenated together into one string. For general data objects these fields
182     * will be the primary key fields defined in the data dictionary. For the case of objects with type
183     * <code>PersistableBusinessObject</code>, the object id field will be used.
184     * </p>
185     *
186     * @param dataObject - data object instance to build identifier string for
187     * @return String identifier string for data object
188     */
189    @Deprecated
190    public String getDataObjectIdentifierString(Object dataObject);
191
192    /**
193     * Determines whether the given data object class has an associated lookup in the local
194     * running application
195     *
196     * @param dataObjectClass data object class to find lookup for
197     * @return boolean true if a lookup exists for the data object class, false if not
198     */
199    @Deprecated
200    public boolean hasLocalLookup(Class<?> dataObjectClass);
201
202    /**
203     * Determines whether the given data object class has an associated inquiry in the local
204     * running application
205     *
206     * @param dataObjectClass data object class to find inquiry for
207     * @return boolean true if a inquiry exists for the data object class, false if not
208     */
209    @Deprecated
210    public boolean hasLocalInquiry(Class<?> dataObjectClass);
211
212}