Coverage Report - org.kuali.rice.kns.service.DataObjectMetaDataService
 
Classes in this File Line Coverage Branch Coverage Complexity
DataObjectMetaDataService
N/A
N/A
1
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.service;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.kuali.rice.kns.bo.BusinessObjectRelationship;
 22  
 import org.kuali.rice.kns.datadictionary.RelationshipDefinition;
 23  
 
 24  
 /**
 25  
  * Provides metadata such as relationships and key fields for data objects
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public interface DataObjectMetaDataService {
 30  
 
 31  
     /**
 32  
      * Checks the DataDictionary and OJB Repository File to determine the primary
 33  
      * fields names for a given class.
 34  
      *
 35  
      * @param clazz The Class to check for primary keys
 36  
      * @return a list of the primary key field names or an empty list if none are found
 37  
      */
 38  
     public List<String> listPrimaryKeyFieldNames(Class<?> clazz);
 39  
    
 40  
     /**
 41  
      * @param DataObject object whose primary key field name,value pairs you want
 42  
      * @return a Map containing the names and values of fields for the given class which
 43  
      *         are designated as key fields in the OJB repository file or DataDictionary
 44  
      * @throws IllegalArgumentException if the given Object is null
 45  
      */
 46  
     public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject);
 47  
 
 48  
     /**
 49  
      * @param persistableObject object whose primary key field name,value pairs you want
 50  
      * @param sortFieldNames if true, the returned Map will iterate through its entries sorted by fieldName
 51  
      * @return a Map containing the names and values of fields for the given class which
 52  
      *         are designated as key fields in the OJB repository file or DataDictionary
 53  
      * @throws IllegalArgumentException if the given Object is null
 54  
      */
 55  
     public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject, boolean sortFieldNames);
 56  
 
 57  
     /**
 58  
      * Compares two dataObject instances for equality of type and key values using toString()
 59  
      * of each value for comparison purposes.
 60  
      * 
 61  
      * @param do1
 62  
      * @param do2
 63  
      * @return boolean indicating whether the two objects are equal.
 64  
      */
 65  
     public boolean equalsByPrimaryKeys(Object do1, Object do2);
 66  
     
 67  
         /**
 68  
          * Attempts to find a relationship for the given attribute within the given
 69  
          * data object
 70  
          * 
 71  
          * <p>
 72  
          * First the data dictionary is queried to find any relationship definitions
 73  
          * setup that include the attribute, if found the
 74  
          * <code>BusinessObjectRetationship</code> is build from that. If not and
 75  
          * the data object class is persistent, relationships are retrieved from the
 76  
          * persistence service. Nested attributes are handled in addition to
 77  
          * external business objects. If multiple relationships are found, the one
 78  
          * that contains the least amount of joining keys is returned
 79  
          * </p>
 80  
          * 
 81  
          * @param dataObject
 82  
          *            - data object instance that contains the attribute
 83  
          * @param dataObjectClass
 84  
          *            - class for the data object that contains the attribute
 85  
          * @param attributeName
 86  
          *            - property name for the attribute
 87  
          * @param attributePrefix
 88  
          *            - property prefix for the attribute
 89  
          * @param keysOnly
 90  
          *            - indicates whether only primary key fields should be returned
 91  
          *            in the relationship
 92  
          * @param supportsLookup
 93  
          *            - indicates whether the relationship should support lookup
 94  
          * @param supportsInquiry
 95  
          *            - indicates whether the relationship should support inquiry
 96  
          * @return BusinessObjectRelationship for the attribute, or null if not
 97  
          *         found
 98  
          */
 99  
         public BusinessObjectRelationship getDataObjectRelationship(Object dataObject, Class<?> dataObjectClass,
 100  
                         String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup,
 101  
                         boolean supportInquiry);
 102  
 
 103  
         /**
 104  
          * This method fetches the RelationshipDefinition using the parameters.
 105  
          * 
 106  
          * @param dataObjectClass - data object class that contains the attribute
 107  
          * @param attributeName - property name for the attribute
 108  
          * @return RelationshipDefinition for the attribute, or null if not found
 109  
          */
 110  
         public RelationshipDefinition getDictionaryRelationship(Class<?> dataObjectClass, String attributeName);
 111  
         
 112  
         /**
 113  
      * Returns the attribute to be associated with for object level markings.  This would
 114  
      * be the field chosen for inquiry links etc.
 115  
      * 
 116  
      * @param dataObjectClass - data object class to obtain title attribute of
 117  
      * @return property name of title attribute or null if data object entry not found
 118  
      * @throws IllegalArgumentException
 119  
      *             if the given Class is null
 120  
      */
 121  
     public String getTitleAttribute(Class<?> dataObjectClass);
 122  
 
 123  
 }