cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r718500 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/trans/ test/java/org/apache/cayenne/access/trans/
Date Tue, 18 Nov 2008 06:35:40 GMT
Author: aadamchik
Date: Mon Nov 17 22:35:39 2008
New Revision: 718500

URL: http://svn.apache.org/viewvc?rev=718500&view=rev
Log:
CAY-795 Horizontal inheritance

refactoring of root entity lookup methods to prepare for multi-DbEntity processing;
adding some semantical spice to QueryAssembleHelper API

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssembler.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/TstQueryAssembler.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteTranslator.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteTranslator.java
Mon Nov 17 22:35:39 2008
@@ -22,6 +22,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.JoinType;
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.DeleteQuery;
 
 /**
@@ -31,6 +32,16 @@
  * @deprecated since 3.0 since {@link DeleteQuery} is deprecated.
  */
 public class DeleteTranslator extends QueryAssembler {
+    
+    @Override
+    public DbEntity getRootDbEntity() {
+        return query.getMetaData(entityResolver).getDbEntity();
+    }
+    
+    @Override
+    public ObjEntity getRootEntity() {
+        return query.getMetaData(entityResolver).getObjEntity();
+    }
 
     @Override
     public void dbRelationshipAdded(

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssembler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssembler.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssembler.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssembler.java
Mon Nov 17 22:35:39 2008
@@ -64,15 +64,15 @@
     protected Map<String, String> getPathAliases() {
         return query.getMetaData(entityResolver).getPathSplitAliases();
     }
-    
+
     public EntityResolver getEntityResolver() {
         return entityResolver;
     }
-    
+
     public DbAdapter getAdapter() {
         return adapter;
     }
-    
+
     /**
      * Returns an EntityInheritanceTree for the root entity.
      * 
@@ -81,7 +81,7 @@
     public EntityInheritanceTree getRootInheritanceTree() {
         return getEntityResolver().lookupInheritanceTree(getRootEntity());
     }
-    
+
     /**
      * Returns query object being processed.
      */
@@ -105,13 +105,9 @@
         this.entityResolver = entityResolver;
     }
 
-    public ObjEntity getRootEntity() {
-        return query.getMetaData(entityResolver).getObjEntity();
-    }
+    public abstract ObjEntity getRootEntity();
 
-    public DbEntity getRootDbEntity() {
-        return query.getMetaData(entityResolver).getDbEntity();
-    }
+    public abstract DbEntity getRootDbEntity();
 
     /**
      * A callback invoked by a child qualifier or ordering processor allowing query

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
Mon Nov 17 22:35:39 2008
@@ -65,11 +65,18 @@
         return queryAssembler.getRootDbEntity();
     }
 
-    public void appendPart(Appendable out) throws IOException {
+    /**
+     * @since 3.0
+     */
+    public <T extends Appendable> T appendPart(T out) throws IOException {
         this.out = out;
         doAppendPart();
+        return out;
     }
 
+    /**
+     * @since 3.0
+     */
     protected abstract void doAppendPart() throws IOException;
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
Mon Nov 17 22:35:39 2008
@@ -88,6 +88,16 @@
      */
     boolean forcingDistinct;
 
+    @Override
+    public DbEntity getRootDbEntity() {
+        return query.getMetaData(entityResolver).getDbEntity();
+    }
+
+    @Override
+    public ObjEntity getRootEntity() {
+        return query.getMetaData(entityResolver).getObjEntity();
+    }
+
     protected JoinStack createJoinStack() {
         return new JoinStack();
     }
@@ -104,13 +114,12 @@
         this.resultColumns = buildResultColumns();
 
         // build qualifier
-        StringBuilder qualifierBuffer = new StringBuilder();
-        adapter.getQualifierTranslator(this).appendPart(qualifierBuffer);
+        StringBuilder qualifierBuffer = adapter.getQualifierTranslator(this).appendPart(
+                new StringBuilder());
 
         // build ORDER BY
         OrderingTranslator orderingTranslator = new OrderingTranslator(this);
-        StringBuilder orderingBuffer = new StringBuilder();
-        orderingTranslator.appendPart(orderingBuffer);
+        StringBuilder orderingBuffer = orderingTranslator.appendPart(new StringBuilder());
 
         // assemble
         StringBuilder queryBuf = new StringBuilder();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateTranslator.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateTranslator.java
Mon Nov 17 22:35:39 2008
@@ -27,6 +27,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.JoinType;
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.UpdateQuery;
 
 /**
@@ -44,6 +45,16 @@
             String joinSplitAlias) {
         throw new UnsupportedOperationException("db relationships not supported");
     }
+    
+    @Override
+    public DbEntity getRootDbEntity() {
+        return query.getMetaData(entityResolver).getDbEntity();
+    }
+    
+    @Override
+    public ObjEntity getRootEntity() {
+        return query.getMetaData(entityResolver).getObjEntity();
+    }
 
     @Override
     public String getCurrentAlias() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/TstQueryAssembler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/TstQueryAssembler.java?rev=718500&r1=718499&r2=718500&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/TstQueryAssembler.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/TstQueryAssembler.java
Mon Nov 17 22:35:39 2008
@@ -25,8 +25,10 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.JoinType;
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.Query;
 
 public class TstQueryAssembler extends QueryAssembler {
@@ -46,6 +48,16 @@
         super.setEntityResolver(node.getEntityResolver());
         super.setQuery(q);
     }
+    
+    @Override
+    public DbEntity getRootDbEntity() {
+        return query.getMetaData(entityResolver).getDbEntity();
+    }
+    
+    @Override
+    public ObjEntity getRootEntity() {
+        return query.getMetaData(entityResolver).getObjEntity();
+    }
 
     public void dispose() throws SQLException {
         connection.close();



Mime
View raw message