Author: aadamchik
Date: Thu Nov 15 19:37:53 2012
New Revision: 1409946

URL: http://svn.apache.org/viewvc?rev=1409946&view=rev
Log:
CAY-1772  Real support for DbEntity catalogs

* entity full name must include catalog
* building identifiers with quoting strategy must incldue catalog

Modified:
    
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java
    
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
    
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java

Modified: 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java?rev=1409946&r1=1409945&r2=1409946&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java
 Thu Nov 15 19:37:53 2012
@@ -39,10 +39,17 @@ class DefaultQuotingStrategy implements 
 
     public String quoteFullyQualifiedName(DbEntity entity) {
         StringBuilder buf = new StringBuilder();
+        
+        if(entity.getCatalog() != null) {
+            buf.append(quoteString(entity.getCatalog())).append(".");
+        }
+        
         if (entity.getSchema() != null) {
             buf.append(quoteString(entity.getSchema())).append(".");
         }
+        
         buf.append(quoteString(entity.getName()));
+        
         return buf.toString();
     }
 }
\ No newline at end of file

Modified: 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=1409946&r1=1409945&r2=1409946&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
 Thu Nov 15 19:37:53 2012
@@ -49,7 +49,8 @@ import org.apache.cayenne.util.XMLEncode
 import org.apache.commons.collections.Transformer;
 
 /**
- * A DbEntity is a mapping descriptor that defines a structure of a database 
table.
+ * A DbEntity is a mapping descriptor that defines a structure of a database
+ * table.
  */
 public class DbEntity extends Entity implements ConfigurationNode, 
DbEntityListener, DbAttributeListener,
         DbRelationshipListener {
@@ -65,7 +66,8 @@ public class DbEntity extends Entity imp
     protected DbKeyGenerator primaryKeyGenerator;
 
     /**
-     * Qualifier, that will be applied to all select queries and joins with 
this DbEntity
+     * Qualifier, that will be applied to all select queries and joins with 
this
+     * DbEntity
      */
     protected Expression qualifier;
 
@@ -86,7 +88,7 @@ public class DbEntity extends Entity imp
         this();
         this.setName(name);
     }
-    
+
     /**
      * @since 3.1
      */
@@ -136,10 +138,16 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Returns table name including schema, if present.
+     * Returns table name including catalog and schema, if any of those are
+     * present.
      */
     public String getFullyQualifiedName() {
-        return (schema != null) ? schema + '.' + getName() : getName();
+
+        if (catalog != null) {
+            return (schema != null) ? catalog + '.' + schema + '.' + name : 
catalog + '.' + name;
+        } else {
+            return (schema != null) ? schema + '.' + name : name;
+        }
     }
 
     /**
@@ -173,8 +181,8 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Returns an unmodifiable collection of DbAttributes representing the 
primary key of
-     * the table described by this DbEntity.
+     * Returns an unmodifiable collection of DbAttributes representing the
+     * primary key of the table described by this DbEntity.
      * 
      * @since 3.0
      */
