diff options
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java')
| -rw-r--r-- | projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EOModelGroup.java | 79 |
1 files changed, 40 insertions, 39 deletions
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 |
