cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1407494 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/
Date Fri, 09 Nov 2012 15:30:41 GMT
Author: aadamchik
Date: Fri Nov  9 15:30:40 2012
New Revision: 1407494

URL: http://svn.apache.org/viewvc?rev=1407494&view=rev
Log:
CAY-1762 cdbimport improvements: Support for "defaultPackage" parameter, as the new DataMaps
ends up placing entities in the root package

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
    cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1407494&r1=1407493&r2=1407494&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Nov  9 15:30:40 2012
@@ -26,6 +26,7 @@ CAY-1754 Modeler suggested URL for SQLSe
 CAY-1759 cdbimport improvements: add 'catalog', rename 'schemaName' to 'schema'
 CAY-1760 cdbimport improvements: Default adapter (if none specified) must be AutoAdapter,
not JdbcAdapter 
 CAY-1761 cdbimport improvements: DbLoader must reverse engineer PK auto-increment state.

+CAY-1762 cdbimport improvements: Support for "defaultPackage" parameter, as the new DataMaps
ends up placing entities in the root package 
 
 Bug Fixes:
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java?rev=1407494&r1=1407493&r2=1407494&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
Fri Nov  9 15:30:40 2012
@@ -144,6 +144,8 @@ public class DbLoaderTest extends Server
         boolean supportsFK = accessStackAdapter.supportsFKConstraints();
 
         DataMap map = new DataMap();
+        map.setDefaultPackage("foo.x");
+        
         String tableLabel = adapter.tableTypeForTable();
 
         // *** TESTING THIS ***
@@ -195,20 +197,7 @@ public class DbLoaderTest extends Server
         loader.setCreatingMeaningfulPK(false);
         loader.loadObjEntities(map);
 
-        ObjEntity ae = map.getObjEntity("Artist");
-        assertNotNull(ae);
-        assertEquals("Artist", ae.getName());
-        // assert primary key is not an attribute
-        assertNull(ae.getAttribute("artistId"));
-        if (supportsLobs) {
-            assertLobObjEntities(map);
-        }
-
-        if (supportsFK) {
-            Collection<?> rels1 = ae.getRelationships();
-            assertNotNull(rels1);
-            assertTrue(rels1.size() > 0);
-        }
+        assertObjEntities(map);
 
         // now when the map is loaded, test
         // various things
@@ -258,6 +247,31 @@ public class DbLoaderTest extends Server
         }
     }
 
+    private void assertObjEntities(DataMap map) {
+
+        boolean supportsLobs = accessStackAdapter.supportsLobs();
+        boolean supportsFK = accessStackAdapter.supportsFKConstraints();
+
+        ObjEntity ae = map.getObjEntity("Artist");
+        assertNotNull(ae);
+        assertEquals("Artist", ae.getName());
+        
+        // assert primary key is not an attribute
+        assertNull(ae.getAttribute("artistId"));
+        
+        if (supportsLobs) {
+            assertLobObjEntities(map);
+        }
+
+        if (supportsFK) {
+            Collection<?> rels1 = ae.getRelationships();
+            assertNotNull(rels1);
+            assertTrue(rels1.size() > 0);
+        }
+        
+        assertEquals("foo.x.Artist", ae.getClassName());
+    }
+
     private void assertLobDbEntities(DataMap map) {
         DbEntity blobEnt = getDbEntity(map, "BLOB_TEST");
         assertNotNull(blobEnt);

Modified: cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java?rev=1407494&r1=1407493&r2=1407494&view=diff
==============================================================================
--- cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
(original)
+++ cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
Fri Nov  9 15:30:40 2012
@@ -67,6 +67,16 @@ public class DbImporterMojo extends Abst
     private File map;
 
     /**
+     * A default package for ObjEntity Java classes. If not specified, and the
+     * existing DataMap already has the default package, the existing package
+     * will be used.
+     * 
+     * @parameter expression="${cdbimport.defaultPackage}"
+     * @since 3.2
+     */
+    private String defaultPackage;
+
+    /**
      * Indicates whether existing DB and object entities should be overwritten.
      * This is an all-or-nothing setting. If you need finer granularity, please
      * use the Cayenne Modeler.
@@ -248,6 +258,13 @@ public class DbImporterMojo extends Abst
         }
 
         DataMap dataMap = map.exists() ? loadDataMap() : new DataMap();
+
+        // do not override default package of existsing DataMap unless it is
+        // explicitly requested by the plugin caller
+        if (defaultPackage != null && defaultPackage.length() > 0) {
+            dataMap.setDefaultPackage(defaultPackage);
+        }
+
         String[] types = loader.getDefaultTableTypes();
         loader.load(dataMap, catalog, schema, tablePattern, types);
 



Mime
View raw message