cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: add table types into configuration
Date Fri, 12 Dec 2014 08:47:43 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master b8ddcdafa -> 75d49a95c


add table types into configuration


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/75d49a95
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/75d49a95
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/75d49a95

Branch: refs/heads/master
Commit: 75d49a95cc1a3c66e10c3374d50337838fae86a8
Parents: b8ddcda
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Authored: Thu Dec 11 21:01:02 2014 +0300
Committer: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Committed: Thu Dec 11 21:05:13 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/access/DbLoader.java     | 12 +++---
 .../apache/cayenne/tools/DbImporterTask.java    | 10 +++++
 .../tools/dbimport/DbImportConfiguration.java   |  4 ++
 .../tools/dbimport/config/AntNestedElement.java |  4 ++
 .../config/DefaultReverseEngineeringLoader.java | 12 ++++++
 .../dbimport/config/ReverseEngineering.java     | 31 ++++++++++++++
 .../cayenne/tools/DbImporterTaskTest.java       |  5 +++
 .../tools/dbimport/DbImportActionTest.java      |  6 +--
 .../DefaultReverseEngineeringLoaderTest.java    | 13 ++++++
 .../apache/cayenne/tools/build-table-types.xml  | 40 ++++++++++++++++++
 .../config/reverseEngineering-tableTypes.xml    | 29 +++++++++++++
 .../apache/cayenne/tools/DbImporterMojo.java    |  1 +
 .../tools/DbImporterMojoConfigurationTest.java  |  5 +++
 .../cayenne/tools/DbImporterMojoTest.java       |  4 ++
 .../cayenne/tools/config/pom-table-types.xml    | 41 +++++++++++++++++++
 .../tools/dbimport/testTableTypes-pom.xml       | 43 ++++++++++++++++++++
 .../dbimport/testTableTypes.map.xml-result      | 29 +++++++++++++
 .../cayenne/tools/dbimport/testTableTypes.sql   | 25 ++++++++++++
 18 files changed, 305 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
