http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Schema.java ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Schema.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Schema.java deleted file mode 100644 index b92cad7..0000000 --- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Schema.java +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************** - * 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. - ****************************************************************/ -package org.apache.cayenne.tools.dbimport.config; - -/** - * @since 4.0. - */ -public class Schema extends FilterContainer { - - private String name; - - public Schema() { - } - - public Schema(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void set(String name) { - setName(name); - } - - public void addConfiguredName(AntNestedElement name) { - setName(name.getName()); - } - - public void addText(String name) { - if (name.trim().isEmpty()) { - return; - } - - setName(name); - } - - @Override - public StringBuilder toString(StringBuilder res, String prefix) { - res.append(prefix).append("Schema: ").append(name).append("\n"); - - return super.toString(res, prefix + " "); - } -}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Type.java ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Type.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Type.java index fa7413f..b995c62 100644 --- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Type.java +++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/Type.java @@ -20,17 +20,32 @@ package org.apache.cayenne.tools.dbimport.config; import org.apache.cayenne.util.ToStringBuilder; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + /** * @since 4.0. */ +@XmlAccessorType(XmlAccessType.FIELD) public class Type { + @XmlElement(name = "jdbc") private String jdbc; + + @XmlElement(name = "java") private String java; + @XmlElement(name = "length") private Integer length; + + @XmlElement(name = "precision") private Integer precision; + + @XmlElement(name = "scale") private Integer scale; + + @XmlElement(name = "notNull") private Boolean notNull; public String getJdbc() { http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/TypeMapper.java ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/TypeMapper.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/TypeMapper.java index c83215e..048c753 100644 --- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/TypeMapper.java +++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/TypeMapper.java @@ -21,18 +21,24 @@ package org.apache.cayenne.tools.dbimport.config; import org.apache.cayenne.util.EqualsBuilder; import org.apache.cayenne.util.HashCodeBuilder; +import javax.xml.bind.annotation.*; import java.util.Collection; import java.util.LinkedList; /** * @since 4.0. */ +@XmlRootElement(name = "typeMapper") +@XmlAccessorType(XmlAccessType.FIELD) public class TypeMapper { + @XmlElement(name = "mapperClassName") private String mapperClassName; + @XmlElement(name = "usePrimitives") private Boolean usePrimitives; + @XmlElement(name = "type") private Collection<Type> types = new LinkedList<Type>(); public String getMapperClassName() { http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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 075d88d..c597036 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 @@ -18,12 +18,7 @@ ****************************************************************/ package org.apache.cayenne.tools; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalog; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalogAndSchema; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertFlat; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertSchema; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertSkipRelationshipsLoading; -import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertTableTypes; +import static org.apache.cayenne.dbimport.DefaultReverseEngineeringLoaderTest.*; import static org.apache.commons.lang.StringUtils.isBlank; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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 b49c873..7b90bd3 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 @@ -18,35 +18,6 @@ */ package org.apache.cayenne.tools.dbimport; -import static java.util.Arrays.asList; -import static org.apache.cayenne.merge.builders.ObjectMother.dbAttr; -import static org.apache.cayenne.merge.builders.ObjectMother.dbEntity; -import static org.apache.cayenne.merge.builders.ObjectMother.objAttr; -import static org.apache.cayenne.merge.builders.ObjectMother.objEntity; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.stub; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.net.URL; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; - -import javax.sql.DataSource; - import org.apache.cayenne.CayenneRuntimeException; import org.apache.cayenne.access.DbLoader; import org.apache.cayenne.access.DbLoaderDelegate; @@ -77,16 +48,41 @@ import org.apache.commons.logging.Log; import org.junit.Test; import org.xml.sax.InputSource; -public class DbImportActionTest { +import javax.sql.DataSource; +import java.io.File; +import java.net.URL; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; - public static final File FILE_STUB = new File("") { +import static java.util.Arrays.asList; +import static org.apache.cayenne.merge.builders.ObjectMother.dbAttr; +import static org.apache.cayenne.merge.builders.ObjectMother.dbEntity; +import static org.apache.cayenne.merge.builders.ObjectMother.objAttr; +import static org.apache.cayenne.merge.builders.ObjectMother.objEntity; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.stub; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; - private static final long serialVersionUID = -7513956717393115824L; +public class DbImportActionTest { - @Override - public boolean exists() { - return true; - } + public static final File FILE_STUB = new File("") { + @Override + public boolean exists() { + return true; + } @Override public boolean canRead() { @@ -109,9 +105,9 @@ public class DbImportActionTest { } }; - DbImportConfiguration params = mock(DbImportConfiguration.class); - when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))).thenReturn( - dbLoader); + DbImportConfiguration params = mock(DbImportConfiguration.class); + when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))) + .thenReturn(dbLoader); when(params.createDataMap()).thenReturn(new DataMap("testImport")); when(params.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate()); @@ -120,11 +116,11 @@ public class DbImportActionTest { final DataMap DATA_MAP = new DataMap(); when(params.initializeDataMap(any(DataMap.class))).thenReturn(DATA_MAP); - final boolean[] haveWeTriedToSave = { false }; - DbImportAction action = buildDbImportAction(new FileProjectSaver() { - @Override - public void save(Project project) { - haveWeTriedToSave[0] = true; + final boolean[] haveWeTriedToSave = {false}; + DbImportActionDefault action = buildDbImportAction(new FileProjectSaver() { + @Override + public void save(Project project) { + haveWeTriedToSave[0] = true; // Validation phase assertEquals(DATA_MAP, project.getRootNode()); @@ -136,18 +132,22 @@ public class DbImportActionTest { assertTrue("We should try to save.", haveWeTriedToSave[0]); } - @Test - public void testImportWithFieldChanged() throws Exception { - DbLoader dbLoader = new DbLoader(null, null, null) { - @Override - public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException { - new DataMapBuilder(dataMap).with( - dbEntity("ARTGROUP").attributes(dbAttr("GROUP_ID").typeInt().primaryKey(), - dbAttr("NAME").typeVarchar(100).mandatory(), - dbAttr("NAME_01").typeVarchar(100).mandatory(), dbAttr("PARENT_GROUP_ID").typeInt())) - .with(objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes( - objAttr("name").type(String.class).dbPath("NAME"))); - } + @Test + public void testImportWithFieldChanged() throws Exception { + DbLoader dbLoader = new DbLoader(null, null, null) { + @Override + public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException { + new DataMapBuilder(dataMap).with( + dbEntity("ARTGROUP").attributes( + dbAttr("GROUP_ID").typeInt().primaryKey(), + dbAttr("NAME").typeVarchar(100).mandatory(), + dbAttr("NAME_01").typeVarchar(100).mandatory(), + dbAttr("PARENT_GROUP_ID").typeInt() + )).with( + objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes( + objAttr("name").type(String.class).dbPath("NAME") + )); + } @Override public String[] getDefaultTableTypes() { @@ -155,20 +155,20 @@ public class DbImportActionTest { } }; - DbImportConfiguration params = mock(DbImportConfiguration.class); - when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))).thenReturn( - dbLoader); + DbImportConfiguration params = mock(DbImportConfiguration.class); + when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))) + .thenReturn(dbLoader); when(params.createDataMap()).thenReturn(new DataMap("testImport")); when(params.getDataMapFile()).thenReturn(FILE_STUB); when(params.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate()); when(params.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration()); - final boolean[] haveWeTriedToSave = { false }; - DbImportAction action = buildDbImportAction(new FileProjectSaver() { - @Override - public void save(Project project) { - haveWeTriedToSave[0] = true; + final boolean[] haveWeTriedToSave = {false}; + DbImportActionDefault action = buildDbImportAction(new FileProjectSaver() { + @Override + public void save(Project project) { + haveWeTriedToSave[0] = true; // Validation phase DataMap rootNode = (DataMap) project.getRootNode(); @@ -182,29 +182,35 @@ public class DbImportActionTest { } }, new MapLoader() { - @Override - public synchronized DataMap loadDataMap(InputSource src) throws CayenneRuntimeException { - return new DataMapBuilder() - .with(dbEntity("ARTGROUP").attributes(dbAttr("GROUP_ID").typeInt().primaryKey(), - dbAttr("NAME").typeVarchar(100).mandatory(), dbAttr("PARENT_GROUP_ID").typeInt())) - .with(objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes( - objAttr("name").type(String.class).dbPath("NAME"))).build(); - } - }); + @Override + public synchronized DataMap loadDataMap(InputSource src) throws CayenneRuntimeException { + return new DataMapBuilder().with( + dbEntity("ARTGROUP").attributes( + dbAttr("GROUP_ID").typeInt().primaryKey(), + dbAttr("NAME").typeVarchar(100).mandatory(), + dbAttr("PARENT_GROUP_ID").typeInt() + )).with( + objEntity("org.apache.cayenne.testdo.testmap", "ArtGroup", "ARTGROUP").attributes( + objAttr("name").type(String.class).dbPath("NAME") + )).build(); + } + }); action.execute(params); assertTrue("We should try to save.", haveWeTriedToSave[0]); } - @Test - public void testImportWithoutChanges() throws Exception { - DbLoader dbLoader = new DbLoader(null, null, null) { - @Override - public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException { - new DataMapBuilder(dataMap).with(dbEntity("ARTGROUP").attributes( - dbAttr("NAME").typeVarchar(100).mandatory())); - } + @Test + public void testImportWithoutChanges() throws Exception { + DbLoader dbLoader = new DbLoader(null, null, null) { + @Override + public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException { + new DataMapBuilder(dataMap).with( + dbEntity("ARTGROUP").attributes( + dbAttr("NAME").typeVarchar(100).mandatory() + )); + } @Override public String[] getDefaultTableTypes() { @@ -212,9 +218,9 @@ public class DbImportActionTest { } }; - DbImportConfiguration params = mock(DbImportConfiguration.class); - when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))).thenReturn( - dbLoader); + DbImportConfiguration params = mock(DbImportConfiguration.class); + when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))) + .thenReturn(dbLoader); when(params.createDataMap()).thenReturn(new DataMap("testImport")); when(params.getDataMapFile()).thenReturn(FILE_STUB); @@ -228,12 +234,13 @@ public class DbImportActionTest { FileProjectSaver projectSaver = mock(FileProjectSaver.class); doNothing().when(projectSaver).save(any(Project.class)); - MapLoader mapLoader = mock(MapLoader.class); - stub(mapLoader.loadDataMap(any(InputSource.class))).toReturn( - new DataMapBuilder().with(dbEntity("ARTGROUP").attributes(dbAttr("NAME").typeVarchar(100).mandatory())) - .build()); + MapLoader mapLoader = mock(MapLoader.class); + stub(mapLoader.loadDataMap(any(InputSource.class))).toReturn(new DataMapBuilder().with( + dbEntity("ARTGROUP").attributes( + dbAttr("NAME").typeVarchar(100).mandatory() + )).build()); - DbImportAction action = buildDbImportAction(log, projectSaver, mapLoader); + DbImportActionDefault action = buildDbImportAction(log, projectSaver, mapLoader); action.execute(params); @@ -247,9 +254,9 @@ public class DbImportActionTest { when(dbLoader.getDefaultTableTypes()).thenReturn(null); doThrow(new SQLException()).when(dbLoader).load(any(DataMap.class), any(DbLoaderConfiguration.class)); - DbImportConfiguration params = mock(DbImportConfiguration.class); - when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))).thenReturn( - dbLoader); + DbImportConfiguration params = mock(DbImportConfiguration.class); + when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))) + .thenReturn(dbLoader); FileProjectSaver projectSaver = mock(FileProjectSaver.class); doNothing().when(projectSaver).save(any(Project.class)); @@ -257,7 +264,7 @@ public class DbImportActionTest { MapLoader mapLoader = mock(MapLoader.class); when(mapLoader.loadDataMap(any(InputSource.class))).thenReturn(null); - DbImportAction action = buildDbImportAction(projectSaver, mapLoader); + DbImportActionDefault action = buildDbImportAction(projectSaver, mapLoader); try { action.execute(params); @@ -270,18 +277,17 @@ public class DbImportActionTest { verify(mapLoader, never()).loadDataMap(any(InputSource.class)); } - private DbImportAction buildDbImportAction(FileProjectSaver projectSaver, MapLoader mapLoader) throws Exception { - Log log = mock(Log.class); - when(log.isDebugEnabled()).thenReturn(true); - when(log.isInfoEnabled()).thenReturn(true); + private DbImportActionDefault buildDbImportAction(FileProjectSaver projectSaver, MapLoader mapLoader) throws Exception { + Log log = mock(Log.class); + when(log.isDebugEnabled()).thenReturn(true); + when(log.isInfoEnabled()).thenReturn(true); return buildDbImportAction(log, projectSaver, mapLoader); } - private DbImportAction buildDbImportAction(Log log, FileProjectSaver projectSaver, MapLoader mapLoader) - throws Exception { - DbAdapter dbAdapter = mock(DbAdapter.class); - when(dbAdapter.mergerFactory()).thenReturn(new MergerFactory()); + private DbImportActionDefault buildDbImportAction(Log log, FileProjectSaver projectSaver, MapLoader mapLoader) throws Exception { + DbAdapter dbAdapter = mock(DbAdapter.class); + when(dbAdapter.mergerFactory()).thenReturn(new MergerFactory()); DbAdapterFactory adapterFactory = mock(DbAdapterFactory.class); when(adapterFactory.createAdapter(any(DataNodeDescriptor.class), any(DataSource.class))).thenReturn(dbAdapter); @@ -290,15 +296,15 @@ public class DbImportActionTest { DataSource mock = mock(DataSource.class); when(dataSourceFactory.getDataSource(any(DataNodeDescriptor.class))).thenReturn(mock); - return new DbImportAction(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader); - } + return new DbImportActionDefault(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader); + } @Test public void testSaveLoaded() throws Exception { Log log = mock(Log.class); Injector i = DIBootstrap.createInjector(new ToolsModule(log), new DbImportModule()); - DbImportAction action = i.getInstance(DbImportAction.class); + DbImportActionDefault action = (DbImportActionDefault) i.getInstance(DbImportAction.class); String packagePath = getClass().getPackage().getName().replace('.', '/'); URL packageUrl = getClass().getClassLoader().getResource(packagePath); @@ -328,9 +334,9 @@ public class DbImportActionTest { tokens.add(new CreateTableToDb(null)); tokens.add(new CreateTableToModel(null)); - assertEquals(asList("AddColumnToDb", "CreateTableToDb", "CreateTableToModel", "AddRelationshipToDb"), - toClasses(DbImportAction.sort(tokens))); - } + assertEquals(asList("AddColumnToDb", "CreateTableToDb", "CreateTableToModel", "AddRelationshipToDb"), + toClasses(DbImportActionDefault.sort(tokens))); + } private List<String> toClasses(List<MergerToken> sort) { LinkedList<String> res = new LinkedList<String>(); http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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 deleted file mode 100644 index 52c21bd..0000000 --- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/DefaultReverseEngineeringLoaderTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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. - */ - -package org.apache.cayenne.tools.dbimport.config; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.net.MalformedURLException; -import java.util.Iterator; - -import org.apache.cayenne.resource.URLResource; -import org.apache.cayenne.tools.ExcludeTable; -import org.junit.Test; - -public class DefaultReverseEngineeringLoaderTest { - - @Test - public void testLoadCatalog() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-catalog.xml")); - - assertCatalog(engineering); - } - - public static void assertCatalog(ReverseEngineering engineering) { - Iterator<Catalog> catalogs = engineering.getCatalogs().iterator(); - assertEquals("catalog-name-01", catalogs.next().getName()); - assertEquals("catalog-name-02", catalogs.next().getName()); - - assertCatalog(catalogs); - } - - public static void assertCatalog(Iterator<Catalog> catalogs) { - Catalog catalog = catalogs.next(); - assertEquals("catalog-name-03", catalog.getName()); - - Iterator<IncludeTable> includeTables = catalog.getIncludeTables().iterator(); - assertEquals("includeTable-01", includeTables.next().getPattern()); - assertEquals("includeTable-02", includeTables.next().getPattern()); - - IncludeTable includeTable = includeTables.next(); - assertEquals("includeTable-03", includeTable.getPattern()); - assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern()); - assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern()); - - Iterator<ExcludeTable> excludeTables = catalog.getExcludeTables().iterator(); - assertEquals("excludeTable-01", excludeTables.next().getPattern()); - assertEquals("excludeTable-02", excludeTables.next().getPattern()); - assertEquals("excludeTable-03", excludeTables.next().getPattern()); - - Iterator<ExcludeColumn> excludeColumns = catalog.getExcludeColumns().iterator(); - assertEquals("excludeColumn-01", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-02", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-03", excludeColumns.next().getPattern()); - Iterator<IncludeColumn> includeColumns = catalog.getIncludeColumns().iterator(); - assertEquals("includeColumn-01", includeColumns.next().getPattern()); - assertEquals("includeColumn-02", includeColumns.next().getPattern()); - assertEquals("includeColumn-03", includeColumns.next().getPattern()); - - Iterator<ExcludeProcedure> excludeProcedures = catalog.getExcludeProcedures().iterator(); - assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern()); - Iterator<IncludeProcedure> includeProcedures = catalog.getIncludeProcedures().iterator(); - assertEquals("includeProcedure-01", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-02", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-03", includeProcedures.next().getPattern()); - } - - @Test - public void testLoadSchema() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-schema.xml")); - - assertSchema(engineering); - } - - public static void assertSchema(ReverseEngineering engineering) { - Iterator<Schema> schemas = engineering.getSchemas().iterator(); - assertEquals("schema-name-01", schemas.next().getName()); - assertEquals("schema-name-02", schemas.next().getName()); - - Schema schema = schemas.next(); - assertEquals("schema-name-03", schema.getName()); - - assertSchemaContent(schema); - } - - public static void assertSchemaContent(Schema schema) { - Iterator<IncludeTable> includeTables = schema.getIncludeTables().iterator(); - assertEquals("includeTable-01", includeTables.next().getPattern()); - assertEquals("includeTable-02", includeTables.next().getPattern()); - - IncludeTable includeTable = includeTables.next(); - assertEquals("includeTable-03", includeTable.getPattern()); - assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern()); - assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern()); - - Iterator<ExcludeTable> excludeTables = schema.getExcludeTables().iterator(); - assertEquals("excludeTable-01", excludeTables.next().getPattern()); - assertEquals("excludeTable-02", excludeTables.next().getPattern()); - assertEquals("excludeTable-03", excludeTables.next().getPattern()); - - Iterator<ExcludeColumn> excludeColumns = schema.getExcludeColumns().iterator(); - assertEquals("excludeColumn-01", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-02", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-03", excludeColumns.next().getPattern()); - Iterator<IncludeColumn> includeColumns = schema.getIncludeColumns().iterator(); - assertEquals("includeColumn-01", includeColumns.next().getPattern()); - assertEquals("includeColumn-02", includeColumns.next().getPattern()); - assertEquals("includeColumn-03", includeColumns.next().getPattern()); - - Iterator<ExcludeProcedure> excludeProcedures = schema.getExcludeProcedures().iterator(); - assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern()); - Iterator<IncludeProcedure> includeProcedures = schema.getIncludeProcedures().iterator(); - assertEquals("includeProcedure-01", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-02", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-03", includeProcedures.next().getPattern()); - } - - @Test - public void testLoadCatalogAndSchema() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-catalog-and-schema.xml")); - - assertCatalogAndSchema(engineering); - } - - public static void assertCatalogAndSchema(ReverseEngineering engineering) { - Catalog catalog = engineering.getCatalogs().iterator().next(); - assertEquals("catalog-name", catalog.getName()); - - Schema schema = catalog.getSchemas().iterator().next(); - assertEquals("schema-name", schema.getName()); - - assertSchemaContent(schema); - } - - @Test - public void testLoadFlat() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-flat.xml")); - - assertFlat(engineering); - } - - public static void assertFlat(ReverseEngineering engineering) { - Iterator<IncludeTable> includeTables = engineering.getIncludeTables().iterator(); - assertEquals("includeTable-01", includeTables.next().getPattern()); - assertEquals("includeTable-02", includeTables.next().getPattern()); - - IncludeTable includeTable = includeTables.next(); - assertEquals("includeTable-03", includeTable.getPattern()); - assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern()); - assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern()); - - Iterator<ExcludeTable> excludeTables = engineering.getExcludeTables().iterator(); - assertEquals("excludeTable-01", excludeTables.next().getPattern()); - assertEquals("excludeTable-02", excludeTables.next().getPattern()); - assertEquals("excludeTable-03", excludeTables.next().getPattern()); - - Iterator<ExcludeColumn> excludeColumns = engineering.getExcludeColumns().iterator(); - assertEquals("excludeColumn-01", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-02", excludeColumns.next().getPattern()); - assertEquals("excludeColumn-03", excludeColumns.next().getPattern()); - Iterator<IncludeColumn> includeColumns = engineering.getIncludeColumns().iterator(); - assertEquals("includeColumn-01", includeColumns.next().getPattern()); - assertEquals("includeColumn-02", includeColumns.next().getPattern()); - assertEquals("includeColumn-03", includeColumns.next().getPattern()); - - Iterator<ExcludeProcedure> excludeProcedures = engineering.getExcludeProcedures().iterator(); - assertEquals("excludeProcedure-01", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-02", excludeProcedures.next().getPattern()); - assertEquals("excludeProcedure-03", excludeProcedures.next().getPattern()); - Iterator<IncludeProcedure> includeProcedures = engineering.getIncludeProcedures().iterator(); - assertEquals("includeProcedure-01", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-02", includeProcedures.next().getPattern()); - assertEquals("includeProcedure-03", includeProcedures.next().getPattern()); - } - - @Test - public void testSkipRelationships() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-skipRelationshipsLoading.xml")); - - assertSkipRelationshipsLoading(engineering); - } - - public static void assertSkipRelationshipsLoading(ReverseEngineering engineering) { - assertTrue(engineering.getSkipRelationshipsLoading()); - } - - @Test - public void testSkipPrimaryKeyLoading() throws Exception { - ReverseEngineering engineering = new DefaultReverseEngineeringLoader() - .load(getResource("reverseEngineering-skipPrimaryKeyLoading.xml")); - - assertSkipPrimaryKeyLoading(engineering); - } - - public static void assertSkipPrimaryKeyLoading(ReverseEngineering engineering) { - assertTrue(engineering.getSkipPrimaryKeyLoading()); - } - - @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)); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilderTest.java ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilderTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilderTest.java deleted file mode 100644 index e3086a7..0000000 --- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilderTest.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * 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. - */ - -package org.apache.cayenne.tools.dbimport.config; - -import org.apache.cayenne.tools.ExcludeTable; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class FiltersConfigBuilderTest { - - @Test - public void testCompact_01() { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addIncludeTable(new IncludeTable("table1")); - engineering.addIncludeTable(new IncludeTable("table2")); - engineering.addIncludeTable(new IncludeTable("table3")); - - engineering.addIncludeColumn(new IncludeColumn("includeColumn")); - - FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering); - builder.compact(); - assertEquals( - "ReverseEngineering: \n" + - " Catalog: null\n" + - " Schema: null\n" + - " IncludeTable: table1\n" + - " IncludeColumn: includeColumn\n" + - " IncludeTable: table2\n" + - " IncludeColumn: includeColumn\n" + - " IncludeTable: table3\n" + - " IncludeColumn: includeColumn\n", engineering.toString()); - } - - @Test - public void testCompact_02() { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addCatalog(new Catalog("catalogName")); - engineering.addSchema(new Schema("schemaName01")); - engineering.addSchema(new Schema("schemaName02")); - - engineering.addIncludeTable(new IncludeTable("table1")); - engineering.addExcludeTable(new ExcludeTable("table2")); - - engineering.addIncludeColumn(new IncludeColumn("includeColumn")); - - FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering); - builder.compact(); - assertEquals( - "ReverseEngineering: \n" + - " Catalog: catalogName\n" + - " Schema: schemaName01\n" + - " IncludeTable: table1\n" + - " IncludeColumn: includeColumn\n" + - " ExcludeTable: table2\n" + - " Schema: schemaName02\n" + - " IncludeTable: table1\n" + - " IncludeColumn: includeColumn\n" + - " ExcludeTable: table2\n", engineering.toString()); - } - - @Test - public void testCompact_03() { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addCatalog(new Catalog("APP1")); - engineering.addCatalog(new Catalog("APP2")); - - engineering.addExcludeTable(new ExcludeTable("SYS_.*")); - engineering.addExcludeColumn(new ExcludeColumn("calculated_.*")); - - FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering); - builder.compact(); - assertEquals( - "ReverseEngineering: \n" + - " Catalog: APP1\n" + - " Schema: null\n" + - " IncludeTable: null\n" + - " ExcludeColumn: calculated_.*\n" + - " ExcludeTable: SYS_.*\n" + - " Catalog: APP2\n" + - " Schema: null\n" + - " IncludeTable: null\n" + - " ExcludeColumn: calculated_.*\n" + - " ExcludeTable: SYS_.*\n", engineering.toString()); - } - - @Test - public void testCompact_04() { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addSchema(new Schema("s")); - - FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering); - builder.compact(); - assertEquals( - "ReverseEngineering: \n" + - " Catalog: null\n" + - " Schema: s\n" + - " IncludeTable: null\n", engineering.toString()); - } - - @Test - public void testCompact_full() { - ReverseEngineering engineering = new ReverseEngineering(); - Catalog cat01 = new Catalog("cat_01"); - - Schema sch01 = new Schema("sch_01"); - - sch01.addIncludeTable(includeTable("t1", "c11", "c12")); - sch01.addExcludeTable(new ExcludeTable("t2")); - sch01.addIncludeProcedure(new IncludeProcedure("p1")); - sch01.addExcludeProcedure(new ExcludeProcedure("p2")); - sch01.addIncludeColumn(new IncludeColumn("c_x1")); - sch01.addExcludeColumn(new ExcludeColumn("c_x2")); - - cat01.addSchema(sch01); - - cat01.addIncludeTable(includeTable("t3", "c31", "c32")); - cat01.addExcludeTable(new ExcludeTable("t4")); - cat01.addIncludeProcedure(new IncludeProcedure("p3")); - cat01.addExcludeProcedure(new ExcludeProcedure("p4")); - cat01.addIncludeColumn(new IncludeColumn("c_xx1")); - cat01.addExcludeColumn(new ExcludeColumn("c_xx2")); - - engineering.addCatalog(cat01); - - Schema sch02 = new Schema("sch_02"); - - sch02.addIncludeTable(includeTable("t5", "c51", "c52")); - sch02.addExcludeTable(new ExcludeTable("t6")); - sch02.addIncludeProcedure(new IncludeProcedure("p5")); - sch02.addExcludeProcedure(new ExcludeProcedure("p6")); - sch02.addIncludeColumn(new IncludeColumn("c2_x1")); - sch02.addExcludeColumn(new ExcludeColumn("c2_x2")); - - engineering.addSchema(sch02); - - engineering.addIncludeTable(includeTable("t7", "c71", "c72")); - engineering.addExcludeTable(new ExcludeTable("t8")); - engineering.addIncludeProcedure(new IncludeProcedure("p7")); - engineering.addExcludeProcedure(new ExcludeProcedure("p8")); - engineering.addIncludeColumn(new IncludeColumn("c_xxx1")); - engineering.addExcludeColumn(new ExcludeColumn("c_xxx2")); - - FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering); - assertEquals("Original ReverseEngineering should be", - "ReverseEngineering: \n" + - " Catalog: cat_01\n" + - " Schema: sch_01\n" + - " IncludeTable: t1\n" + - " IncludeColumn: c11\n" + - " ExcludeColumn: c12\n" + - " ExcludeTable: t2\n" + - " IncludeColumn: c_x1\n" + - " ExcludeColumn: c_x2\n" + - " IncludeProcedure: p1\n" + - " ExcludeProcedure: p2\n" + - " IncludeTable: t3\n" + - " IncludeColumn: c31\n" + - " ExcludeColumn: c32\n" + - " ExcludeTable: t4\n" + - " IncludeColumn: c_xx1\n" + - " ExcludeColumn: c_xx2\n" + - " IncludeProcedure: p3\n" + - " ExcludeProcedure: p4\n" + - " Schema: sch_02\n" + - " IncludeTable: t5\n" + - " IncludeColumn: c51\n" + - " ExcludeColumn: c52\n" + - " ExcludeTable: t6\n" + - " IncludeColumn: c2_x1\n" + - " ExcludeColumn: c2_x2\n" + - " IncludeProcedure: p5\n" + - " ExcludeProcedure: p6\n" + - " IncludeTable: t7\n" + - " IncludeColumn: c71\n" + - " ExcludeColumn: c72\n" + - " ExcludeTable: t8\n" + - " IncludeColumn: c_xxx1\n" + - " ExcludeColumn: c_xxx2\n" + - " IncludeProcedure: p7\n" + - " ExcludeProcedure: p8\n", engineering.toString()); - - - builder.compact(); - assertEquals( - "ReverseEngineering: \n" + - " Catalog: cat_01\n" + - " Schema: sch_01\n" + - " IncludeTable: t1\n" + - " IncludeColumn: c11\n" + - " IncludeColumn: c_xxx1\n" + - " IncludeColumn: c_xx1\n" + - " IncludeColumn: c_x1\n" + - " ExcludeColumn: c12\n" + - " ExcludeColumn: c_xxx2\n" + - " ExcludeColumn: c_xx2\n" + - " ExcludeColumn: c_x2\n" + - " IncludeTable: t7\n" + - " IncludeColumn: c71\n" + - " IncludeColumn: c_xxx1\n" + - " ExcludeColumn: c72\n" + - " ExcludeColumn: c_xxx2\n" + - " IncludeTable: t3\n" + - " IncludeColumn: c31\n" + - " IncludeColumn: c_xxx1\n" + - " IncludeColumn: c_xx1\n" + - " ExcludeColumn: c32\n" + - " ExcludeColumn: c_xxx2\n" + - " ExcludeColumn: c_xx2\n" + - " ExcludeTable: t2\n" + - " ExcludeTable: t8\n" + - " ExcludeTable: t4\n" + - " IncludeProcedure: p1\n" + - " IncludeProcedure: p7\n" + - " IncludeProcedure: p3\n" + - " ExcludeProcedure: p2\n" + - " ExcludeProcedure: p8\n" + - " ExcludeProcedure: p4\n" + - " Schema: sch_02\n" + - " IncludeTable: t5\n" + - " IncludeColumn: c51\n" + - " IncludeColumn: c_xxx1\n" + - " IncludeColumn: c2_x1\n" + - " ExcludeColumn: c52\n" + - " ExcludeColumn: c_xxx2\n" + - " ExcludeColumn: c2_x2\n" + - " IncludeTable: t7\n" + - " IncludeColumn: c71\n" + - " IncludeColumn: c_xxx1\n" + - " ExcludeColumn: c72\n" + - " ExcludeColumn: c_xxx2\n" + - " ExcludeTable: t6\n" + - " ExcludeTable: t8\n" + - " IncludeProcedure: p5\n" + - " IncludeProcedure: p7\n" + - " ExcludeProcedure: p6\n" + - " ExcludeProcedure: p8\n", engineering.toString()); - } - - protected IncludeTable includeTable(String name, String incCol, String excCol) { - IncludeTable incTable01 = new IncludeTable(name); - incTable01.addIncludeColumn(new IncludeColumn(incCol)); - incTable01.addExcludeColumn(new ExcludeColumn(excCol)); - return incTable01; - } - - /*@Test - public void testEmptyDbEntitiesFilters() throws Exception { - ReverseEngineering engineering = new ReverseEngineering(); - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - assertEquals("If nothing was configured we have to import everything. Filter %/%/% true/true/true", - new FiltersConfig(eFilters(path(), TRUE, TRUE, NULL)), - executions); - } - - @Test - public void testOnlyOneCatalogDbEntitiesFilters() throws Exception { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addCatalog(new Catalog("catalog_01")); - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - - assertEquals(new FiltersConfig(eFilters(path("catalog_01", null), TRUE, TRUE, NULL)), - executions); - } - - @Test - public void testCatalogDbEntitiesFilters() throws Exception { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addCatalog(new Catalog("catalog_01")); - engineering.addCatalog(new Catalog("catalog_02").schema(new Schema("schema_01"))); - engineering.addCatalog(new Catalog("catalog_02").schema(new Schema("schema_02"))); - engineering.addCatalog(new Catalog("catalog_02").schema(new Schema("schema_03"))); - engineering.addCatalog(new Catalog("catalog_03").schema(new Schema("schema_01"))); - engineering.addCatalog(new Catalog("catalog_03").schema(new Schema("schema_01"))); - engineering.addCatalog(new Catalog("catalog_03").schema(new Schema("schema_01"))); - engineering.addCatalog(new Catalog("catalog_03").schema(new Schema("schema_01"))); - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - - assertEquals(new FiltersConfig( - eFilters(path("catalog_01", null), TRUE, TRUE, NULL), - eFilters(path("catalog_02", "schema_01"), TRUE, TRUE, NULL), - eFilters(path("catalog_02", "schema_02"), TRUE, TRUE, NULL), - eFilters(path("catalog_02", "schema_03"), TRUE, TRUE, NULL), - eFilters(path("catalog_03", "schema_01"), TRUE, TRUE, NULL) - ), - executions); - } - - @Test - public void testSchemaDbEntitiesFilters() throws Exception { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addSchema(new Schema("schema_01")); - engineering.addSchema(new Schema("schema_02")); - engineering.addSchema(new Schema("schema_03")); - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - - assertEquals(new FiltersConfig( - eFilters(path(null, "schema_01"), TRUE, TRUE, NULL), - eFilters(path(null, "schema_02"), TRUE, TRUE, NULL), - eFilters(path(null, "schema_03"), TRUE, TRUE, NULL) - ), - executions); - } - - @Test - public void testFiltersDbEntitiesFilters() throws Exception { - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addIncludeTable(new IncludeTable("IncludeTable")); - engineering.addIncludeColumn(new IncludeColumn("IncludeColumn")); - engineering.addIncludeProcedure(new IncludeProcedure("IncludeProcedure")); - engineering.addExcludeTable(new ExcludeTable("ExcludeTable")); - engineering.addExcludeColumn(new ExcludeColumn("ExcludeColumn")); - engineering.addExcludeProcedure(new ExcludeProcedure("ExcludeProcedure")); - - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - assertEquals(new FiltersConfig( - eFilters(path(), - list(include("IncludeTable"), exclude("ExcludeTable")), - list(include("IncludeColumn"), exclude("ExcludeColumn")), - list(include("IncludeProcedure"), exclude("ExcludeProcedure"))), - eFilters(path(null, null, "IncludeTable"), NULL, TRUE, NULL) - ), - executions); - } - - @Test - public void testComplexConfiguration() throws Exception { - IncludeTable table = new IncludeTable("table"); - table.addIncludeColumn(new IncludeColumn("column")); - - Schema schema = new Schema("schema"); - schema.addIncludeTable(table); - - Catalog catalog = new Catalog("catalog"); - catalog.addSchema(schema); - - ReverseEngineering engineering = new ReverseEngineering(); - engineering.addCatalog(catalog); - - FiltersConfig executions = new FiltersConfigBuilder(engineering).filtersConfig(); - - assertEquals(new FiltersConfig( - eFilters(path("catalog", "schema"), include("table"), NULL, NULL), - eFilters(path("catalog", "schema", "table"), NULL, include("column"), NULL) - ), - executions); - } - - @Test - public void testAddNull() throws Exception { - FiltersConfigBuilder builder = new FiltersConfigBuilder(new ReverseEngineering()); - DbPath path = new DbPath(); - builder.add(new EntityFilters(path, NULL, NULL, NULL)); - builder.add(new EntityFilters(path, NULL, NULL, NULL)); - builder.add(new EntityFilters(path, NULL, NULL, NULL)); - builder.add(new EntityFilters(path, NULL, NULL, NULL)); - - EntityFilters filter = builder.filtersConfig().filter(path); - assertFalse(filter.isEmpty()); - }*/ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-ant-mapping.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-ant-mapping.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-ant-mapping.xml deleted file mode 100644 index 4bdd44a..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-ant-mapping.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?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> - - <typeMapper mapperClassName="class" usePrimitives="false"> - <type java="my.personal.type" jdbc="varchar" /> - <type java="java-01" jdbc="jdbc-01" /> - <type java="java-02" jdbc="jdbc-02" length="21" notNull="true" /> - <type java="java-03" jdbc="jdbc-03" precision="5" scale="2" /> - <type java="java-03" jdbc="jdbc-03" precision="7" notNull="true" /> - </typeMapper> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog-and-schema.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog-and-schema.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog-and-schema.xml deleted file mode 100644 index 46c26d0..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog-and-schema.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?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> - <catalog name="catalog-name"> - <schema name="schema-name"> - <includeTable>includeTable-01</includeTable> - - <includeTable> - <pattern>includeTable-02</pattern> - </includeTable> - - <includeTable pattern="includeTable-03"> - <includeColumn pattern="includeColumn-01" /> - <excludeColumn pattern="excludeColumn-01" /> - </includeTable> - - <excludeTable>excludeTable-01</excludeTable> - <excludeTable> - <pattern>excludeTable-02</pattern> - </excludeTable> - <excludeTable pattern="excludeTable-03" /> - - <includeColumn>includeColumn-01</includeColumn> - <includeColumn> - <pattern>includeColumn-02</pattern> - </includeColumn> - <includeColumn pattern="includeColumn-03" /> - <excludeColumn>excludeColumn-01</excludeColumn> - <excludeColumn> - <pattern>excludeColumn-02</pattern> - </excludeColumn> - <excludeColumn pattern="excludeColumn-03" /> - - <includeProcedure>includeProcedure-01</includeProcedure> - <includeProcedure> - <pattern>includeProcedure-02</pattern> - </includeProcedure> - <includeProcedure pattern="includeProcedure-03" /> - <excludeProcedure>excludeProcedure-01</excludeProcedure> - <excludeProcedure> - <pattern>excludeProcedure-02</pattern> - </excludeProcedure> - <excludeProcedure pattern="excludeProcedure-03" /> - </schema> - </catalog> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog.xml deleted file mode 100644 index d820aa4..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-catalog.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?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> - <catalog>catalog-name-01</catalog> - - <catalog> - <name>catalog-name-02</name> - </catalog> - - <catalog name="catalog-name-03"> - <includeTable>includeTable-01</includeTable> - - <includeTable> - <pattern>includeTable-02</pattern> - </includeTable> - - <includeTable pattern="includeTable-03"> - <includeColumn pattern="includeColumn-01" /> - <excludeColumn pattern="excludeColumn-01" /> - </includeTable> - - <excludeTable>excludeTable-01</excludeTable> - <excludeTable> - <pattern>excludeTable-02</pattern> - </excludeTable> - <excludeTable pattern="excludeTable-03" /> - - <includeColumn>includeColumn-01</includeColumn> - <includeColumn> - <pattern>includeColumn-02</pattern> - </includeColumn> - <includeColumn pattern="includeColumn-03" /> - <excludeColumn>excludeColumn-01</excludeColumn> - <excludeColumn> - <pattern>excludeColumn-02</pattern> - </excludeColumn> - <excludeColumn pattern="excludeColumn-03" /> - - <includeProcedure>includeProcedure-01</includeProcedure> - <includeProcedure> - <pattern>includeProcedure-02</pattern> - </includeProcedure> - <includeProcedure pattern="includeProcedure-03" /> - <excludeProcedure>excludeProcedure-01</excludeProcedure> - <excludeProcedure> - <pattern>excludeProcedure-02</pattern> - </excludeProcedure> - <excludeProcedure pattern="excludeProcedure-03" /> - </catalog> -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-flat.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-flat.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-flat.xml deleted file mode 100644 index 5b785af..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-flat.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?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> - <includeTable>includeTable-01</includeTable> - - <includeTable> - <pattern>includeTable-02</pattern> - </includeTable> - - <includeTable pattern="includeTable-03"> - <includeColumn pattern="includeColumn-01" /> - <excludeColumn pattern="excludeColumn-01" /> - </includeTable> - - <excludeTable>excludeTable-01</excludeTable> - <excludeTable> - <pattern>excludeTable-02</pattern> - </excludeTable> - <excludeTable pattern="excludeTable-03" /> - - <includeColumn>includeColumn-01</includeColumn> - <includeColumn> - <pattern>includeColumn-02</pattern> - </includeColumn> - <includeColumn pattern="includeColumn-03" /> - <excludeColumn>excludeColumn-01</excludeColumn> - <excludeColumn> - <pattern>excludeColumn-02</pattern> - </excludeColumn> - <excludeColumn pattern="excludeColumn-03" /> - - <includeProcedure>includeProcedure-01</includeProcedure> - <includeProcedure> - <pattern>includeProcedure-02</pattern> - </includeProcedure> - <includeProcedure pattern="includeProcedure-03" /> - <excludeProcedure>excludeProcedure-01</excludeProcedure> - <excludeProcedure> - <pattern>excludeProcedure-02</pattern> - </excludeProcedure> - <excludeProcedure pattern="excludeProcedure-03" /> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-maven-mapping.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-maven-mapping.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-maven-mapping.xml deleted file mode 100644 index c9d722e..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-maven-mapping.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?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> - - <typeMapper > - <mapperClassName>class</mapperClassName> - <usePrimitives>false</usePrimitives> - - <type> - <java>my.personal.type</java> - <jdbc>varchar</jdbc> - </type> - <type> - <java>java-01</java> - <jdbc>jdbc-01</jdbc> - </type> - <type> - <java>java-02</java> - <jdbc>jdbc-02</jdbc> - <length>21</length> - <notNull>true</notNull> - </type> - <type> - <java>java-03</java> - <jdbc>jdbc-03</jdbc> - <precision>5</precision> - <scale>2</scale> - </type> - <type> - <java>java-03</java> - <jdbc>jdbc-03</jdbc> - <precision>7</precision> - <notNull>true</notNull> - </type> - </typeMapper> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-mixed-mapping.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-mixed-mapping.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-mixed-mapping.xml deleted file mode 100644 index deb3dab..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-mixed-mapping.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?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> - - <typeMapper > - <mapperClassName>class</mapperClassName> - <usePrimitives>false</usePrimitives> - - <type java="my.personal.type" jdbc="varchar" /> - <type java="java-01" jdbc="jdbc-01" /> - <type java="java-02" jdbc="jdbc-02"> - <length>21</length> - <notNull>true</notNull> - </type> - <type java="java-03" jdbc="jdbc-03"> - <precision>5</precision> - <scale>2</scale> - </type> - <type precision="7" notNull="true"> - <java>java-03</java> - <jdbc>jdbc-03</jdbc> - </type> - </typeMapper> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-schema.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-schema.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-schema.xml deleted file mode 100644 index 97c2c6f..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-schema.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?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> - <schema>schema-name-01</schema> - - <schema> - <name>schema-name-02</name> - </schema> - - <schema name="schema-name-03"> - <includeTable>includeTable-01</includeTable> - - <includeTable> - <pattern>includeTable-02</pattern> - </includeTable> - - <includeTable pattern="includeTable-03"> - <includeColumn pattern="includeColumn-01" /> - <excludeColumn pattern="excludeColumn-01" /> - </includeTable> - - <excludeTable>excludeTable-01</excludeTable> - <excludeTable> - <pattern>excludeTable-02</pattern> - </excludeTable> - <excludeTable pattern="excludeTable-03" /> - - <includeColumn>includeColumn-01</includeColumn> - <includeColumn> - <pattern>includeColumn-02</pattern> - </includeColumn> - <includeColumn pattern="includeColumn-03" /> - <excludeColumn>excludeColumn-01</excludeColumn> - <excludeColumn> - <pattern>excludeColumn-02</pattern> - </excludeColumn> - <excludeColumn pattern="excludeColumn-03" /> - - <includeProcedure>includeProcedure-01</includeProcedure> - <includeProcedure> - <pattern>includeProcedure-02</pattern> - </includeProcedure> - <includeProcedure pattern="includeProcedure-03" /> - <excludeProcedure>excludeProcedure-01</excludeProcedure> - <excludeProcedure> - <pattern>excludeProcedure-02</pattern> - </excludeProcedure> - <excludeProcedure pattern="excludeProcedure-03" /> - </schema> - -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipPrimaryKeyLoading.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipPrimaryKeyLoading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipPrimaryKeyLoading.xml deleted file mode 100644 index e0d74bd..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipPrimaryKeyLoading.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?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> - <skipPrimaryKeyLoading>true</skipPrimaryKeyLoading> -</reverseEngineering> http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipRelationshipsLoading.xml ---------------------------------------------------------------------- diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipRelationshipsLoading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipRelationshipsLoading.xml deleted file mode 100644 index 9eac789..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-skipRelationshipsLoading.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?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> - <skipRelationshipsLoading>true</skipRelationshipsLoading> -</reverseEngineering> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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 deleted file mode 100644 index f9ea8ca..0000000 --- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/dbimport/config/reverseEngineering-tableTypes.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?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/fe82b47e/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java index bf1f398..0b78d9e 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java @@ -62,7 +62,7 @@ import org.apache.cayenne.modeler.action.ExitAction; import org.apache.cayenne.modeler.action.FindAction; import org.apache.cayenne.modeler.action.GenerateCodeAction; import org.apache.cayenne.modeler.action.GenerateDBAction; -import org.apache.cayenne.modeler.action.ImportDBAction; +import org.apache.cayenne.modeler.action.ReverseEngineeringAction; import org.apache.cayenne.modeler.action.ImportDataMapAction; import org.apache.cayenne.modeler.action.ImportEOModelAction; import org.apache.cayenne.modeler.action.InferRelationshipsAction; @@ -224,7 +224,7 @@ public class CayenneModelerFrame extends JFrame implements DataNodeDisplayListen projectMenu.addSeparator(); projectMenu.add(getAction(RemoveAction.class).buildMenu()); - toolMenu.add(getAction(ImportDBAction.class).buildMenu()); + toolMenu.add(getAction(ReverseEngineeringAction.class).buildMenu()); toolMenu.add(getAction(InferRelationshipsAction.class).buildMenu()); toolMenu.add(getAction(ImportEOModelAction.class).buildMenu()); toolMenu.addSeparator(); http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java index c625bb4..80bd355 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java @@ -95,7 +95,7 @@ public class DefaultActionManager implements ActionManager { registerAction(new ObjEntitySyncAction(application)); registerAction(new DbEntityCounterpartAction(application)); registerAction(new ObjEntityCounterpartAction(application)); - registerAction(new ImportDBAction(application)); + registerAction(new ReverseEngineeringAction(application)); registerAction(new InferRelationshipsAction(application)); registerAction(new ImportEOModelAction(application)); registerAction(new GenerateDBAction(application)); @@ -165,7 +165,7 @@ public class DefaultActionManager implements ActionManager { CreateDataMapAction.class.getName(), RemoveAction.class.getName(), CreateNodeAction.class.getName(), - ImportDBAction.class.getName(), + ReverseEngineeringAction.class.getName(), ImportEOModelAction.class.getName(), GenerateCodeAction.class.getName(), GenerateDBAction.class.getName(), http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java deleted file mode 100644 index 95c8224..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************** - * 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. - ****************************************************************/ - -package org.apache.cayenne.modeler.action; - -import java.awt.event.ActionEvent; -import java.sql.Connection; - -import javax.swing.SwingUtilities; - -import org.apache.cayenne.dba.DbAdapter; -import org.apache.cayenne.modeler.Application; -import org.apache.cayenne.modeler.dialog.db.ConnectionWizard; -import org.apache.cayenne.modeler.dialog.db.DbLoaderHelper; -import org.apache.cayenne.modeler.pref.DBConnectionInfo; - -/** - * Action that imports database structure into a DataMap. - */ -public class ImportDBAction extends DBWizardAction { - - public static String getActionName() { - return "Reengineer Database Schema"; - } - - public ImportDBAction(Application application) { - super(getActionName(), application); - } - - /** - * Connects to DB and delegates processing to DbLoaderController, starting it - * asynchronously. - */ - public void performAction(ActionEvent event) { - - // guess node connection - DBConnectionInfo nodeInfo = preferredDataSource(); - String nodeKey = preferredDataSourceLabel(nodeInfo); - - // connect - ConnectionWizard connectWizard = new ConnectionWizard( - getProjectController(), - "Reengineer DB Schema: Connect to Database", - nodeKey, - nodeInfo); - - if (!connectWizard.startupAction()) { - // canceled - return; - } - - Connection connection = connectWizard.getConnection(); - DbAdapter adapter = connectWizard.getAdapter(); - DBConnectionInfo dataSourceInfo = connectWizard.getConnectionInfo(); - - // from here pass control to DbLoaderHelper, running it from a thread separate - // from EventDispatch - - final DbLoaderHelper helper = new DbLoaderHelper( - getProjectController(), - connection, - adapter, - dataSourceInfo.getUserName()); - Thread th = new Thread(new Runnable() { - - public void run() { - helper.execute(); - - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - application.getUndoManager().discardAllEdits(); - } - }); - } - }); - - th.start(); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java index c5f3314..ac0ed01 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java @@ -29,7 +29,7 @@ import org.apache.cayenne.access.DbLoader; import org.apache.cayenne.dba.DbAdapter; import org.apache.cayenne.map.DataMap; import org.apache.cayenne.modeler.Application; -import org.apache.cayenne.modeler.dialog.db.DataSourceWizard; +import org.apache.cayenne.modeler.dialog.db.DataSourceController; import org.apache.cayenne.modeler.dialog.db.DbMigrateOptionsDialog; import org.apache.cayenne.modeler.dialog.db.MergerOptions; import org.apache.cayenne.modeler.pref.DBConnectionInfo; @@ -52,7 +52,7 @@ public class MigrateAction extends DBWizardAction { DBConnectionInfo nodeInfo = preferredDataSource(); String nodeKey = preferredDataSourceLabel(nodeInfo); - DataSourceWizard connectWizard = new DataSourceWizard( + DataSourceController connectWizard = new DataSourceController( getProjectController(), "Migrate DB Schema: Connect to Database", nodeKey, @@ -62,10 +62,10 @@ public class MigrateAction extends DBWizardAction { // canceled return; } - + DataMap map = getProjectController().getCurrentDataMap(); //migarte options - + // sanity check if (map == null) { throw new IllegalStateException("No current DataMap selected."); @@ -97,8 +97,8 @@ public class MigrateAction extends DBWizardAction { connectWizard.getConnectionInfo(), map, selectedSchema).startupAction(); } - - private List<String> getSchemas(DataSourceWizard connectWizard) throws Exception { + + private List<String> getSchemas(DataSourceController connectWizard) throws Exception { DbAdapter dbAdapter = connectWizard.getConnectionInfo() .makeAdapter(getApplication().getClassLoadingService()); DataSource dataSource = connectWizard.getConnectionInfo() http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java index 282b7a1..3e3f13d 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java @@ -72,6 +72,7 @@ import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.net.URL; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; /** @@ -448,7 +449,12 @@ public class RemoveAction extends CayenneAction { domain.getDataMaps().remove(map); if (map.getConfigurationSource() != null) { URL mapURL = map.getConfigurationSource().getURL(); - getCurrentProject().getUnusedResources().add(mapURL); + Collection<URL> unusedResources = getCurrentProject().getUnusedResources(); + unusedResources.add(mapURL); + if (map.getReverseEngineering() != null && map.getReverseEngineering().getConfigurationSource() != null) { + URL reverseEngineeringURL = map.getReverseEngineering().getConfigurationSource().getURL(); + unusedResources.add(reverseEngineeringURL); + } } Iterator<DataNodeDescriptor> iterator = domain.getNodeDescriptors().iterator();