cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r734492 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/merge/ test/java/org/apache/cayenne/merge/ test/java/org/apache/cayenne/util/ test/resources/
Date Wed, 14 Jan 2009 19:46:40 GMT
Author: andrey
Date: Wed Jan 14 11:46:39 2009
New Revision: 734492

URL: http://svn.apache.org/viewvc?rev=734492&view=rev
Log:
CAY-1169 Weird behavior when adding entity via merging
2,3,4,5

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/CreateTableToModelTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java?rev=734492&r1=734491&r2=734492&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
Wed Jan 14 11:46:39 2009
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.merge;
 
-import org.apache.cayenne.CayenneDataObject;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
@@ -31,7 +30,12 @@
  */
 public class CreateTableToModel extends AbstractToModelToken.Entity {
 
-    private String objEntityClassName = CayenneDataObject.class.getName();
+    /**
+     * className if {@link ObjEntity} should be generated with a
+     *  special class name.
+     * Setting this to <code>null</code>, because by default class name should
be generated 
+     */
+    private String objEntityClassName = null; //CayenneDataObject.class.getName();
 
     public CreateTableToModel(DbEntity entity) {
         super(entity);
@@ -42,7 +46,7 @@
      * special class name. Set to null if the {@link ObjEntity} should be created with a
      * name based on {@link DataMap#getDefaultPackage()} and {@link ObjEntity#getName()}
      * <p>
-     * The default value is the class name of {@link CayenneDataObject}
+     * The default value is <code>null</code>
      */
     public void setObjEntityClassName(String n) {
         objEntityClassName = n;
@@ -79,6 +83,22 @@
         }
 
         objEntity.setClassName(className);
+        
+        objEntity.setSuperClassName(map.getDefaultSuperclass());
+        
+        if (map.isClientSupported()) {
+            String clientPkg = map.getDefaultClientPackage();
+            if (clientPkg != null) {
+                if (!clientPkg.endsWith(".")) {
+                    clientPkg = clientPkg + ".";
+                }
+
+                objEntity.setClientClassName(clientPkg + objEntity.getName());
+            }
+
+            objEntity.setClientSuperClassName(map.getDefaultClientSuperclass());
+        }
+        
         map.addObjEntity(objEntity);
 
         synchronizeWithObjEntity(getEntity());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/CreateTableToModelTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/CreateTableToModelTest.java?rev=734492&r1=734491&r2=734492&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/CreateTableToModelTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/CreateTableToModelTest.java
Wed Jan 14 11:46:39 2009
@@ -69,6 +69,12 @@
             }
         }
         assertNotNull(objEntity);
+        
+        assertEquals(objEntity.getClassName(), map.getDefaultPackage() + "." + objEntity.getName());
+        assertEquals(objEntity.getSuperClassName(), map.getDefaultSuperclass());
+        assertEquals(objEntity.getClientClassName(), 
+                map.getDefaultClientPackage() + "." + objEntity.getName());
+        assertEquals(objEntity.getClientSuperClassName(), map.getDefaultClientSuperclass());
 
         assertEquals(1, objEntity.getAttributes().size());
         assertEquals("java.lang.String", objEntity

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java?rev=734492&r1=734491&r2=734492&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
Wed Jan 14 11:46:39 2009
@@ -90,5 +90,10 @@
                  DeleteRule.DEFAULT_DELETE_RULE_TO_MANY);
          assertEquals(((ObjRelationship) objEntity2.getRelationship("rel2To1")).getDeleteRule(),
                  DeleteRule.DEFAULT_DELETE_RULE_TO_ONE);
+         
+         map.removeObjEntity(objEntity2.getName());
+         map.removeObjEntity(objEntity1.getName());
+         map.removeDbEntity(dbEntity2.getName());
+         map.removeDbEntity(dbEntity1.getName());
      }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml?rev=734492&r1=734491&r2=734492&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
Wed Jan 14 11:46:39 2009
@@ -1,6 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <data-map project-version="3.0">
 	<property name="defaultPackage" value="org.apache.art"/>
+	<property name="defaultSuperclass" value="org.apache.cayenne.CayenneDataObject"/>
+	<property name="clientSupported" value="true"/>
+	<property name="defaultClientPackage" value="test.client"/>
+	<property name="defaultClientSuperclass" value="org.apache.cayenne.PersistentObject"/>
+	
 	<procedure name="cayenne_tst_out_proc">
 		<procedure-parameter name="in_param" type="INTEGER" direction="in"/>
 		<procedure-parameter name="out_param" type="INTEGER" direction="out"/>



Mime
View raw message