@@ -183,8 +191,8 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Returns a Collection of all attributes that either belong to this 
DbEntity or
-     * inherited.
+     * Returns a Collection of all attributes that either belong to this
+     * DbEntity or inherited.
      */
     @Override
     public Collection<DbAttribute> getAttributes() {
@@ -192,8 +200,8 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Returns an unmodifiable collection of DbAttributes that are generated 
by the
-     * database.
+     * Returns an unmodifiable collection of DbAttributes that are generated by
+     * the database.
      * 
      * @since 1.2
      */
@@ -204,10 +212,11 @@ public class DbEntity extends Entity imp
     /**
      * Adds a new attribute to this entity.
      * 
-     * @throws IllegalArgumentException if Attribute has no name or there is 
an existing
-     *             attribute with the same name
-     * @throws IllegalArgumentException if a relationship has the same name as 
this
-     *             attribute
+     * @throws IllegalArgumentException
+     *             if Attribute has no name or there is an existing attribute
+     *             with the same name
+     * @throws IllegalArgumentException
+     *             if a relationship has the same name as this attribute
      * @since 3.0
      */
     public void addAttribute(DbAttribute attr) {
@@ -216,8 +225,9 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Removes attribute from the entity, removes any relationship joins 
containing this
-     * attribute. Does nothing if the attribute name is not found.
+     * Removes attribute from the entity, removes any relationship joins
+     * containing this attribute. Does nothing if the attribute name is not
+     * found.
      * 
      * @see org.apache.cayenne.map.Entity#removeAttribute(String)
      */
@@ -272,54 +282,45 @@ public class DbEntity extends Entity imp
      */
     @Override
     @SuppressWarnings("unchecked")
-    public PathComponent<DbAttribute, DbRelationship> lastPathComponent(
-            Expression path,
-            Map aliasMap) {
+    public PathComponent<DbAttribute, DbRelationship> 
lastPathComponent(Expression path, Map aliasMap) {
         return super.lastPathComponent(path, aliasMap);
     }
 
     /**
-     * Returns an Iterable instance over expression path components based on 
this entity.
+     * Returns an Iterable instance over expression path components based on
+     * this entity.
      * 
      * @since 3.0
      */
     @Override
     @SuppressWarnings("unchecked")
-    public Iterable<PathComponent<DbAttribute, DbRelationship>> resolvePath(
-            final Expression pathExp,
-            final Map aliasMap) {
+    public Iterable<PathComponent<DbAttribute, DbRelationship>> 
resolvePath(final Expression pathExp, final Map aliasMap) {
 
         if (pathExp.getType() == Expression.DB_PATH) {
 
             return new Iterable<PathComponent<DbAttribute, DbRelationship>>() {
 
                 public Iterator iterator() {
-                    return new PathComponentIterator(DbEntity.this, (String) 
pathExp
-                            .getOperand(0), aliasMap);
+                    return new PathComponentIterator(DbEntity.this, (String) 
pathExp.getOperand(0), aliasMap);
                 }
             };
         }
 
-        throw new ExpressionException("Invalid expression type: '"
-                + pathExp.expName()
-                + "',  DB_PATH is expected.");
+        throw new ExpressionException("Invalid expression type: '" + 
pathExp.expName() + "',  DB_PATH is expected.");
     }
 
     @Override
-    public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp)
-            throws ExpressionException {
+    public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) 
throws ExpressionException {
         if (pathExp.getType() != Expression.DB_PATH) {
-            throw new ExpressionException("Invalid expression type: '"
-                    + pathExp.expName()
-                    + "',  DB_PATH is expected.");
+            throw new ExpressionException("Invalid expression type: '" + 
pathExp.expName() + "',  DB_PATH is expected.");
         }
 
         return new PathIterator((String) pathExp.getOperand(0));
     }
 
     /**
-     * Set the primary key generator for this entity. If null is passed, 
nothing is
-     * changed.
+     * Set the primary key generator for this entity. If null is passed, 
nothing
+     * is changed.
      */
     public void setPrimaryKeyGenerator(DbKeyGenerator primaryKeyGenerator) {
         this.primaryKeyGenerator = primaryKeyGenerator;
@@ -336,9 +337,9 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * DbEntity property changed event. May be name, attribute or relationship 
added or
-     * removed, etc. Attribute and relationship property changes are handled 
in respective
-     * listeners.
+     * DbEntity property changed event. May be name, attribute or relationship
+     * added or removed, etc. Attribute and relationship property changes are
+     * handled in respective listeners.
      * 
      * @since 1.2
      */
@@ -353,7 +354,8 @@ public class DbEntity extends Entity imp
             String newName = e.getNewName();
             DataMap map = getDataMap();
             if (map != null) {
-                // handle all of the relationship target names that need to be 
changed
+                // handle all of the relationship target names that need to be
+                // changed
                 for (DbEntity dbe : map.getDbEntities()) {
                     for (DbRelationship relationship : dbe.getRelationships()) 
{
                         if (relationship.getTargetEntity() == this) {
@@ -427,7 +429,8 @@ public class DbEntity extends Entity imp
             if (map != null) {
                 for (DbEntity ent : map.getDbEntities()) {
 
-                    // handle all of the dependent object entity attribute 
changes
+                    // handle all of the dependent object entity attribute
+                    // changes
                     for (ObjEntity oe : map.getMappedEntities(ent)) {
                         for (ObjAttribute attr : oe.getAttributes()) {
                             if (attr.getDbAttribute() == dbAttribute) {
@@ -436,7 +439,8 @@ public class DbEntity extends Entity imp
                         }
                     }
 
-                    // handle all of the relationships / joins that use the 
changed
+                    // handle all of the relationships / joins that use the
+                    // changed
                     // attribute
                     for (Relationship rel : ent.getRelationships()) {
                         for (DbJoin join : ((DbRelationship) rel).getJoins()) {
@@ -461,46 +465,46 @@ public class DbEntity extends Entity imp
         // handle PK refresh
         if (primaryKey.contains(dbAttribute) || dbAttribute.isPrimaryKey()) {
             switch (e.getId()) {
-                case MapEvent.ADD:
-                    this.primaryKey.add(dbAttribute);
-                    break;
+            case MapEvent.ADD:
+                this.primaryKey.add(dbAttribute);
+                break;
 
-                case MapEvent.REMOVE:
-                    this.primaryKey.remove(dbAttribute);
-                    break;
+            case MapEvent.REMOVE:
+                this.primaryKey.remove(dbAttribute);
+                break;
 
-                default:
-                    // generic update
-                    this.primaryKey.clear();
-                    for (Object next : getAttributes()) {
-                        DbAttribute dba = (DbAttribute) next;
-                        if (dba.isPrimaryKey()) {
-                            this.primaryKey.add(dba);
-                        }
+            default:
+                // generic update
+                this.primaryKey.clear();
+                for (Object next : getAttributes()) {
+                    DbAttribute dba = (DbAttribute) next;
+                    if (dba.isPrimaryKey()) {
+                        this.primaryKey.add(dba);
                     }
+                }
             }
         }
 
         // handle generated key refresh
         if (generatedAttributes.contains(dbAttribute) || 
dbAttribute.isGenerated()) {
             switch (e.getId()) {
-                case MapEvent.ADD:
-                    this.generatedAttributes.add(dbAttribute);
-                    break;
+            case MapEvent.ADD:
+                this.generatedAttributes.add(dbAttribute);
+                break;
 
-                case MapEvent.REMOVE:
-                    this.generatedAttributes.remove(dbAttribute);
-                    break;
+            case MapEvent.REMOVE:
+                this.generatedAttributes.remove(dbAttribute);
+                break;
 
-                default:
-                    // generic update
-                    this.generatedAttributes.clear();
-                    for (Object next : getAttributes()) {
-                        DbAttribute dba = (DbAttribute) next;
-                        if (dba.isGenerated()) {
-                            this.generatedAttributes.add(dba);
-                        }
+            default:
+                // generic update
+                this.generatedAttributes.clear();
+                for (Object next : getAttributes()) {
+                    DbAttribute dba = (DbAttribute) next;
+                    if (dba.isGenerated()) {
+                        this.generatedAttributes.add(dba);
                     }
+                }
             }
         }
     }
@@ -525,19 +529,19 @@ public class DbEntity extends Entity imp
         // handle relationship name changes
         if (e.getId() == RelationshipEvent.CHANGE && e.isNameChange()) {
             String oldName = e.getOldName();
-            
+
             DataMap map = getDataMap();
             if (map != null) {
-                
+
                 // updating dbAttributePaths for attributes of all ObjEntities
                 for (ObjEntity objEntity : getDataMap().getObjEntities()) {
-                    
+
                     for (ObjAttribute attribute : objEntity.getAttributes()) {
                         attribute.updateDbAttributePath();
                     }
                 }
             }
-            
+
             // clear the relationship out of the collection
             relationships.remove(oldName);
 
@@ -557,7 +561,8 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * @return qualifier that will be ANDed to all select queries with this 
entity
+     * @return qualifier that will be ANDed to all select queries with this
+     *         entity
      */
     public Expression getQualifier() {
         return qualifier;
@@ -571,8 +576,9 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Returns true if there is full replacement id is attached to an 
ObjectId. "Full"
-     * means that all PK columns are present and only PK columns are present.
+     * Returns true if there is full replacement id is attached to an ObjectId.
+     * "Full" means that all PK columns are present and only PK columns are
+     * present.
      * 
      * @since 1.2
      */
@@ -597,15 +603,13 @@ public class DbEntity extends Entity imp
     }
 
     /**
-     * Transforms Expression rooted in this entity to an analogous expression 
rooted in
-     * related entity.
+     * Transforms Expression rooted in this entity to an analogous expression
+     * rooted in related entity.
      * 
      * @since 1.1
      */
     @Override
-    public Expression translateToRelatedEntity(
-            Expression expression,
-            String relationshipPath) {
+    public Expression translateToRelatedEntity(Expression expression, String 
relationshipPath) {
 
         if (expression == null) {
             return null;
@@ -651,31 +655,39 @@ public class DbEntity extends Entity imp
 
             String path = (String) expression.getOperand(0);
             String converted = translatePath(path);
-            Expression transformed = ExpressionFactory
-                    .expressionOfType(Expression.DB_PATH);
+            Expression transformed = 
ExpressionFactory.expressionOfType(Expression.DB_PATH);
             transformed.setOperand(0, converted);
             return transformed;
         }
-        
+
         private PathComponentIterator createPathIterator(String path) {
-            return new PathComponentIterator(DbEntity.this, path, 
-                    new HashMap<String, String>()); //TODO: do we need aliases 
here?
+            return new PathComponentIterator(DbEntity.this, path, new 
HashMap<String, String>()); // TODO:
+                                                                               
                   // do
+                                                                               
                   // we
+                                                                               
                   // need
+                                                                               
                   // aliases
+                                                                               
                   // here?
         }
 
         String translatePath(String path) {
 
             // algorithm to determine the translated path:
-            // 0. If relationship has at least one to-many component, travel 
all the way
+            // 0. If relationship has at least one to-many component, travel 
all
+            // the way
             // back, and then all the way forward
-            // 1. If relationship path equals to input, travel one step back, 
and then one
+            // 1. If relationship path equals to input, travel one step back,
+            // and then one
             // step forward.
-            // 2. If input completely includes relationship path, use input's 
remaining
+            // 2. If input completely includes relationship path, use input's
+            // remaining
             // tail.
-            // 3. If relationship path and input have none or some leading 
components in
+            // 3. If relationship path and input have none or some leading
+            // components in
             // common,
             // (a) strip common leading part;
             // (b) reverse the remaining relationship part;
-            // (c) append remaining input to the reversed remaining 
relationship.
+            // (c) append remaining input to the reversed remaining
+            // relationship.
 
             // case (0)
             if (toMany) {
@@ -705,7 +717,8 @@ public class DbEntity extends Entity imp
                 LinkedList<String> finalPath = new LinkedList<String>();
                 PathComponentIterator pathIt = createPathIterator(path);
 
-                // just do one step back and one step forward to create 
correct joins...
+                // just do one step back and one step forward to create correct
+                // joins...
                 // find last rel...
                 DbRelationship lastDBR = null;
 
@@ -783,40 +796,30 @@ public class DbEntity extends Entity imp
             return converted.toString();
         }
 
-        private void prependReversedPath(
-                LinkedList<String> finalPath,
-                DbRelationship relationship) {
+        private void prependReversedPath(LinkedList<String> finalPath, 
DbRelationship relationship) {
             DbRelationship revNextDBR = relationship.getReverseRelationship();
 
             if (revNextDBR == null) {
-                throw new CayenneRuntimeException(
-                        "Unable to find reverse DbRelationship for "
-                                + relationship.getSourceEntity().getName()
-                                + Entity.PATH_SEPARATOR
-                                + relationship.getName()
-                                + ".");
+                throw new CayenneRuntimeException("Unable to find reverse 
DbRelationship for "
+                        + relationship.getSourceEntity().getName() + 
Entity.PATH_SEPARATOR + relationship.getName()
+                        + ".");
             }
 
             finalPath.addFirst(revNextDBR.getName());
         }
 
-        private void appendPath(
-                LinkedList<String> finalPath,
-                CayenneMapEntry pathComponent) {
+        private void appendPath(LinkedList<String> finalPath, CayenneMapEntry 
pathComponent) {
             finalPath.addLast(pathComponent.getName());
         }
-        
-        private void appendPath(
-                LinkedList<String> finalPath,
-                PathComponent<Attribute, Relationship> pathComponent) {
-            CayenneMapEntry mapEntry = pathComponent.getAttribute() != null ?
-                pathComponent.getAttribute() :
-                pathComponent.getRelationship();
+
+        private void appendPath(LinkedList<String> finalPath, 
PathComponent<Attribute, Relationship> pathComponent) {
+            CayenneMapEntry mapEntry = pathComponent.getAttribute() != null ? 
pathComponent.getAttribute()
+                    : pathComponent.getRelationship();
             String name = mapEntry.getName();
             if (pathComponent.getJoinType() == JoinType.LEFT_OUTER) {
                 name += OUTER_JOIN_INDICATOR;
             }
-            
+
             finalPath.addLast(name);
         }
     }

Modified: 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java?rev=1409946&r1=1409945&r2=1409946&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java
 Thu Nov 15 19:37:53 2012
@@ -56,9 +56,7 @@ public class DbEntityTest extends Server
         assertTrue(d2.getPrimaryKeys().contains(pk2));
 
         assertNotNull(d2.getGeneratedAttributes());
-        assertEquals(entity.getGeneratedAttributes().size(), d2
-                .getGeneratedAttributes()
-                .size());
+        assertEquals(entity.getGeneratedAttributes().size(), 
d2.getGeneratedAttributes().size());
 
         DbAttribute generated2 = (DbAttribute) 
d2.getAttribute(generated.getName());
         assertNotNull(generated2);
@@ -76,9 +74,7 @@ public class DbEntityTest extends Server
         generated.setGenerated(true);
         entity.addAttribute(generated);
 
-        DbEntity d2 = (DbEntity) HessianUtil.cloneViaClientServerSerialization(
-                entity,
-                new EntityResolver());
+        DbEntity d2 = (DbEntity) 
HessianUtil.cloneViaClientServerSerialization(entity, new EntityResolver());
 
         assertNotNull(d2.getPrimaryKeys());
         assertEquals(entity.getPrimaryKeys().size(), 
d2.getPrimaryKeys().size());
@@ -88,9 +84,7 @@ public class DbEntityTest extends Server
         assertTrue(d2.getPrimaryKeys().contains(pk2));
 
         assertNotNull(d2.getGeneratedAttributes());
-        assertEquals(entity.getGeneratedAttributes().size(), d2
-                .getGeneratedAttributes()
-                .size());
+        assertEquals(entity.getGeneratedAttributes().size(), 
d2.getGeneratedAttributes().size());
 
         DbAttribute generated2 = (DbAttribute) 
d2.getAttribute(generated.getName());
         assertNotNull(generated2);
@@ -122,19 +116,25 @@ public class DbEntityTest extends Server
     }
 
     public void testFullyQualifiedName() {
-        DbEntity ent = new DbEntity("abc");
-
-        String tstName = "tst_name";
-        String schemaName = "tst_schema_name";
-        ent.setName(tstName);
-
-        assertEquals(tstName, ent.getName());
-        assertEquals(tstName, ent.getFullyQualifiedName());
 
-        ent.setSchema(schemaName);
+        DbEntity e1 = new DbEntity("e1");
+        assertEquals("e1", e1.getFullyQualifiedName());
 
-        assertEquals(tstName, ent.getName());
-        assertEquals(schemaName + "." + tstName, ent.getFullyQualifiedName());
+        DbEntity e2 = new DbEntity("e2");
+        e2.setSchema("s2");
+        assertEquals("e2", e2.getName());
+        assertEquals("s2.e2", e2.getFullyQualifiedName());
+
+        DbEntity e3 = new DbEntity("e3");
+        e3.setSchema("s3");
+        e3.setCatalog("c3");
+        assertEquals("e3", e3.getName());
+        assertEquals("c3.s3.e3", e3.getFullyQualifiedName());
+        
+        DbEntity e4 = new DbEntity("e4");
+        e4.setCatalog("c4");
+        assertEquals("e4", e4.getName());
+        assertEquals("c4.e4", e4.getFullyQualifiedName());
     }
 
     public void testGetPrimaryKey() {
@@ -237,67 +237,47 @@ public class DbEntityTest extends Server
     }
 
     public void testTranslateToRelatedEntityIndependentPath() {
-        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity(
-                "ARTIST");
+        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity("ARTIST");
 
         Expression e1 = Expression.fromString("db:paintingArray");
-        Expression translated = artistE
-                .translateToRelatedEntity(e1, "artistExhibitArray");
-        assertEquals("failure: " + translated, Expression
-                .fromString("db:toArtist.paintingArray"), translated);
+        Expression translated = artistE.translateToRelatedEntity(e1, 
"artistExhibitArray");
+        assertEquals("failure: " + translated, 
Expression.fromString("db:toArtist.paintingArray"), translated);
     }
 
     public void testTranslateToRelatedEntityTrimmedPath() {
-        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity(
-                "ARTIST");
+        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity("ARTIST");
 
         Expression e1 = 
Expression.fromString("db:artistExhibitArray.toExhibit");
-        Expression translated = artistE
-                .translateToRelatedEntity(e1, "artistExhibitArray");
-        assertEquals("failure: " + translated, Expression
-                .fromString("db:toArtist.artistExhibitArray.toExhibit"), 
translated);
+        Expression translated = artistE.translateToRelatedEntity(e1, 
"artistExhibitArray");
+        assertEquals("failure: " + translated, 
Expression.fromString("db:toArtist.artistExhibitArray.toExhibit"),
+                translated);
     }
 
     public void testTranslateToRelatedEntitySplitHalfWay() {
-        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity(
-                "ARTIST");
+        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity("ARTIST");
 
-        Expression e1 = Expression
-                .fromString("db:paintingArray.toPaintingInfo.TEXT_REVIEW");
-        Expression translated = artistE.translateToRelatedEntity(
-                e1,
-                "paintingArray.toGallery");
-        assertEquals(
-                "failure: " + translated,
-                Expression
-                        
.fromString("db:paintingArray.toArtist.paintingArray.toPaintingInfo.TEXT_REVIEW"),
-                translated);
+        Expression e1 = 
Expression.fromString("db:paintingArray.toPaintingInfo.TEXT_REVIEW");
+        Expression translated = artistE.translateToRelatedEntity(e1, 
"paintingArray.toGallery");
+        assertEquals("failure: " + translated,
+                
Expression.fromString("db:paintingArray.toArtist.paintingArray.toPaintingInfo.TEXT_REVIEW"),
 translated);
     }
 
     public void testTranslateToRelatedEntityMatchingPath() {
-        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity(
-                "ARTIST");
+        DbEntity artistE = 
runtime.getDataDomain().getEntityResolver().getDbEntity("ARTIST");
 
         Expression e1 = 
Expression.fromString("db:artistExhibitArray.toExhibit");
-        Expression translated = artistE.translateToRelatedEntity(
-                e1,
-                "artistExhibitArray.toExhibit");
-
-        assertEquals(
-                "failure: " + translated,
-                Expression
-                        
.fromString("db:artistExhibitArray.toArtist.artistExhibitArray.toExhibit"),
-                translated);
+        Expression translated = artistE.translateToRelatedEntity(e1, 
"artistExhibitArray.toExhibit");
+
+        assertEquals("failure: " + translated,
+                
Expression.fromString("db:artistExhibitArray.toArtist.artistExhibitArray.toExhibit"),
 translated);
     }
 
     public void testTranslateToRelatedEntityToOne() {
-        DbEntity paintingE = 
runtime.getDataDomain().getEntityResolver().getDbEntity(
-                "PAINTING");
+        DbEntity paintingE = 
runtime.getDataDomain().getEntityResolver().getDbEntity("PAINTING");
 
         Expression e1 = Expression.fromString("db:toArtist.ARTIST_NAME = 
'aa'");
         Expression translated = paintingE.translateToRelatedEntity(e1, 
"toArtist");
 
-        assertEquals("failure: " + translated, Expression
-                .fromString("db:ARTIST_NAME = 'aa'"), translated);
+        assertEquals("failure: " + translated, 
Expression.fromString("db:ARTIST_NAME = 'aa'"), translated);
     }
 }


Reply via email to