summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
commit40a9d99496e098562f090fb7ffce9e749011b131 (patch)
tree437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java
parentff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff)
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java')
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java551
1 files changed, 253 insertions, 298 deletions
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java
index 2e350f1..489d779 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EODatabaseDataSource.java
@@ -28,312 +28,267 @@ import net.wotonomy.foundation.NSSet;
import net.wotonomy.foundation.internal.WotonomyException;
/**
-* EODatabaseSource is a general-purpose implementation
-* of EODataSource that is EOClassDescription-aware and
-* that can vend appropriate EODetailDataSources.
-*
-* @author michael@mpowers.net
-* @author $Author: cgruber $
-* @version $Revision: 894 $
-*/
-public abstract class EODatabaseDataSource
-{
- EOQualifier auxiliaryQualifier;
- EOEditingContext editingContext;
- String entityName;
- String fetchSpecificationName;
- EOFetchSpecification fetchSpecification;
- NSDictionary qualifierBindings;
- EOClassDescription classDescription;
- boolean fetchEnabled;
-
- /**
- * Constructs a data source that fetches all objects of
- * the specified entity type.
- */
- public EODatabaseDataSource(
- EOEditingContext aContext, String anEntityName)
- {
- this( aContext, anEntityName, null );
- }
-
- /**
- * Constructs a data source that fetches objects of the
- * specified entity type according to the fetch specification
- * with the specified name.
- */
- public EODatabaseDataSource(
- EOEditingContext aContext, String anEntityName, String aFetchSpecName)
- {
- fetchEnabled = true;
- editingContext = aContext;
- entityName = anEntityName;
- setFetchSpecificationByName( fetchSpecificationName );
- }
-
- /**
- * Returns the qualifier that is applied to the results fetched by the fetch
- * specification before objects are returned by fetch objects, or null if no
- * such qualifier has been specified.
- */
- public EOQualifier auxiliaryQualifier()
- {
- return auxiliaryQualifier;
- }
-
- /**
- * Returns the description of the class of the
- * objects that is vended by this data source,
- * or null if no entity name is specified.
- */
- public EOClassDescription classDescriptionForObjects ()
- {
- if ( entityName == null ) return null;
- return EOClassDescription.classDescriptionForEntityName( entityName );
- }
-
- /**
- * Returns the object store at the root of the
- * editing context's editing hierarchy.
- */
- public EOObjectStore databaseContext()
- {
- EOObjectStore store = editingContext();
- while ( store instanceof EOEditingContext )
- {
- store = ((EOEditingContext)store).parentObjectStore();
- }
- return store;
- }
-
- /**
- * Returns a detail data source that is capable of
- * manipulating objects of the type returned by
- * applying the specified key to objects
- * vended by this data source.
- * @see #qualifyWithRelationshipKey
- */
- public EODataSource dataSourceQualifiedByKey ( String aKey )
- {
- throw new WotonomyException( "Not implemented yet." );
- }
-
- /**
- * Deletes the specified object from this data source.
- * This implementation deletes the specified object from
- * the editing context.
- */
- public void deleteObject ( Object anObject )
- {
- editingContext.deleteObject( anObject );
- }
-
- /**
- * Returns the editing context for this data source,
- * or null if no editing context was specified.
- */
- public EOEditingContext editingContext ()
- {
- return editingContext;
- }
+ * EODatabaseSource is a general-purpose implementation of EODataSource that is
+ * EOClassDescription-aware and that can vend appropriate EODetailDataSources.
+ *
+ * @author michael@mpowers.net
+ * @author $Author: cgruber $
+ * @version $Revision: 894 $
+ */
+public abstract class EODatabaseDataSource {
+ EOQualifier auxiliaryQualifier;
+ EOEditingContext editingContext;
+ String entityName;
+ String fetchSpecificationName;
+ EOFetchSpecification fetchSpecification;
+ NSDictionary qualifierBindings;
+ EOClassDescription classDescription;
+ boolean fetchEnabled;
-/*
- public EOEntity entity() {}
-*/
+ /**
+ * Constructs a data source that fetches all objects of the specified entity
+ * type.
+ */
+ public EODatabaseDataSource(EOEditingContext aContext, String anEntityName) {
+ this(aContext, anEntityName, null);
+ }
+
+ /**
+ * Constructs a data source that fetches objects of the specified entity type
+ * according to the fetch specification with the specified name.
+ */
+ public EODatabaseDataSource(EOEditingContext aContext, String anEntityName, String aFetchSpecName) {
+ fetchEnabled = true;
+ editingContext = aContext;
+ entityName = anEntityName;
+ setFetchSpecificationByName(fetchSpecificationName);
+ }
+
+ /**
+ * Returns the qualifier that is applied to the results fetched by the fetch
+ * specification before objects are returned by fetch objects, or null if no
+ * such qualifier has been specified.
+ */
+ public EOQualifier auxiliaryQualifier() {
+ return auxiliaryQualifier;
+ }
+
+ /**
+ * Returns the description of the class of the objects that is vended by this
+ * data source, or null if no entity name is specified.
+ */
+ public EOClassDescription classDescriptionForObjects() {
+ if (entityName == null)
+ return null;
+ return EOClassDescription.classDescriptionForEntityName(entityName);
+ }
+
+ /**
+ * Returns the object store at the root of the editing context's editing
+ * hierarchy.
+ */
+ public EOObjectStore databaseContext() {
+ EOObjectStore store = editingContext();
+ while (store instanceof EOEditingContext) {
+ store = ((EOEditingContext) store).parentObjectStore();
+ }
+ return store;
+ }
+
+ /**
+ * Returns a detail data source that is capable of manipulating objects of the
+ * type returned by applying the specified key to objects vended by this data
+ * source.
+ *
+ * @see #qualifyWithRelationshipKey
+ */
+ public EODataSource dataSourceQualifiedByKey(String aKey) {
+ throw new WotonomyException("Not implemented yet.");
+ }
+
+ /**
+ * Deletes the specified object from this data source. This implementation
+ * deletes the specified object from the editing context.
+ */
+ public void deleteObject(Object anObject) {
+ editingContext.deleteObject(anObject);
+ }
+
+ /**
+ * Returns the editing context for this data source, or null if no editing
+ * context was specified.
+ */
+ public EOEditingContext editingContext() {
+ return editingContext;
+ }
+
+ /*
+ * public EOEntity entity() {}
+ */
+
+ /**
+ * Returns a List containing the objects of the current entity type that conform
+ * to the specified fetch specification. If an auxiliary qualifier has been
+ * specified, that qualifier is applied to the objects before returning the
+ * result. If fetch is not enabled, this method returns null.
+ */
+ public NSArray fetchObjects() {
+ if (!isFetchEnabled())
+ return null;
+ NSArray result = editingContext.objectsWithFetchSpecification(fetchSpecification());
+ if (auxiliaryQualifier() != null) {
+ result = EOQualifier.filteredArrayWithQualifier(result, auxiliaryQualifier());
+ }
+ return result;
+ }
- /**
- * Returns a List containing the objects of the current
- * entity type that conform to the specified fetch specification.
- * If an auxiliary qualifier has been specified, that qualifier
- * is applied to the objects before returning the result.
- * If fetch is not enabled, this method returns null.
- */
- public NSArray fetchObjects ()
- {
- if ( ! isFetchEnabled() ) return null;
- NSArray result =
- editingContext.objectsWithFetchSpecification( fetchSpecification() );
- if ( auxiliaryQualifier() != null )
- {
- result = EOQualifier.filteredArrayWithQualifier( result, auxiliaryQualifier() );
- }
- return result;
- }
-
- /**
- * Returns the fetch specification currently used by this data
- * source to fetch objects, or null if none is specified.
- * If null, this fetchObjects() will return all objects of the
- * specified entity type.
- */
- public EOFetchSpecification fetchSpecification()
- {
- return fetchSpecification;
- }
-
- /**
- * Returns a copy of the fetch specification that will be used to
- * determine fetch for this data source. If this data source has
- * an auxiliary qualifier, that qualifier will be inserted into
- * the returned fetch specification's qualifier.
- */
- public EOFetchSpecification fetchSpecificationForFetch()
- {
- EOFetchSpecification result = (EOFetchSpecification) fetchSpecification.clone();
- if ( auxiliaryQualifier() != null )
- {
- NSMutableArray join = new NSMutableArray();
- join.addObject( fetchSpecification.qualifier() );
- join.addObject( auxiliaryQualifier() );
- result.setQualifier( new EOAndQualifier( join ) );
- }
- return result;
- }
-
- /**
- * Returns the name of the current fetch specification, or null
- * if no name has been specified.
- */
- public String fetchSpecificationName()
- {
- return fetchSpecificationName;
- }
-
- /**
- * Inserts the specified object into this data source.
- * This implementation registers the object as an inserted
- * object with the editing context.
- */
- public void insertObject ( Object anObject )
- {
- editingContext.insertObject( anObject );
- }
-
- /**
- * Returns whether fetching is currently allowed.
- * If false, fetchObjects() will return null.
- * Default is true.
- */
- public boolean isFetchEnabled()
- {
- return fetchEnabled;
- }
-
- /**
- * Returns a List of the union of the binding keys for the fetch spec's
- * qualifier and the auxiliary qualifier.
- */
- public NSArray qualifierBindingKeys()
- {
- NSSet union = new NSSet();
- if ( ( fetchSpecification != null )
- && ( fetchSpecification.qualifier() != null ) )
- {
- union.addAll( fetchSpecification.qualifier().bindingKeys() );
- }
- if ( auxiliaryQualifier() != null )
- {
- union.addAll( auxiliaryQualifier().bindingKeys() );
- }
- return new NSArray( (Collection) union );
- }
-
- /**
- * Returns a Map of the bindings that will be applied against
- * the fetch spec's qualifier and the auxiliary qualifier,
- * or null if no bindings exist.
- */
- public NSDictionary qualifierBindings()
- {
- if ( qualifierBindings == null ) return null;
- return new NSDictionary( (Map) qualifierBindings );
- }
-
- /**
- * Restricts this data source to vend those
- * objects that are associated with the specified
- * key on the specified object.
- */
- public void qualifyWithRelationshipKey (
- String aKey, Object anObject )
- {
- throw new WotonomyException( "Not implemented yet" );
- }
-
- /**
- * Sets the auxiliary qualifier that will be applied to
- * objects returned from the fetch described by the fetch specification.
- */
- public void setAuxiliaryQualifier(EOQualifier aQualifier)
- {
- auxiliaryQualifier = aQualifier;
- }
-
- /**
- * Sets whether fetches are currently allowed.
- * If false, fetchObjects() will return null.
- */
- public void setFetchEnabled(boolean isFetchEnabled)
- {
- fetchEnabled = isFetchEnabled;
- }
-
- /**
- * Sets the fetch specification used by this data source.
- * If null, all objects of the specified entity type will
- * be returned by fetchObjects().
- */
- public void setFetchSpecification( EOFetchSpecification aFetchSpec)
- {
- fetchSpecificationName = null;
- fetchSpecification = aFetchSpec;
- }
-
- /**
- * Sets the fetch specification used by this data source,
- * requesting it from the class description for this data source's
- * entity class description, if any. If the name cannot be resolved,
- * the fetch specification will be set to null.
- */
- public void setFetchSpecificationByName(String aName)
- {
- fetchSpecificationName = aName;
- fetchSpecification = EOFetchSpecification.fetchSpecificationNamed( aName, entityName );
- }
-
- /*
- public void setParentDataSourceRelationshipKey( EODataSource aDataSource, String aKey)
- */
-
- /**
- * Sets the bindings to be applied to the fetch specification and the auxiliary qualifier.
- */
- public void setQualifierBindings(Map aBindingMap)
- {
- if ( aBindingMap == null )
- {
- qualifierBindings = null;
- }
- else
- {
- qualifierBindings = new NSDictionary( (Map) aBindingMap );
- }
- }
+ /**
+ * Returns the fetch specification currently used by this data source to fetch
+ * objects, or null if none is specified. If null, this fetchObjects() will
+ * return all objects of the specified entity type.
+ */
+ public EOFetchSpecification fetchSpecification() {
+ return fetchSpecification;
+ }
+
+ /**
+ * Returns a copy of the fetch specification that will be used to determine
+ * fetch for this data source. If this data source has an auxiliary qualifier,
+ * that qualifier will be inserted into the returned fetch specification's
+ * qualifier.
+ */
+ public EOFetchSpecification fetchSpecificationForFetch() {
+ EOFetchSpecification result = (EOFetchSpecification) fetchSpecification.clone();
+ if (auxiliaryQualifier() != null) {
+ NSMutableArray join = new NSMutableArray();
+ join.addObject(fetchSpecification.qualifier());
+ join.addObject(auxiliaryQualifier());
+ result.setQualifier(new EOAndQualifier(join));
+ }
+ return result;
+ }
+
+ /**
+ * Returns the name of the current fetch specification, or null if no name has
+ * been specified.
+ */
+ public String fetchSpecificationName() {
+ return fetchSpecificationName;
+ }
+
+ /**
+ * Inserts the specified object into this data source. This implementation
+ * registers the object as an inserted object with the editing context.
+ */
+ public void insertObject(Object anObject) {
+ editingContext.insertObject(anObject);
+ }
+
+ /**
+ * Returns whether fetching is currently allowed. If false, fetchObjects() will
+ * return null. Default is true.
+ */
+ public boolean isFetchEnabled() {
+ return fetchEnabled;
+ }
+
+ /**
+ * Returns a List of the union of the binding keys for the fetch spec's
+ * qualifier and the auxiliary qualifier.
+ */
+ public NSArray qualifierBindingKeys() {
+ NSSet union = new NSSet();
+ if ((fetchSpecification != null) && (fetchSpecification.qualifier() != null)) {
+ union.addAll(fetchSpecification.qualifier().bindingKeys());
+ }
+ if (auxiliaryQualifier() != null) {
+ union.addAll(auxiliaryQualifier().bindingKeys());
+ }
+ return new NSArray((Collection) union);
+ }
+
+ /**
+ * Returns a Map of the bindings that will be applied against the fetch spec's
+ * qualifier and the auxiliary qualifier, or null if no bindings exist.
+ */
+ public NSDictionary qualifierBindings() {
+ if (qualifierBindings == null)
+ return null;
+ return new NSDictionary((Map) qualifierBindings);
+ }
+
+ /**
+ * Restricts this data source to vend those objects that are associated with the
+ * specified key on the specified object.
+ */
+ public void qualifyWithRelationshipKey(String aKey, Object anObject) {
+ throw new WotonomyException("Not implemented yet");
+ }
+
+ /**
+ * Sets the auxiliary qualifier that will be applied to objects returned from
+ * the fetch described by the fetch specification.
+ */
+ public void setAuxiliaryQualifier(EOQualifier aQualifier) {
+ auxiliaryQualifier = aQualifier;
+ }
+
+ /**
+ * Sets whether fetches are currently allowed. If false, fetchObjects() will
+ * return null.
+ */
+ public void setFetchEnabled(boolean isFetchEnabled) {
+ fetchEnabled = isFetchEnabled;
+ }
+
+ /**
+ * Sets the fetch specification used by this data source. If null, all objects
+ * of the specified entity type will be returned by fetchObjects().
+ */
+ public void setFetchSpecification(EOFetchSpecification aFetchSpec) {
+ fetchSpecificationName = null;
+ fetchSpecification = aFetchSpec;
+ }
+
+ /**
+ * Sets the fetch specification used by this data source, requesting it from the
+ * class description for this data source's entity class description, if any. If
+ * the name cannot be resolved, the fetch specification will be set to null.
+ */
+ public void setFetchSpecificationByName(String aName) {
+ fetchSpecificationName = aName;
+ fetchSpecification = EOFetchSpecification.fetchSpecificationNamed(aName, entityName);
+ }
+
+ /*
+ * public void setParentDataSourceRelationshipKey( EODataSource aDataSource,
+ * String aKey)
+ */
+
+ /**
+ * Sets the bindings to be applied to the fetch specification and the auxiliary
+ * qualifier.
+ */
+ public void setQualifierBindings(Map aBindingMap) {
+ if (aBindingMap == null) {
+ qualifierBindings = null;
+ } else {
+ qualifierBindings = new NSDictionary((Map) aBindingMap);
+ }
+ }
}
/*
- * $Log$
- * Revision 1.2 2006/02/16 16:47:14 cgruber
- * Move some classes in to "internal" packages and re-work imports, etc.
+ * $Log$ Revision 1.2 2006/02/16 16:47:14 cgruber Move some classes in to
+ * "internal" packages and re-work imports, etc.
*
- * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
+ * Also use UnsupportedOperationExceptions where appropriate, instead of
+ * WotonomyExceptions.
*
- * Revision 1.1 2006/02/16 13:19:57 cgruber
- * Check in all sources in eclipse-friendly maven-enabled packages.
+ * Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in
+ * eclipse-friendly maven-enabled packages.
*
- * Revision 1.1 2001/11/24 17:38:00 mpowers
- * Contributing EODatabaseDataSource.
+ * Revision 1.1 2001/11/24 17:38:00 mpowers Contributing EODatabaseDataSource.
*
*
*/
-