index 0e38ce9..7acda33 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
@@ -697,7 +697,7 @@ public class DbLoader {
      *
      * @since 1.0.7
      * @deprecated since 4.0 use
-     * {@link #load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration, String...)}
+     * {@link #load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)}
      * method that supports catalogs.
      */
     @Deprecated
@@ -717,7 +717,7 @@ public class DbLoader {
      * of tables to read.
      *
      * @deprecated since 4.0 use
-     * {@link #load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration, String...)}
+     * {@link #load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)}
      * method that supports catalogs.
      */
     @Deprecated
@@ -730,7 +730,7 @@ public class DbLoader {
                 new DbPath(null, schemaPattern), transformPatternToFilter(tablePattern),
TRUE, NULL)));
         config.setTableTypes(tableTypes);
 
-        load(dataMap, config, tableTypes);
+        load(dataMap, config);
         return dataMap;
     }
 
@@ -751,9 +751,9 @@ public class DbLoader {
      *
      * @since 4.0
      */
-    public void load(DataMap dataMap, DbLoaderConfiguration config, String... tableTypes)
throws SQLException {
+    public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException {
 
-        Map<DbPath, Map<String, DbEntity>> tables = getTables(config, tableTypes);
+        Map<DbPath, Map<String, DbEntity>> tables = getTables(config, config.getTableTypes());
         List<DbEntity> entities = loadDbEntities(dataMap, config, tables);
 
         if (entities != null) {
@@ -777,7 +777,7 @@ public class DbLoader {
     public DataMap load(DbLoaderConfiguration config) throws SQLException {
 
         DataMap dataMap = new DataMap();
-        load(dataMap, config, config.getTableTypes());
+        load(dataMap, config);
         loadProcedures(dataMap, config);
 
         return dataMap;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
index 43df27b..5750531 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
@@ -19,10 +19,14 @@
 package org.apache.cayenne.tools;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 
 import org.apache.cayenne.access.loader.filters.EntityFilters;
 import org.apache.cayenne.access.loader.filters.FilterFactory;
 import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.tools.dbimport.config.AntNestedElement;
 import org.apache.cayenne.tools.dbimport.config.Catalog;
 import org.apache.cayenne.tools.dbimport.config.ExcludeColumn;
 import org.apache.cayenne.tools.dbimport.config.ExcludeProcedure;
@@ -71,6 +75,8 @@ public class DbImporterTask extends Task {
 
         Log logger = new AntLogger(this);
         config.setLogger(logger);
+        config.setTableTypes(reverseEngineering.getTableTypes());
+        
         Injector injector = DIBootstrap.createInjector(new ToolsModule(logger), new DbImportModule());
 
         try {
@@ -261,6 +267,10 @@ public class DbImporterTask extends Task {
         reverseEngineering.addCatalog(catalog);
     }
 
+    public void addConfiguredTableType(AntNestedElement type) {
+        reverseEngineering.addTableType(type.getName());
+    }
+
     public ReverseEngineering getReverseEngineering() {
         return reverseEngineering;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
index a116801..51c22bf 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
@@ -325,4 +325,8 @@ public class DbImportConfiguration {
     public void setSkipRelationshipsLoading(Boolean skipRelationshipsLoading) {
         this.dbLoaderConfiguration.setSkipRelationshipsLoading(skipRelationshipsLoading);
     }
+
+    public void setTableTypes(String[] tableTypes) {
+        dbLoaderConfiguration.setTableTypes(tableTypes);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/AntNestedElement.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/AntNestedElement.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/AntNestedElement.java
index 08512dc..c8a801b 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/AntNestedElement.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/AntNestedElement.java
@@ -32,6 +32,10 @@ public class AntNestedElement {
         return name;
     }
 
+    public void setName(String name) {
+        this.name = name;
+    }
+
     public void addText(String str) {
         name = str;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoader.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoader.java
index 216e218..f7c3d97 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoader.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoader.java
@@ -58,6 +58,8 @@ public class DefaultReverseEngineeringLoader implements ReverseEngineeringLoader
 
             Element root = doc.getDocumentElement();
             engineering.setSkipRelationshipsLoading(loadBoolean(root, "skipRelationshipsLoading"));
+            engineering.setTableTypes(loadTableTypes(root));
+
             engineering.setCatalogs(loadCatalogs(root));
             engineering.setSchemas(loadSchemas(root));
             engineering.setIncludeTables(loadIncludeTables(root));
@@ -158,6 +160,16 @@ public class DefaultReverseEngineeringLoader implements ReverseEngineeringLoader
         return res;
     }
 
+    private Collection<String> loadTableTypes(Node parent) {
+        List<Node> types = getElementsByTagName(parent, "tableType");
+        Collection<String> res = new LinkedList<String>();
+        for (Node typeNode : types) {
+            res.add(loadName(typeNode));
+        }
+
+        return res;
+    }
+
     private String loadName(Node catalogNode) {
         return loadByName(catalogNode, "name");
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/ReverseEngineering.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/ReverseEngineering.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/ReverseEngineering.java
index 1d372f2..b668ff9 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/ReverseEngineering.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/ReverseEngineering.java
@@ -29,6 +29,13 @@ public class ReverseEngineering extends FilterContainer {
 
     private Boolean skipRelationshipsLoading;
 
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    private Collection<String> tableTypes = new LinkedList<String>();
+
     private Collection<Catalog> catalogs = new LinkedList<Catalog>();
     private Collection<Schema> schemas = new LinkedList<Schema>();
 
@@ -59,6 +66,28 @@ public class ReverseEngineering extends FilterContainer {
         this.schemas = schemas;
     }
 
+    public String[] getTableTypes() {
+        return tableTypes.toArray(new String[tableTypes.size()]);
+    }
+
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    public void setTableTypes(Collection<String> tableTypes) {
+        this.tableTypes = tableTypes;
+    }
+
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    public void addTableType(String type) {
+        this.tableTypes.add(type);
+    }
+
     public void addSchema(Schema schema) {
         this.schemas.add(schema);
     }
@@ -84,4 +113,6 @@ public class ReverseEngineering extends FilterContainer {
 
         return res.toString();
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
index 9121132..62aebe9 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
@@ -81,6 +81,11 @@ public class DbImporterTaskTest {
 		assertSkipRelationshipsLoading(getCdbImport("build-skip-relationships-loading.xml").getReverseEngineering());
 	}
 
+    @Test
+    public void testTableTypes() throws Exception {
+        assertTableTypes(getCdbImport("build-table-types.xml").getReverseEngineering());
+    }
+
 	@Test
 	public void testIncludeTable() throws Exception {
 		test("build-include-table.xml");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
index 018ebb8..a2fb0f1 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DbImportActionTest.java
@@ -88,7 +88,7 @@ public class DbImportActionTest {
 
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config, String ... tables)
throws SQLException {
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
                  new DataMapBuilder(dataMap).withDbEntities(2).build();
             }
 
@@ -129,7 +129,7 @@ public class DbImportActionTest {
     public void testImportWithFieldChanged() throws Exception {
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config, String ... tables)
throws SQLException {
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("GROUP_ID").typeInt().primaryKey(),
@@ -198,7 +198,7 @@ public class DbImportActionTest {
     public void testImportWithoutChanges() throws Exception {
         DbLoader dbLoader = new DbLoader(null, null, null) {
             @Override
-            public void load(DataMap dataMap, DbLoaderConfiguration config, String ... tables)
throws SQLException {
+            public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
{
                 new DataMapBuilder(dataMap).with(
                         dbEntity("ARTGROUP").attributes(
                                 dbAttr("NAME").typeVarchar(100).mandatory()

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java
b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java
index ff3e04d..7b0f21b 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java
@@ -27,6 +27,7 @@ import java.io.File;
 import java.net.MalformedURLException;
 import java.util.Iterator;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -210,6 +211,18 @@ public class DefaultReverseEngineeringLoaderTest {
         assertTrue(engineering.getSkipRelationshipsLoading());
     }
 
+    @Test
+    public void testTableTypes() throws Exception {
+        ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+                .load(getResource("reverseEngineering-tableTypes.xml"));
+
+        assertTableTypes(engineering);
+    }
+
+    public static void assertTableTypes(ReverseEngineering engineering) {
+        assertArrayEquals(engineering.getTableTypes(), new String[]{"type1", "type2", "type3"});
+    }
+
     protected URLResource getResource(String file) throws MalformedURLException {
 		return new URLResource(getClass().getResource(file));
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
new file mode 100644
index 0000000..6985520
--- /dev/null
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
@@ -0,0 +1,40 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"  />
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+            <tableType>type1</tableType>
+
+            <tableType name="type2" />
+            <tableType name="type3" />
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-tableTypes.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-tableTypes.xml
b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-tableTypes.xml
new file mode 100644
index 0000000..f9ea8ca
--- /dev/null
+++ b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-tableTypes.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<reverseEngineering>
+    <tableType>type1</tableType>
+
+    <tableType name="type2" />
+
+    <tableType>
+        <name>type3</name>
+    </tableType>
+</reverseEngineering>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
index 93ce3c8..e60794b 100644
--- a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
+++ b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
@@ -277,6 +277,7 @@ public class DbImporterMojo extends AbstractMojo {
         config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering)
                 .add(filterBuilder.build()).filtersConfig());
         config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
+        config.setTableTypes(reverseEngineering.getTableTypes());
         return config;
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
index 97736a7..8606277 100644
--- a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
+++ b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
@@ -80,6 +80,11 @@ public class DbImporterMojoConfigurationTest extends AbstractMojoTestCase
{
         assertSkipRelationshipsLoading(getCdbImport("pom-skip-relationships-loading.xml").getReverseEngineering());
     }
 
+    @Test
+    public void testTableTypes() throws Exception {
+        assertTableTypes(getCdbImport("pom-table-types.xml").getReverseEngineering());
+    }
+
     private DbImporterMojo getCdbImport(String pomFileName) throws Exception {
         return (DbImporterMojo) lookupMojo("cdbimport",
                 getTestFile("src/test/resources/org/apache/cayenne/tools/config/" + pomFileName));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
index 5aa2093..98d8f0c 100644
--- a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
+++ b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
@@ -108,6 +108,10 @@ public class DbImporterMojoTest extends AbstractMojoTestCase {
 		test("testViewsExclude");
 	}
 	
+	public void testTableTypes() throws Exception {
+		test("testTableTypes");
+	}
+
 	public void testDefaultPackage() throws Exception {
 		test("testDefaultPackage");
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-table-types.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-table-types.xml
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-table-types.xml
new file mode 100644
index 0000000..60aed11
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/config/pom-table-types.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+	http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-cayenne-plugin</artifactId>
+                <configuration>
+                    <map>target/test/org/apache/cayenne/tools/dbimporter-map1.map.xml</map>
+
+                    <reverseEngineering>
+                        <tableType>type1</tableType>
+                        <tableType>type2</tableType>
+                        <tableType>type3</tableType>
+                    </reverseEngineering>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes-pom.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes-pom.xml
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes-pom.xml
new file mode 100644
index 0000000..4f7bbb7
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes-pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+	http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+	<name>DbImporterMojo Test1</name>	
+
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-cayenne-plugin</artifactId>
+				<configuration>
+					<map>target/test-classes/org/apache/cayenne/tools/dbimport/testTableTypes.map.xml</map>
+                    <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+                    <url>jdbc:derby:memory:DbImporterMojoTest;create=true</url>
+
+                    <reverseEngineering>
+                        <tableType>TABLE</tableType>
+                    </reverseEngineering>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.map.xml-result
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.map.xml-result
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.map.xml-result
new file mode 100644
index 0000000..805898d
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.map.xml-result
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
+          project-version="7">
+    <db-entity name="PERSON" schema="APP">
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"
length="10"/>
+    </db-entity>
+    <obj-entity name="Person" className="Person" dbEntityName="PERSON">
+    </obj-entity>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/75d49a95/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.sql
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.sql
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.sql
new file mode 100644
index 0000000..cb7d3f5
--- /dev/null
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testTableTypes.sql
@@ -0,0 +1,25 @@
+--  Licensed to the Apache Software Foundation (ASF) under one
+--  or more contributor license agreements.  See the NOTICE file
+--  distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+--  to you under the Apache License, Version 2.0 (the
+--  "License"); you may not use this file except in compliance
+--  with the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+--  Unless required by applicable law or agreed to in writing,
+--  software distributed under the License is distributed on an
+--  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+--  KIND, either express or implied.  See the License for the
+--  specific language governing permissions and limitations
+--  under the License.
+
+CREATE TABLE Person (
+  id INTEGER NOT NULL,
+
+  PRIMARY KEY (id)
+);
+
+CREATE VIEW girl (id) AS SELECT id FROM Person;
+CREATE VIEW v_vview (id) AS SELECT id FROM Person;
\ No newline at end of file


Mime
View raw message