cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r712417 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/gen/ main/resources/dotemplates/v1_2/ test/java/org/apache/cayenne/ test/java/org/apache/cayenne/testdo/mt/ test/java/org/apache/cayenne...
Date Sat, 08 Nov 2008 18:38:24 GMT
Author: aadamchik
Date: Sat Nov  8 10:38:23 2008
New Revision: 712417

URL: http://svn.apache.org/viewvc?rev=712417&view=rev
Log:
CAY-1113 Primitives in ROP support

support for boolean;
unit tests

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/ClientMtTableBool.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MtTableBool.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MultiTier.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_ClientMtTableBool.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MtTableBool.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MultiTier.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/client-superclass.vm
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/multi-tier.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java?rev=712417&r1=712416&r2=712417&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
Sat Nov  8 10:38:23 2008
@@ -30,6 +30,12 @@
 
     public static final String SUBCLASS_TEMPLATE = "dotemplates/v1_2/client-subclass.vm";
     public static final String SUPERCLASS_TEMPLATE = "dotemplates/v1_2/client-superclass.vm";
+    
+    public static final String DMAP_SINGLE_CLASS_TEMPLATE = "dotemplates/v1_2/datamap-singleclass.vm";
+    public static final String DMAP_SUBCLASS_TEMPLATE = "dotemplates/v1_2/datamap-subclass.vm";
+    public static final String DMAP_SUPERCLASS_TEMPLATE = "dotemplates/v1_2/datamap-superclass.vm";
+    
+    public static final String CLIENT_SUPERCLASS_PREFIX = "_Client";
 
     @Override
     protected String defaultTemplateName(TemplateType type) {
@@ -42,6 +48,11 @@
                 return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
             case EMBEDDABLE_SUPERCLASS:
                 return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
+            
+            case DATAMAP_SUPERCLASS:
+                return ClientClassGenerationAction.DMAP_SUPERCLASS_TEMPLATE;
+            case DATAMAP_SUBCLASS:
+                return ClientClassGenerationAction.DMAP_SUBCLASS_TEMPLATE;
             default:
                 throw new IllegalArgumentException("Unsupported template type: " + type);
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/client-superclass.vm
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/client-superclass.vm?rev=712417&r1=712416&r2=712417&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/client-superclass.vm
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/client-superclass.vm
Sat Nov  8 10:38:23 2008
@@ -83,13 +83,24 @@
 
 ## Create attribute set/get methods
 #foreach( $attr in ${object.DeclaredAttributes} )
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}()
{
+
+#if ( $importUtils.isBoolean(${attr.Type}) )
+	public boolean is${stringUtils.capitalized($attr.Name)}() {
+		if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${attr.Name}", false);
+        }
+
+        return ${attr.Name};
+    }
+#else 
+public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}()
{
         if(objectContext != null) {
             objectContext.prepareForAccess(this, "${attr.Name}", false);
         }
 
         return ${attr.Name};
     }
+#end
 #if ("true" != "${object.isReadOnly()}")
     public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type})
$stringUtils.formatVariableName(${attr.Name})) {
         if(objectContext != null) {
@@ -106,7 +117,6 @@
     }
 #end
 
-
 #end
 ##
 ##

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java?rev=712417&r1=712416&r2=712417&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
Sat Nov  8 10:38:23 2008
@@ -39,8 +39,10 @@
 import org.apache.cayenne.testdo.mt.ClientMtReflexive;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
+import org.apache.cayenne.testdo.mt.ClientMtTableBool;
 import org.apache.cayenne.testdo.mt.MtReflexive;
 import org.apache.cayenne.testdo.mt.MtTable1;
+import org.apache.cayenne.testdo.mt.MtTableBool;
 import org.apache.cayenne.unit.AccessStack;
 import org.apache.cayenne.unit.CayenneCase;
 import org.apache.cayenne.unit.CayenneResources;
@@ -77,6 +79,81 @@
 
         assertEquals(0, context.getQueryCache().size());
     }
