diff options
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access')
26 files changed, 1077 insertions, 923 deletions
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessArrayFaultHandler.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessArrayFaultHandler.java index 1aafa13..ebb8199 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessArrayFaultHandler.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessArrayFaultHandler.java @@ -21,25 +21,31 @@ import net.wotonomy.control.EOEditingContext; import net.wotonomy.control.EOKeyGlobalID; /** -* A fault handler for to-many relationships. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/public class EOAccessArrayFaultHandler extends EOAccessGenericFaultHandler { + * A fault handler for to-many relationships. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ +public class EOAccessArrayFaultHandler extends EOAccessGenericFaultHandler { protected EOKeyGlobalID _sourceID; protected String _relation; - public EOAccessArrayFaultHandler(EOKeyGlobalID sourceID, String relationName, EODatabaseContext dbc, EOEditingContext ec) { + public EOAccessArrayFaultHandler(EOKeyGlobalID sourceID, String relationName, EODatabaseContext dbc, + EOEditingContext ec) { super(); _sourceID = sourceID; _relation = relationName; setContext(dbc, ec); } - /* (non-Javadoc) - * @see net.wotonomy.control.EOFaultHandler#completeInitializationOfObject(java.lang.Object) + /* + * (non-Javadoc) + * + * @see + * net.wotonomy.control.EOFaultHandler#completeInitializationOfObject(java.lang. + * Object) */ public void completeInitializationOfObject(Object obj) { // TODO Auto-generated method stub @@ -56,16 +62,16 @@ import net.wotonomy.control.EOKeyGlobalID; } /* - * $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 2003/08/19 19:53:20 chochos - * EOAccess fault handlers (still incomplete) + * Revision 1.1 2003/08/19 19:53:20 chochos EOAccess fault handlers (still + * incomplete) * */ diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessFaultHandler.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessFaultHandler.java index d4cabe9..0690295 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessFaultHandler.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessFaultHandler.java @@ -21,13 +21,14 @@ import net.wotonomy.control.EOEditingContext; import net.wotonomy.control.EOKeyGlobalID; /** -* A fault handler for single objects. Usually the destinations of a -* to-one relationship. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/public class EOAccessFaultHandler extends EOAccessGenericFaultHandler { + * A fault handler for single objects. Usually the destinations of a to-one + * relationship. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ +public class EOAccessFaultHandler extends EOAccessGenericFaultHandler { protected EOKeyGlobalID _gid; @@ -37,8 +38,12 @@ import net.wotonomy.control.EOKeyGlobalID; setContext(dbc, ec); } - /* (non-Javadoc) - * @see net.wotonomy.control.EOFaultHandler#completeInitializationOfObject(java.lang.Object) + /* + * (non-Javadoc) + * + * @see + * net.wotonomy.control.EOFaultHandler#completeInitializationOfObject(java.lang. + * Object) */ public void completeInitializationOfObject(Object obj) { // TODO Auto-generated method stub @@ -51,16 +56,16 @@ import net.wotonomy.control.EOKeyGlobalID; } /* - * $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 2003/08/19 19:53:20 chochos - * EOAccess fault handlers (still incomplete) + * Revision 1.1 2003/08/19 19:53:20 chochos EOAccess fault handlers (still + * incomplete) * */ diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessGenericFaultHandler.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessGenericFaultHandler.java index 6876151..31378f4 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessGenericFaultHandler.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessGenericFaultHandler.java @@ -21,12 +21,12 @@ import net.wotonomy.control.EOEditingContext; import net.wotonomy.control.EOFaultHandler; /** -* A generic fault handler for EOAccess. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * A generic fault handler for EOAccess. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public abstract class EOAccessGenericFaultHandler extends EOFaultHandler { protected EODatabaseContext _dbContext; @@ -36,7 +36,9 @@ public abstract class EOAccessGenericFaultHandler extends EOFaultHandler { super(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see net.wotonomy.control.EOFaultHandler#faultWillFire(java.lang.Object) */ public void faultWillFire(Object obj) { @@ -59,17 +61,16 @@ public abstract class EOAccessGenericFaultHandler extends EOFaultHandler { } /* - * $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 2003/08/19 19:53:20 chochos - * EOAccess fault handlers (still incomplete) + * Revision 1.1 2003/08/19 19:53:20 chochos EOAccess fault handlers (still + * incomplete) * */ -
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessLock.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessLock.java index 28199c5..f305579 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessLock.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAccessLock.java @@ -20,8 +20,8 @@ package net.wotonomy.access; import net.wotonomy.foundation.NSRecursiveLock; /** - * This class offers a very simple interface to a global locking - * mechanism to be used by the whole access layer. + * This class offers a very simple interface to a global locking mechanism to be + * used by the whole access layer. * * @author ezamudio@nasoft.com * @author $Author: cgruber $ @@ -45,16 +45,15 @@ public class EOAccessLock { } /* - * $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.1 2003/08/29 20:43:25 chochos - * a global access layer lock + * Revision 1.1 2003/08/29 20:43:25 chochos a global access layer lock * */ diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptor.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptor.java index 28295d1..17d6454 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptor.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptor.java @@ -26,11 +26,11 @@ import net.wotonomy.foundation.NSMutableDictionary; import net.wotonomy.foundation.NSTimestamp; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public abstract class EOAdaptor { @@ -48,6 +48,7 @@ public abstract class EOAdaptor { /** * Creates an adaptor with model's adaptorName and sets its connection * dictionary to the model's connection dictionary. + * * @param model The model to take adaptorName and connectionDictionary from. * @return The adaptor specified in model. */ @@ -64,11 +65,13 @@ public abstract class EOAdaptor { } /** - * Instantiates an adaptor of a concrete EOAdaptor subclass, based on name. - * If name is a fully qualified class name, then it returns an instance of that class - * by invoking the constructor with a string argument. Otherwise, it - * tries to find a class called (name)Adaptor in a package called - * net.wotonomy.(lowercase name)adaptor; if it can't find one, an exception is raised. + * Instantiates an adaptor of a concrete EOAdaptor subclass, based on name. If + * name is a fully qualified class name, then it returns an instance of that + * class by invoking the constructor with a string argument. Otherwise, it tries + * to find a class called (name)Adaptor in a package called + * net.wotonomy.(lowercase name)adaptor; if it can't find one, an exception is + * raised. + * * @param name The name of the adaptor, or a fully qualified class name. * @return */ @@ -78,10 +81,10 @@ public abstract class EOAdaptor { if (name.endsWith("Adaptor") && name.indexOf('.') > 0) { cname = name; int lastdot = name.lastIndexOf('.'); - //take off the package and the 'Adaptor' suffix + // take off the package and the 'Adaptor' suffix name = cname.substring(lastdot, cname.length() - 7); } else { - //construct the fully qualified class name + // construct the fully qualified class name cname = "net.wotonomy." + name.toLowerCase() + "adaptor." + name + "Adaptor"; } try { @@ -92,12 +95,14 @@ public abstract class EOAdaptor { EOAdaptor adaptor = null; java.lang.reflect.Constructor callme = null; try { - callme = adaptorClass.getConstructor(new Class[]{ String.class }); - adaptor = (EOAdaptor)callme.newInstance((Object[])new String[]{ name }); + callme = adaptorClass.getConstructor(new Class[] { String.class }); + adaptor = (EOAdaptor) callme.newInstance((Object[]) new String[] { name }); } catch (ClassCastException ex) { - throw new IllegalArgumentException("Class " + adaptorClass.getName() + " must inherit from net.wotonomy.access.EOAdaptor"); - }catch (Exception ex) { - throw new IllegalArgumentException("Cannot find or invoke constructor with name argument in class " + adaptorClass.getName()); + throw new IllegalArgumentException( + "Class " + adaptorClass.getName() + " must inherit from net.wotonomy.access.EOAdaptor"); + } catch (Exception ex) { + throw new IllegalArgumentException( + "Cannot find or invoke constructor with name argument in class " + adaptorClass.getName()); } return adaptor; } @@ -105,8 +110,9 @@ public abstract class EOAdaptor { public static void setExpressionClassName(String expClassName, String adaptorClassName) { _expressionClassesByName.setObjectForKey(expClassName, adaptorClassName); } + public static String expressionClassName(String adaptorClassName) { - return (String)_expressionClassesByName.objectForKey(adaptorClassName); + return (String) _expressionClassesByName.objectForKey(adaptorClassName); } public void assignExternalInfoForAttribute(EOAttribute attribute) { @@ -126,11 +132,11 @@ public abstract class EOAdaptor { public void assignExternalInfoForEntireModel(EOModel model) { NSArray ents = model.entities(); for (int i = 0; i < ents.count(); i++) { - EOEntity e = (EOEntity)ents.objectAtIndex(i); - //TODO: check that entity is not a prototypes entity + EOEntity e = (EOEntity) ents.objectAtIndex(i); + // TODO: check that entity is not a prototypes entity NSArray atts = e.attributes(); for (int j = 0; j < atts.count(); j++) { - EOAttribute a = (EOAttribute)atts.objectAtIndex(i); + EOAttribute a = (EOAttribute) atts.objectAtIndex(i); assignExternalInfoForAttribute(a); } assignExternalInfoForEntity(e); @@ -149,6 +155,7 @@ public abstract class EOAdaptor { public void setConnectionDictionary(NSDictionary connection) { _connectionDictionary = connection; } + public NSDictionary connectionDictionary() { return _connectionDictionary; } @@ -205,19 +212,19 @@ public abstract class EOAdaptor { if (value == NSKeyValueCoding.NullValue) return value; if (value instanceof String) - return fetchedValueForStringValue((String)value, attr); + return fetchedValueForStringValue((String) value, attr); if (value instanceof NSData) - return fetchedValueForDataValue((NSData)value, attr); + return fetchedValueForDataValue((NSData) value, attr); if (value instanceof Number) - return fetchedValueForNumberValue((Number)value, attr); + return fetchedValueForNumberValue((Number) value, attr); if (value instanceof NSTimestamp) - return fetchedValueForDateValue((NSTimestamp)value, attr); + return fetchedValueForDateValue((NSTimestamp) value, attr); return value; } public void handleDroppedConnection() { for (int i = 0; i < _contexts.count(); i++) { - EOAdaptorContext c = (EOAdaptorContext)_contexts.objectAtIndex(i); + EOAdaptorContext c = (EOAdaptorContext) _contexts.objectAtIndex(i); c.transactionDidRollback(); c.handleDroppedConnection(); } @@ -226,7 +233,7 @@ public abstract class EOAdaptor { public boolean hasOpenChannels() { for (int i = 0; i < _contexts.count(); i++) { - EOAdaptorContext c = (EOAdaptorContext)_contexts.objectAtIndex(i); + EOAdaptorContext c = (EOAdaptorContext) _contexts.objectAtIndex(i); if (c.hasOpenChannels()) return true; } @@ -251,19 +258,19 @@ public abstract class EOAdaptor { } /* - * $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.2 2005/12/08 06:52:32 cgruber - * Move tests, improve build.xml, and make certain casts explicit so that Java 1.5 doesn't complain about varargs. + * Revision 1.2 2005/12/08 06:52:32 cgruber Move tests, improve build.xml, and + * make certain casts explicit so that Java 1.5 doesn't complain about varargs. * - * Revision 1.1 2003/08/13 00:37:45 chochos - * an almost complete implementation of the abstract adaptor-layer classes + * Revision 1.1 2003/08/13 00:37:45 chochos an almost complete implementation of + * the abstract adaptor-layer classes * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorChannel.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorChannel.java index 09b8a6d..44b3401 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorChannel.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorChannel.java @@ -24,11 +24,11 @@ import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableDictionary; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public abstract class EOAdaptorChannel { protected EOAdaptorContext _context; @@ -102,7 +102,7 @@ public abstract class EOAdaptorChannel { public NSMutableDictionary dictionaryWithObjectsForAttributes(Object[] values, NSArray attributes) { Object[] keys = new Object[attributes.count()]; for (int i = 0; i < attributes.count(); i++) - keys[i] = ((EOAttribute)attributes.objectAtIndex(i)).name(); + keys[i] = ((EOAttribute) attributes.objectAtIndex(i)).name(); return new NSMutableDictionary(values, keys); } @@ -150,57 +150,60 @@ public abstract class EOAdaptorChannel { public void performAdaptorOperation(EOAdaptorOperation operation) { int opcode = operation.adaptorOperator(); switch (opcode) { - case EODatabaseOperation.AdaptorLockOperator: - if (operation.entity() == null) - throw new EOGeneralAdaptorException("A lock operation must have an entity assigned to it.", + case EODatabaseOperation.AdaptorLockOperator: + if (operation.entity() == null) + throw new EOGeneralAdaptorException("A lock operation must have an entity assigned to it.", new NSDictionary(operation, "operation")); - if (operation.qualifier() == null) - throw new EOGeneralAdaptorException("A lock operation must have a qualifier assigned to it.", + if (operation.qualifier() == null) + throw new EOGeneralAdaptorException("A lock operation must have a qualifier assigned to it.", new NSDictionary(operation, "operation")); - if (operation.qualifier() == null) - throw new EOGeneralAdaptorException("A lock operation must have changedValues assigned to it.", + if (operation.qualifier() == null) + throw new EOGeneralAdaptorException("A lock operation must have changedValues assigned to it.", new NSDictionary(operation, "operation")); - lockRowComparingAttributes(operation.attributes(), operation.entity(), operation.qualifier(), operation.changedValues()); - break; - case EODatabaseOperation.AdaptorInsertOperator: - if (operation.entity() == null) - throw new EOGeneralAdaptorException("An insert operation must have an entity assigned to it.", + lockRowComparingAttributes(operation.attributes(), operation.entity(), operation.qualifier(), + operation.changedValues()); + break; + case EODatabaseOperation.AdaptorInsertOperator: + if (operation.entity() == null) + throw new EOGeneralAdaptorException("An insert operation must have an entity assigned to it.", new NSDictionary(operation, "operation")); - if (operation.changedValues() == null) - throw new EOGeneralAdaptorException("An insert operation must have changedValues assigned to it.", + if (operation.changedValues() == null) + throw new EOGeneralAdaptorException("An insert operation must have changedValues assigned to it.", new NSDictionary(operation, "operation")); - insertRow(operation.changedValues(), operation.entity()); - break; - case EODatabaseOperation.AdaptorUpdateOperator: - if (operation.entity() == null) - throw new EOGeneralAdaptorException("An update operation must have an entity assigned to it.", + insertRow(operation.changedValues(), operation.entity()); + break; + case EODatabaseOperation.AdaptorUpdateOperator: + if (operation.entity() == null) + throw new EOGeneralAdaptorException("An update operation must have an entity assigned to it.", new NSDictionary(operation, "operation")); - if (operation.changedValues() == null) - throw new EOGeneralAdaptorException("An update operation must have changedValues assigned to it.", + if (operation.changedValues() == null) + throw new EOGeneralAdaptorException("An update operation must have changedValues assigned to it.", new NSDictionary(operation, "operation")); - updateValuesInRowsDescribedByQualifier(operation.changedValues(), operation.qualifier(), operation.entity()); - break; - case EODatabaseOperation.AdaptorDeleteOperator: - if (operation.entity() == null) - throw new EOGeneralAdaptorException("A delete operation must have an entity assigned to it.", + updateValuesInRowsDescribedByQualifier(operation.changedValues(), operation.qualifier(), + operation.entity()); + break; + case EODatabaseOperation.AdaptorDeleteOperator: + if (operation.entity() == null) + throw new EOGeneralAdaptorException("A delete operation must have an entity assigned to it.", new NSDictionary(operation, "operation")); - deleteRowsDescribedByQualifier(operation.qualifier(), operation.entity()); - break; - case EODatabaseOperation.AdaptorStoredProcedureOperator: - if (operation.storedProcedure() == null) - throw new EOGeneralAdaptorException("A stored procedure operation must have a stored procedure assigned to it.", + deleteRowsDescribedByQualifier(operation.qualifier(), operation.entity()); + break; + case EODatabaseOperation.AdaptorStoredProcedureOperator: + if (operation.storedProcedure() == null) + throw new EOGeneralAdaptorException( + "A stored procedure operation must have a stored procedure assigned to it.", new NSDictionary(operation, "operation")); - executeStoredProcedure(operation.storedProcedure(), operation.changedValues()); - break; - default: - throw new EOGeneralAdaptorException("I don't know how to perform an operation with code " + opcode, + executeStoredProcedure(operation.storedProcedure(), operation.changedValues()); + break; + default: + throw new EOGeneralAdaptorException("I don't know how to perform an operation with code " + opcode, new NSDictionary(operation, "operation")); } } public void performAdaptorOperations(NSArray ops) { for (int i = 0; i < ops.count(); i++) { - EOAdaptorOperation adop = (EOAdaptorOperation)ops.objectAtIndex(i); + EOAdaptorOperation adop = (EOAdaptorOperation) ops.objectAtIndex(i); performAdaptorOperation(adop); } } @@ -217,28 +220,29 @@ public abstract class EOAdaptorChannel { int count = updateValuesInRowsDescribedByQualifier(row, q, entity); if (count != 1) { adaptorContext().rollbackTransaction(); - throw new EOGeneralAdaptorException("The qualifier should describe exactly one row (updated " + count + " rows)"); + throw new EOGeneralAdaptorException( + "The qualifier should describe exactly one row (updated " + count + " rows)"); } adaptorContext().commitTransaction(); } } /* - * $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.2 2005/05/11 15:21:53 cgruber - * Change enum to enumeration, since enum is now a keyword as of Java 5.0 + * Revision 1.2 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.1 2003/08/13 00:37:45 chochos - * an almost complete implementation of the abstract adaptor-layer classes + * Revision 1.1 2003/08/13 00:37:45 chochos an almost complete implementation of + * the abstract adaptor-layer classes * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorContext.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorContext.java index aff0ddd..35a1468 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorContext.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorContext.java @@ -22,11 +22,11 @@ import net.wotonomy.foundation.NSMutableArray; import net.wotonomy.foundation.NSNotificationCenter; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public abstract class EOAdaptorContext { @@ -63,7 +63,7 @@ public abstract class EOAdaptorContext { public boolean hasBusyChannels() { for (int i = 0; i < _channels.count(); i++) { - EOAdaptorChannel chan = (EOAdaptorChannel)_channels.objectAtIndex(i); + EOAdaptorChannel chan = (EOAdaptorChannel) _channels.objectAtIndex(i); if (chan.isFetchInProgress()) return true; } @@ -72,7 +72,7 @@ public abstract class EOAdaptorContext { public boolean hasOpenChannels() { for (int i = 0; i < _channels.count(); i++) { - EOAdaptorChannel chan = (EOAdaptorChannel)_channels.objectAtIndex(i); + EOAdaptorChannel chan = (EOAdaptorChannel) _channels.objectAtIndex(i); if (chan.isOpen()) return true; } @@ -85,34 +85,31 @@ public abstract class EOAdaptorContext { public void transactionDidBegin() { _hasOpenTransaction = true; - NSNotificationCenter.defaultCenter().postNotification( - AdaptorContextBeginTransactionNotification, this); + NSNotificationCenter.defaultCenter().postNotification(AdaptorContextBeginTransactionNotification, this); } public void transactionDidCommit() { _hasOpenTransaction = false; - NSNotificationCenter.defaultCenter().postNotification( - AdaptorContextCommitTransactionNotification, this); + NSNotificationCenter.defaultCenter().postNotification(AdaptorContextCommitTransactionNotification, this); } public void transactionDidRollback() { _hasOpenTransaction = false; - NSNotificationCenter.defaultCenter().postNotification( - AdaptorContextRollbackTransactionNotification, this); + NSNotificationCenter.defaultCenter().postNotification(AdaptorContextRollbackTransactionNotification, this); } } /* - * $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 2003/08/13 00:37:45 chochos - * an almost complete implementation of the abstract adaptor-layer classes + * Revision 1.1 2003/08/13 00:37:45 chochos an almost complete implementation of + * the abstract adaptor-layer classes * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorOperation.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorOperation.java index 818985d..6c977b9 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorOperation.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAdaptorOperation.java @@ -22,14 +22,13 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSDictionary; /** -* Represents a single primitive operation in a database server. -* Can be insert, update, delete, lock a row, or execute a -* stored procedure. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * Represents a single primitive operation in a database server. Can be insert, + * update, delete, lock a row, or execute a stored procedure. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOAdaptorOperation { protected EOEntity _entity; @@ -48,6 +47,7 @@ public class EOAdaptorOperation { public void setAdaptorOperator(int adOp) { _adaptorOp = adOp; } + public int adaptorOperator() { return _adaptorOp; } @@ -55,6 +55,7 @@ public class EOAdaptorOperation { public void setAttributes(NSArray atts) { _attributes = atts; } + public NSArray attributes() { return _attributes; } @@ -62,6 +63,7 @@ public class EOAdaptorOperation { public void setChangedValues(NSDictionary values) { _changedValues = values; } + public NSDictionary changedValues() { return _changedValues; } @@ -85,6 +87,7 @@ public class EOAdaptorOperation { public void setException(Throwable t) { _exception = t; } + public Throwable exception() { return _exception; } @@ -92,6 +95,7 @@ public class EOAdaptorOperation { public void setQualifier(EOQualifier q) { _qualifier = q; } + public EOQualifier qualifier() { return _qualifier; } @@ -99,22 +103,23 @@ public class EOAdaptorOperation { public void setStoredProcedure(EOStoredProcedure sp) { _proc = sp; } + public EOStoredProcedure storedProcedure() { return _proc; } } /* - * $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.1 2003/08/13 00:37:45 chochos - * an almost complete implementation of the abstract adaptor-layer classes + * Revision 1.1 2003/08/13 00:37:45 chochos an almost complete implementation of + * the abstract adaptor-layer classes * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAttribute.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAttribute.java index 8b651ec..d77a162 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAttribute.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOAttribute.java @@ -22,18 +22,18 @@ import net.wotonomy.foundation.NSMutableDictionary; import net.wotonomy.foundation.NSSelector; /** -* Represents an attribute inside an entity. Contains mapping data for -* the attribute's external name, external and internal datatypes, etc. -* It can also represent a flattened or derived attribute, or a prototype; -* and they are also used to represent parameters in a stored procedure. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * Represents an attribute inside an entity. Contains mapping data for the + * attribute's external name, external and internal datatypes, etc. It can also + * represent a flattened or derived attribute, or a prototype; and they are also + * used to represent parameters in a stored procedure. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { - //These are used for stored procedure parameters. + // These are used for stored procedure parameters. public static final int Void = 0; public static final int InParameter = 1; public static final int OutParameter = 2; @@ -75,26 +75,26 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public EOAttribute(NSDictionary dict, Object obj) { super(); if (obj instanceof EOEntity) - _entity = (EOEntity)obj; - setName((String)dict.objectForKey("name")); + _entity = (EOEntity) obj; + setName((String) dict.objectForKey("name")); if (dict.objectForKey("columnName") != null) - setColumnName((String)dict.objectForKey("columnName")); + setColumnName((String) dict.objectForKey("columnName")); if (dict.objectForKey("definition") != null) - setDefinition((String)dict.objectForKey("definition")); - _prototypeName = (String)dict.objectForKey("prototypeName"); - setExternalType((String)dict.objectForKey("externalType")); - setClassName((String)dict.objectForKey("valueClassName")); - setValueType((String)dict.objectForKey("valueType")); - _writeFormat = (String)dict.objectForKey("writeFormat"); - _readFormat = (String)dict.objectForKey("readFormat"); + setDefinition((String) dict.objectForKey("definition")); + _prototypeName = (String) dict.objectForKey("prototypeName"); + setExternalType((String) dict.objectForKey("externalType")); + setClassName((String) dict.objectForKey("valueClassName")); + setValueType((String) dict.objectForKey("valueType")); + _writeFormat = (String) dict.objectForKey("writeFormat"); + _readFormat = (String) dict.objectForKey("readFormat"); if (dict.objectForKey("precision") != null) - setPrecision(Integer.parseInt((String)dict.objectForKey("precision"))); + setPrecision(Integer.parseInt((String) dict.objectForKey("precision"))); if (dict.objectForKey("scale") != null) - setScale(Integer.parseInt((String)dict.objectForKey("scale"))); + setScale(Integer.parseInt((String) dict.objectForKey("scale"))); if (dict.objectForKey("width") != null) - setWidth(Integer.parseInt((String)dict.objectForKey("width"))); + setWidth(Integer.parseInt((String) dict.objectForKey("width"))); if (dict.objectForKey("parameterDirection") != null) - setParameterDirection(Integer.parseInt((String)dict.objectForKey("parameterDirection"))); + setParameterDirection(Integer.parseInt((String) dict.objectForKey("parameterDirection"))); setAllowsNull("Y".equals(dict.objectForKey("allowsNull"))); } @@ -105,6 +105,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setName(String name) { _name = name; } + public String name() { return _name; } @@ -112,6 +113,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setColumnName(String name) { _columnName = name; } + public String columnName() { if (_columnName != null) return _columnName; @@ -124,6 +126,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setClassName(String name) { _className = name; } + public String className() { if (_className != null) return _className; @@ -137,6 +140,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { _definition = def; _columnName = null; } + public String definition() { if (_definition != null) return _definition; @@ -149,6 +153,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setExternalType(String type) { _externalType = type; } + public String externalType() { if (_externalType != null) return _externalType; @@ -162,6 +167,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { _allowsNull = flag; _has_allowsNull = true; } + public boolean allowsNull() { if (_has_allowsNull) return _allowsNull; @@ -173,6 +179,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setReadOnly(boolean flag) { _readOnly = flag; } + public boolean readOnly() { return _readOnly; } @@ -184,6 +191,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { else _prototypeName = null; } + public EOAttribute prototype() { if (_prototypeName != null && _prototype == null) { try { @@ -202,6 +210,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setPrecision(int value) { _precision = value; } + public int precision() { if (_precision > 0) return _precision; @@ -213,6 +222,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setScale(int value) { _scale = value; } + public int scale() { if (_scale > 0) return _scale; @@ -224,10 +234,11 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setWidth(int value) { _width = value; } + public int width() { if (_width > 0) return _width; - if (prototype() != null) + if (prototype() != null) return _prototype.width(); return _width; } @@ -236,6 +247,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setValueClassName(String name) { setClassName(name); } + /** @deprecated Use className() instead. */ public String valueClassName() { return className(); @@ -244,6 +256,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setValueType(String type) { _valueType = type; } + public String valueType() { if (_valueType != null) return _valueType; @@ -255,6 +268,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setReadFormat(String value) { _readFormat = value; } + public String readFormat() { return _readFormat; } @@ -262,6 +276,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setWriteFormat(String value) { _writeFormat = value; } + public String writeFormat() { return _writeFormat; } @@ -270,9 +285,11 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { return (definition() != null); } - /** Determines whether the receiver is a flattened attribute. - * A flattened attribute has as its definition a relationship - * path that can be resolved to an attribute. + /** + * Determines whether the receiver is a flattened attribute. A flattened + * attribute has as its definition a relationship path that can be resolved to + * an attribute. + * * @return true if the receiver is flattened. */ public boolean isFlattened() { @@ -292,6 +309,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setParameterDirection(int dir) { _parameterDirection = dir; } + public int parameterDirection() { return _parameterDirection; } @@ -305,6 +323,7 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { public void setUserInfo(NSDictionary value) { _userInfo = value; } + public NSDictionary userInfo() { return _userInfo; } @@ -348,34 +367,31 @@ public class EOAttribute extends EOProperty implements EOPropertyListEncoding { } /* - * $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.7 2003/08/14 02:13:56 chochos - * implement and use _attributeForPath() + * Revision 1.7 2003/08/14 02:13:56 chochos implement and use + * _attributeForPath() * - * Revision 1.6 2003/08/12 01:45:04 chochos - * added some code to handle prototypes + * Revision 1.6 2003/08/12 01:45:04 chochos added some code to handle prototypes * - * Revision 1.5 2003/08/11 19:38:27 chochos - * Can now read from a file and re-write to another file. + * Revision 1.5 2003/08/11 19:38:27 chochos Can now read from a file and + * re-write to another file. * - * Revision 1.4 2003/08/09 01:35:35 chochos - * implement EOPropertyListEncoding + * Revision 1.4 2003/08/09 01:35:35 chochos implement EOPropertyListEncoding * - * Revision 1.3 2003/08/08 06:52:09 chochos - * isFlattened() works + * Revision 1.3 2003/08/08 06:52:09 chochos isFlattened() works * - * Revision 1.2 2003/08/08 02:15:03 chochos - * added parameterDirection (for use with stored procedures) + * Revision 1.2 2003/08/08 02:15:03 chochos added parameterDirection (for use + * with stored procedures) * - * Revision 1.1 2003/08/07 02:39:45 chochos - * EOAttribute. Can be initialized from a property list. + * Revision 1.1 2003/08/07 02:39:45 chochos EOAttribute. Can be initialized from + * a property list. * -*/
\ No newline at end of file + */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabase.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabase.java index a9177c5..a995290 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabase.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabase.java @@ -28,11 +28,11 @@ import net.wotonomy.foundation.NSMutableDictionary; import net.wotonomy.foundation.NSTimestamp; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EODatabase { protected EOAdaptor _adaptor; @@ -98,10 +98,10 @@ public class EODatabase { public EOEntity entityForObject(EOEnterpriseObject eo) { String cname = eo.getClass().getName(); for (int i = 0; i < _models.count(); i++) { - EOModel m = (EOModel)_models.objectAtIndex(i); + EOModel m = (EOModel) _models.objectAtIndex(i); NSArray ents = m.entities(); for (int j = 0; j < ents.count(); j++) { - EOEntity e = (EOEntity)ents.objectAtIndex(i); + EOEntity e = (EOEntity) ents.objectAtIndex(i); if (e.className().equals(cname)) return e; } @@ -111,10 +111,10 @@ public class EODatabase { public EOEntity entityNamed(String name) { for (int i = 0; i < _models.count(); i++) { - EOModel m = (EOModel)_models.objectAtIndex(i); + EOModel m = (EOModel) _models.objectAtIndex(i); NSArray ents = m.entities(); for (int j = 0; j < ents.count(); j++) { - EOEntity e = (EOEntity)ents.objectAtIndex(i); + EOEntity e = (EOEntity) ents.objectAtIndex(i); if (e.name().equals(name)) return e; } @@ -132,13 +132,13 @@ public class EODatabase { public void forgetSnapshotsForGlobalIDs(NSArray gids) { for (int i = 0; i < gids.count(); i++) - forgetSnapshotForGlobalID((EOGlobalID)gids.objectAtIndex(i)); + forgetSnapshotForGlobalID((EOGlobalID) gids.objectAtIndex(i)); } public void handleDroppedConnection() { adaptor().handleDroppedConnection(); for (int i = 0; i < _contexts.count(); i++) { - EODatabaseContext c = (EODatabaseContext)_contexts.objectAtIndex(i); + EODatabaseContext c = (EODatabaseContext) _contexts.objectAtIndex(i); c.handleDroppedConnection(); } } @@ -160,7 +160,7 @@ public class EODatabase { } public void recordSnapshotForSourceGlobalID(NSArray gids, EOGlobalID gid, String name) { - NSMutableDictionary d = (NSMutableDictionary)_snapshots.objectForKey(gid); + NSMutableDictionary d = (NSMutableDictionary) _snapshots.objectForKey(gid); if (d == null) { d = new NSMutableDictionary(); _snapshots.setObjectForKey(d, gid); @@ -175,12 +175,12 @@ public class EODatabase { public void recordToManySnapshots(NSDictionary snaps) { Enumeration enumeration = snaps.keyEnumerator(); while (enumeration.hasMoreElements()) { - EOGlobalID gid = (EOGlobalID)enumeration.nextElement(); - NSDictionary rels = (NSDictionary)snaps.objectForKey(gid); + EOGlobalID gid = (EOGlobalID) enumeration.nextElement(); + NSDictionary rels = (NSDictionary) snaps.objectForKey(gid); Enumeration relEnum = rels.keyEnumerator(); while (relEnum.hasMoreElements()) { - String relName = (String)relEnum.nextElement(); - NSArray gids = (NSArray)rels.objectForKey(relName); + String relName = (String) relEnum.nextElement(); + NSArray gids = (NSArray) rels.objectForKey(relName); recordSnapshotForSourceGlobalID(gids, gid, relName); } } @@ -203,7 +203,7 @@ public class EODatabase { } public NSArray resultCacheForEntityNamed(String name) { - return (NSArray)_resultCache.objectForKey(name); + return (NSArray) _resultCache.objectForKey(name); } public void setResultCache(NSArray cache, String entityName) { @@ -215,7 +215,7 @@ public class EODatabase { } public NSDictionary snapshotForGlobalID(EOGlobalID gid) { - return (NSDictionary)_snapshots.objectForKey(gid); + return (NSDictionary) _snapshots.objectForKey(gid); } public NSDictionary snapshotForGlobalID(EOGlobalID gid, long l) { @@ -223,10 +223,10 @@ public class EODatabase { } public NSArray snapshotForSourceGlobalID(EOGlobalID gid, String name) { - NSDictionary d = (NSDictionary)_snapshots.objectForKey(gid); + NSDictionary d = (NSDictionary) _snapshots.objectForKey(gid); if (d == null) return null; - return (NSArray)d.objectForKey(name); + return (NSArray) d.objectForKey(name); } public NSDictionary snapshotForSourceGlobalID(EOGlobalID gid, String s, long l) { @@ -247,21 +247,21 @@ public class EODatabase { } /* - * $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.2 2005/05/11 15:21:53 cgruber - * Change enum to enumeration, since enum is now a keyword as of Java 5.0 + * Revision 1.2 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.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 diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseChannel.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseChannel.java index 10424e9..72427ef 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseChannel.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseChannel.java @@ -27,11 +27,11 @@ import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableArray; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EODatabaseChannel { protected EODatabaseContext _context; @@ -65,14 +65,15 @@ public class EODatabaseChannel { EOGlobalID gid = _currEntity.globalIDForRow(r); Object eo = _currEC.objectForGlobalID(gid); if (eo == null) { - eo = EOClassDescription.classDescriptionForEntityName(_currEntity.name()).createInstanceWithEditingContext(_currEC, gid); + eo = EOClassDescription.classDescriptionForEntityName(_currEntity.name()) + .createInstanceWithEditingContext(_currEC, gid); if (eo instanceof EOKeyValueCodingAdditions) - ((EOKeyValueCodingAdditions)eo).takeValuesFromDictionary(r); + ((EOKeyValueCodingAdditions) eo).takeValuesFromDictionary(r); else EOKeyValueCodingAdditions.DefaultImplementation.takeValuesFromDictionary(eo, r); } else { if (isRefreshingObjects()) { - //TODO: refresh object (how?) + // TODO: refresh object (how?) } } return eo; @@ -120,19 +121,19 @@ public class EODatabaseChannel { } /* - * $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.2 2003/08/29 21:15:46 chochos - * use EOEntity's globalIDForRow method. + * Revision 1.2 2003/08/29 21:15:46 chochos use EOEntity's globalIDForRow + * method. * - * 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 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 diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseOperation.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseOperation.java index 596180e..d8bd726 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseOperation.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EODatabaseOperation.java @@ -18,11 +18,11 @@ package net.wotonomy.access; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ public class EODatabaseOperation { public static final int AdaptorLockOperator = 0; @@ -38,11 +38,10 @@ public class EODatabaseOperation { } /* - * $Log$ - * Revision 1.1 2006/02/16 13:19:57 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.1 2003/08/13 00:38:47 chochos - * for the moment, this only contains some constants needed by EOAdaptorChannel and EOAdaptorOperation. + * Revision 1.1 2003/08/13 00:38:47 chochos for the moment, this only contains + * some constants needed by EOAdaptorChannel and EOAdaptorOperation. * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntity.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntity.java index 4adc4a1..47a31c0 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntity.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntity.java @@ -42,14 +42,14 @@ import net.wotonomy.foundation.NSMutableDictionary; import net.wotonomy.foundation.NSPropertyListSerialization; /** -* An EOEntity is a mapping between a Java class and a database table or view. -* It indicates which attributes should be fetched from the table/view, what -* attributes are part of the primary key, what class the entity should map to. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * An EOEntity is a mapping between a Java class and a database table or view. + * It indicates which attributes should be fetched from the table/view, what + * attributes are part of the primary key, what class the entity should map to. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOEntity implements EOPropertyListEncoding { protected NSMutableDictionary _attributes = new NSMutableDictionary(); @@ -80,55 +80,55 @@ public class EOEntity implements EOPropertyListEncoding { public EOEntity(NSDictionary dict, Object obj) { super(); - _model = (EOModel)obj; - setName((String)dict.objectForKey("name")); - setExternalName((String)dict.objectForKey("externalName")); - setClassName((String)dict.objectForKey("className")); + _model = (EOModel) obj; + setName((String) dict.objectForKey("name")); + setExternalName((String) dict.objectForKey("externalName")); + setClassName((String) dict.objectForKey("className")); if (dict.objectForKey("internalInfo") != null) - _internalInfo = (NSDictionary)dict.objectForKey("internalInfo"); + _internalInfo = (NSDictionary) dict.objectForKey("internalInfo"); if (dict.objectForKey("userInfo") != null) - _userInfo = (NSDictionary)dict.objectForKey("userInfo"); + _userInfo = (NSDictionary) dict.objectForKey("userInfo"); - //Read the attributes - NSArray atr = (NSArray)dict.objectForKey("attributes"); + // Read the attributes + NSArray atr = (NSArray) dict.objectForKey("attributes"); for (int i = 0; i < atr.count(); i++) { - NSDictionary d = (NSDictionary)atr.objectAtIndex(i); + NSDictionary d = (NSDictionary) atr.objectAtIndex(i); EOAttribute atrib = new EOAttribute(d, this); addAttribute(atrib); } - //Set the primary key - atr = (NSArray)dict.objectForKey("primaryKeyAttributes"); + // Set the primary key + atr = (NSArray) dict.objectForKey("primaryKeyAttributes"); NSMutableArray pka = new NSMutableArray(); for (int i = 0; i < atr.count(); i++) { - EOAttribute a = attributeNamed((String)atr.objectAtIndex(i)); + EOAttribute a = attributeNamed((String) atr.objectAtIndex(i)); pka.addObject(a); } _pkAttributes = new NSArray(pka); _pkAttributeNames = atr; - //attributes used for locking + // attributes used for locking _lockingAttributes.removeAllObjects(); - atr = (NSArray)dict.objectForKey("attributesUsedForLocking"); + atr = (NSArray) dict.objectForKey("attributesUsedForLocking"); for (int i = 0; i < atr.count(); i++) { - String x = (String)atr.objectAtIndex(i); + String x = (String) atr.objectAtIndex(i); EOAttribute a = attributeNamed(x); _lockingAttributes.addObject(a); } - //class properties - atr = (NSArray)dict.objectForKey("classProperties"); + // class properties + atr = (NSArray) dict.objectForKey("classProperties"); if (atr != null) { for (int i = 0; i < atr.count(); i++) if (!_classPropertyNames.containsObject((atr.objectAtIndex(i)))) _classPropertyNames.addObject(atr.objectAtIndex(i)); } - //Read the relationships - atr = (NSArray)dict.objectForKey("relationships"); + // Read the relationships + atr = (NSArray) dict.objectForKey("relationships"); if (atr != null) { for (int i = 0; i < atr.count(); i++) { - NSDictionary d = (NSDictionary)atr.objectAtIndex(i); + NSDictionary d = (NSDictionary) atr.objectAtIndex(i); EORelationship rel = new EORelationship(d, this); addRelationship(rel); } @@ -169,7 +169,7 @@ public class EOEntity implements EOPropertyListEncoding { public EOFetchSpecification fetchSpecificationNamed(String name) { loadFetchSpecifications(); - return (EOFetchSpecification)_fetchSpecs.objectForKey(name); + return (EOFetchSpecification) _fetchSpecs.objectForKey(name); } public NSArray fetchSpecificationNames() { @@ -177,8 +177,8 @@ public class EOEntity implements EOPropertyListEncoding { return _fetchSpecs.allKeys(); } - /** Loads fetch specifications from the .fspec file, - * if one exists. + /** + * Loads fetch specifications from the .fspec file, if one exists. */ private void loadFetchSpecifications() { if (_loadedFetchSpecs) @@ -187,7 +187,7 @@ public class EOEntity implements EOPropertyListEncoding { if (model().path() == null) return; File f = new File(model().path()); - //Read the fetch specification file, if it exists + // Read the fetch specification file, if it exists f = new File(f, name() + ".fspec"); if (!f.exists()) return; @@ -207,11 +207,11 @@ public class EOEntity implements EOPropertyListEncoding { throw new IllegalArgumentException("Cannot read dictionary from " + f); NSArray keys = fdict.allKeys(); - //Unarchive the fetch specification + // Unarchive the fetch specification EOKeyValueUnarchiver unarch = new EOKeyValueUnarchiver(fdict); for (int i = 0; i < keys.count(); i++) { - String k = (String)keys.objectAtIndex(i); - EOFetchSpecification fs = (EOFetchSpecification)unarch.decodeObjectForKey(k); + String k = (String) keys.objectAtIndex(i); + EOFetchSpecification fs = (EOFetchSpecification) unarch.decodeObjectForKey(k); if (fs != null) _fetchSpecs.setObjectForKey(fs, k); } @@ -222,7 +222,7 @@ public class EOEntity implements EOPropertyListEncoding { } public EOAttribute attributeNamed(String name) { - return (EOAttribute)_attributes.objectForKey(name); + return (EOAttribute) _attributes.objectForKey(name); } public NSArray flattenedAttributes() { @@ -232,6 +232,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setClassName(String name) { _className = name; } + public String className() { return _className; } @@ -239,6 +240,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setName(String name) { _name = name; } + public String name() { return _name; } @@ -246,6 +248,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setExternalName(String name) { _externalName = name; } + public String externalName() { return _externalName; } @@ -274,7 +277,9 @@ public class EOEntity implements EOPropertyListEncoding { _classPropertyOneRelationships.removeObject(rel); } - /** Returns the relationships from this entity to other entities. + /** + * Returns the relationships from this entity to other entities. + * * @return An array of the relationships of this entity. */ public NSArray relationships() { @@ -282,8 +287,9 @@ public class EOEntity implements EOPropertyListEncoding { } public EORelationship relationshipNamed(String name) { - return (EORelationship)_relations.objectForKey(name); + return (EORelationship) _relations.objectForKey(name); } + public EOModel model() { return _model; } @@ -291,6 +297,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setPrimaryKeyAtributes(NSArray pk) { _pkAttributes = pk; } + public NSArray primaryKeyAttributes() { return _pkAttributes; } @@ -299,7 +306,7 @@ public class EOEntity implements EOPropertyListEncoding { if (_pkAttributeNames.count() != _pkAttributes.count()) { NSMutableArray arr = new NSMutableArray(); for (int i = 0; i < _pkAttributes.count(); i++) { - EOAttribute a = (EOAttribute)_pkAttributes.objectAtIndex(i); + EOAttribute a = (EOAttribute) _pkAttributes.objectAtIndex(i); arr.addObject(a.name()); } _pkAttributeNames = new NSArray(arr); @@ -319,6 +326,7 @@ public class EOEntity implements EOPropertyListEncoding { _lockingAttributes.removeAllObjects(); _lockingAttributes.addObjectsFromArray(value); } + public NSArray attributesUsedForLocking() { return new NSArray(_lockingAttributes); } @@ -331,18 +339,19 @@ public class EOEntity implements EOPropertyListEncoding { _classPropertyOneRelationships.removeAllObjects(); _classPropertyManyRelationships.removeAllObjects(); for (int i = 0; i < value.count(); i++) { - EOProperty o = (EOProperty)value.objectAtIndex(i); + EOProperty o = (EOProperty) value.objectAtIndex(i); _classPropertyNames.addObject(o.name()); if (o instanceof EOAttribute) { _classPropertyAttributes.addObject(o); } else if (o instanceof EORelationship) { - if (((EORelationship)o).isToMany()) + if (((EORelationship) o).isToMany()) _classPropertyManyRelationships.addObject(o); else _classPropertyOneRelationships.addObject(o); } } } + public NSArray classProperties() { if (_classProperties == null) { if (_classPropertyNames == null) @@ -353,7 +362,7 @@ public class EOEntity implements EOPropertyListEncoding { NSMutableArray ones = new NSMutableArray(); NSMutableArray manies = new NSMutableArray(); for (int i = 0; i < _classPropertyNames.count(); i++) { - String name = (String)_classPropertyNames.objectAtIndex(i); + String name = (String) _classPropertyNames.objectAtIndex(i); EOAttribute a = attributeNamed(name); EORelationship r = relationshipNamed(name); if (a != null) { @@ -385,8 +394,8 @@ public class EOEntity implements EOPropertyListEncoding { if (_classPropertyAttributes == null) return NSArray.EmptyArray; NSMutableArray arr = new NSMutableArray(_classPropertyAttributes.count()); - for (int i = 0 ; i < _classPropertyAttributes.count(); i++) { - EOAttribute a = (EOAttribute)_classPropertyAttributes.objectAtIndex(i); + for (int i = 0; i < _classPropertyAttributes.count(); i++) { + EOAttribute a = (EOAttribute) _classPropertyAttributes.objectAtIndex(i); arr.addObject(a.name()); } return arr; @@ -396,8 +405,8 @@ public class EOEntity implements EOPropertyListEncoding { if (_classPropertyManyRelationships == null) return NSArray.EmptyArray; NSMutableArray arr = new NSMutableArray(_classPropertyManyRelationships.count()); - for (int i = 0 ; i < _classPropertyManyRelationships.count(); i++) { - EOAttribute a = (EOAttribute)_classPropertyManyRelationships.objectAtIndex(i); + for (int i = 0; i < _classPropertyManyRelationships.count(); i++) { + EOAttribute a = (EOAttribute) _classPropertyManyRelationships.objectAtIndex(i); arr.addObject(a.name()); } return arr; @@ -407,8 +416,8 @@ public class EOEntity implements EOPropertyListEncoding { if (_classPropertyOneRelationships == null) return NSArray.EmptyArray; NSMutableArray arr = new NSMutableArray(_classPropertyOneRelationships.count()); - for (int i = 0 ; i < _classPropertyOneRelationships.count(); i++) { - EOAttribute a = (EOAttribute)_classPropertyOneRelationships.objectAtIndex(i); + for (int i = 0; i < _classPropertyOneRelationships.count(); i++) { + EOAttribute a = (EOAttribute) _classPropertyOneRelationships.objectAtIndex(i); arr.addObject(a.name()); } return arr; @@ -417,6 +426,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setIsAbstractEntity(boolean flag) { _isAbstract = flag; } + public boolean isAbstractEntity() { return _isAbstract; } @@ -424,12 +434,14 @@ public class EOEntity implements EOPropertyListEncoding { public void setReadOnly(boolean flag) { _isReadOnly = flag; } + public boolean isReadOnly() { return _isReadOnly; } public void setStoredProcedure(EOStoredProcedure proc, String operation) { } + public EOStoredProcedure storedProcedureForOperation(String operation) { return null; } @@ -462,8 +474,9 @@ public class EOEntity implements EOPropertyListEncoding { } /** - * Creates a global ID for a row. The row must have values - * for all the primary key attributes. + * Creates a global ID for a row. The row must have values for all the primary + * key attributes. + * * @param row A raw row for this entity. * @return A key global ID to identify this row. */ @@ -471,7 +484,7 @@ public class EOEntity implements EOPropertyListEncoding { NSArray pknames = primaryKeyAttributeNames(); EOKeyGlobalID gid = null; if (pknames.count() == 1 && row.get(pknames.objectAtIndex(0)) instanceof Number) { - Number n = (Number)row.get(pknames.objectAtIndex(0)); + Number n = (Number) row.get(pknames.objectAtIndex(0)); gid = new EOIntegralKeyGlobalID(name(), n); } else { Object[] vals = new Object[pknames.count()]; @@ -485,15 +498,15 @@ public class EOEntity implements EOPropertyListEncoding { } /** - * Returns a dictionary with the primary key values contained in - * the global id. + * Returns a dictionary with the primary key values contained in the global id. + * * @param gid A Key global ID. * @return A dictionary with the primary key values for gid. */ public NSDictionary primaryKeyForGlobalID(EOGlobalID gid) { if (!(gid instanceof EOKeyGlobalID)) return null; - Object[] vals = ((EOKeyGlobalID)gid).keyValues(); + Object[] vals = ((EOKeyGlobalID) gid).keyValues(); NSArray pknames = primaryKeyAttributeNames(); return new NSDictionary(vals, pknames.toArray()); } @@ -503,14 +516,14 @@ public class EOEntity implements EOPropertyListEncoding { EOQualifier q = null; NSMutableArray subq = new NSMutableArray(pknames.count()); for (int i = 0; i < pknames.count(); i++) { - String key = (String)pknames.objectAtIndex(i); + String key = (String) pknames.objectAtIndex(i); Object v = pkey.get(key); if (v == null || v == NSKeyValueCoding.NullValue) throw new IllegalArgumentException("Primary key with null values."); subq.addObject(new EOKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, v)); } if (subq.count() == 1) - q = (EOQualifier)subq.objectAtIndex(0); + q = (EOQualifier) subq.objectAtIndex(0); else q = new EOAndQualifier(subq); return q; @@ -519,6 +532,7 @@ public class EOEntity implements EOPropertyListEncoding { public void setUserInfo(NSDictionary value) { _userInfo = value; } + public NSDictionary userInfo() { return _userInfo; } @@ -531,20 +545,20 @@ public class EOEntity implements EOPropertyListEncoding { dict.setObjectForKey(externalName(), "externalName"); dict.setObjectForKey(className(), "className"); - //Encode attributes + // Encode attributes NSMutableArray arr = new NSMutableArray(_attributes.allValues()); for (int i = 0; i < _attributes.count(); i++) { - EOAttribute a = (EOAttribute)arr.objectAtIndex(i); + EOAttribute a = (EOAttribute) arr.objectAtIndex(i); NSMutableDictionary d = new NSMutableDictionary(); a.encodeIntoPropertyList(d); arr.replaceObjectAtIndex(i, d); } dict.setObjectForKey(arr, "attributes"); - //Encode relationships + // Encode relationships if (_relations.count() > 0) { arr = new NSMutableArray(_relations.allValues()); for (int i = 0; i < _relations.count(); i++) { - EORelationship r = (EORelationship)arr.objectAtIndex(i); + EORelationship r = (EORelationship) arr.objectAtIndex(i); NSMutableDictionary d = new NSMutableDictionary(); r.encodeIntoPropertyList(d); arr.replaceObjectAtIndex(i, d); @@ -552,29 +566,29 @@ public class EOEntity implements EOPropertyListEncoding { dict.setObjectForKey(arr, "relationships"); } - //Fetch specifications + // Fetch specifications NSMutableDictionary d = new NSMutableDictionary(); loadFetchSpecifications(); java.util.Enumeration enumeration = _fetchSpecs.keyEnumerator(); while (enumeration.hasMoreElements()) { - String k = (String)enumeration.nextElement(); - EOFetchSpecification f = (EOFetchSpecification)_fetchSpecs.objectForKey(k); + String k = (String) enumeration.nextElement(); + EOFetchSpecification f = (EOFetchSpecification) _fetchSpecs.objectForKey(k); EOKeyValueArchiver arch = new EOKeyValueArchiver(); f.encodeWithKeyValueArchiver(arch); d.setObjectForKey(arch.dictionary(), k); } dict.setObjectForKey(d, "fetchSpecificationDictionary"); - //Other information + // Other information dict.setObjectForKey(_classPropertyNames, "classProperties"); dict.setObjectForKey(_pkAttributeNames, "primaryKeyAttributes"); arr = new NSMutableArray(_lockingAttributes); for (int i = 0; i < arr.count(); i++) - arr.replaceObjectAtIndex(i, ((EOAttribute)arr.objectAtIndex(i)).name()); + arr.replaceObjectAtIndex(i, ((EOAttribute) arr.objectAtIndex(i)).name()); dict.setObjectForKey(arr, "attributesUsedForLocking"); - if (_userInfo != null && _userInfo.count() > 0 ) + if (_userInfo != null && _userInfo.count() > 0) dict.setObjectForKey(_userInfo, "userInfo"); - if (_internalInfo != null && _internalInfo.count() > 0 ) + if (_internalInfo != null && _internalInfo.count() > 0) dict.setObjectForKey(_internalInfo, "internalInfo"); } @@ -584,54 +598,54 @@ public class EOEntity implements EOPropertyListEncoding { return null; EORelationship r = null; EOEntity e = this; - for (int i = 0; i < comps.count()-1; i++) { - String name = (String)comps.objectAtIndex(i); + for (int i = 0; i < comps.count() - 1; i++) { + String name = (String) comps.objectAtIndex(i); r = e.relationshipNamed(name); if (r == null) return null; e = r.destinationEntity(); } - return e.attributeNamed((String)comps.lastObject()); + return e.attributeNamed((String) comps.lastObject()); } } /* - * $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.9 2005/05/11 15:21:53 cgruber - * Change enum to enumeration, since enum is now a keyword as of Java 5.0 + * Revision 1.9 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.8 2003/08/19 19:47:58 chochos - * added some methods to handle EOGlobalIDs and primary keys. + * Revision 1.8 2003/08/19 19:47:58 chochos added some methods to handle + * EOGlobalIDs and primary keys. * - * Revision 1.7 2003/08/14 02:13:56 chochos - * implement and use _attributeForPath() + * Revision 1.7 2003/08/14 02:13:56 chochos implement and use + * _attributeForPath() * - * Revision 1.6 2003/08/11 19:38:27 chochos - * Can now read from a file and re-write to another file. + * Revision 1.6 2003/08/11 19:38:27 chochos Can now read from a file and + * re-write to another file. * - * Revision 1.5 2003/08/11 18:19:33 chochos - * encoding into property list seems to work fine now. + * Revision 1.5 2003/08/11 18:19:33 chochos encoding into property list seems to + * work fine now. * - * Revision 1.4 2003/08/09 01:39:04 chochos - * better handling of class properties; use EOKeyValueArchiving to encode/decode fetch specifications; implement EOPropertyListEncoding + * Revision 1.4 2003/08/09 01:39:04 chochos better handling of class properties; + * use EOKeyValueArchiving to encode/decode fetch specifications; implement + * EOPropertyListEncoding * - * Revision 1.3 2003/08/08 05:52:21 chochos - * gets the class description for the entity. + * Revision 1.3 2003/08/08 05:52:21 chochos gets the class description for the + * entity. * - * Revision 1.2 2003/08/08 02:14:20 chochos - * now it can read stored procedures. + * Revision 1.2 2003/08/08 02:14:20 chochos now it can read stored procedures. * - * Revision 1.1 2003/08/07 02:38:33 chochos - * implementation of EOEntity. What works for now is reading an entity from file. + * Revision 1.1 2003/08/07 02:38:33 chochos implementation of EOEntity. What + * works for now is reading an entity from file. * */ diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntityClassDescription.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntityClassDescription.java index a235c99..0485497 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntityClassDescription.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOEntityClassDescription.java @@ -26,10 +26,10 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSMutableArray; /** -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOEntityClassDescription extends EOClassDescription { protected EOEntity _entity; @@ -47,7 +47,7 @@ public class EOEntityClassDescription extends EOClassDescription { NSArray arr = entity().attributes(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EOAttribute atrib = (EOAttribute)arr.objectAtIndex(i); + EOAttribute atrib = (EOAttribute) arr.objectAtIndex(i); a.addObject(atrib); } return a; @@ -61,7 +61,7 @@ public class EOEntityClassDescription extends EOClassDescription { NSArray arr = entity().relationships(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EORelationship r = (EORelationship)arr.objectAtIndex(i); + EORelationship r = (EORelationship) arr.objectAtIndex(i); if (r.isToMany()) a.addObject(r); } @@ -72,21 +72,21 @@ public class EOEntityClassDescription extends EOClassDescription { NSArray arr = entity().relationships(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EORelationship r = (EORelationship)arr.objectAtIndex(i); + EORelationship r = (EORelationship) arr.objectAtIndex(i); if (!r.isToMany()) a.addObject(r); } return a; } - /** Returns all attributes that correspond to columns - * in a database table. + /** + * Returns all attributes that correspond to columns in a database table. */ public NSArray attributeKeys() { NSArray arr = entity().attributes(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EOAttribute atrib = (EOAttribute)arr.objectAtIndex(i); + EOAttribute atrib = (EOAttribute) arr.objectAtIndex(i); if (!atrib.isDerived()) a.addObject(atrib); } @@ -128,7 +128,7 @@ public class EOEntityClassDescription extends EOClassDescription { NSArray arr = entity().relationships(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EORelationship r = (EORelationship)arr.objectAtIndex(i); + EORelationship r = (EORelationship) arr.objectAtIndex(i); if (r.isToMany() && !r.isFlattened()) a.addObject(r); } @@ -139,7 +139,7 @@ public class EOEntityClassDescription extends EOClassDescription { NSArray arr = entity().relationships(); NSMutableArray a = new NSMutableArray(arr.count()); for (int i = 0; i < arr.count(); i++) { - EORelationship r = (EORelationship)arr.objectAtIndex(i); + EORelationship r = (EORelationship) arr.objectAtIndex(i); if (!r.isToMany() && !r.isFlattened()) a.addObject(r); } @@ -147,7 +147,7 @@ public class EOEntityClassDescription extends EOClassDescription { } public Object createInstanceWithEditingContext(EOEditingContext ec, EOGlobalID gid) { - if (theClass == null) { + if (theClass == null) { try { theClass = Class.forName(entity().className()); } catch (ClassNotFoundException ex) { @@ -161,25 +161,26 @@ public class EOEntityClassDescription extends EOClassDescription { } /* - * $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.4 2003/08/19 01:55:54 chochos - * the behavior is now more consistent with its Apple counterpart. + * Revision 1.4 2003/08/19 01:55:54 chochos the behavior is now more consistent + * with its Apple counterpart. * - * Revision 1.3 2003/08/09 01:40:31 chochos - * use EOClassDescription's methods to get a destination entity's class description. + * Revision 1.3 2003/08/09 01:40:31 chochos use EOClassDescription's methods to + * get a destination entity's class description. * - * Revision 1.2 2003/08/08 05:51:59 chochos - * createInstanceWithEditingContext now works. It sets theClass with the class from the entity className() before calling super. + * Revision 1.2 2003/08/08 05:51:59 chochos createInstanceWithEditingContext now + * works. It sets theClass with the class from the entity className() before + * calling super. * - * Revision 1.1 2003/08/08 00:36:19 chochos - * concrete implementation of EOClassDescription that uses an EOEntity + * Revision 1.1 2003/08/08 00:36:19 chochos concrete implementation of + * EOClassDescription that uses an EOEntity * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOGeneralAdaptorException.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOGeneralAdaptorException.java index 6c48a3f..435d6a1 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOGeneralAdaptorException.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOGeneralAdaptorException.java @@ -20,12 +20,12 @@ package net.wotonomy.access; import net.wotonomy.foundation.NSDictionary; /** -* Generic exception thrown by wotonomy.access. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ + * Generic exception thrown by wotonomy.access. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ public class EOGeneralAdaptorException extends RuntimeException implements java.io.Serializable { private NSDictionary _userInfo; @@ -41,9 +41,8 @@ public class EOGeneralAdaptorException extends RuntimeException implements java. public EOGeneralAdaptorException(String selectorName, String className, String msg) { super(msg); - _userInfo = new NSDictionary( - new Object[]{ selectorName, className }, - new Object[]{ "selectorName", "className" }); + _userInfo = new NSDictionary(new Object[] { selectorName, className }, + new Object[] { "selectorName", "className" }); } public NSDictionary userInfo() { @@ -52,11 +51,9 @@ public class EOGeneralAdaptorException extends RuntimeException implements java. } /* - * $Log$ - * Revision 1.1 2006/02/16 13:19:57 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.1 2003/08/13 00:41:50 chochos - * general adaptor exception + * Revision 1.1 2003/08/13 00:41:50 chochos general adaptor exception * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOJoin.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOJoin.java index 693a7d0..01326ac 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOJoin.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOJoin.java @@ -18,13 +18,13 @@ package net.wotonomy.access; /** -* An EOJoin represents a connection between two attributes in -* different entities. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ + * An EOJoin represents a connection between two attributes in different + * entities. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ public class EOJoin { protected EOAttribute _source; @@ -45,12 +45,10 @@ public class EOJoin { } /* - * $Log$ - * Revision 1.1 2006/02/16 13:19:57 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.1 2003/08/07 02:41:04 chochos - * these don't do much for now. + * Revision 1.1 2003/08/07 02:41:04 chochos these don't do much for now. * */ } diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModel.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModel.java index 46fc8d0..9c77d45 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModel.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModel.java @@ -31,18 +31,18 @@ import net.wotonomy.foundation.NSMutableDictionary; import net.wotonomy.foundation.NSPropertyListSerialization; /** -* An EOModel is a set of entities and stored procedures, along with a connection -* dictionary to connect to a database. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * An EOModel is a set of entities and stored procedures, along with a + * connection dictionary to connect to a database. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOModel { protected static final String IDX_NAME = "index.eomodeld"; - //This array contains dictionaries with "className" and "name" + // This array contains dictionaries with "className" and "name" protected NSMutableArray _entities = new NSMutableArray(); protected NSMutableDictionary _entitiesByName = new NSMutableDictionary(); protected NSMutableDictionary _entitiesByClass = new NSMutableDictionary(); @@ -86,24 +86,25 @@ public class EOModel { throw new IllegalArgumentException("Cannot read index.eomodeld"); } NSDictionary d = NSPropertyListSerialization.dictionaryForString(x); - String version = (String)d.objectForKey("EOModelVersion"); + String version = (String) d.objectForKey("EOModelVersion"); if (version == null || !version.startsWith("2.")) throw new IllegalArgumentException("Invalid eomodel version: " + version); - setAdaptorName((String)d.objectForKey("adaptorName")); - setConnectionDictionary((NSDictionary)d.objectForKey("connectionDictionary")); - _entities = ((NSArray)d.objectForKey("entities")).mutableClone(); + setAdaptorName((String) d.objectForKey("adaptorName")); + setConnectionDictionary((NSDictionary) d.objectForKey("connectionDictionary")); + _entities = ((NSArray) d.objectForKey("entities")).mutableClone(); if (d.objectForKey("storedProcedures") != null) - _storedProcedureNames.addObjectsFromArray((NSArray)d.objectForKey("storedProcedures")); + _storedProcedureNames.addObjectsFromArray((NSArray) d.objectForKey("storedProcedures")); if (d.objectForKey("internalInfo") != null) - _internalInfo = (NSDictionary)d.objectForKey("internalInfo"); + _internalInfo = (NSDictionary) d.objectForKey("internalInfo"); if (d.objectForKey("userInfo") != null) - _userInfo = (NSDictionary)d.objectForKey("userInfo"); + _userInfo = (NSDictionary) d.objectForKey("userInfo"); entityNamed("EOPrototypes"); } public void setConnectionDictionary(NSDictionary dict) { _connectionDictionary = dict; } + public NSDictionary connectionDictionary() { return _connectionDictionary; } @@ -130,10 +131,10 @@ public class EOModel { } public EOStoredProcedure storedProcedureNamed(String name) { - EOStoredProcedure proc = (EOStoredProcedure)_storedProcedures.objectForKey(name); - //if we can't find it, check if we should load it + EOStoredProcedure proc = (EOStoredProcedure) _storedProcedures.objectForKey(name); + // if we can't find it, check if we should load it if (proc == null && _path != null && _storedProcedureNames.containsObject(name)) { - //try to read it from file + // try to read it from file File f = new File(new File(_path), name + ".storedProcedure"); if (!f.exists()) return null; @@ -149,9 +150,10 @@ public class EOModel { } NSDictionary plist = NSPropertyListSerialization.dictionaryForString(sdict); if (plist == null) - throw new IllegalArgumentException("File " + f + " does not contain a valid stored procedure property list."); + throw new IllegalArgumentException( + "File " + f + " does not contain a valid stored procedure property list."); proc = new EOStoredProcedure(plist, this); - //add it to our collection + // add it to our collection _storedProcedures.setObjectForKey(proc, proc.name()); } return proc; @@ -159,8 +161,8 @@ public class EOModel { public NSArray storedProcedures() { if (_storedProcedures.count() < _storedProcedureNames.count()) { - for (int i=0; i<_storedProcedureNames.count(); i++) - storedProcedureNamed((String)_storedProcedureNames.objectAtIndex(i)); + for (int i = 0; i < _storedProcedureNames.count(); i++) + storedProcedureNamed((String) _storedProcedureNames.objectAtIndex(i)); } return _storedProcedures.allValues(); } @@ -172,6 +174,7 @@ public class EOModel { public void setAdaptorName(String value) { _adaptorName = value; } + public String adaptorName() { return _adaptorName; } @@ -181,8 +184,8 @@ public class EOModel { return _entitiesByName.allValues(); NSMutableArray es = new NSMutableArray(); for (int i = 0; i < _entities.count(); i++) { - NSDictionary d = (NSDictionary)_entities.objectAtIndex(i); - es.addObject(entityNamed((String)d.objectForKey("name"))); + NSDictionary d = (NSDictionary) _entities.objectAtIndex(i); + es.addObject(entityNamed((String) d.objectForKey("name"))); } return es; } @@ -192,18 +195,18 @@ public class EOModel { return _entitiesByName.allKeys(); NSMutableArray names = new NSMutableArray(); for (int i = 0; i < _entities.count(); i++) { - NSDictionary d = (NSDictionary)_entities.objectAtIndex(i); + NSDictionary d = (NSDictionary) _entities.objectAtIndex(i); names.addObject(d.objectForKey("name")); } return names; } public EOEntity entityNamed(String name) { - EOEntity e = (EOEntity)_entitiesByName.objectForKey(name); + EOEntity e = (EOEntity) _entitiesByName.objectForKey(name); if (e == null && path() != null) { boolean exists = false; for (int i = 0; i < _entities.count(); i++) { - NSDictionary d = (NSDictionary)_entities.objectAtIndex(i); + NSDictionary d = (NSDictionary) _entities.objectAtIndex(i); if (d.objectForKey("name").equals(name)) exists = true; } @@ -242,6 +245,7 @@ public class EOModel { public void setModelGroup(EOModelGroup group) { _group = group; } + public EOModelGroup modelGroup() { return _group; } @@ -266,7 +270,8 @@ public class EOModel { File[] kids = f.listFiles(); for (int i = 0; i < kids.length; i++) { String fname = kids[i].getName(); - if (kids[i].isFile() && (fname.endsWith(".plist") || fname.endsWith(".eomodeld") || fname.endsWith(".fspec") || fname.endsWith(".storedProcedure"))) + if (kids[i].isFile() && (fname.endsWith(".plist") || fname.endsWith(".eomodeld") + || fname.endsWith(".fspec") || fname.endsWith(".storedProcedure"))) kids[i].delete(); } } else @@ -275,7 +280,7 @@ public class EOModel { f.mkdirs(); File kid = new File(f, "index.eomodeld"); - //encode the index file + // encode the index file NSMutableDictionary d = new NSMutableDictionary(); d.setObjectForKey(_adaptorName, "adaptorName"); d.setObjectForKey("2.1", "EOModelVersion"); @@ -287,23 +292,24 @@ public class EOModel { if (_storedProcedureNames.count() > 0) d.setObjectForKey(_storedProcedureNames, "storedProcedures"); - //encode the entity list + // encode the entity list entities(); storedProcedures(); NSMutableArray arr = new NSMutableArray(_entitiesByName.count()); Enumeration enumeration = _entitiesByName.keyEnumerator(); NSMutableDictionary md = new NSMutableDictionary(); while (enumeration.hasMoreElements()) { - String key = (String)enumeration.nextElement(); - EOEntity ent = (EOEntity)_entitiesByName.objectForKey(key); + String key = (String) enumeration.nextElement(); + EOEntity ent = (EOEntity) _entitiesByName.objectForKey(key); md.removeAllObjects(); ent.encodeIntoPropertyList(md); File plist; - NSDictionary fetchSpecs = (NSDictionary)md.objectForKey("fetchSpecificationDictionary"); + NSDictionary fetchSpecs = (NSDictionary) md.objectForKey("fetchSpecificationDictionary"); if (fetchSpecs != null) { if (fetchSpecs.count() > 0) { plist = new File(f, key + ".fspec"); - String ps = NSPropertyListSerialization.stringForPropertyList(md.objectForKey("fetchSpecificationDictionary")); + String ps = NSPropertyListSerialization + .stringForPropertyList(md.objectForKey("fetchSpecificationDictionary")); try { PrintStream stream = new PrintStream(new FileOutputStream(plist)); stream.println(ps); @@ -321,14 +327,13 @@ public class EOModel { stream.close(); } catch (IOException ex) { } - //add to the entity list for the index - arr.addObject(new NSDictionary( - new Object[]{ ent.name(), ent.className() }, - new Object[]{ "name", "className" })); + // add to the entity list for the index + arr.addObject(new NSDictionary(new Object[] { ent.name(), ent.className() }, + new Object[] { "name", "className" })); } d.setObjectForKey(arr, "entities"); - //write the index file + // write the index file String s = NSPropertyListSerialization.stringForPropertyList(d); try { PrintStream stream = new PrintStream(new FileOutputStream(kid)); @@ -338,9 +343,10 @@ public class EOModel { throw new RuntimeException("Cannot write index.eomodeld"); } - //write the stored procedures + // write the stored procedures for (int i = 0; i < _storedProcedureNames.count(); i++) { - EOStoredProcedure proc = (EOStoredProcedure)_storedProcedures.objectForKey(_storedProcedureNames.objectAtIndex(i)); + EOStoredProcedure proc = (EOStoredProcedure) _storedProcedures + .objectForKey(_storedProcedureNames.objectAtIndex(i)); kid = new File(f, proc.name() + ".storedProcedure"); d.removeAllObjects(); proc.encodeIntoPropertyList(d); @@ -358,39 +364,36 @@ public class EOModel { } /* - * $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.8 2005/05/11 15:21:53 cgruber - * Change enum to enumeration, since enum is now a keyword as of Java 5.0 + * Revision 1.8 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.7 2003/08/13 20:46:12 chochos - * entityNamed() only throws if the searched entity is in the entities array and not in a file. + * Revision 1.7 2003/08/13 20:46:12 chochos entityNamed() only throws if the + * searched entity is in the entities array and not in a file. * - * Revision 1.6 2003/08/12 01:45:04 chochos - * added some code to handle prototypes + * Revision 1.6 2003/08/12 01:45:04 chochos added some code to handle prototypes * - * Revision 1.5 2003/08/11 19:38:27 chochos - * Can now read from a file and re-write to another file. + * Revision 1.5 2003/08/11 19:38:27 chochos Can now read from a file and + * re-write to another file. * - * Revision 1.4 2003/08/11 18:20:08 chochos - * saving to a file seems to work now. + * Revision 1.4 2003/08/11 18:20:08 chochos saving to a file seems to work now. * - * Revision 1.3 2003/08/08 02:16:55 chochos - * can now read stored procedures from file. + * Revision 1.3 2003/08/08 02:16:55 chochos can now read stored procedures from + * file. * - * Revision 1.2 2003/08/08 00:37:00 chochos - * add stored procedure functionality + * Revision 1.2 2003/08/08 00:37:00 chochos add stored procedure functionality * - * Revision 1.1 2003/08/07 02:42:28 chochos - * EOModel can read an .eomodeld file. EOModelGroup doesn't do much for now. + * Revision 1.1 2003/08/07 02:42:28 chochos EOModel can read an .eomodeld file. + * EOModelGroup doesn't do much for now. * -*/
\ No newline at end of file + */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java index dbab09d..70c1088 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java @@ -24,14 +24,14 @@ import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableDictionary; /** -* A group of models that connect to the same database. Entities in -* these models can have relationships that point to other entities -* in any model of the same group. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * A group of models that connect to the same database. Entities in these models + * can have relationships that point to other entities in any model of the same + * group. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOModelGroup { private static EOModelGroup _defaultGroup; @@ -46,14 +46,14 @@ public class EOModelGroup { if (model.name() == null) throw new IllegalArgumentException("Cannot add an unnamed model to a group."); if (_models.objectForKey(model.name()) != null) - throw new IllegalArgumentException("Cannot add model " + model.name() + - " to group because it already contains a model with the same name."); + throw new IllegalArgumentException("Cannot add model " + model.name() + + " to group because it already contains a model with the same name."); NSArray ents = model.entityNames(); for (int i = 0; i < ents.count(); i++) { - String ename = (String)ents.objectAtIndex(i); + String ename = (String) ents.objectAtIndex(i); if (entityNamed(ename) != null) - throw new IllegalArgumentException("Cannot add model " + model.name() + - " to group because it contains entity named " + ename); + throw new IllegalArgumentException( + "Cannot add model " + model.name() + " to group because it contains entity named " + ename); } _models.setObjectForKey(model, model.name()); } @@ -73,6 +73,7 @@ public class EOModelGroup { public static void setDefaultGroup(EOModelGroup group) { _defaultGroup = group; } + public static EOModelGroup defaultGroup() { if (_defaultGroup == null) { _defaultGroup = globalModelGroup(); @@ -83,7 +84,7 @@ public class EOModelGroup { public static EOModelGroup globalModelGroup() { if (_globalGroup == null) { _globalGroup = new EOModelGroup(); - //TODO: read all frameworks and get models from them + // TODO: read all frameworks and get models from them } return _globalGroup; } @@ -95,7 +96,7 @@ public class EOModelGroup { public EOEntity entityNamed(String name) { java.util.Enumeration enumeration = _models.objectEnumerator(); while (enumeration.hasMoreElements()) { - EOModel m = (EOModel)enumeration.nextElement(); + EOModel m = (EOModel) enumeration.nextElement(); if (m.entityNamed(name) != null) return m.entityNamed(name); } @@ -103,7 +104,7 @@ public class EOModelGroup { } public EOModel modelNamed(String name) { - return (EOModel)_models.objectForKey(name); + return (EOModel) _models.objectForKey(name); } public NSArray modelNames() { @@ -117,7 +118,7 @@ public class EOModelGroup { public EOModel modelWithPath(String path) { java.util.Enumeration enumeration = _models.objectEnumerator(); while (enumeration.hasMoreElements()) { - EOModel m = (EOModel)enumeration.nextElement(); + EOModel m = (EOModel) enumeration.nextElement(); if (m.path() != null && m.path().equals(path)) return m; } @@ -127,7 +128,7 @@ public class EOModelGroup { public EOStoredProcedure storedProcedureNamed(String name) { java.util.Enumeration enumeration = _models.objectEnumerator(); while (enumeration.hasMoreElements()) { - EOModel m = (EOModel)enumeration.nextElement(); + EOModel m = (EOModel) enumeration.nextElement(); if (m.storedProcedureNamed(name) != null) return m.storedProcedureNamed(name); } @@ -144,12 +145,12 @@ public class EOModelGroup { public void loadAllModelObjects() { java.util.Enumeration enumeration = _models.objectEnumerator(); while (enumeration.hasMoreElements()) { - EOModel m = (EOModel)enumeration.nextElement(); - //this causes all entities to be loaded + EOModel m = (EOModel) enumeration.nextElement(); + // this causes all entities to be loaded NSArray ents = m.entities(); - for (int i=0; i<ents.count(); i++) { - EOEntity e = (EOEntity)ents.objectAtIndex(i); - //this loads all the fetch specifications + for (int i = 0; i < ents.count(); i++) { + EOEntity e = (EOEntity) ents.objectAtIndex(i); + // this loads all the fetch specifications e.fetchSpecificationNamed("whatever"); } } @@ -160,39 +161,39 @@ public class EOModelGroup { d.setObjectForKey(group, "ModelGroup"); coord.setUserInfo(d); } + public static EOModelGroup modelGroupForObjectStoreCoordinator(EOObjectStoreCoordinator coord) { NSDictionary d = coord.userInfo(); if (d == null) return defaultGroup(); Object g = d.objectForKey("ModelGroup"); if (g != null && g instanceof EOModelGroup) - return (EOModelGroup)g; + return (EOModelGroup) g; return defaultGroup(); } } /* - * $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.4 2005/05/11 15:21:53 cgruber - * Change enum to enumeration, since enum is now a keyword as of Java 5.0 + * Revision 1.4 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.3 2003/08/08 00:44:04 chochos - * manage model groups for object store coordinators. + * Revision 1.3 2003/08/08 00:44:04 chochos manage model groups for object store + * coordinators. * - * Revision 1.2 2003/08/08 00:36:41 chochos - * add a little more functionality + * Revision 1.2 2003/08/08 00:36:41 chochos add a little more functionality * - * Revision 1.1 2003/08/07 02:42:28 chochos - * EOModel can read an .eomodeld file. EOModelGroup doesn't do much for now. + * Revision 1.1 2003/08/07 02:42:28 chochos EOModel can read an .eomodeld file. + * EOModelGroup doesn't do much for now. * -*/
\ No newline at end of file + */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOProperty.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOProperty.java index 89f1fea..10eaa74 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOProperty.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOProperty.java @@ -18,12 +18,12 @@ License along with this library; if not, see http://www.gnu.org package net.wotonomy.access; /** -* Abstract superclass of EOAttribute and EORelationship. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ + * Abstract superclass of EOAttribute and EORelationship. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ public abstract class EOProperty { public EOProperty() { @@ -36,11 +36,10 @@ public abstract class EOProperty { } /* - * $Log$ - * Revision 1.1 2006/02/16 13:19:57 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.1 2006/02/16 13:19:57 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.1 2003/08/08 06:51:37 chochos - * abstract superclass for relationships and attributes + * Revision 1.1 2003/08/08 06:51:37 chochos abstract superclass for + * relationships and attributes * */ diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOPropertyListEncoding.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOPropertyListEncoding.java index af456d2..2b7e9cf 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOPropertyListEncoding.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOPropertyListEncoding.java @@ -21,13 +21,13 @@ import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableDictionary; /** -* Implemented by classes that are read from property lists and that -* can be written back to property lists. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * Implemented by classes that are read from property lists and that can be + * written back to property lists. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public interface EOPropertyListEncoding { public abstract void awakeWithPropertyList(NSDictionary plist); @@ -36,18 +36,16 @@ public interface EOPropertyListEncoding { } -/* $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 2003/08/09 01:34:43 chochos -/* an interface to provide property list encoding capabilities -/* + * /* Revision 1.1 2006/02/16 13:19:57 cgruber /* Check in all sources in + * eclipse-friendly maven-enabled packages. /* /* Revision 1.1 2003/08/09 + * 01:34:43 chochos /* an interface to provide property list encoding + * capabilities /* * */ -
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOQualifierSQLGeneration.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOQualifierSQLGeneration.java index 4627f76..e7dff0f 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOQualifierSQLGeneration.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOQualifierSQLGeneration.java @@ -27,15 +27,14 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSMutableDictionary; /** -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public interface EOQualifierSQLGeneration { - public EOQualifier qualifierMigratedFromEntityRelationshipPath( - EOEntity entity, String path); + public EOQualifier qualifierMigratedFromEntityRelationshipPath(EOEntity entity, String path); public EOQualifier schemaBasedQualifierWithRootEntity(EOEntity entity); @@ -60,8 +59,9 @@ public interface EOQualifierSQLGeneration { public static void setSupportForClass(Support sup, Class aClass) { _classes.setObjectForKey(sup, aClass.getName()); } + public static Support supportForClass(Class aClass) { - return (Support)_classes.objectForKey(aClass.getName()); + return (Support) _classes.objectForKey(aClass.getName()); } public abstract String sqlStringForSQLExpression(EOQualifier q, EOSQLExpression exp); @@ -79,7 +79,7 @@ public interface EOQualifierSQLGeneration { } public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression exp) { - EOKeyValueQualifier q = (EOKeyValueQualifier)qualifier; + EOKeyValueQualifier q = (EOKeyValueQualifier) qualifier; String sql1 = exp.sqlStringForAttributeNamed(q.key()); String sql2 = exp.sqlStringForSelector(q.selector(), q.value()); String sql3 = exp.sqlStringForValue(q.value(), q.key()); @@ -87,7 +87,7 @@ public interface EOQualifierSQLGeneration { return exp.sqlStringForCaseInsensitiveLike(sql1, sql3); else if (q.selector() == EOQualifier.QualifierOperatorLike) sql3 = exp.sqlPatternFromShellPattern(sql3); - return sql1 + sql2 + sql3; + return sql1 + sql2 + sql3; } public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier q, EOEntity e) { @@ -107,10 +107,9 @@ public interface EOQualifierSQLGeneration { } public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression exp) { - EOKeyComparisonQualifier q = (EOKeyComparisonQualifier)qualifier; - return exp.sqlStringForAttributeNamed(q.leftKey()) + - exp.sqlStringForSelector(q.selector(), null) + - exp.sqlStringForAttributeNamed(q.rightKey()); + EOKeyComparisonQualifier q = (EOKeyComparisonQualifier) qualifier; + return exp.sqlStringForAttributeNamed(q.leftKey()) + exp.sqlStringForSelector(q.selector(), null) + + exp.sqlStringForAttributeNamed(q.rightKey()); } public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier q, EOEntity e) { @@ -130,18 +129,21 @@ public interface EOQualifierSQLGeneration { } public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression exp) { - EONotQualifier q = (EONotQualifier)qualifier; - return "NOT (" + EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()).sqlStringForSQLExpression(q.qualifier(), exp) + ")"; + EONotQualifier q = (EONotQualifier) qualifier; + return "NOT (" + EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()) + .sqlStringForSQLExpression(q.qualifier(), exp) + ")"; } public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier qualifier, EOEntity e) { - EONotQualifier q = (EONotQualifier)qualifier; - return new EONotQualifier(EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()).schemaBasedQualifierWithRootEntity(q.qualifier(), e)); + EONotQualifier q = (EONotQualifier) qualifier; + return new EONotQualifier(EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()) + .schemaBasedQualifierWithRootEntity(q.qualifier(), e)); } public EOQualifier qualifierMigratedFromEntityRelationshipPath(EOQualifier qualifier, EOEntity e, String path) { - EONotQualifier q = (EONotQualifier)qualifier; - return new EONotQualifier(EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()).qualifierMigratedFromEntityRelationshipPath(q.qualifier(), e, path)); + EONotQualifier q = (EONotQualifier) qualifier; + return new EONotQualifier(EOQualifierSQLGeneration.Support.supportForClass(q.qualifier().getClass()) + .qualifierMigratedFromEntityRelationshipPath(q.qualifier(), e, path)); } } @@ -153,16 +155,16 @@ public interface EOQualifierSQLGeneration { } public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression exp) { - EOAndQualifier q = (EOAndQualifier)qualifier; + EOAndQualifier q = (EOAndQualifier) qualifier; NSArray qus = q.qualifiers(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < qus.count(); i++) { - EOQualifier sub = (EOQualifier)qus.objectAtIndex(i); + EOQualifier sub = (EOQualifier) qus.objectAtIndex(i); EOQualifierSQLGeneration.Support sup = EOQualifierSQLGeneration.Support.supportForClass(sub.getClass()); if (sup == null) throw new IllegalStateException("Cannot find support class for " + sub.getClass().getName()); buf.append(sup.sqlStringForSQLExpression(sub, exp)); - if (i < qus.count()-1) + if (i < qus.count() - 1) buf.append(" AND "); } if (qus.count() > 1) { @@ -189,16 +191,16 @@ public interface EOQualifierSQLGeneration { } public String sqlStringForSQLExpression(EOQualifier qualifier, EOSQLExpression exp) { - EOOrQualifier q = (EOOrQualifier)qualifier; + EOOrQualifier q = (EOOrQualifier) qualifier; NSArray qus = q.qualifiers(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < qus.count(); i++) { - EOQualifier sub = (EOQualifier)qus.objectAtIndex(i); + EOQualifier sub = (EOQualifier) qus.objectAtIndex(i); EOQualifierSQLGeneration.Support sup = EOQualifierSQLGeneration.Support.supportForClass(sub.getClass()); if (sup == null) throw new IllegalStateException("Cannot find support class for " + sub.getClass().getName()); buf.append(sup.sqlStringForSQLExpression(sub, exp)); - if (i < qus.count()-1) + if (i < qus.count() - 1) buf.append(" OR "); } if (qus.count() > 1) { @@ -220,22 +222,23 @@ public interface EOQualifierSQLGeneration { } /* - * $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.3 2003/08/14 02:13:10 chochos - * KeyValueQualifierSupport generates proper SQL + * Revision 1.3 2003/08/14 02:13:10 chochos KeyValueQualifierSupport generates + * proper SQL * - * Revision 1.2 2003/08/14 01:05:51 chochos - * added abstract Support inner class, with incomplete implementations for the main qualifiers (not, and, or, key-value, key-comparison) + * Revision 1.2 2003/08/14 01:05:51 chochos added abstract Support inner class, + * with incomplete implementations for the main qualifiers (not, and, or, + * key-value, key-comparison) * - * Revision 1.1 2003/08/12 01:45:49 chochos - * interface to be implemented by qualifiers (or support classes) to indicate they can generate SQL + * Revision 1.1 2003/08/12 01:45:49 chochos interface to be implemented by + * qualifiers (or support classes) to indicate they can generate SQL * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EORelationship.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EORelationship.java index a5a207f..4efd068 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EORelationship.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EORelationship.java @@ -21,13 +21,15 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableArray; import net.wotonomy.foundation.NSMutableDictionary; + /** -* Represents a relationship from one entity to another. Relationships are unidirectional. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * Represents a relationship from one entity to another. Relationships are + * unidirectional. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EORelationship extends EOProperty implements EOPropertyListEncoding { public static final int InnerJoin = 0; @@ -60,14 +62,14 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public EORelationship(NSDictionary dict, Object obj) { super(); - _entity = (EOEntity)obj; - setName((String)dict.objectForKey("name")); + _entity = (EOEntity) obj; + setName((String) dict.objectForKey("name")); setToMany("Y".equals(dict.objectForKey("isToMany"))); setPropagatesPrimaryKey("Y".equals(dict.objectForKey("propagatesPrimaryKey"))); setIsMandatory("Y".equals(dict.objectForKey("isMandatory"))); setOwnsDestination("Y".equals(dict.objectForKey("ownsDestination"))); - setDefinition((String)dict.objectForKey("definition")); - String delrule = (String)dict.objectForKey("deleteRule"); + setDefinition((String) dict.objectForKey("definition")); + String delrule = (String) dict.objectForKey("deleteRule"); if (delrule != null) { if (delrule.equals("EODeleteRuleCascade")) setDeleteRule(0); @@ -78,7 +80,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding else if (delrule.equals("EODeleteRuleNullify")) setDeleteRule(0); } - delrule = (String)dict.objectForKey("joinSemantic"); + delrule = (String) dict.objectForKey("joinSemantic"); if (delrule != null) { if (delrule.equals("EOInnerJoin")) setJoinSemantic(InnerJoin); @@ -89,13 +91,13 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding else if (delrule.equals("EORightOuterJoin")) setJoinSemantic(RightOuterJoin); } - delrule = (String)dict.objectForKey("batchCount"); + delrule = (String) dict.objectForKey("batchCount"); if (delrule != null) setNumberOfToManyFaultsToBatchFetch(Integer.parseInt(delrule)); - NSDictionary d = (NSDictionary)dict.objectForKey("userInfo"); + NSDictionary d = (NSDictionary) dict.objectForKey("userInfo"); if (d != null) _userInfo = d; - d = (NSDictionary)dict.objectForKey("internalInfo"); + d = (NSDictionary) dict.objectForKey("internalInfo"); if (d != null) _internalInfo = d; plist = dict; @@ -104,6 +106,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setName(String name) { _name = name; } + public String name() { return _name; } @@ -125,7 +128,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding if (_destination == null && plist != null) { EOModel model = _entity.model(); EOModelGroup group = model.modelGroup(); - String destEntity = (String)plist.objectForKey("destination"); + String destEntity = (String) plist.objectForKey("destination"); if (group != null) _destination = group.entityNamed(destEntity); else @@ -137,6 +140,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setOwnsDestination(boolean flag) { _ownsDestination = flag; } + public boolean ownsDestination() { return _ownsDestination; } @@ -144,6 +148,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setToMany(boolean flag) { _isToMany = flag; } + public boolean isToMany() { return _isToMany; } @@ -151,6 +156,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setIsMandatory(boolean flag) { _isMandatory = flag; } + public boolean isMandatory() { return _isMandatory; } @@ -158,6 +164,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setPropagatesPrimaryKey(boolean flag) { _propagatesPrimaryKey = flag; } + public boolean propagatesPrimaryKey() { return _propagatesPrimaryKey; } @@ -165,6 +172,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setDeleteRule(int value) { _deleteRule = value; } + public int deleteRule() { return _deleteRule; } @@ -172,6 +180,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setJoinSemantic(int value) { _joinSemantic = value; } + public int joinSemantic() { return _joinSemantic; } @@ -179,17 +188,18 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setNumberOfToManyFaultsToBatchFetch(int count) { _batchCount = count; } + public int numberOfToManyFaultsToBatchFetch() { return _batchCount; } public NSArray joins() { if (_joins.count() == 0 && plist != null) { - NSArray joins = (NSArray)plist.objectForKey("joins"); + NSArray joins = (NSArray) plist.objectForKey("joins"); for (int i = 0; i < joins.count(); i++) { - NSDictionary d = (NSDictionary)joins.objectAtIndex(i); - String srcName = (String)d.objectForKey("sourceAttribute"); - String dstName = (String)d.objectForKey("destinationAttribute"); + NSDictionary d = (NSDictionary) joins.objectAtIndex(i); + String srcName = (String) d.objectForKey("sourceAttribute"); + String dstName = (String) d.objectForKey("destinationAttribute"); EOAttribute a1 = _entity.attributeNamed(srcName); EOAttribute a2 = destinationEntity().attributeNamed(dstName); EOJoin j = new EOJoin(a1, a2); @@ -202,6 +212,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setDefinition(String def) { _definition = def; } + public String definition() { return _definition; } @@ -218,7 +229,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding EORelationship r = null; EOEntity e = entity(); for (int i = 0; i < comps.count(); i++) { - String name = (String)comps.objectAtIndex(i); + String name = (String) comps.objectAtIndex(i); r = e.relationshipNamed(name); if (r == null) return false; @@ -242,6 +253,7 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding public void setUserInfo(NSDictionary value) { _userInfo = value; } + public NSDictionary userInfo() { return _userInfo; } @@ -260,18 +272,18 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding if (isToMany()) dict.setObjectForKey("Y", "isToMany"); switch (_joinSemantic) { - case InnerJoin: - dict.setObjectForKey("EOInnerJoin", "joinSemantic"); - break; - case FullOuterJoin: - dict.setObjectForKey("EOFullOuterJoin", "joinSemantic"); - break; - case LeftOuterJoin: - dict.setObjectForKey("EOLefOuterJoin", "joinSemantic"); - break; - case RightOuterJoin: - dict.setObjectForKey("EORightOuterJoin", "joinSemantic"); - break; + case InnerJoin: + dict.setObjectForKey("EOInnerJoin", "joinSemantic"); + break; + case FullOuterJoin: + dict.setObjectForKey("EOFullOuterJoin", "joinSemantic"); + break; + case LeftOuterJoin: + dict.setObjectForKey("EOLefOuterJoin", "joinSemantic"); + break; + case RightOuterJoin: + dict.setObjectForKey("EORightOuterJoin", "joinSemantic"); + break; } if (_batchCount > 0) dict.setObjectForKey(new Integer(_batchCount), "batchCount"); @@ -280,10 +292,10 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding else { NSMutableArray jarr = new NSMutableArray(joins().count()); for (int i = 0; i < _joins.count(); i++) { - EOJoin j = (EOJoin)_joins.objectAtIndex(i); + EOJoin j = (EOJoin) _joins.objectAtIndex(i); NSDictionary d = new NSDictionary( - new Object[]{ j.sourceAttribute().name(), j.destinationAttribute().name() }, - new Object[]{ "sourceAttribute", "destinationAttribute" }); + new Object[] { j.sourceAttribute().name(), j.destinationAttribute().name() }, + new Object[] { "sourceAttribute", "destinationAttribute" }); jarr.addObject(d); } dict.setObjectForKey(jarr, "joins"); @@ -292,28 +304,25 @@ public class EORelationship extends EOProperty implements EOPropertyListEncoding } /* - * $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 2003/08/11 19:38:27 chochos - * Can now read from a file and re-write to another file. + * Revision 1.5 2003/08/11 19:38:27 chochos Can now read from a file and + * re-write to another file. * - * Revision 1.4 2003/08/09 01:35:35 chochos - * implement EOPropertyListEncoding + * Revision 1.4 2003/08/09 01:35:35 chochos implement EOPropertyListEncoding * - * Revision 1.3 2003/08/08 06:51:53 chochos - * isFlattened() works + * Revision 1.3 2003/08/08 06:51:53 chochos isFlattened() works * - * Revision 1.2 2003/08/08 02:17:43 chochos - * main accessors are in place. + * Revision 1.2 2003/08/08 02:17:43 chochos main accessors are in place. * - * Revision 1.1 2003/08/07 02:41:30 chochos - * a relationship that for the moment can be created from a property list. + * Revision 1.1 2003/08/07 02:41:30 chochos a relationship that for the moment + * can be created from a property list. * -*/
\ No newline at end of file + */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpression.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpression.java index 4cb15e5..c2b6e76 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpression.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpression.java @@ -37,10 +37,10 @@ import net.wotonomy.foundation.NSTimestamp; import net.wotonomy.foundation.NSTimestampFormatter; /** -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public abstract class EOSQLExpression { public static final String BindVariableAttributeKey = "BindVariableAttribute"; @@ -54,9 +54,8 @@ public abstract class EOSQLExpression { private static final int _DefaultOrderByStringLength = 128; private static final int _DefaultPathLength = 128; private static final int _DefaultTableListLength = 128; - protected static final char[] _hexChars = new char[]{ - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' - }; + protected static final char[] _hexChars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F' }; private static final int _ValueLengthLimit = 40; protected NSMutableDictionary _aliasesByRelationshipPath; protected NSMutableDictionary _aliasesByEntityName; @@ -77,7 +76,7 @@ public abstract class EOSQLExpression { private EOSQLExpression() { super(); } - + public EOSQLExpression(EOEntity entity) { super(); _entity = entity; @@ -88,7 +87,7 @@ public abstract class EOSQLExpression { } public String _aliasForRelationshipPath(String path) { - return (String)_aliasesByRelationshipPath.objectForKey(path); + return (String) _aliasesByRelationshipPath.objectForKey(path); } protected NSTimestampFormatter _defaultDateFormatter() { @@ -115,7 +114,7 @@ public abstract class EOSQLExpression { _entity = value; } - public String _sqlStringForJoinSemanticMatchSemantic(int semantic,int match) { + public String _sqlStringForJoinSemanticMatchSemantic(int semantic, int match) { return null; } @@ -129,11 +128,13 @@ public abstract class EOSQLExpression { return _valueListString; } - public void addBindVariableDictionary( NSDictionary dict ) { + public void addBindVariableDictionary(NSDictionary dict) { } - /** Adds the SQL to create the attribute to the attribute list. - * The appended text is of the form attr_name attr_type allow_null + /** + * Adds the SQL to create the attribute to the attribute list. The appended text + * is of the form attr_name attr_type allow_null + * * @param attr The attribute to create the SQL for. */ public void addCreateClauseForAttribute(EOAttribute attr) { @@ -158,9 +159,11 @@ public abstract class EOSQLExpression { public void addOrderByAttributeOrdering(EOSortOrdering order) { String sql = sqlStringForAttributeNamed(order.key()); - if (order.selector().equals(EOSortOrdering.CompareCaseInsensitiveAscending) || order.selector().equals(EOSortOrdering.CompareCaseInsensitiveDescending)) + if (order.selector().equals(EOSortOrdering.CompareCaseInsensitiveAscending) + || order.selector().equals(EOSortOrdering.CompareCaseInsensitiveDescending)) sql = "UPPER(" + sql + ")"; - if (order.selector().equals(EOSortOrdering.CompareCaseInsensitiveAscending) || order.selector().equals(EOSortOrdering.CompareAscending)) + if (order.selector().equals(EOSortOrdering.CompareCaseInsensitiveAscending) + || order.selector().equals(EOSortOrdering.CompareAscending)) sql += " ASC"; else sql += " DESC"; @@ -205,8 +208,8 @@ public abstract class EOSQLExpression { return s; } - public String assembleInsertStatementWithRow(NSDictionary row, - String tableList, String columnList, String valueList) { + public String assembleInsertStatementWithRow(NSDictionary row, String tableList, String columnList, + String valueList) { String sql = "INSERT INTO " + tableList; if (columnList != null) sql += " (" + columnList + ")"; @@ -223,9 +226,9 @@ public abstract class EOSQLExpression { return leftName + op + rightName; } - public String assembleSelectStatementWithAttributes(NSArray attributes, - boolean lock, EOQualifier q, NSArray fetchOrder, String selectString, String columnList, - String tableList, String whereClause, String joinClause, String orderByClause, String lockClause) { + public String assembleSelectStatementWithAttributes(NSArray attributes, boolean lock, EOQualifier q, + NSArray fetchOrder, String selectString, String columnList, String tableList, String whereClause, + String joinClause, String orderByClause, String lockClause) { String sql = selectString + " " + columnList + " FROM " + tableList; if (lockClause != null) sql += " " + lockClause; @@ -242,7 +245,8 @@ public abstract class EOSQLExpression { return sql; } - public String assembleUpdateStatementWithRow(NSDictionary row, EOQualifier q, String tableList, String updateList, String whereClause) { + public String assembleUpdateStatementWithRow(NSDictionary row, EOQualifier q, String tableList, String updateList, + String whereClause) { String s = "UPDATE " + tableList + " SET " + updateList; if (whereClause != null && whereClause.length() > 0) s += " WHERE " + whereClause; @@ -280,14 +284,14 @@ public abstract class EOSQLExpression { } /** - * Returns the received string wrapped in single quotes, - * with any quotes or escape chars found inside it - * properly escaped. + * Returns the received string wrapped in single quotes, with any quotes or + * escape chars found inside it properly escaped. + * * @param s The string to format. */ public String formatStringValue(String s) { StringBuffer buf = new StringBuffer(s); - for (int i = buf.length()-1; i >= 0; i--) { + for (int i = buf.length() - 1; i >= 0; i--) { if (buf.charAt(i) == sqlEscapeChar()) { buf.insert(i, sqlEscapeChar()); i++; @@ -306,10 +310,10 @@ public abstract class EOSQLExpression { if (value == null || value == NSKeyValueCoding.NullValue) return "NULL"; if (value instanceof String) - return formatStringValue((String)value); + return formatStringValue((String) value); if (value instanceof Number) - return sqlStringForNumber((Number)value); - //TODO: format timestamps + return sqlStringForNumber((Number) value); + // TODO: format timestamps return value.toString(); } @@ -338,7 +342,7 @@ public abstract class EOSQLExpression { } public String orderByString() { - if (_orderByString == null) + if (_orderByString == null) return null; return _orderByString.toString(); } @@ -356,7 +360,7 @@ public abstract class EOSQLExpression { StringBuffer values = new StringBuffer("("); Enumeration enumeration = row.keyEnumerator(); while (enumeration.hasMoreElements()) { - String key = (String)enumeration.nextElement(); + String key = (String) enumeration.nextElement(); EOAttribute a = _entity.attributeNamed(key); cols.append(a.columnName()); values.append(formatValueForAttribute(row.objectForKey(key), a)); @@ -379,30 +383,31 @@ public abstract class EOSQLExpression { q = fspec.qualifier(); order = fspec.sortOrderings(); } - //Assemble the column list (this yields the alias list) + // Assemble the column list (this yields the alias list) for (int i = 0; i < atts.count(); i++) - addSelectListAttribute((EOAttribute)atts.objectAtIndex(i)); - //assemble the where string + addSelectListAttribute((EOAttribute) atts.objectAtIndex(i)); + // assemble the where string if (q != null) { if (q instanceof EOQualifierSQLGeneration) - setWhereClauseString(sqlStringForQualifier((EOQualifierSQLGeneration)q)); + setWhereClauseString(sqlStringForQualifier((EOQualifierSQLGeneration) q)); else { EOQualifierSQLGeneration.Support sup = EOQualifierSQLGeneration.Support.supportForClass(q.getClass()); setWhereClauseString(sup.sqlStringForSQLExpression(q, this)); } } - //assemble the join string + // assemble the join string joinExpression(); - //assemble the order by string + // assemble the order by string if (order != null && order.count() > 0) { for (int i = 0; i < order.count(); i++) { - EOSortOrdering so = (EOSortOrdering)order.objectAtIndex(i); + EOSortOrdering so = (EOSortOrdering) order.objectAtIndex(i); addOrderByAttributeOrdering(so); } } - //create the statement + // create the statement setStatement(assembleSelectStatementWithAttributes(atts, lock, q, order, "SELECT", listString(), - tableListWithRootEntity(_entity), whereClauseString(), joinClauseString(), orderByString(), lockClause())); + tableListWithRootEntity(_entity), whereClauseString(), joinClauseString(), orderByString(), + lockClause())); } /** Build an UPDATE statement with the given information. */ @@ -410,10 +415,11 @@ public abstract class EOSQLExpression { StringBuffer buf = new StringBuffer(); Enumeration enumeration = row.keyEnumerator(); while (enumeration.hasMoreElements()) { - String key = (String)enumeration.nextElement(); + String key = (String) enumeration.nextElement(); EOAttribute a = _entity.attributeNamed(key); if (a == null) - throw new EOGeneralAdaptorException("Cannot find attribute named " + key + " in entity " + _entity.name()); + throw new EOGeneralAdaptorException( + "Cannot find attribute named " + key + " in entity " + _entity.name()); buf.append(a.columnName()); buf.append('='); buf.append(formatValueForAttribute(row.objectForKey(key), a)); @@ -423,7 +429,8 @@ public abstract class EOSQLExpression { if (q != null) { setWhereClauseString(sqlStringForQualifier(null)); } - setStatement(assembleUpdateStatementWithRow(row, q, _entity.externalName(), buf.toString(), whereClauseString())); + setStatement( + assembleUpdateStatementWithRow(row, q, _entity.externalName(), buf.toString(), whereClauseString())); } public void setStatement(String statement) { @@ -453,6 +460,7 @@ public abstract class EOSQLExpression { public static void setUseQuotedExternalNames(boolean flag) { _quoteExternalNames = flag; } + /** @deprecated Use the instance method externalNameQuoteCharacter instead. */ public static boolean useQuotedExternalNames() { return _quoteExternalNames; @@ -481,33 +489,33 @@ public abstract class EOSQLExpression { public String sqlPatternFromShellPatternWithEscapeCharacter(String pattern, char escape) { StringBuffer buf = new StringBuffer(pattern); int idx = 0; - //escape all '%' + // escape all '%' do { idx = buf.indexOf("%"); if (idx == 0) buf.insert(escape, 0); - else if (idx > 0 && buf.charAt(idx-1) != escape) + else if (idx > 0 && buf.charAt(idx - 1) != escape) buf.insert(escape, idx); } while (idx >= 0); - //escape all '_' + // escape all '_' do { idx = buf.indexOf("_"); if (idx == 0) buf.insert(escape, 0); - else if (idx > 0 && buf.charAt(idx-1) != escape) + else if (idx > 0 && buf.charAt(idx - 1) != escape) buf.insert(escape, idx); } while (idx >= 0); - //substitute all '*' + // substitute all '*' do { idx = buf.indexOf("*"); if (idx >= 0) - buf.replace(idx, idx+1, "%"); + buf.replace(idx, idx + 1, "%"); } while (idx >= 0); - //substitute all '?' + // substitute all '?' do { idx = buf.indexOf("?"); if (idx >= 0) - buf.replace(idx, idx+1, "_"); + buf.replace(idx, idx + 1, "_"); } while (idx >= 0); return buf.toString(); } @@ -515,7 +523,7 @@ public abstract class EOSQLExpression { public String sqlStringForAttribute(EOAttribute attr) { if (_aliasesByEntityName == null) _aliasesByEntityName = new NSMutableDictionary(); - String alias = (String)_aliasesByEntityName.objectForKey(attr.entity().name()); + String alias = (String) _aliasesByEntityName.objectForKey(attr.entity().name()); if (alias == null) { alias = "t" + (_aliasesByEntityName.count() + 1); _aliasesByEntityName.setObjectForKey(alias, attr.entity().name()); @@ -531,20 +539,21 @@ public abstract class EOSQLExpression { return sqlStringForAttribute(_entity._attributeForPath(name)); } return sqlStringForAttribute(_entity.attributeNamed(name)); - + } /** - * Returns a string representing the path from the first - * relationship in the array to the last one. + * Returns a string representing the path from the first relationship in the + * array to the last one. + * * @param path An array of EORelationship objects. - * @return A string consisting of the names of the relationships - * separated by dots. + * @return A string consisting of the names of the relationships separated by + * dots. */ public String sqlStringForAttributePath(NSArray path) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < path.count(); i++) { - EORelationship rel = (EORelationship)path.objectAtIndex(i); + EORelationship rel = (EORelationship) path.objectAtIndex(i); if (i > 0) buf.append('.'); buf.append(rel.name()); @@ -558,7 +567,8 @@ public abstract class EOSQLExpression { public String sqlStringForConjoinedQualifiers(NSArray qualifiers) { EOAndQualifier q = new EOAndQualifier(qualifiers); - return EOQualifierSQLGeneration.Support.supportForClass(EOAndQualifier.class).sqlStringForSQLExpression(q, this); + return EOQualifierSQLGeneration.Support.supportForClass(EOAndQualifier.class).sqlStringForSQLExpression(q, + this); } public String sqlStringForData(NSData data) { @@ -580,11 +590,13 @@ public abstract class EOSQLExpression { } public String sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier q) { - return EOQualifierSQLGeneration.Support.supportForClass(EOKeyComparisonQualifier.class).sqlStringForSQLExpression(q, this); + return EOQualifierSQLGeneration.Support.supportForClass(EOKeyComparisonQualifier.class) + .sqlStringForSQLExpression(q, this); } public String sqlStringForKeyValueQualifier(EOKeyValueQualifier q) { - return EOQualifierSQLGeneration.Support.supportForClass(EOKeyValueQualifier.class).sqlStringForSQLExpression(q, this); + return EOQualifierSQLGeneration.Support.supportForClass(EOKeyValueQualifier.class).sqlStringForSQLExpression(q, + this); } public String sqlStringForNegatedQualifier(EOQualifier q) { @@ -622,7 +634,8 @@ public abstract class EOSQLExpression { return "<="; } else if (sel == EOQualifier.QualifierOperatorGreaterThanOrEqualTo) { return ">="; - } else if (sel == EOQualifier.QualifierOperatorLike || sel == EOQualifier.QualifierOperatorCaseInsensitiveLike) { + } else if (sel == EOQualifier.QualifierOperatorLike + || sel == EOQualifier.QualifierOperatorCaseInsensitiveLike) { return " like "; } return sel.name(); @@ -646,7 +659,7 @@ public abstract class EOSQLExpression { if (_aliasesByEntityName.count() > 0) { Enumeration enumeration = _aliasesByEntityName.keyEnumerator(); while (enumeration.hasMoreElements()) { - String key = (String)enumeration.nextElement(); + String key = (String) enumeration.nextElement(); if (!key.equals(root.name())) { buf.append(", "); buf.append(key); @@ -668,30 +681,31 @@ public abstract class EOSQLExpression { } /* - * $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.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/08/29 21:14:18 chochos - * fix the algorithm in formatStringValue. + * Revision 1.4 2003/08/29 21:14:18 chochos fix the algorithm in + * formatStringValue. * - * Revision 1.3 2003/08/14 02:12:32 chochos - * implemented use of (simple) qualifiers + * Revision 1.3 2003/08/14 02:12:32 chochos implemented use of (simple) + * qualifiers * - * Revision 1.2 2003/08/13 22:59:39 chochos - * Can now generate simple one-entity select statements. + * Revision 1.2 2003/08/13 22:59:39 chochos Can now generate simple one-entity + * select statements. * - * Revision 1.1 2003/08/13 01:04:32 chochos - * the SQL generation classes. EOSQLExpression still needs a lot of work, but the factory is pretty much done. + * Revision 1.1 2003/08/13 01:04:32 chochos the SQL generation classes. + * EOSQLExpression still needs a lot of work, but the factory is pretty much + * done. * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpressionFactory.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpressionFactory.java index 6bdbffe..4e20a7a 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpressionFactory.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOSQLExpressionFactory.java @@ -25,11 +25,11 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSDictionary; /** -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOSQLExpressionFactory { protected EOAdaptor _adaptor; @@ -49,8 +49,9 @@ public class EOSQLExpressionFactory { } /** - * Creates an instance of the adaptor's expression class, - * with entity assigned to it. + * Creates an instance of the adaptor's expression class, with entity assigned + * to it. + * * @param entity The entity with which to initialize the expression. * @return An EOSQLExpression. */ @@ -58,13 +59,14 @@ public class EOSQLExpressionFactory { EOSQLExpression expr = null; if (_instantiator == null) { try { - _instantiator = _expressionClass.getConstructor(new Class[]{ EOEntity.class }); + _instantiator = _expressionClass.getConstructor(new Class[] { EOEntity.class }); } catch (Exception ex) { - throw new IllegalArgumentException("The expression class " + _expressionClass.getName() + " has no constructor with an entity parameter."); + throw new IllegalArgumentException("The expression class " + _expressionClass.getName() + + " has no constructor with an entity parameter."); } } try { - expr = (EOSQLExpression)_instantiator.newInstance(new Object[]{ entity }); + expr = (EOSQLExpression) _instantiator.newInstance(new Object[] { entity }); } catch (Exception ex) { throw new IllegalArgumentException("Cannot create new expression of class " + _expressionClass.getName()); } @@ -87,7 +89,8 @@ public class EOSQLExpressionFactory { return expr; } - public EOSQLExpression selectStatementForAttributes(NSArray atts, boolean lock, EOFetchSpecification fspec, EOEntity entity) { + public EOSQLExpression selectStatementForAttributes(NSArray atts, boolean lock, EOFetchSpecification fspec, + EOEntity entity) { EOSQLExpression expr = createExpression(entity); expr.prepareSelectExpressionWithAttributes(atts, lock, fspec); return expr; @@ -102,7 +105,7 @@ public class EOSQLExpressionFactory { public EOSQLExpression expressionForString(String sql) { EOSQLExpression expr = null; try { - expr = (EOSQLExpression)_expressionClass.newInstance(); + expr = (EOSQLExpression) _expressionClass.newInstance(); } catch (Exception e) { return null; } @@ -116,16 +119,17 @@ public class EOSQLExpressionFactory { } /* - * $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 2003/08/13 01:04:32 chochos - * the SQL generation classes. EOSQLExpression still needs a lot of work, but the factory is pretty much done. + * Revision 1.1 2003/08/13 01:04:32 chochos the SQL generation classes. + * EOSQLExpression still needs a lot of work, but the factory is pretty much + * done. * */
\ No newline at end of file diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOStoredProcedure.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOStoredProcedure.java index f38ec2a..6fab43a 100644 --- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOStoredProcedure.java +++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOStoredProcedure.java @@ -22,13 +22,14 @@ import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableArray; import net.wotonomy.foundation.NSMutableDictionary; + /** -* Represents a stored procedure in a database. -* -* @author ezamudio@nasoft.com -* @author $Author: cgruber $ -* @version $Revision: 894 $ -*/ + * Represents a stored procedure in a database. + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 894 $ + */ public class EOStoredProcedure implements EOPropertyListEncoding { protected String _name; @@ -42,23 +43,23 @@ public class EOStoredProcedure implements EOPropertyListEncoding { public EOStoredProcedure(NSDictionary dict, Object obj) { super(); if (obj instanceof EOModel) - _model = (EOModel)obj; - NSArray a = (NSArray)dict.objectForKey("arguments"); + _model = (EOModel) obj; + NSArray a = (NSArray) dict.objectForKey("arguments"); if (a != null) { NSMutableArray args = new NSMutableArray(a.count()); for (int i = 0; i < a.count(); i++) { - NSDictionary ad = (NSDictionary)a.objectAtIndex(i); + NSDictionary ad = (NSDictionary) a.objectAtIndex(i); EOAttribute arg = new EOAttribute(ad, this); args.addObject(arg); } _arguments = args; } - setName((String)dict.objectForKey("name")); - setExternalName((String)dict.objectForKey("externalName")); + setName((String) dict.objectForKey("name")); + setExternalName((String) dict.objectForKey("externalName")); if (dict.objectForKey("userInfo") != null) - setUserInfo((NSDictionary)dict.objectForKey("userInfo")); + setUserInfo((NSDictionary) dict.objectForKey("userInfo")); if (dict.objectForKey("internalInfo") != null) - _internalInfo = (NSDictionary)dict.objectForKey("internalInfo"); + _internalInfo = (NSDictionary) dict.objectForKey("internalInfo"); } public EOStoredProcedure(String withName) { @@ -69,6 +70,7 @@ public class EOStoredProcedure implements EOPropertyListEncoding { public void setName(String value) { _name = value; } + public String name() { return _name; } @@ -76,6 +78,7 @@ public class EOStoredProcedure implements EOPropertyListEncoding { public void setExternalName(String value) { _externalName = value; } + public String externalName() { return _externalName; } @@ -83,6 +86,7 @@ public class EOStoredProcedure implements EOPropertyListEncoding { public void setArguments(NSArray value) { _arguments = value; } + public NSArray arguments() { return _arguments; } @@ -94,6 +98,7 @@ public class EOStoredProcedure implements EOPropertyListEncoding { public void setUserInfo(NSDictionary info) { _userInfo = info; } + public NSDictionary userInfo() { return _userInfo; } @@ -107,7 +112,7 @@ public class EOStoredProcedure implements EOPropertyListEncoding { NSMutableArray arr = new NSMutableArray(_arguments.count()); NSMutableDictionary d = null; for (int i = 0; i < _arguments.count(); i++) { - EOAttribute a = (EOAttribute)_arguments.objectAtIndex(i); + EOAttribute a = (EOAttribute) _arguments.objectAtIndex(i); d = new NSMutableDictionary(); a.encodeIntoPropertyList(d); arr.addObject(d); @@ -117,25 +122,23 @@ public class EOStoredProcedure implements EOPropertyListEncoding { } /* - * $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.4 2003/08/11 19:38:27 chochos - * Can now read from a file and re-write to another file. + * Revision 1.4 2003/08/11 19:38:27 chochos Can now read from a file and + * re-write to another file. * - * Revision 1.3 2003/08/09 01:36:32 chochos - * implement EOPropertyListEncoding + * Revision 1.3 2003/08/09 01:36:32 chochos implement EOPropertyListEncoding * - * Revision 1.2 2003/08/08 02:14:43 chochos - * can create a stored procedure from a property list. main accessors are in place. + * Revision 1.2 2003/08/08 02:14:43 chochos can create a stored procedure from a + * property list. main accessors are in place. * - * Revision 1.1 2003/08/07 02:41:04 chochos - * these don't do much for now. + * Revision 1.1 2003/08/07 02:41:04 chochos these don't do much for now. * -*/
\ No newline at end of file + */
\ No newline at end of file |
