001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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: */
016: package org.kuali.core.service;
017:
018: import java.util.List;
019: import java.util.Map;
020:
021: import org.kuali.core.bo.PersistableBusinessObject;
022: import org.kuali.core.exceptions.ClassNotPersistableException;
023:
024: public interface PersistenceService {
025: // public void initialize();
026:
027: public void loadRepositoryDescriptor(String ojbRepositoryFilePath);
028:
029: public void clearCache();
030:
031: public Object resolveProxy(Object o);
032:
033: /**
034: * @param persistableObject object whose primary key field name,value pairs you want
035: * @return a Map containing the names and values of fields specified the given class which are designated as key fields in the
036: * OJB repository file
037: * @throws IllegalArgumentException if the given Object is null
038: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
039: */
040: public Map getPrimaryKeyFieldValues(Object persistableObject);
041:
042: /**
043: * @param persistableObject object whose primary key field name,value pairs you want
044: * @param sortFieldNames if true, the returned Map will iterate through its entries sorted by fieldName
045: * @return a Map containing the names and values of fields specified the given class which are designated as key fields in the
046: * OJB repository file
047: * @throws IllegalArgumentException if the given Object is null
048: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
049: */
050: public Map getPrimaryKeyFieldValues(Object persistableObject,
051: boolean sortFieldNames);
052:
053: /**
054: * @param persistableObject object whose objects need to be filled in based on primary keys
055: * @return the object whose key fields have just been retrieved
056: * @throws IllegalArgumentException if the given Object is null
057: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
058: */
059: public void retrieveNonKeyFields(Object persistableObject);
060:
061: /**
062: * @param persistableObject object whose specified reference object needs to be filled in based on primary keys
063: * @param referenceObjectName the name of the reference object that will be filled in based on primary key values
064: * @throws IllegalArgumentException if the given Object is null
065: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
066: */
067: public void retrieveReferenceObject(Object persistableObject,
068: String referenceObjectName);
069:
070: /**
071: * @param persistableObject object whose specified reference objects need to be filled in based on primary keys
072: * @param referenceObjectNames the names of the reference objects that will be filled in based on primary key values
073: * @throws IllegalArgumentException if either of the given lists is null or empty, or if any of the referenceObjectNames is
074: * blank
075: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
076: */
077: public void retrieveReferenceObjects(Object persistableObject,
078: List referenceObjectNames);
079:
080: /**
081: * @param persistableObjects objects whose specified reference objects need to be filled in based on primary keys
082: * @param referenceObjectNames the names of the reference objects that will be filled in based on primary key values
083: * @throws IllegalArgumentException if either of the given lists is null or empty, or if any of the referenceObjectNames is
084: * blank
085: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
086: */
087: public void retrieveReferenceObjects(List persistableObjects,
088: List referenceObjectNames);
089:
090: /**
091: * @param persistableObject object whose objects need to have keys filled
092: * @return the object whose key fields have just been filled
093: * @throws IllegalArgumentException if the given Object is null
094: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
095: */
096: public void linkObjects(Object persistableObject);
097:
098: /**
099: * Gets the value for the given field name from the object, works for anonymous fields as well as simple fields
100: *
101: * @param persistableObject object to get value from
102: * @param fieldName name of the field to get from the object
103: * @return Object value of field in object, or null
104: */
105: public Object getFieldValue(Object persistableObject,
106: String fieldName);
107:
108: /**
109: * @param persistableObject object whose primary key field name,value pairs you want
110: * @param bounded - whether to restrict the number of rows returned
111: * @return a String representation of the primary key fields and values for the given persistableObject
112: * @throws IllegalArgumentException if the given Object is null
113: * @throws ClassNotPersistableException if the given object is of a type not described in the OJB repository
114: */
115: public String getFlattenedPrimaryKeyFieldValues(
116: Object persistableObject);
117:
118: /**
119: *
120: * This method examines whether all the foreign key fields for the specified reference contain values.
121: *
122: * @param bo
123: * @param referenceName
124: * @return true if they all are accessible and have values, false otherwise
125: *
126: */
127: public boolean allForeignKeyValuesPopulatedForReference(
128: PersistableBusinessObject bo, String referenceName);
129:
130: /**
131: *
132: * This method refreshes all reference objects to this main object that are 'non-updateable'. In general, this means that if a
133: * reference object is configured to not be updated when the parent document is saved, then they are non-updated.
134: *
135: * This will not refresh updateable objects, which can cause problems when you're creating new objects.
136: *
137: * See PersistenceServiceImpl.isUpdateableReference() for the full logic.
138: *
139: * @param bo - the businessObject to be refreshed
140: *
141: */
142: public void refreshAllNonUpdatingReferences(
143: PersistableBusinessObject bo);
144:
145: }
|