From 40a9d99496e098562f090fb7ffce9e749011b131 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 20 May 2024 17:58:16 -0400 Subject: Formatting pass --- .../java/net/wotonomy/access/EORelationship.java | 113 +++++++++++---------- 1 file changed, 61 insertions(+), 52 deletions(-) (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/access/EORelationship.java') 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 -- cgit v1.2.3