+    
+    public void testSelect(){
+        insertValue();
+        DataContext context = createDataContext();
+        ClientServerChannel clientServerChannel = new ClientServerChannel(context);
+        UnitLocalConnection connection = new UnitLocalConnection(
+                clientServerChannel,
+                LocalConnection.HESSIAN_SERIALIZATION);
+        ClientChannel channel = new ClientChannel(connection);
+        CayenneContext clientContext = new CayenneContext(channel);
+    
+        SelectQuery query = new SelectQuery(ClientMtTableBool.class);
+ 
+        List<ClientMtTableBool> results = clientContext.performQuery(query);
+        assertTrue(results.get(1).isBlablacheck());
+        assertFalse(results.get(4).isBlablacheck());
+        
+        assertEquals(1, results.get(1).getNumber());
+        assertEquals(5, results.get(5).getNumber());
+
+    }
+    
+    public void testCommitChangesPrimitives(){
+        
+        DataContext dataContext = createDataContext();
+        
+        ClientConnection connection = new LocalConnection(new ClientServerChannel(
+                getDomain()));
+        ClientChannel channel = new ClientChannel(connection);
+        CayenneContext context = new CayenneContext(channel);
+        ClientMtTableBool obj  = context.newObject(ClientMtTableBool.class);
+        
+        obj.setBlablacheck(true);
+        obj.setNumber(3);
+        
+        context.commitChanges();
+        
+        SelectQuery query = new SelectQuery(MtTableBool.class);
+        List<MtTableBool> results = dataContext.performQuery(query);
+        
+        assertTrue(results.get(0).isBlablacheck());
+        assertEquals(3, results.get(0).getNumber());
+        
+        obj.setBlablacheck(false);
+        obj.setNumber(8);
+        context.commitChanges();
+        
+        query = new SelectQuery(MtTableBool.class);
+        results = dataContext.performQuery(query);
+        
+        assertFalse(results.get(0).isBlablacheck());
+        assertEquals(8, results.get(0).getNumber());
+        
+    }
+    
+    public void insertValue(){
+        DataContext context = createDataContext();
+        
+        MtTableBool obj ;
+        
+        for(int i=0;i<6;i++){
+            if(i<3){
+                obj = context.newObject(MtTableBool.class);
+                obj.setBlablacheck(true);
+                obj.setNumber(i);
+                context.commitChanges();
+            }
+            else{
+                obj = context.newObject(MtTableBool.class);
+                obj.setBlablacheck(false);
+                obj.setNumber(i);
+                context.commitChanges();
+            }
+        }
+    }
 
     public void testPrePersistCallback() throws Exception {
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/ClientMtTableBool.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/ClientMtTableBool.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/ClientMtTableBool.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/ClientMtTableBool.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,10 @@
+package org.apache.cayenne.testdo.mt;
+
+import org.apache.cayenne.testdo.mt.auto._ClientMtTableBool;
+
+/**
+ * A persistent class mapped as "MtTableBool" Cayenne entity.
+ */
+public class ClientMtTableBool extends _ClientMtTableBool {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MtTableBool.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MtTableBool.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MtTableBool.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MtTableBool.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.mt;
+
+import org.apache.cayenne.testdo.mt.auto._MtTableBool;
+
+public class MtTableBool extends _MtTableBool {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MultiTier.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MultiTier.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MultiTier.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/MultiTier.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,18 @@
+package org.apache.cayenne.testdo.mt;
+
+import org.apache.cayenne.testdo.mt.auto._MultiTier;
+
+public class MultiTier extends _MultiTier {
+
+    private static MultiTier instance;
+
+    private MultiTier() {}
+
+    public static MultiTier getInstance() {
+        if(instance == null) {
+            instance = new MultiTier();
+        }
+
+        return instance;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_ClientMtTableBool.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_ClientMtTableBool.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_ClientMtTableBool.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_ClientMtTableBool.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,68 @@
+package org.apache.cayenne.testdo.mt.auto;
+
+import org.apache.cayenne.PersistentObject;
+
+/**
+ * A generated persistent class mapped as "MtTableBool" Cayenne entity. It is a good idea
to
+ * avoid changing this class manually, since it will be overwritten next time code is
+ * regenerated. If you need to make any customizations, put them in a subclass.
+ */
+public abstract class _ClientMtTableBool extends PersistentObject {
+
+    public static final String BLABLACHECK_PROPERTY = "blablacheck";
+    public static final String NUMBER_PROPERTY = "number";
+
+    protected boolean blablacheck;
+    protected int number;
+
+
+	public boolean isBlablacheck() {
+		if(objectContext != null) {
+            objectContext.prepareForAccess(this, "blablacheck", false);
+        }
+
+        return blablacheck;
+    }
+    public void setBlablacheck(boolean blablacheck) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "blablacheck", false);
+        }
+
+        Object oldValue = this.blablacheck;
+        this.blablacheck = blablacheck;
+
+        // notify objectContext about simple property change
+        if(objectContext != null) {
+            objectContext.propertyChanged(this, "blablacheck", oldValue, blablacheck);
+        }
+    }
+
+
+
+
+
+public int getNumber() {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "number", false);
+        }
+
+        return number;
+    }
+    public void setNumber(int number) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "number", false);
+        }
+
+        Object oldValue = this.number;
+        this.number = number;
+
+        // notify objectContext about simple property change
+        if(objectContext != null) {
+            objectContext.propertyChanged(this, "number", oldValue, number);
+        }
+    }
+
+
+
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MtTableBool.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MtTableBool.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MtTableBool.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MtTableBool.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,34 @@
+package org.apache.cayenne.testdo.mt.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+
+/**
+ * Class _MtTableBool was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _MtTableBool extends CayenneDataObject {
+
+    public static final String BLABLACHECK_PROPERTY = "blablacheck";
+    public static final String NUMBER_PROPERTY = "number";
+
+    public static final String ID_PK_COLUMN = "id";
+
+    public void setBlablacheck(boolean blablacheck) {
+        writeProperty("blablacheck", blablacheck);
+    }
+	public boolean isBlablacheck() {
+        Boolean value = (Boolean)readProperty("blablacheck");
+        return (value != null) ? value.booleanValue() : false;
+    }
+
+    public void setNumber(int number) {
+        writeProperty("number", number);
+    }
+    public int getNumber() {
+        Object value = readProperty("number");
+        return (value != null) ? (Integer) value : 0;
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MultiTier.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MultiTier.java?rev=712417&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MultiTier.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/mt/auto/_MultiTier.java
Sat Nov  8 10:38:23 2008
@@ -0,0 +1,36 @@
+package org.apache.cayenne.testdo.mt.auto;
+
+import java.util.List;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.query.NamedQuery;
+import org.apache.cayenne.testdo.mt.MtTable1;
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class _MultiTier {
+
+    public List<MtTable1> performAllMtTable1(ObjectContext context ) {
+        return context.performQuery(new NamedQuery("AllMtTable1"));
+    }
+
+    public List<MtTable1> performMtQueryWithLocalCache(ObjectContext context ) {
+        return context.performQuery(new NamedQuery("MtQueryWithLocalCache"));
+    }
+
+    public List<MtTable1> performParameterizedMtQueryWithLocalCache(ObjectContext context
, String g) {
+        String[] parameters = {
+            "g",
+        };
+
+        Object[] values = {
+            g,
+        };
+
+        return context.performQuery(new NamedQuery("ParameterizedMtQueryWithLocalCache",
parameters, values));
+    }
+}
\ No newline at end of file

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/multi-tier.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/multi-tier.map.xml?rev=712417&r1=712416&r2=712417&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/multi-tier.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/multi-tier.map.xml
Sat Nov  8 10:38:23 2008
@@ -63,6 +63,11 @@
 	<db-entity name="MT_TABLE5">
 		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 	</db-entity>
+	<db-entity name="MT_TABLE_BOOL">
+		<db-attribute name="blablacheck" type="BOOLEAN"/>
+		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="number" type="INTEGER"/>
+	</db-entity>
 	<obj-entity name="MtDeleteCascade" className="org.apache.cayenne.testdo.mt.MtDeleteCascade"
clientClassName="org.apache.cayenne.testdo.mt.ClientMtDeleteCascade" dbEntityName="MT_DELETE_CASCADE">
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
 	</obj-entity>
@@ -104,6 +109,10 @@
 	</obj-entity>
 	<obj-entity name="MtTable5" className="org.apache.cayenne.testdo.mt.MtTable5" clientClassName="org.apache.cayenne.testdo.mt.ClientMtTable5"
dbEntityName="MT_TABLE5">
 	</obj-entity>
+	<obj-entity name="MtTableBool" className="org.apache.cayenne.testdo.mt.MtTableBool" clientClassName="org.apache.cayenne.testdo.mt.ClientMtTableBool"
dbEntityName="MT_TABLE_BOOL">
+		<obj-attribute name="blablacheck" type="boolean" db-attribute-path="blablacheck"/>
+		<obj-attribute name="number" type="int" db-attribute-path="number"/>
+	</obj-entity>
 	<db-relationship name="cascade" source="MT_DELETE_CASCADE" target="MT_DELETE_RULE" toMany="false">
 		<db-attribute-pair source="DELETE_RULE_ID" target="DELETE_RULE_ID"/>
 	</db-relationship>



Mime
View raw message