1 /** 2 * Copyright 2005-2012 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.service; 17 18 import org.kuali.rice.krad.bo.PersistableBusinessObject; 19 20 import java.util.List; 21 import java.util.Map; 22 23 public interface PersistenceService { 24 // public void initialize(); 25 26 public void loadRepositoryDescriptor(String ojbRepositoryFilePath); 27 28 public void clearCache(); 29 30 public Object resolveProxy(Object o); 31 32 /** 33 * @param persistableObject object whose primary key field name,value pairs you want 34 * @return a Map containing the names and values of fields specified the given class which are designated as key fields in the 35 * OJB repository file 36 * @throws IllegalArgumentException if the given Object is null 37 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 38 */ 39 public Map getPrimaryKeyFieldValues(Object persistableObject); 40 41 /** 42 * @param persistableObject object whose primary key field name,value pairs you want 43 * @param sortFieldNames if true, the returned Map will iterate through its entries sorted by fieldName 44 * @return a Map containing the names and values of fields specified the given class which are designated as key fields in the 45 * OJB repository file 46 * @throws IllegalArgumentException if the given Object is null 47 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 48 */ 49 public Map getPrimaryKeyFieldValues(Object persistableObject, boolean sortFieldNames); 50 51 /** 52 * @param persistableObject object whose objects need to be filled in based on primary keys 53 * @return the object whose key fields have just been retrieved 54 * @throws IllegalArgumentException if the given Object is null 55 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 56 */ 57 public void retrieveNonKeyFields(Object persistableObject); 58 59 /** 60 * @param persistableObject object whose specified reference object needs to be filled in based on primary keys 61 * @param referenceObjectName the name of the reference object that will be filled in based on primary key values 62 * @throws IllegalArgumentException if the given Object is null 63 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 64 */ 65 public void retrieveReferenceObject(Object persistableObject, String referenceObjectName); 66 67 68 /** 69 * @param persistableObject object whose specified reference objects need to be filled in based on primary keys 70 * @param referenceObjectNames the names of the reference objects that will be filled in based on primary key values 71 * @throws IllegalArgumentException if either of the given lists is null or empty, or if any of the referenceObjectNames is 72 * blank 73 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 74 */ 75 public void retrieveReferenceObjects(Object persistableObject, List referenceObjectNames); 76 77 /** 78 * @param persistableObjects objects whose specified reference objects need to be filled in based on primary keys 79 * @param referenceObjectNames the names of the reference objects that will be filled in based on primary key values 80 * @throws IllegalArgumentException if either of the given lists is null or empty, or if any of the referenceObjectNames is 81 * blank 82 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 83 */ 84 public void retrieveReferenceObjects(List persistableObjects, List referenceObjectNames); 85 86 87 /** 88 * @param persistableObject object whose objects need to have keys filled 89 * @return the object whose key fields have just been filled 90 * @throws IllegalArgumentException if the given Object is null 91 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 92 */ 93 public void linkObjects(Object persistableObject); 94 95 96 /** 97 * Gets the value for the given field name from the object, works for anonymous fields as well as simple fields 98 * 99 * @param persistableObject object to get value from 100 * @param fieldName name of the field to get from the object 101 * @return Object value of field in object, or null 102 */ 103 // This method never called 104 //public Object getFieldValue(Object persistableObject, String fieldName); 105 106 /** 107 * @param persistableObject object whose primary key field name,value pairs you want 108 * @param bounded - whether to restrict the number of rows returned 109 * @return a String representation of the primary key fields and values for the given persistableObject 110 * @throws IllegalArgumentException if the given Object is null 111 * @throws org.kuali.rice.krad.exception.ClassNotPersistableException if the given object is of a type not described in the OJB repository 112 */ 113 public String getFlattenedPrimaryKeyFieldValues(Object persistableObject); 114 115 /** 116 * 117 * This method examines whether all the foreign key fields for the specified reference contain values. 118 * 119 * @param bo 120 * @param referenceName 121 * @return true if they all are accessible and have values, false otherwise 122 * 123 */ 124 public boolean allForeignKeyValuesPopulatedForReference(PersistableBusinessObject bo, String referenceName); 125 126 /** 127 * 128 * This method refreshes all reference objects to this main object that are 'non-updateable'. In general, this means that if a 129 * reference object is configured to not be updated when the parent document is saved, then they are non-updated. 130 * 131 * This will not refresh updateable objects, which can cause problems when you're creating new objects. 132 * 133 * See PersistenceServiceImpl.isUpdateableReference() for the full logic. 134 * 135 * @param bo - the businessObject to be refreshed 136 * 137 */ 138 public void refreshAllNonUpdatingReferences(PersistableBusinessObject bo); 139 140 141 /** 142 * Determines if the given object is proxied by the ORM or not 143 * 144 * @param object the object to determine if it is a proxy 145 * @return true if the object is an ORM proxy; false otherwise 146 */ 147 public abstract boolean isProxied(Object object); 148 149 /** 150 * Determines if JPA is enabled for the KNS and for the given class 151 * 152 * @param clazz the class to check for JPA enabling of 153 * @return true if JPA is enabled for the class, false otherwise 154 */ 155 public abstract boolean isJpaEnabledForKradClass(Class clazz); 156 }