summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java')
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java338
1 files changed, 204 insertions, 134 deletions
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java
index af696fe..6ee58a5 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseContext.java
@@ -42,13 +42,12 @@ import net.wotonomy.foundation.NSMutableArray;
import net.wotonomy.foundation.NSMutableDictionary;
/**
-*
-* @author ezamudio@nasoft.com
-* @author $Author: cgruber $
-* @version $Revision: 894 $
-*/
-public class EODatabaseContext
- extends EOCooperatingObjectStore implements NSLocking {
+ *
+ * @author ezamudio@nasoft.com
+ * @author $Author: cgruber $
+ * @version $Revision: 894 $
+ */
+public class EODatabaseContext extends EOCooperatingObjectStore implements NSLocking {
private static Class _contextClass;
protected EODatabase _database;
@@ -79,7 +78,7 @@ public class EODatabaseContext
public EODatabaseChannel availableChannel() {
for (int i = 0; i < _channels.count(); i++) {
- EODatabaseChannel c = (EODatabaseChannel)_channels.objectAtIndex(i);
+ EODatabaseChannel c = (EODatabaseChannel) _channels.objectAtIndex(i);
if (!c.isFetchInProgress())
return c;
}
@@ -94,6 +93,7 @@ public class EODatabaseContext
public static void setContextClassToRegister(Class contextClass) {
_contextClass = contextClass;
}
+
public static Class contextClassToRegister() {
if (_contextClass == null)
_contextClass = EODatabaseContext.class;
@@ -109,21 +109,28 @@ public class EODatabaseContext
}
public void handleDroppedConnection() {
- //TODO: unregister channels
+ // TODO: unregister channels
adaptorContext().handleDroppedConnection();
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#ownsGlobalID(net.wotonomy.control.EOGlobalID)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOCooperatingObjectStore#ownsGlobalID(net.wotonomy.
+ * control.EOGlobalID)
*/
public boolean ownsGlobalID(EOGlobalID gid) {
if (!(gid instanceof EOKeyGlobalID))
return false;
- return (database().entityNamed(((EOKeyGlobalID)gid).entityName()) != null);
+ return (database().entityNamed(((EOKeyGlobalID) gid).entityName()) != null);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#ownsObject(net.wotonomy.control.EOEnterpriseObject)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOCooperatingObjectStore#ownsObject(net.wotonomy.control
+ * .EOEnterpriseObject)
*/
public boolean ownsObject(EOEnterpriseObject eo) {
if (eo.entityName() == null)
@@ -131,8 +138,12 @@ public class EODatabaseContext
return (database().entityNamed(eo.entityName()) != null);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#handlesFetchSpecification(net.wotonomy.control.EOFetchSpecification)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOCooperatingObjectStore#handlesFetchSpecification(net.
+ * wotonomy.control.EOFetchSpecification)
*/
public boolean handlesFetchSpecification(EOFetchSpecification fspec) {
String ename = fspec.entityName();
@@ -143,8 +154,13 @@ public class EODatabaseContext
return adaptorContext().hasBusyChannels();
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#prepareForSaveWithCoordinator(net.wotonomy.control.EOObjectStoreCoordinator, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOCooperatingObjectStore#prepareForSaveWithCoordinator(
+ * net.wotonomy.control.EOObjectStoreCoordinator,
+ * net.wotonomy.control.EOEditingContext)
*/
public void prepareForSaveWithCoordinator(EOObjectStoreCoordinator coord, EOEditingContext ec) {
// TODO Auto-generated method stub
@@ -152,15 +168,21 @@ public class EODatabaseContext
_currEC = ec;
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#recordChangesInEditingContext()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOCooperatingObjectStore#recordChangesInEditingContext()
*/
public void recordChangesInEditingContext() {
// TODO insert, delete, update
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#recordUpdateForObject(net.wotonomy.control.EOEnterpriseObject, net.wotonomy.foundation.NSDictionary)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOCooperatingObjectStore#recordUpdateForObject(net.
+ * wotonomy.control.EOEnterpriseObject, net.wotonomy.foundation.NSDictionary)
*/
public void recordUpdateForObject(EOEnterpriseObject eo, NSDictionary changes) {
// TODO Auto-generated method stub
@@ -175,7 +197,7 @@ public class EODatabaseContext
public void recordSnapshotForSourceGlobalID(NSArray gids, EOGlobalID gid, String relationName) {
if (_manySnaps == null)
throw new IllegalArgumentException("Attempt to record a snapshot without a transaction in progress");
- NSMutableDictionary d = (NSMutableDictionary)_manySnaps.objectForKey(gid);
+ NSMutableDictionary d = (NSMutableDictionary) _manySnaps.objectForKey(gid);
if (d == null) {
d = new NSMutableDictionary();
_manySnaps.setObjectForKey(d, gid);
@@ -187,13 +209,12 @@ public class EODatabaseContext
if (_simpleSnaps == null)
throw new IllegalArgumentException("Attempt to record snapshots without a transaction in progress.");
_simpleSnaps.addEntriesFromDictionary(snaps);
- /* Make sure we don't need to do this instead
- Enumeration enumeration = snaps.keyEnumerator();
- while (enumeration.hasMoreElements()) {
- EOGlobalID g = (EOGlobalID)enumeration.nextElement();
- NSDictionary d = (NSDictionary)snaps.objectForKey(g);
- recordSnapshotForGlobalID(d, g);
- }*/
+ /*
+ * Make sure we don't need to do this instead Enumeration enumeration =
+ * snaps.keyEnumerator(); while (enumeration.hasMoreElements()) { EOGlobalID g =
+ * (EOGlobalID)enumeration.nextElement(); NSDictionary d =
+ * (NSDictionary)snaps.objectForKey(g); recordSnapshotForGlobalID(d, g); }
+ */
}
public void recordToManySnapshots(NSDictionary snaps) {
@@ -202,18 +223,20 @@ public class EODatabaseContext
Enumeration enumeration = snaps.keyEnumerator();
while (enumeration.hasMoreElements()) {
Object key = enumeration.nextElement();
- NSDictionary d = (NSDictionary)snaps.objectForKey(key);
- NSMutableDictionary d2 = (NSMutableDictionary)_manySnaps.objectForKey(key);
+ NSDictionary d = (NSDictionary) snaps.objectForKey(key);
+ NSMutableDictionary d2 = (NSMutableDictionary) _manySnaps.objectForKey(key);
if (d2 == null) {
d2 = new NSMutableDictionary();
_manySnaps.setObjectForKey(d2, key);
}
- //this could also be done with many calls to recordSnapshotForSourceGID
+ // this could also be done with many calls to recordSnapshotForSourceGID
d2.addEntriesFromDictionary(d);
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.control.EOCooperatingObjectStore#performChanges()
*/
public void performChanges() {
@@ -221,70 +244,92 @@ public class EODatabaseContext
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.control.EOCooperatingObjectStore#commitChanges()
*/
public void commitChanges() {
adaptorContext().commitTransaction();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.control.EOCooperatingObjectStore#rollbackChanges()
*/
public void rollbackChanges() {
adaptorContext().rollbackTransaction();
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOCooperatingObjectStore#valuesForKeys(net.wotonomy.foundation.NSArray, net.wotonomy.control.EOEnterpriseObject)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOCooperatingObjectStore#valuesForKeys(net.wotonomy.
+ * foundation.NSArray, net.wotonomy.control.EOEnterpriseObject)
*/
public NSDictionary valuesForKeys(NSArray keys, EOEnterpriseObject eo) {
// TODO check snapshots; eo could be a fault
return eo.valuesForKeys(keys);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.foundation.NSLocking#lock()
*/
public void lock() {
EOAccessLock.lock();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.foundation.NSLocking#unlock()
*/
public void unlock() {
EOAccessLock.unlock();
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#arrayFaultWithSourceGlobalID(net.wotonomy.control.EOGlobalID, java.lang.String, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#arrayFaultWithSourceGlobalID(net.wotonomy.
+ * control.EOGlobalID, java.lang.String, net.wotonomy.control.EOEditingContext)
*/
- public NSArray arrayFaultWithSourceGlobalID(
- EOGlobalID gid, String relName, EOEditingContext ec) {
+ public NSArray arrayFaultWithSourceGlobalID(EOGlobalID gid, String relName, EOEditingContext ec) {
if (!(gid instanceof EOKeyGlobalID))
throw new IllegalArgumentException("an EOKeyGlobalID is needed.");
- EOAccessArrayFaultHandler handler = new EOAccessArrayFaultHandler((EOKeyGlobalID)gid, relName, this, ec);
+ EOAccessArrayFaultHandler handler = new EOAccessArrayFaultHandler((EOKeyGlobalID) gid, relName, this, ec);
return new NSArray(handler);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#faultForGlobalID(net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#faultForGlobalID(net.wotonomy.control.
+ * EOGlobalID, net.wotonomy.control.EOEditingContext)
*/
- public /*EOEnterpriseObject*/Object faultForGlobalID(EOGlobalID gid, EOEditingContext ec) {
+ public /* EOEnterpriseObject */Object faultForGlobalID(EOGlobalID gid, EOEditingContext ec) {
if (!(gid instanceof EOKeyGlobalID))
throw new IllegalArgumentException("Cannot fault an object that doesn't have a key global ID.");
- EOAccessFaultHandler handler = new EOAccessFaultHandler((EOKeyGlobalID)gid, this, ec);
- EOEntity e = database().entityNamed(((EOKeyGlobalID)gid).entityName());
+ EOAccessFaultHandler handler = new EOAccessFaultHandler((EOKeyGlobalID) gid, this, ec);
+ EOEntity e = database().entityNamed(((EOKeyGlobalID) gid).entityName());
Object o = e.classDescriptionForInstances().createInstanceWithEditingContext(ec, gid);
EOFaultHandler.makeObjectIntoFault(o, handler);
return o;
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#faultForRawRow(java.util.Map, java.lang.String, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOObjectStore#faultForRawRow(java.util.Map,
+ * java.lang.String, net.wotonomy.control.EOEditingContext)
*/
- public /*EOEnterpriseObject*/ Object faultForRawRow(Map row, String entityName, EOEditingContext ec) {
+ public /* EOEnterpriseObject */ Object faultForRawRow(Map row, String entityName, EOEditingContext ec) {
EOEntity e = database().entityNamed(entityName);
EOGlobalID gid = e.globalIDForRow(row);
return faultForGlobalID(gid, ec);
@@ -299,74 +344,81 @@ public class EODatabaseContext
public void forgetSnapshotsForGlobalIDs(List gids) {
for (int i = 0; i < gids.size(); i++) {
- EOGlobalID g = (EOGlobalID)gids.get(i);
+ EOGlobalID g = (EOGlobalID) gids.get(i);
forgetSnapshotForGlobalID(g);
database().forgetSnapshotForGlobalID(g);
}
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#initializeObject(java.lang.Object, net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOObjectStore#initializeObject(java.lang.Object,
+ * net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
*/
- public void initializeObject(/*EOEnterpriseObject*/Object eo, EOGlobalID gid, EOEditingContext ec) {
+ public void initializeObject(/* EOEnterpriseObject */Object eo, EOGlobalID gid, EOEditingContext ec) {
if (gid.isTemporary())
return;
NSDictionary snap = snapshotForGlobalID(gid);
Object obj = ec.objectForGlobalID(gid);
- EOEntity e = database().entityNamed(((EOKeyGlobalID)gid).entityName());
+ EOEntity e = database().entityNamed(((EOKeyGlobalID) gid).entityName());
NSArray props = e.classProperties();
for (int i = 0; i < props.count(); i++) {
- EOProperty p = (EOProperty)props.objectAtIndex(i);
+ EOProperty p = (EOProperty) props.objectAtIndex(i);
Object val = snap.objectForKey(p.name());
if (p instanceof EOAttribute) {
- if ( eo instanceof EOKeyValueCoding )
- {
- ((EOKeyValueCoding)eo).takeValueForKey(val, p.name());
- }
- else
- {
- EOKeyValueCodingSupport.takeValueForKey( eo, val, p.name() );
- }
+ if (eo instanceof EOKeyValueCoding) {
+ ((EOKeyValueCoding) eo).takeValueForKey(val, p.name());
+ } else {
+ EOKeyValueCodingSupport.takeValueForKey(eo, val, p.name());
+ }
} else if (p instanceof EORelationship) {
- if (((EORelationship)p).isToMany()) {
+ if (((EORelationship) p).isToMany()) {
val = arrayFaultWithSourceGlobalID(gid, p.name(), ec);
} else {
- EOEntity dest = ((EORelationship)p).destinationEntity();
- EOKeyGlobalID kgid = (EOKeyGlobalID)dest.globalIDForRow(snap);
+ EOEntity dest = ((EORelationship) p).destinationEntity();
+ EOKeyGlobalID kgid = (EOKeyGlobalID) dest.globalIDForRow(snap);
val = ec.objectForGlobalID(kgid);
if (val == null)
val = new EOAccessFaultHandler(kgid, this, ec);
}
if (val == EOKeyValueCoding.NullValue)
val = null;
- if ( eo instanceof EOKeyValueCoding )
- {
- ((EOKeyValueCoding)eo).takeValueForKey(val, p.name());
- }
- else
- {
- EOKeyValueCodingSupport.takeValueForKey( eo, val, p.name() );
- }
+ if (eo instanceof EOKeyValueCoding) {
+ ((EOKeyValueCoding) eo).takeValueForKey(val, p.name());
+ } else {
+ EOKeyValueCodingSupport.takeValueForKey(eo, val, p.name());
+ }
}
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see net.wotonomy.control.EOObjectStore#invalidateAllObjects()
*/
public void invalidateAllObjects() {
invalidateObjectsWithGlobalIDs(database().snapshots().allKeys());
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#invalidateObjectsWithGlobalIDs(java.util.List)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#invalidateObjectsWithGlobalIDs(java.util.
+ * List)
*/
public void invalidateObjectsWithGlobalIDs(List aList) {
forgetSnapshotsForGlobalIDs(aList);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#isObjectLockedWithGlobalID(net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#isObjectLockedWithGlobalID(net.wotonomy.
+ * control.EOGlobalID, net.wotonomy.control.EOEditingContext)
*/
public boolean isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext ec) {
return isObjectLockedWithGlobalID(gid);
@@ -376,8 +428,11 @@ public class EODatabaseContext
return _lockedObjects.containsObject(gid);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#lockObjectWithGlobalID(net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOObjectStore#lockObjectWithGlobalID(net.wotonomy.
+ * control.EOGlobalID, net.wotonomy.control.EOEditingContext)
*/
public void lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext ec) {
NSDictionary snap = snapshotForGlobalID(gid);
@@ -385,7 +440,7 @@ public class EODatabaseContext
return;
if (!(gid instanceof EOKeyGlobalID))
return;
- EOEntity e = database().entityNamed(((EOKeyGlobalID)gid).entityName());
+ EOEntity e = database().entityNamed(((EOKeyGlobalID) gid).entityName());
EOQualifier q = e.qualifierForPrimaryKey(snap);
EOFetchSpecification fspec = new EOFetchSpecification(e.name(), q, null);
fspec.setLocksObjects(true);
@@ -394,48 +449,53 @@ public class EODatabaseContext
throw new IllegalStateException("Cannot lock object with Global ID " + gid);
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#objectsForSourceGlobalID(net.wotonomy.control.EOGlobalID, java.lang.String, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#objectsForSourceGlobalID(net.wotonomy.
+ * control.EOGlobalID, java.lang.String, net.wotonomy.control.EOEditingContext)
*/
- public NSArray objectsForSourceGlobalID(
- EOGlobalID gid, String relationName, EOEditingContext ec) {
- EOEnterpriseObject eo = (EOEnterpriseObject)ec.objectForGlobalID(gid);
+ public NSArray objectsForSourceGlobalID(EOGlobalID gid, String relationName, EOEditingContext ec) {
+ EOEnterpriseObject eo = (EOEnterpriseObject) ec.objectForGlobalID(gid);
if (eo == null)
- throw new IllegalStateException("Cannot find object for global ID " + gid + " in specified editing context.");
- //Get the source object
+ throw new IllegalStateException(
+ "Cannot find object for global ID " + gid + " in specified editing context.");
+ // Get the source object
EOEnterpriseObject source = (EOEnterpriseObject) faultForGlobalID(gid, ec);
if (source == null)
throw new IllegalStateException("There is no snapshot for source global ID " + gid);
- //Check if there is already a value here
- NSArray value = (NSArray)source.valueForKey(relationName);
+ // Check if there is already a value here
+ NSArray value = (NSArray) source.valueForKey(relationName);
EOAccessArrayFaultHandler handler = null;
if (value != null) {
if (EOFaultHandler.isFault(value)) {
- handler = new EOAccessArrayFaultHandler((EOKeyGlobalID)gid, relationName, this, ec);
- //TODO: fire the fault an return the value
+ handler = new EOAccessArrayFaultHandler((EOKeyGlobalID) gid, relationName, this, ec);
+ // TODO: fire the fault an return the value
} else
return value;
}
- //Get the relationship
+ // Get the relationship
EOEntity entity = database().entityNamed(eo.entityName());
EORelationship rel = entity.relationshipNamed(relationName);
if (rel == null)
- throw new IllegalStateException("Cannot find relationship named " + relationName + " in entity " + entity.name());
+ throw new IllegalStateException(
+ "Cannot find relationship named " + relationName + " in entity " + entity.name());
- //create a fetch specification for this
+ // create a fetch specification for this
EOQualifier q = null;
NSArray joins = rel.joins();
NSMutableArray subq = new NSMutableArray(joins.count());
for (int i = 0; i < joins.count(); i++) {
- EOJoin j = (EOJoin)joins.objectAtIndex(i);
+ EOJoin j = (EOJoin) joins.objectAtIndex(i);
String key = j.destinationAttribute().name();
Object val = eo.valueForKey(j.sourceAttribute().name());
subq.addObject(new EOKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, val));
}
if (subq.count() == 1) {
- q = (EOQualifier)subq.objectAtIndex(0);
+ q = (EOQualifier) subq.objectAtIndex(0);
} else {
q = new EOAndQualifier(subq);
}
@@ -448,8 +508,12 @@ public class EODatabaseContext
return res;
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#objectsWithFetchSpecification(net.wotonomy.control.EOFetchSpecification, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#objectsWithFetchSpecification(net.wotonomy
+ * .control.EOFetchSpecification, net.wotonomy.control.EOEditingContext)
*/
public NSArray objectsWithFetchSpecification(EOFetchSpecification fspec, EOEditingContext ec) {
EODatabaseChannel channel = availableChannel();
@@ -464,21 +528,28 @@ public class EODatabaseContext
return arr;
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#refaultObject(java.lang.Object, net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.wotonomy.control.EOObjectStore#refaultObject(java.lang.Object,
+ * net.wotonomy.control.EOGlobalID, net.wotonomy.control.EOEditingContext)
*/
public void refaultObject(Object obj, EOGlobalID gid, EOEditingContext ec) {
if (!(gid instanceof EOKeyGlobalID))
throw new IllegalArgumentException("GlobalID must be an EOKeyGlobalID");
if (obj instanceof EOFaulting)
- //check if it's already a fault
- if (!EOFaultHandler.isFault(obj)) {
- ((EOFaulting)obj).turnIntoFault(EOFaultHandler.handlerForFault(obj));
- }
+ // check if it's already a fault
+ if (!EOFaultHandler.isFault(obj)) {
+ ((EOFaulting) obj).turnIntoFault(EOFaultHandler.handlerForFault(obj));
+ }
}
- /* (non-Javadoc)
- * @see net.wotonomy.control.EOObjectStore#saveChangesInEditingContext(net.wotonomy.control.EOEditingContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.wotonomy.control.EOObjectStore#saveChangesInEditingContext(net.wotonomy.
+ * control.EOEditingContext)
*/
public void saveChangesInEditingContext(EOEditingContext ec) {
prepareForSaveWithCoordinator(null, ec);
@@ -508,7 +579,7 @@ public class EODatabaseContext
public NSDictionary snapshotForGlobalID(EOGlobalID gid) {
NSDictionary d = null;
if (_simpleSnaps != null) {
- d = (NSDictionary)_simpleSnaps.objectForKey(gid);
+ d = (NSDictionary) _simpleSnaps.objectForKey(gid);
}
if (d == null)
d = database().snapshotForGlobalID(gid);
@@ -518,8 +589,8 @@ public class EODatabaseContext
public NSArray snapshotForSourceGlobalID(EOGlobalID gid, String name) {
NSArray a = null;
if (_manySnaps != null) {
- NSDictionary d = (NSDictionary)_manySnaps.objectForKey(gid);
- a = (NSArray)d.objectForKey(name);
+ NSDictionary d = (NSDictionary) _manySnaps.objectForKey(gid);
+ a = (NSArray) d.objectForKey(name);
}
if (a == null)
a = database().snapshotForSourceGlobalID(gid, name);
@@ -536,33 +607,32 @@ public class EODatabaseContext
}
/*
- * $Log$
- * Revision 1.2 2006/02/16 16:47:13 cgruber
- * Move some classes in to "internal" packages and re-work imports, etc.
+ * $Log$ Revision 1.2 2006/02/16 16:47:13 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.5 2005/05/11 15:21:53 cgruber
- * Change enum to enumeration, since enum is now a keyword as of Java 5.0
+ * Revision 1.5 2005/05/11 15:21:53 cgruber Change enum to enumeration, since
+ * enum is now a keyword as of Java 5.0
*
* A few other comments in the code.
*
- * Revision 1.4 2003/12/18 15:37:38 mpowers
- * Changes to retain ability to work with objects that don't necessarily
- * implement EOEnterpriseObject. I would still like to preserve this case
- * for general usage, however the access package is free to assume that
- * those objects will be EOs and cast appropriately.
+ * Revision 1.4 2003/12/18 15:37:38 mpowers Changes to retain ability to work
+ * with objects that don't necessarily implement EOEnterpriseObject. I would
+ * still like to preserve this case for general usage, however the access
+ * package is free to assume that those objects will be EOs and cast
+ * appropriately.
*
- * Revision 1.3 2003/08/29 21:14:44 chochos
- * implement a couple more methods.
+ * Revision 1.3 2003/08/29 21:14:44 chochos implement a couple more methods.
*
- * Revision 1.2 2003/08/20 01:16:22 chochos
- * more methods have code now, but there's no way to test this yet. The core is still pending.
+ * Revision 1.2 2003/08/20 01:16:22 chochos more methods have code now, but
+ * there's no way to test this yet. The core is still pending.
*
- * Revision 1.1 2003/08/19 01:54:43 chochos
- * The EODatabase layer still needs a lot of work, but it's on its way...
+ * Revision 1.1 2003/08/19 01:54:43 chochos The EODatabase layer still needs a
+ * lot of work, but it's on its way...
*
*/ \ No newline at end of file