You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/01/31 15:41:39 UTC
[2/2] cayenne git commit: CAY-2216 cdbimport: reduce configuration
variants - remove direct access to collections,
thus disabling tags like in cdbimport filters config - delete
unused ReverseEngineering file loader and writer
CAY-2216 cdbimport: reduce configuration variants
- remove direct access to collections, thus disabling tags like <includeTables> in cdbimport filters config
- delete unused ReverseEngineering file loader and writer
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/67bf710b
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/67bf710b
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/67bf710b
Branch: refs/heads/master
Commit: 67bf710b7d7bca1d9256a4721cee6b4ff9a98ed0
Parents: bbd7f62
Author: Nikita Timofeev <st...@gmail.com>
Authored: Tue Jan 31 18:40:10 2017 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Tue Jan 31 18:40:10 2017 +0300
----------------------------------------------------------------------
.../reverse/filters/FiltersConfigBuilder.java | 129 ++++------
.../filters/FiltersConfigBuilderTest.java | 152 ++----------
.../org/apache/cayenne/dbimport/Catalog.java | 76 +-----
.../DefaultReverseEngineeringLoader.java | 223 -----------------
.../DefaultReverseEngineeringWriter.java | 59 -----
.../cayenne/dbimport/FilterContainer.java | 129 ++++++----
.../apache/cayenne/dbimport/IncludeTable.java | 8 +-
.../apache/cayenne/dbimport/PatternParam.java | 4 +
.../cayenne/dbimport/ReverseEngineering.java | 40 +---
.../dbimport/ReverseEngineeringLoader.java | 38 ---
.../ReverseEngineeringLoaderException.java | 39 ---
.../dbimport/ReverseEngineeringWriter.java | 34 ---
.../org/apache/cayenne/dbimport/Schema.java | 29 +--
.../cayenne/dbimport/SchemaContainer.java | 67 ++++++
.../DefaultReverseEngineeringLoaderTest.java | 239 -------------------
.../DefaultReverseEngineeringWriterTest.java | 95 --------
.../dbimport/ReverseEngineeringUtils.java | 173 ++++++++++++++
.../cayenne/tools/DbImporterTaskTest.java | 7 +-
.../tools/DbImporterMojoConfigurationTest.java | 8 +-
.../DbImporterOldMojoConfigurationTest.java | 3 +-
20 files changed, 408 insertions(+), 1144 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
index 18af876..7900dde 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
@@ -30,7 +30,6 @@ import org.apache.cayenne.dbimport.ReverseEngineering;
import org.apache.cayenne.dbimport.Schema;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Pattern;
@@ -95,8 +94,7 @@ public final class FiltersConfigBuilder {
return includeTableFilters;
}
- private PatternFilter transform(Collection<? extends PatternParam> include,
- Collection<? extends PatternParam> exclude) {
+ private PatternFilter transform(Collection<? extends PatternParam> include, Collection<? extends PatternParam> exclude) {
PatternFilter filter = new PatternFilter();
for (PatternParam patternParam : include) {
@@ -172,38 +170,30 @@ public final class FiltersConfigBuilder {
compactTableFilter();
compactProcedureFilter();
compactSchemas();
+
+ clearGlobalFilters();
}
private void compactSchemas() {
for (Catalog catalog : engineering.getCatalogs()) {
catalog.getSchemas().addAll(engineering.getSchemas());
}
- engineering.setSchemas(null);
}
private void compactProcedureFilter() {
Collection<IncludeProcedure> engIncludeProcedures = engineering.getIncludeProcedures();
Collection<ExcludeProcedure> engExcludeProcedures = engineering.getExcludeProcedures();
- engineering.setIncludeProcedures(null);
- engineering.setExcludeProcedures(null);
-
for (Catalog catalog : engineering.getCatalogs()) {
Collection<IncludeProcedure> catalogIncludeProcedures = catalog.getIncludeProcedures();
Collection<ExcludeProcedure> catalogExcludeProcedures = catalog.getExcludeProcedures();
- catalog.setIncludeProcedures(null);
- catalog.setExcludeProcedures(null);
-
for (Schema schema : catalog.getSchemas()) {
- if (engIncludeProcedures != null) {
- schema.getIncludeProcedures().addAll(engIncludeProcedures);
- schema.getIncludeProcedures().addAll(catalogIncludeProcedures);
- }
- if (engExcludeProcedures != null) {
- schema.getExcludeProcedures().addAll(engExcludeProcedures);
- schema.getExcludeProcedures().addAll(catalogExcludeProcedures);
- }
+ schema.getIncludeProcedures().addAll(engIncludeProcedures);
+ schema.getIncludeProcedures().addAll(catalogIncludeProcedures);
+
+ schema.getExcludeProcedures().addAll(engExcludeProcedures);
+ schema.getExcludeProcedures().addAll(catalogExcludeProcedures);
}
}
@@ -217,25 +207,16 @@ public final class FiltersConfigBuilder {
Collection<IncludeTable> engIncludeTables = engineering.getIncludeTables();
Collection<ExcludeTable> engExcludeTables = engineering.getExcludeTables();
- engineering.setIncludeTables(null);
- engineering.setExcludeTables(null);
-
for (Catalog catalog : engineering.getCatalogs()) {
Collection<IncludeTable> catalogIncludeTables = catalog.getIncludeTables();
Collection<ExcludeTable> catalogExcludeTables = catalog.getExcludeTables();
- catalog.setIncludeTables(null);
- catalog.setExcludeTables(null);
-
for (Schema schema : catalog.getSchemas()) {
- if (engIncludeTables != null) {
- schema.getIncludeTables().addAll(engIncludeTables);
- schema.getIncludeTables().addAll(catalogIncludeTables);
- }
- if (engExcludeTables != null) {
- schema.getExcludeTables().addAll(engExcludeTables);
- schema.getExcludeTables().addAll(catalogExcludeTables);
- }
+ schema.getIncludeTables().addAll(engIncludeTables);
+ schema.getIncludeTables().addAll(catalogIncludeTables);
+
+ schema.getExcludeTables().addAll(engExcludeTables);
+ schema.getExcludeTables().addAll(catalogExcludeTables);
}
}
@@ -249,55 +230,38 @@ public final class FiltersConfigBuilder {
Collection<IncludeColumn> engIncludeColumns = engineering.getIncludeColumns();
Collection<ExcludeColumn> engExcludeColumns = engineering.getExcludeColumns();
- engineering.setIncludeColumns(null);
- engineering.setExcludeColumns(null);
-
for (Catalog catalog : engineering.getCatalogs()) {
Collection<IncludeColumn> catalogIncludeColumns = catalog.getIncludeColumns();
Collection<ExcludeColumn> catalogExcludeColumns = catalog.getExcludeColumns();
- catalog.setIncludeColumns(null);
- catalog.setExcludeColumns(null);
-
for (Schema schema : catalog.getSchemas()) {
Collection<IncludeColumn> schemaIncludeColumns = schema.getIncludeColumns();
Collection<ExcludeColumn> schemaExcludeColumns = schema.getExcludeColumns();
- schema.setIncludeColumns(null);
- schema.setExcludeColumns(null);
-
for (IncludeTable includeTable : schema.getIncludeTables()) {
- if (engIncludeColumns != null) {
- includeTable.getIncludeColumns().addAll(engIncludeColumns);
- includeTable.getIncludeColumns().addAll(catalogIncludeColumns);
- includeTable.getIncludeColumns().addAll(schemaIncludeColumns);
- }
- if (engExcludeColumns != null) {
- includeTable.getExcludeColumns().addAll(engExcludeColumns);
- includeTable.getExcludeColumns().addAll(catalogExcludeColumns);
- includeTable.getExcludeColumns().addAll(schemaExcludeColumns);
- }
- }
- }
-
- if (catalog.getIncludeTables() != null) {
- for (IncludeTable includeTable : catalog.getIncludeTables()) {
includeTable.getIncludeColumns().addAll(engIncludeColumns);
includeTable.getIncludeColumns().addAll(catalogIncludeColumns);
+ includeTable.getIncludeColumns().addAll(schemaIncludeColumns);
includeTable.getExcludeColumns().addAll(engExcludeColumns);
includeTable.getExcludeColumns().addAll(catalogExcludeColumns);
+ includeTable.getExcludeColumns().addAll(schemaExcludeColumns);
}
}
+
+ for (IncludeTable includeTable : catalog.getIncludeTables()) {
+ includeTable.getIncludeColumns().addAll(engIncludeColumns);
+ includeTable.getIncludeColumns().addAll(catalogIncludeColumns);
+
+ includeTable.getExcludeColumns().addAll(engExcludeColumns);
+ includeTable.getExcludeColumns().addAll(catalogExcludeColumns);
+ }
}
for (Schema schema : engineering.getSchemas()) {
Collection<IncludeColumn> schemaIncludeColumns = schema.getIncludeColumns();
Collection<ExcludeColumn> schemaExcludeColumns = schema.getExcludeColumns();
- schema.setIncludeColumns(null);
- schema.setExcludeColumns(null);
-
for (IncludeTable includeTable : schema.getIncludeTables()) {
includeTable.getIncludeColumns().addAll(engIncludeColumns);
includeTable.getIncludeColumns().addAll(schemaIncludeColumns);
@@ -307,12 +271,35 @@ public final class FiltersConfigBuilder {
}
}
- if (engineering.getIncludeTables() != null) {
- for (IncludeTable includeTable : engineering.getIncludeTables()) {
- includeTable.getIncludeColumns().addAll(engIncludeColumns);
- includeTable.getExcludeColumns().addAll(engExcludeColumns);
+ for (IncludeTable includeTable : engineering.getIncludeTables()) {
+ includeTable.getIncludeColumns().addAll(engIncludeColumns);
+ includeTable.getExcludeColumns().addAll(engExcludeColumns);
+ }
+ }
+
+ private void clearGlobalFilters() {
+ for(Catalog catalog : engineering.getCatalogs()) {
+ catalog.clearIncludeTables();
+ catalog.clearExcludeTables();
+ catalog.clearIncludeProcedures();
+ catalog.clearExcludeProcedures();
+ catalog.clearIncludeColumns();
+ catalog.clearExcludeColumns();
+
+ for (Schema schema : catalog.getSchemas()) {
+ schema.clearIncludeColumns();
+ schema.clearExcludeColumns();
}
}
+
+ engineering.clearIncludeTables();
+ engineering.clearExcludeTables();
+ engineering.clearIncludeProcedures();
+ engineering.clearExcludeProcedures();
+ engineering.clearIncludeColumns();
+ engineering.clearExcludeColumns();
+
+ engineering.getSchemas().clear();
}
private void addEmptyElements() {
@@ -321,29 +308,19 @@ public final class FiltersConfigBuilder {
}
for (Catalog catalog : engineering.getCatalogs()) {
- if (catalog.getSchemas().isEmpty()
- && engineering.getSchemas().isEmpty()) {
+ if (catalog.getSchemas().isEmpty() && engineering.getSchemas().isEmpty()) {
catalog.addSchema(new Schema());
}
for (Schema schema : catalog.getSchemas()) {
- if (schema.getIncludeTables().isEmpty()
- && catalog.getIncludeTables().isEmpty()
- && engineering.getIncludeTables().isEmpty()) {
-
+ if (schema.getIncludeTables().isEmpty() && catalog.getIncludeTables().isEmpty() && engineering.getIncludeTables().isEmpty()) {
schema.addIncludeTable(new IncludeTable());
}
}
}
- if (engineering.getSchemas() == null) {
- engineering.setSchemas(new LinkedList<Schema>());
- }
-
for (Schema schema : engineering.getSchemas()) {
- if (schema.getIncludeTables().isEmpty()
- && engineering.getIncludeTables().isEmpty()) {
-
+ if (schema.getIncludeTables().isEmpty() && engineering.getIncludeTables().isEmpty()) {
schema.addIncludeTable(new IncludeTable());
}
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilderTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilderTest.java
index aac5fe9..91d537c 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilderTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilderTest.java
@@ -180,14 +180,14 @@ public class FiltersConfigBuilderTest {
" 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" +
+ " 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" +
@@ -197,14 +197,14 @@ public class FiltersConfigBuilderTest {
" 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());
+ " 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();
@@ -269,124 +269,4 @@ public class FiltersConfigBuilderTest {
incTable01.addExcludeColumn(new ExcludeColumn(excCol));
return incTable01;
}
-
- /*@Test
- public void testEmptyDbEntitiesFilters() throws Exception {
- ReverseEngineering engineering = new ReverseEngineering();
- FiltersConfig executions = new FiltersConfigBuilder(engineering).build();
-
- 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).build();
-
-
- 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).build();
-
-
- 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).build();
-
-
- 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).build();
-
- 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).build();
-
- 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.build().filter(path);
- assertFalse(filter.isEmpty());
- }*/
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Catalog.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Catalog.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Catalog.java
index a6fb4de..9f14dd6 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Catalog.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Catalog.java
@@ -18,93 +18,21 @@
****************************************************************/
package org.apache.cayenne.dbimport;
-import java.util.Collection;
-import java.util.LinkedList;
-
/**
* @since 4.0.
*/
-public class Catalog extends FilterContainer {
-
- private String name;
-
- private Collection<Schema> schemas = new LinkedList<>();
+public class Catalog extends SchemaContainer {
public Catalog() {
}
public Catalog(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Collection<Schema> getSchemas() {
- return schemas;
- }
-
- public void setSchemas(Collection<Schema> schemas) {
- this.schemas = schemas;
- }
-
- public void addSchema(Schema schema) {
- this.schemas.add(schema);
- }
-
- 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);
- }
-
- public Catalog schema(Schema name) {
- addSchema(name);
- return this;
- }
-
@Override
- public boolean isEmptyContainer() {
- if (!super.isEmptyContainer()) {
- return false;
- }
-
- if (schemas.isEmpty()) {
- return true;
- }
-
- for (Schema schema : schemas) {
- if (!schema.isEmptyContainer()) {
- return false;
- }
- }
- return true;
- }
-
public StringBuilder toString(StringBuilder res, String prefix) {
- res.append(prefix).append("Catalog: ").append(name).append("\n");
-
- if (!isBlank(schemas)) {
- for (Schema schema : schemas) {
- schema.toString(res, prefix + " ");
- }
- }
-
+ res.append(prefix).append("Catalog: ").append(getName()).append("\n");
return super.toString(res, prefix + " ");
}
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoader.java
deleted file mode 100644
index ce3154e..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoader.java
+++ /dev/null
@@ -1,223 +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.dbimport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @since 4.0.
- * @deprecated
- */
-public class DefaultReverseEngineeringLoader implements ReverseEngineeringLoader {
-
- private static final Log LOG = LogFactory.getLog(ReverseEngineeringLoader.class);
-
- @Override
- public ReverseEngineering load(InputStream inputStream) throws IOException, ReverseEngineeringLoaderException {
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
-
- DocumentBuilder dBuilder = null;
- try {
- dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(inputStream);
-
- ReverseEngineering engineering = new ReverseEngineering();
-
- Element root = doc.getDocumentElement();
- engineering.setSkipRelationshipsLoading(loadBoolean(root, "skipRelationshipsLoading"));
- engineering.setSkipPrimaryKeyLoading(loadBoolean(root, "skipPrimaryKeyLoading"));
- engineering.setTableTypes(loadTableTypes(root));
-
- engineering.setCatalogs(loadCatalogs(root));
- engineering.setSchemas(loadSchemas(root));
- engineering.setIncludeTables(loadIncludeTables(root));
- engineering.setExcludeTables(loadExcludeTables(root));
- engineering.setIncludeColumns(loadIncludeColumns(root));
- engineering.setExcludeColumns(loadExcludeColumns(root));
- engineering.setIncludeProcedures(loadIncludeProcedures(root));
- engineering.setExcludeProcedures(loadExcludeProcedures(root));
-
- return engineering;
- } catch (ParserConfigurationException e) {
- throw new ReverseEngineeringLoaderException(e.getMessage(), e);
- } catch (SAXException e) {
- throw new ReverseEngineeringLoaderException(e.getMessage(), e);
- }
- }
-
- private Boolean loadBoolean(Element root, String name) {
- return Boolean.valueOf(loadByName(root, name));
- }
-
- private Collection<ExcludeProcedure> loadExcludeProcedures(Node parent) {
- return loadPatternParams(ExcludeProcedure.class, getElementsByTagName(parent, "excludeProcedure"));
- }
-
- private Collection<IncludeProcedure> loadIncludeProcedures(Node parent) {
- return loadPatternParams(IncludeProcedure.class, getElementsByTagName(parent, "includeProcedure"));
- }
-
- private Collection<ExcludeColumn> loadExcludeColumns(Node parent) {
- return loadPatternParams(ExcludeColumn.class, getElementsByTagName(parent, "excludeColumn"));
- }
-
- private Collection<IncludeColumn> loadIncludeColumns(Node parent) {
- return loadPatternParams(IncludeColumn.class, getElementsByTagName(parent, "includeColumn"));
- }
-
- private Collection<ExcludeTable> loadExcludeTables(Node parent) {
- return loadPatternParams(ExcludeTable.class, getElementsByTagName(parent, "excludeTable"));
- }
-
- private Collection<IncludeTable> loadIncludeTables(Node parent) {
- List<Node> includeTables = getElementsByTagName(parent, "includeTable");
- Collection<IncludeTable> res = new LinkedList<IncludeTable>();
- for (Node node : includeTables) {
- IncludeTable includeTable = new IncludeTable();
-
- includeTable.setPattern(loadPattern(node));
- includeTable.setIncludeColumns(loadIncludeColumns(node));
- includeTable.setExcludeColumns(loadExcludeColumns(node));
- res.add(includeTable);
- }
- return res;
- }
-
- private Collection<Schema> loadSchemas(Node parent) {
- List<Node> schemas = getElementsByTagName(parent, "schema");
- Collection<Schema> res = new LinkedList<Schema>();
- for (Node schemaNode : schemas) {
- Schema schema = new Schema();
-
- schema.setName(loadName(schemaNode));
- schema.setIncludeTables(loadIncludeTables(schemaNode));
- schema.setExcludeTables(loadExcludeTables(schemaNode));
- schema.setIncludeColumns(loadIncludeColumns(schemaNode));
- schema.setExcludeColumns(loadExcludeColumns(schemaNode));
- schema.setIncludeProcedures(loadIncludeProcedures(schemaNode));
- schema.setExcludeProcedures(loadExcludeProcedures(schemaNode));
- res.add(schema);
- }
-
- return res;
- }
-
- private Collection<Catalog> loadCatalogs(Node parent) {
- List<Node> catalogs = getElementsByTagName(parent, "catalog");
- Collection<Catalog> res = new LinkedList<Catalog>();
- for (Node catalogNode : catalogs) {
- Catalog catalog = new Catalog();
-
- catalog.setName(loadName(catalogNode));
- catalog.setSchemas(loadSchemas(catalogNode));
- catalog.setIncludeTables(loadIncludeTables(catalogNode));
- catalog.setExcludeTables(loadExcludeTables(catalogNode));
- catalog.setIncludeColumns(loadIncludeColumns(catalogNode));
- catalog.setExcludeColumns(loadExcludeColumns(catalogNode));
- catalog.setIncludeProcedures(loadIncludeProcedures(catalogNode));
- catalog.setExcludeProcedures(loadExcludeProcedures(catalogNode));
-
- res.add(catalog);
- }
-
- 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");
- }
-
- private String loadPattern(Node catalogNode) {
- return loadByName(catalogNode, "pattern");
- }
-
- private String loadByName(Node node, String attrName) {
- Node name = node.getAttributes().getNamedItem(attrName);
- if (name != null) {
- return name.getTextContent();
- }
-
- String content = node.getTextContent().trim();
- if (!content.isEmpty()) {
- return content;
- }
-
- List<Node> names = getElementsByTagName(node, attrName);
- if (names.isEmpty()) {
- return null;
- }
-
- return names.get(0).getTextContent();
- }
-
- private <T extends PatternParam> Collection<T> loadPatternParams(Class<T> clazz, List<Node> nodes) {
- Collection<T> res = new LinkedList<T>();
- for (Node node : nodes) {
- try {
- T obj = clazz.newInstance();
- obj.setPattern(loadPattern(node));
-
- res.add(obj);
- } catch (InstantiationException e) {
- LOG.info(e.getMessage(), e);
- } catch (IllegalAccessException e) {
- LOG.info(e.getMessage(), e);
- }
- }
- return res;
- }
-
- private List<Node> getElementsByTagName(Node catalogNode, String name) {
- List<Node> nodes = new LinkedList<Node>();
- NodeList childNodes = catalogNode.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node item = childNodes.item(i);
- if (name.equals(item.getNodeName())) {
- nodes.add(item);
- }
- }
-
- return nodes;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java
deleted file mode 100644
index b9fc745..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java
+++ /dev/null
@@ -1,59 +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.dbimport;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.resource.Resource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * @since 4.0
- * @deprecated
- */
-public class DefaultReverseEngineeringWriter implements ReverseEngineeringWriter {
- private final static Log LOGGER = LogFactory.getLog(DefaultReverseEngineeringWriter.class);
-
- @Override
- public Resource write(ReverseEngineering reverseEngineering, Writer writer) throws CayenneRuntimeException {
-
- try {
- JAXBContext context = JAXBContext.newInstance(reverseEngineering.getClass());
- Marshaller marshaller = context.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
- marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
- "http://cayenne.apache.org/schema/8/reverseEngineering http://cayenne.apache.org/schema/8/reverseEngineering.xsd");
-
- marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
- marshaller.marshal(reverseEngineering, writer);
- writer.close();
- return null;//reverseEngineering.getConfigurationSource();
- } catch (JAXBException | IOException e) {
- LOGGER.error(e.getMessage(), e);
- throw new CayenneRuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FilterContainer.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FilterContainer.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FilterContainer.java
index ee7bf36..44cfcea 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FilterContainer.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FilterContainer.java
@@ -24,99 +24,124 @@ import java.util.LinkedList;
/**
* @since 4.0.
*/
-public abstract class FilterContainer {
+abstract class FilterContainer {
- private Collection<IncludeTable> includeTables = new LinkedList<>();
+ private String name;
- private Collection<ExcludeTable> excludeTables = new LinkedList<>();
+ private final Collection<IncludeTable> includeTableCollection = new LinkedList<>();
- private Collection<IncludeColumn> includeColumns = new LinkedList<>();
+ private final Collection<ExcludeTable> excludeTableCollection = new LinkedList<>();
- private Collection<ExcludeColumn> excludeColumns = new LinkedList<>();
+ private final Collection<IncludeColumn> includeColumnCollection = new LinkedList<>();
- private Collection<IncludeProcedure> includeProcedures = new LinkedList<>();
+ private final Collection<ExcludeColumn> excludeColumnCollection = new LinkedList<>();
- private Collection<ExcludeProcedure> excludeProcedures = new LinkedList<>();
+ private final Collection<IncludeProcedure> includeProcedureCollection = new LinkedList<>();
+
+ private final Collection<ExcludeProcedure> excludeProcedureCollection = new LinkedList<>();
public Collection<IncludeTable> getIncludeTables() {
- return includeTables;
+ return includeTableCollection;
}
- public void setIncludeTables(Collection<IncludeTable> includeTables) {
- this.includeTables = includeTables;
+ public Collection<ExcludeTable> getExcludeTables() {
+ return excludeTableCollection;
}
- public Collection<ExcludeTable> getExcludeTables() {
- return excludeTables;
+ public Collection<IncludeColumn> getIncludeColumns() {
+ return includeColumnCollection;
}
- public void setExcludeTables(Collection<ExcludeTable> excludeTables) {
- this.excludeTables = excludeTables;
+ public Collection<ExcludeColumn> getExcludeColumns() {
+ return excludeColumnCollection;
}
- public Collection<IncludeColumn> getIncludeColumns() {
- return includeColumns;
+ public Collection<IncludeProcedure> getIncludeProcedures() {
+ return includeProcedureCollection;
}
- public void setIncludeColumns(Collection<IncludeColumn> includeColumns) {
- this.includeColumns = includeColumns;
+ public Collection<ExcludeProcedure> getExcludeProcedures() {
+ return excludeProcedureCollection;
}
- public Collection<ExcludeColumn> getExcludeColumns() {
- return excludeColumns;
+ public void addIncludeColumn(IncludeColumn includeColumn) {
+ this.includeColumnCollection.add(includeColumn);
}
- public void setExcludeColumns(Collection<ExcludeColumn> excludeColumns) {
- this.excludeColumns = excludeColumns;
+ public void addExcludeColumn(ExcludeColumn excludeColumn) {
+ this.excludeColumnCollection.add(excludeColumn);
}
- public Collection<IncludeProcedure> getIncludeProcedures() {
- return includeProcedures;
+ public void addIncludeTable(IncludeTable includeTable) {
+ this.includeTableCollection.add(includeTable);
}
- public void setIncludeProcedures(Collection<IncludeProcedure> includeProcedures) {
- this.includeProcedures = includeProcedures;
+ public void addExcludeTable(ExcludeTable excludeTable) {
+ this.excludeTableCollection.add(excludeTable);
}
- public Collection<ExcludeProcedure> getExcludeProcedures() {
- return excludeProcedures;
+ public void addIncludeProcedure(IncludeProcedure includeProcedure) {
+ this.includeProcedureCollection.add(includeProcedure);
+ }
+
+ public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
+ this.excludeProcedureCollection.add(excludeProcedure);
}
- public void setExcludeProcedures(Collection<ExcludeProcedure> excludeProcedures) {
- this.excludeProcedures = excludeProcedures;
+ public void clearIncludeTables() {
+ includeTableCollection.clear();
}
- public void addIncludeColumn(IncludeColumn includeColumn) {
- this.includeColumns.add(includeColumn);
+ public void clearExcludeTables() {
+ excludeTableCollection.clear();
}
- public void addExcludeColumn(ExcludeColumn excludeColumn) {
- this.excludeColumns.add(excludeColumn);
+ public void clearIncludeProcedures() {
+ includeProcedureCollection.clear();
}
- public void addIncludeTable(IncludeTable includeTable) {
- this.includeTables.add(includeTable);
+ public void clearExcludeProcedures() {
+ excludeProcedureCollection.clear();
}
- public void addExcludeTable(ExcludeTable excludeTable) {
- this.excludeTables.add(excludeTable);
+ public void clearIncludeColumns() {
+ includeColumnCollection.clear();
}
- public void addIncludeProcedure(IncludeProcedure includeProcedure) {
- this.includeProcedures.add(includeProcedure);
+ public void clearExcludeColumns() {
+ excludeColumnCollection.clear();
}
- public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
- this.excludeProcedures.add(excludeProcedure);
+ 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);
}
public boolean isEmptyContainer() {
- return includeColumns.isEmpty() && excludeColumns.isEmpty()
- && includeTables.isEmpty() && excludeTables.isEmpty()
- && includeProcedures.isEmpty() && excludeProcedures.isEmpty();
+ return includeColumnCollection.isEmpty() && excludeColumnCollection.isEmpty()
+ && includeTableCollection.isEmpty() && excludeTableCollection.isEmpty()
+ && includeProcedureCollection.isEmpty() && excludeProcedureCollection.isEmpty();
}
- public static boolean isBlank(Collection<?> collection) {
+ static boolean isBlank(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
@@ -126,12 +151,12 @@ public abstract class FilterContainer {
}
public StringBuilder toString(StringBuilder res, String prefix) {
- appendCollection(res, prefix, includeTables);
- appendCollection(res, prefix, excludeTables);
- appendCollection(res, prefix, includeColumns);
- appendCollection(res, prefix, excludeColumns);
- appendCollection(res, prefix, includeProcedures);
- appendCollection(res, prefix, excludeProcedures);
+ appendCollection(res, prefix, includeTableCollection);
+ appendCollection(res, prefix, excludeTableCollection);
+ appendCollection(res, prefix, includeColumnCollection);
+ appendCollection(res, prefix, excludeColumnCollection);
+ appendCollection(res, prefix, includeProcedureCollection);
+ appendCollection(res, prefix, excludeProcedureCollection);
return res;
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java
index d4ed08a..dbd0a18 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java
@@ -26,9 +26,9 @@ import java.util.LinkedList;
*/
public class IncludeTable extends PatternParam {
- private Collection<IncludeColumn> includeColumns = new LinkedList<>();
+ private final Collection<IncludeColumn> includeColumns = new LinkedList<>();
- private Collection<ExcludeColumn> excludeColumns = new LinkedList<>();
+ private final Collection<ExcludeColumn> excludeColumns = new LinkedList<>();
public IncludeTable() {
}
@@ -42,7 +42,7 @@ public class IncludeTable extends PatternParam {
}
public void setIncludeColumns(Collection<IncludeColumn> includeColumns) {
- this.includeColumns = includeColumns;
+ this.includeColumns.addAll(includeColumns);
}
public Collection<ExcludeColumn> getExcludeColumns() {
@@ -50,7 +50,7 @@ public class IncludeTable extends PatternParam {
}
public void setExcludeColumns(Collection<ExcludeColumn> excludeColumns) {
- this.excludeColumns = excludeColumns;
+ this.excludeColumns.addAll(excludeColumns);
}
public void addIncludeColumn(IncludeColumn includeColumn) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java
index 162c718..240cd5d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java
@@ -40,6 +40,10 @@ public class PatternParam {
this.pattern = pattern;
}
+ public void setName(String name) {
+ setPattern(name);
+ }
+
/**
* Used by Maven plugin
*/
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java
index 7d66ceb..dd24211 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java
@@ -25,7 +25,7 @@ import java.util.LinkedList;
/**
* @since 4.0
*/
-public class ReverseEngineering extends FilterContainer implements Serializable {
+public class ReverseEngineering extends SchemaContainer implements Serializable {
private Boolean skipRelationshipsLoading;
@@ -106,11 +106,9 @@ public class ReverseEngineering extends FilterContainer implements Serializable
* <li> "SYNONYM"
* </ul>
*/
- private Collection<String> tableTypes = new LinkedList<>();
+ private final Collection<String> tableTypes = new LinkedList<>();
- private Collection<Catalog> catalogs = new LinkedList<>();
-
- private Collection<Schema> schemas = new LinkedList<>();
+ private final Collection<Catalog> catalogCollection = new LinkedList<>();
public ReverseEngineering() {
}
@@ -132,19 +130,7 @@ public class ReverseEngineering extends FilterContainer implements Serializable
}
public Collection<Catalog> getCatalogs() {
- return catalogs;
- }
-
- public void setCatalogs(Collection<Catalog> catalogs) {
- this.catalogs = catalogs;
- }
-
- public Collection<Schema> getSchemas() {
- return schemas;
- }
-
- public void setSchemas(Collection<Schema> schemas) {
- this.schemas = schemas;
+ return catalogCollection;
}
public String[] getTableTypes() {
@@ -157,7 +143,7 @@ public class ReverseEngineering extends FilterContainer implements Serializable
* "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
*/
public void setTableTypes(Collection<String> tableTypes) {
- this.tableTypes = tableTypes;
+ this.tableTypes.addAll(tableTypes);
}
/*
@@ -169,12 +155,8 @@ public class ReverseEngineering extends FilterContainer implements Serializable
this.tableTypes.add(type);
}
- public void addSchema(Schema schema) {
- this.schemas.add(schema);
- }
-
public void addCatalog(Catalog catalog) {
- this.catalogs.add(catalog);
+ this.catalogCollection.add(catalog);
}
@Override
@@ -182,18 +164,12 @@ public class ReverseEngineering extends FilterContainer implements Serializable
StringBuilder res = new StringBuilder();
res.append("ReverseEngineering: ").append("\n");
- if (!isBlank(catalogs)) {
- for (Catalog catalog : catalogs) {
+ if (!isBlank(catalogCollection)) {
+ for (Catalog catalog : catalogCollection) {
catalog.toString(res, " ");
}
}
- if (!isBlank(schemas)) {
- for (Schema schema : schemas) {
- schema.toString(res, " ");
- }
- }
-
if (skipRelationshipsLoading != null && skipRelationshipsLoading) {
res.append("\n Skip Relationships Loading");
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoader.java
deleted file mode 100644
index 291594d..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoader.java
+++ /dev/null
@@ -1,38 +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.dbimport;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * @since 4.0.
- * @deprecated
- */
-public interface ReverseEngineeringLoader {
-
- ReverseEngineering load(InputStream inputStream) throws CayenneRuntimeException, SAXException,
- ParserConfigurationException, IOException, ReverseEngineeringLoaderException;
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoaderException.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoaderException.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoaderException.java
deleted file mode 100644
index 92c3801..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoaderException.java
+++ /dev/null
@@ -1,39 +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.dbimport;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * @since 4.0
- * @deprecated
- */
-public class ReverseEngineeringLoaderException extends CayenneRuntimeException {
-
- public ReverseEngineeringLoaderException(String message, ParserConfigurationException e) {
- super(message, e);
- }
-
- public ReverseEngineeringLoaderException(String message, SAXException e) {
- super(message, e);
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringWriter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringWriter.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringWriter.java
deleted file mode 100644
index 3022fd3..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringWriter.java
+++ /dev/null
@@ -1,34 +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.dbimport;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.resource.Resource;
-
-import java.io.Writer;
-
-/**
- * @since 4.0
- * @deprecated
- */
-public interface ReverseEngineeringWriter {
-
- Resource write(ReverseEngineering configurationResource, Writer writer) throws CayenneRuntimeException;
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java
index e572433..5c3592b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java
@@ -23,43 +23,16 @@ package org.apache.cayenne.dbimport;
*/
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");
-
+ res.append(prefix).append("Schema: ").append(getName()).append("\n");
return super.toString(res, prefix + " ");
}
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/SchemaContainer.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/SchemaContainer.java b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/SchemaContainer.java
new file mode 100644
index 0000000..935d1e8
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/SchemaContainer.java
@@ -0,0 +1,67 @@
+/*****************************************************************
+ * 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.dbimport;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * @since 4.0
+ */
+abstract class SchemaContainer extends FilterContainer {
+
+ private final Collection<Schema> schemaCollection = new LinkedList<>();
+
+ public Collection<Schema> getSchemas() {
+ return schemaCollection;
+ }
+
+ public void addSchema(Schema schema) {
+ this.schemaCollection.add(schema);
+ }
+
+ @Override
+ public boolean isEmptyContainer() {
+ if (!super.isEmptyContainer()) {
+ return false;
+ }
+
+ if (schemaCollection.isEmpty()) {
+ return true;
+ }
+
+ for (Schema schema : schemaCollection) {
+ if (!schema.isEmptyContainer()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public StringBuilder toString(StringBuilder res, String prefix) {
+ if (!isBlank(schemaCollection)) {
+ for (Schema schema : schemaCollection) {
+ schema.toString(res, prefix);
+ }
+ }
+
+ return super.toString(res, prefix + " ");
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
deleted file mode 100644
index dd88eda..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
+++ /dev/null
@@ -1,239 +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.dbimport;
-
-
-import org.apache.cayenne.resource.URLResource;
-import org.junit.Test;
-
-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;
-
-public class DefaultReverseEngineeringLoaderTest {
-
- 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.next());
- }
-
- public static void assertCatalog(Catalog catalog ) {
- 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());
- }
-
- 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());
- }
-
- 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);
- }
-
- 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());
- }
-
- public static void assertSkipRelationshipsLoading(ReverseEngineering engineering) {
- assertTrue(engineering.getSkipRelationshipsLoading());
- }
-
- public static void assertSkipPrimaryKeyLoading(ReverseEngineering engineering) {
- assertTrue(engineering.getSkipPrimaryKeyLoading());
- }
-
- public static void assertTableTypes(ReverseEngineering engineering) {
- assertArrayEquals(new String[]{"type1", "type2", "type3"}, engineering.getTableTypes());
- }
-
- @Test
- public void testLoadCatalog() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-catalog.xml").getURL().openStream());
-
- assertCatalog(engineering);
- }
-
- @Test
- public void testLoadSchema() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-schema.xml").getURL().openStream());
-
- assertSchema(engineering);
- }
-
- @Test
- public void testLoadCatalogAndSchema() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-catalog-and-schema.xml").getURL().openStream());
-
- assertCatalogAndSchema(engineering);
- }
-
- @Test
- public void testLoadFlat() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-flat.xml").getURL().openStream());
-
- assertFlat(engineering);
- }
-
- @Test
- public void testSkipRelationships() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-skipRelationshipsLoading.xml").getURL().openStream());
-
- assertSkipRelationshipsLoading(engineering);
- }
-
- @Test
- public void testSkipPrimaryKeyLoading() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-skipPrimaryKeyLoading.xml").getURL().openStream());
-
- assertSkipPrimaryKeyLoading(engineering);
- }
-
- @Test
- public void testTableTypes() throws Exception {
- ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
- .load(getResource("reverseEngineering-tableTypes.xml").getURL().openStream());
-
- assertTableTypes(engineering);
- }
-
- protected URLResource getResource(String file) throws MalformedURLException {
- return new URLResource(getClass().getResource(file));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/67bf710b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriterTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriterTest.java b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriterTest.java
deleted file mode 100644
index 7d46c4a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriterTest.java
+++ /dev/null
@@ -1,95 +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.dbimport;
-
-import org.apache.cayenne.resource.Resource;
-import org.apache.cayenne.resource.URLResource;
-import org.custommonkey.xmlunit.Diff;
-import org.junit.Ignore;
-import org.junit.Test;
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-
-import static org.junit.Assert.assertTrue;
-
-public class DefaultReverseEngineeringWriterTest {
-
- @Ignore("reverseEngineering.xml is depreceted")
- @Test
- public void testWriteReverseEngineering() throws Exception {
- ReverseEngineeringWriter engineering = new DefaultReverseEngineeringWriter();
- ReverseEngineering reverseEngineering = new ReverseEngineering();
-
- Catalog catalog1 = new Catalog("catalog1");
- Catalog catalog2 = new Catalog("catalog2");
- Catalog catalog3 = new Catalog("catalog3");
-
- catalog1.addSchema(new Schema("schema1"));
- catalog1.addSchema(new Schema("schema2"));
-
- catalog1.addExcludeColumn(new ExcludeColumn("excludedColumn1"));
- catalog1.addExcludeColumn(new ExcludeColumn("excludedColumn2"));
- catalog1.addIncludeColumn(new IncludeColumn("includedColumn1"));
- catalog1.addIncludeColumn(new IncludeColumn("includedColumn2"));
-
- catalog1.addExcludeProcedure(new ExcludeProcedure("excludedProcedure1"));
- catalog1.addExcludeProcedure(new ExcludeProcedure("excludedProcedure2"));
- catalog1.addIncludeProcedure(new IncludeProcedure("includedProcedure1"));
- catalog1.addIncludeProcedure(new IncludeProcedure("includedProcedure2"));
-
- catalog1.addExcludeTable(new ExcludeTable("excludedTable1"));
- catalog1.addExcludeTable(new ExcludeTable("excludedTable2"));
- catalog1.addIncludeTable(new IncludeTable("includedTable1"));
- catalog1.addIncludeTable(new IncludeTable("includedTable2"));
-
- reverseEngineering.addCatalog(catalog1);
- reverseEngineering.addCatalog(catalog2);
- reverseEngineering.addCatalog(catalog3);
-
- reverseEngineering.addSchema(new Schema("schema3"));
-
- URL url = getClass().getResource("reverseEngineering.xml");
- String decodedURL = URLDecoder.decode(url.getPath(), "UTF-8");
- Writer printWriter = new PrintWriter(decodedURL);
-
-// reverseEngineering.setConfigurationSource(new URLResource(url));
-// Resource reverseEngineeringResource = engineering.write(reverseEngineering, printWriter);
-// assertReverseEngineering(reverseEngineeringResource);
- }
-
- public void assertReverseEngineering(Resource resource) throws Exception {
- URL url1 = resource.getURL();
- URL url2 = getResource("reverseEngineering-expected.xml").getURL();
-
- FileReader writedXML;
- FileReader expectedXML;
- writedXML = new FileReader(URLDecoder.decode(url1.getPath(), "UTF-8"));
- expectedXML = new FileReader(URLDecoder.decode(url2.getPath(), "UTF-8"));
- Diff diff = new Diff(writedXML, expectedXML);
- assertTrue(diff.identical());
- }
-
- protected URLResource getResource(String file) throws MalformedURLException {
- return new URLResource(getClass().getResource(file));
- }
-}