cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject [6/8] cayenne git commit: CAY-2051 | Applying new Reverse Engineering to the Modeler
Date Fri, 26 Feb 2016 08:40:55 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..8509108
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/IncludeTable.java
@@ -0,0 +1,91 @@
+/*****************************************************************
+ *   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 javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import static org.apache.commons.lang.StringUtils.join;
+
+/**
+ * @since 4.0.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class IncludeTable extends PatternParam {
+
+    @XmlElement(name = "includeColumn")
+    private Collection<IncludeColumn> includeColumns = new LinkedList<IncludeColumn>();
+
+    @XmlElement(name = "excludeColumn")
+    private Collection<ExcludeColumn> excludeColumns = new LinkedList<ExcludeColumn>();
+
+    public IncludeTable() {
+    }
+
+    public IncludeTable(String pattern) {
+        super(pattern);
+    }
+
+    public Collection<IncludeColumn> getIncludeColumns() {
+        return includeColumns;
+    }
+
+    public void setIncludeColumns(Collection<IncludeColumn> includeColumns) {
+        this.includeColumns = includeColumns;
+    }
+
+    public Collection<ExcludeColumn> getExcludeColumns() {
+        return excludeColumns;
+    }
+
+    public void setExcludeColumns(Collection<ExcludeColumn> excludeColumns) {
+        this.excludeColumns = excludeColumns;
+    }
+
+    public void addIncludeColumn(IncludeColumn includeColumn) {
+        this.includeColumns.add(includeColumn);
+    }
+
+    public void addExcludeColumn(ExcludeColumn excludeColumn) {
+        this.excludeColumns.add(excludeColumn);
+    }
+
+    @Override
+    public StringBuilder toString(StringBuilder res, String s) {
+        super.toString(res, s);
+
+        String prefix = s + "  ";
+        if (includeColumns != null && !includeColumns.isEmpty()) {
+            for (IncludeColumn includeColumn : includeColumns) {
+                includeColumn.toString(res, prefix);
+            }
+        }
+
+        if (excludeColumns != null && !excludeColumns.isEmpty()) {
+            for (ExcludeColumn excludeColumn : excludeColumns) {
+                excludeColumn.toString(res, prefix);
+            }
+        }
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..9573232
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/PatternParam.java
@@ -0,0 +1,85 @@
+/*****************************************************************
+ *   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 javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @since 4.0.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PatternParam {
+
+    @XmlAttribute(name = "pattern")
+    private String pattern;
+
+    public PatternParam() {
+    }
+
+    public PatternParam(String pattern) {
+        this.pattern = pattern;
+    }
+
+    public String getPattern() {
+        return pattern;
+    }
+
+    public void setPattern(String pattern) {
+        this.pattern = pattern;
+    }
+
+    /**
+     * used my maven
+     *
+     * @param pattern
+     */
+    public void set(String pattern) {
+        setPattern(pattern);
+    }
+
+
+    /**
+     * used my ant
+     *
+     * @param pattern
+     */
+    public void addText(String pattern) {
+        if (pattern.trim().isEmpty()) {
+            return;
+        }
+
+        setPattern(pattern);
+    }
+
+    public void addConfiguredPattern(AntNestedElement pattern) {
+        set(pattern.getName());
+    }
+
+    @Override
+    public String toString() {
+        return toString(new StringBuilder(), "").toString();
+    }
+
+    public StringBuilder toString(StringBuilder res, String s) {
+        res.append(s).append(getClass().getSimpleName()).append(": ").append(pattern).append("\n");
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..7fa0a12
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineering.java
@@ -0,0 +1,196 @@
+/*****************************************************************
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.resource.Resource;
+import org.apache.cayenne.util.XMLEncoder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.annotation.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * @since 4.0.
+ */
+@XmlRootElement(name = "reverseEngineering")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ReverseEngineering extends FilterContainer implements ConfigurationNode, Serializable {
+
+    private static final Log LOG = LogFactory.getLog(ReverseEngineering.class);
+
+    public ReverseEngineering(String name) {
+        this.name = name;
+    }
+
+    @XmlTransient
+    private String name;
+
+    private Boolean skipRelationshipsLoading;
+
+    private Boolean skipPrimaryKeyLoading;
+
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    @XmlElement(name = "tableType")
+    private Collection<String> tableTypes = new LinkedList<String>();
+
+    @XmlElement(name = "catalog")
+    private Collection<Catalog> catalogs = new LinkedList<Catalog>();
+
+    @XmlElement(name = "schema")
+    private Collection<Schema> schemas = new LinkedList<Schema>();
+
+    /**
+     * @since 4.0
+     */
+    @XmlTransient
+    protected Resource configurationSource;
+
+    public ReverseEngineering() {
+    }
+
+    public Boolean getSkipRelationshipsLoading() {
+        return skipRelationshipsLoading;
+    }
+
+    public void setSkipRelationshipsLoading(Boolean skipRelationshipsLoading) {
+        this.skipRelationshipsLoading = skipRelationshipsLoading;
+    }
+
+    public Boolean getSkipPrimaryKeyLoading() {
+        return skipPrimaryKeyLoading;
+    }
+
+    public void setSkipPrimaryKeyLoading(Boolean skipPrimaryKeyLoading) {
+        this.skipPrimaryKeyLoading = skipPrimaryKeyLoading;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    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;
+    }
+
+    public String[] getTableTypes() {
+        return tableTypes.toArray(new String[tableTypes.size()]);
+    }
+
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    public void setTableTypes(Collection<String> tableTypes) {
+        this.tableTypes = tableTypes;
+    }
+
+    /*
+     * Typical types are "TABLE",
+     * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
+     * "LOCAL TEMPORARY", "ALIAS", "SYNONYM"., etc.
+     */
+    public void addTableType(String type) {
+        this.tableTypes.add(type);
+    }
+
+    public void addSchema(Schema schema) {
+        this.schemas.add(schema);
+    }
+
+    public void addCatalog(Catalog catalog) {
+        this.catalogs.add(catalog);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder res = new StringBuilder();
+        res.append("ReverseEngineering: ").append("\n");
+
+        if (!isBlank(catalogs)) {
+            for (Catalog catalog : catalogs) {
+                catalog.toString(res, "  ");
+            }
+        }
+
+        if (!isBlank(schemas)) {
+            for (Schema schema : schemas) {
+                schema.toString(res, "  ");
+            }
+        }
+
+        if (skipRelationshipsLoading != null && skipRelationshipsLoading) {
+            res.append("\n").append("        Skip Relationships Loading");
+        }
+        if (skipPrimaryKeyLoading != null && skipPrimaryKeyLoading) {
+            res.append("\n").append("        Skip PrimaryKey Loading");
+        }
+
+        return super.toString(res, "  ").toString();
+    }
+
+    @Override
+    public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+        return visitor.visitReverseEngineering(this);
+    }
+
+    public void encodeAsXML(XMLEncoder encoder) {
+        DefaultReverseEngineeringWriter defaultReverseEngineeringWriter = new DefaultReverseEngineeringWriter();
+        defaultReverseEngineeringWriter.write(this, encoder.getPrintWriter());
+    }
+
+    /**
+     * @since 4.0
+     */
+    public Resource getConfigurationSource() {
+        return configurationSource;
+    }
+
+    /**
+     * @since 4.0
+     */
+    public void setConfigurationSource(Resource configurationSource) {
+        this.configurationSource = configurationSource;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..b3dbb8d
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoader.java
@@ -0,0 +1,36 @@
+/*****************************************************************
+ *   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.
+ */
+public interface ReverseEngineeringLoader {
+
+    ReverseEngineering load(InputStream inputStream) throws CayenneRuntimeException, SAXException, ParserConfigurationException, IOException, ReverseEngineeringLoaderException;
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..01e2cb3
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringLoaderException.java
@@ -0,0 +1,37 @@
+/*****************************************************************
+ *   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.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * @since 4.0
+ */
+public class ReverseEngineeringLoaderException extends RuntimeException {
+
+    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/fe82b47e/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
new file mode 100644
index 0000000..41b80f6
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/ReverseEngineeringWriter.java
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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
+ */
+public interface ReverseEngineeringWriter {
+
+    Resource write(ReverseEngineering configurationResource, Writer writer) throws CayenneRuntimeException;
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..8667891
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/Schema.java
@@ -0,0 +1,71 @@
+/*****************************************************************
+ *   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 javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @since 4.0.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Schema extends FilterContainer {
+
+    @XmlAttribute(name = "name")
+    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-server/src/main/java/org/apache/cayenne/map/DataMap.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java b/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
index b19ad79..9c511c8 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
@@ -25,6 +25,7 @@ import org.apache.cayenne.Persistent;
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.dbimport.ReverseEngineering;
 import org.apache.cayenne.map.event.DbEntityListener;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.ObjEntityListener;
@@ -144,6 +145,7 @@ public class DataMap implements Serializable, ConfigurationNode, XMLSerializable
 	private SortedMap<String, Procedure> procedureMap;
 	private SortedMap<String, QueryDescriptor> queryDescriptorMap;
 	private SortedMap<String, SQLResult> results;
+    private ReverseEngineering reverseEngineering;
 
 	/**
 	 * @deprecated since 4.0 unused as listeners are no longer tied to a
@@ -319,6 +321,12 @@ public class DataMap implements Serializable, ConfigurationNode, XMLSerializable
 		encoder.printProjectVersion();
 		encoder.println(">");
 
+        if (reverseEngineering != null) {
+            encoder.print("<reverseEngineering");
+            encoder.printAttribute("name", reverseEngineering.getName().trim());
+            encoder.println("/>");
+        }
+
 		// properties
 		if (defaultLockType == ObjEntity.LOCK_TYPE_OPTIMISTIC) {
 			encoder.printProperty(DEFAULT_LOCK_TYPE_PROPERTY, "optimistic");
@@ -1391,4 +1399,12 @@ public class DataMap implements Serializable, ConfigurationNode, XMLSerializable
     public String getNameWithDefaultClientPackage(String name) {
         return getNameWithPackage(defaultClientPackage, name);
     }
+
+    public ReverseEngineering getReverseEngineering() {
+        return reverseEngineering;
+    }
+
+    public void setReverseEngineering(ReverseEngineering reverseEngineering) {
+        this.reverseEngineering = reverseEngineering;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-server/src/main/java/org/apache/cayenne/map/DbEntity.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/DbEntity.java b/cayenne-server/src/main/java/org/apache/cayenne/map/DbEntity.java
index b0ffa5a..376cb07 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/DbEntity.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/DbEntity.java
@@ -611,9 +611,11 @@ public class DbEntity extends Entity implements ConfigurationNode, DbEntityListe
     public Collection<ObjEntity> mappedObjEntities() {
         Collection<ObjEntity> objEntities = new HashSet<ObjEntity>();
         MappingNamespace mns = getDataMap().getNamespace();
-        for (ObjEntity objEntity : mns.getObjEntities()) {
-            if (equals(objEntity.getDbEntity())) {
-                objEntities.add(objEntity);
+        if (mns != null) {
+            for (ObjEntity objEntity : mns.getObjEntities()) {
+                if (equals(objEntity.getDbEntity())) {
+                    objEntities.add(objEntity);
+                }
             }
         }
         return objEntities;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-server/src/main/java/org/apache/cayenne/map/MapLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/MapLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/map/MapLoader.java
index 101bebd..c4787c7 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/MapLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/MapLoader.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.dbimport.*;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.util.Util;
@@ -44,6 +45,12 @@ public class MapLoader extends DefaultHandler {
 	final static String _2_0_PACKAGE_PREFIX = "org.apache.cayenne.";
 
 	public static final String DATA_MAP_TAG = "data-map";
+
+	/**
+	 * @since 4.0
+	 */
+	public static final String REVERSE_ENGINEERING = "reverseEngineering";
+
 	public static final String PROPERTY_TAG = "property";
 
 	/**
@@ -145,6 +152,7 @@ public class MapLoader extends DefaultHandler {
 	private Procedure procedure;
 	private QueryDescriptorLoader queryBuilder;
 	private String sqlKey;
+	private ReverseEngineering reverseEngineering;
 
 	private String descending;
 	private String ignoreCase;
@@ -169,6 +177,15 @@ public class MapLoader extends DefaultHandler {
 			}
 		});
 
+		startTagOpMap.put(REVERSE_ENGINEERING, new StartClosure() {
+
+			@Override
+			void execute(Attributes attributes) throws SAXException {
+				processStartReverseEngineering(attributes);
+			}
+		});
+
+		
 		startTagOpMap.put(DB_ENTITY_TAG, new StartClosure() {
 
 			@Override
@@ -561,6 +578,13 @@ public class MapLoader extends DefaultHandler {
 		});
 	}
 
+	private void processStartReverseEngineering(Attributes attributes) {
+		reverseEngineering = new ReverseEngineering();
+		reverseEngineering.setName(attributes.getValue("", "name"));
+
+		dataMap.setReverseEngineering(reverseEngineering);
+	}
+	
 	private void processStartDataMap(Attributes attributes) {
 		this.mapVersion = attributes.getValue("", "project-version");
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameCheckers.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameCheckers.java b/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameCheckers.java
index b6f6070..67639d6 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameCheckers.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameCheckers.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.map.naming;
 
 import org.apache.cayenne.access.DataDomain;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.Entity;
@@ -63,6 +64,23 @@ public enum NameCheckers implements NameChecker {
 		}
 	},
 
+	reverseEngineering("reverseEngineering") {
+		@Override
+		public boolean isNameInUse(Object namingContext, String name) {
+			if (namingContext == null) {
+				return false;
+			}
+
+			for (DataMap dataMap : ((DataChannelDescriptor) namingContext).getDataMaps()) {
+                if (dataMap!= null && dataMap.getReverseEngineering() != null &&
+                        dataMap.getReverseEngineering().getName()!=null && dataMap.getReverseEngineering().getName().equals(name)) {
+                    return true;
+                }
+			}
+			return false;
+		}
+	},
+
 	objEntity("ObjEntity") {
 		@Override
 		public boolean isNameInUse(Object namingContext, String name) {
@@ -75,7 +93,7 @@ public enum NameCheckers implements NameChecker {
 		@Override
 		public boolean isNameInUse(Object namingContext, String name) {
 			DataMap map = (DataMap) namingContext;
-            return map.getEmbeddable(map.getNameWithDefaultPackage(name)) != null;
+			return map.getEmbeddable(map.getNameWithDefaultPackage(name)) != null;
 		}
 	},
 
@@ -150,7 +168,7 @@ public enum NameCheckers implements NameChecker {
 		@Override
 		public boolean isNameInUse(Object namingContext, String name) {
 			DataChannelDescriptor domain = (DataChannelDescriptor) namingContext;
-			for (org.apache.cayenne.configuration.DataNodeDescriptor dataNodeDescriptor : domain
+			for (DataNodeDescriptor dataNodeDescriptor : domain
 					.getNodeDescriptors()) {
 				if (dataNodeDescriptor.getName().equals(name)) {
 					return true;
@@ -166,7 +184,7 @@ public enum NameCheckers implements NameChecker {
 			ObjEntity ent = (ObjEntity) namingContext;
 			return dbAttribute.isNameInUse(namingContext, name)
 					|| ent.getCallbackMethods().contains(
-							"get" + StringUtils.capitalize(name));
+					"get" + StringUtils.capitalize(name));
 		}
 	},
 
@@ -184,7 +202,7 @@ public enum NameCheckers implements NameChecker {
 
 			return name.startsWith("get")
 					&& dbAttribute.isNameInUse(namingContext,
-							StringUtils.uncapitalize(name.substring(3)))
+					StringUtils.uncapitalize(name.substring(3)))
 					|| ent.getCallbackMethods().contains(name);
 		}
 	};

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..4dcc690
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringLoaderTest.java
@@ -0,0 +1,240 @@
+/*
+ * 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 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.junit.Test;
+
+public class DefaultReverseEngineeringLoaderTest {
+
+	@Test
+	public void testLoadCatalog() throws Exception {
+		ReverseEngineering engineering = new DefaultReverseEngineeringLoader()
+				.load(getResource("reverseEngineering-catalog.xml").getURL().openStream());
+
+		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").getURL().openStream());
+
+		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").getURL().openStream());
+
+		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").getURL().openStream());
+
+		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").getURL().openStream());
+
+		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").getURL().openStream());
+
+		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").getURL().openStream());
+
+		assertTableTypes(engineering);
+	}
+
+	public static void assertTableTypes(ReverseEngineering engineering) {
+		assertArrayEquals(engineering.getTableTypes(), new String[] { "type1", "type2", "type3" });
+	}
+
+	protected URLResource getResource(String file) throws MalformedURLException {
+		return new URLResource(getClass().getResource(file));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/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
new file mode 100644
index 0000000..e028431
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriterTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.cayenne.resource.URLResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Difference;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+import sun.security.util.Resources;
+
+import javax.xml.bind.JAXBException;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+/*
+ * @since 4.0
+ */
+
+public class DefaultReverseEngineeringWriterTest {
+
+    @Test
+    public void testWriteReverseEngineering() throws Exception {
+        ReverseEngineeringWriter engineering = new DefaultReverseEngineeringWriter();
+        ReverseEngineering reverseEngineering = new ReverseEngineering();
+        Resource resource = getResource("reverseEngineering.xml");
+        reverseEngineering.setConfigurationSource(resource);
+
+        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"));
+
+        File file = new File(resource.getURL().getPath());
+        PrintWriter printWriter = new PrintWriter(new FileWriter(file));
+
+        assertReverseEngineering(engineering.write(reverseEngineering, printWriter));
+    }
+
+    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(url1.getPath());
+        expectedXML = new FileReader(url2.getPath());
+        Diff diff = new Diff(writedXML, expectedXML);
+        assertTrue(diff.identical());
+    }
+
+    protected URLResource getResource(String file) throws MalformedURLException {
+        return new URLResource(getClass().getResource(file));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
new file mode 100644
index 0000000..9a94618
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/dbimport/FiltersConfigBuilderTest.java
@@ -0,0 +1,382 @@
+/*
+ * 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.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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-ant-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-ant-mapping.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-ant-mapping.xml
new file mode 100644
index 0000000..4bdd44a
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-ant-mapping.xml
@@ -0,0 +1,31 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog-and-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog-and-schema.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog-and-schema.xml
new file mode 100644
index 0000000..46c26d0
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog-and-schema.xml
@@ -0,0 +1,65 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog.xml
new file mode 100644
index 0000000..d820aa4
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-catalog.xml
@@ -0,0 +1,68 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-expected.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-expected.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-expected.xml
new file mode 100644
index 0000000..4f3f928
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-expected.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<reverseEngineering>
+    <catalog name="catalog1">
+        <includeTable pattern="includedTable1"/>
+        <includeTable pattern="includedTable2"/>
+        <excludeTable pattern="excludedTable1"/>
+        <excludeTable pattern="excludedTable2"/>
+        <includeColumn pattern="includedColumn1"/>
+        <includeColumn pattern="includedColumn2"/>
+        <excludeColumn pattern="excludedColumn1"/>
+        <excludeColumn pattern="excludedColumn2"/>
+        <includeProcedure pattern="includedProcedure1"/>
+        <includeProcedure pattern="includedProcedure2"/>
+        <excludeProcedure pattern="excludedProcedure1"/>
+        <excludeProcedure pattern="excludedProcedure2"/>
+        <schema name="schema1"/>
+        <schema name="schema2"/>
+    </catalog>
+    <catalog name="catalog2"/>
+    <catalog name="catalog3"/>
+    <schema name="schema3"/>
+</reverseEngineering>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fe82b47e/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-flat.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-flat.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-flat.xml
new file mode 100644
index 0000000..5b785af
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-flat.xml
@@ -0,0 +1,61 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-maven-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-maven-mapping.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-maven-mapping.xml
new file mode 100644
index 0000000..c9d722e
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-maven-mapping.xml
@@ -0,0 +1,55 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-mixed-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-mixed-mapping.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-mixed-mapping.xml
new file mode 100644
index 0000000..deb3dab
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-mixed-mapping.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-schema.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-schema.xml
new file mode 100644
index 0000000..97c2c6f
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-schema.xml
@@ -0,0 +1,69 @@
+<?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-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-skipPrimaryKeyLoading.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-skipPrimaryKeyLoading.xml b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-skipPrimaryKeyLoading.xml
new file mode 100644
index 0000000..e0d74bd
--- /dev/null
+++ b/cayenne-server/src/test/resources/org/apache/cayenne/dbimport/reverseEngineering-skipPrimaryKeyLoading.xml
@@ -0,0 +1,23 @@
+<?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>


Mime
View raw message