Repository: cayenne
Updated Branches:
  refs/heads/master 80f26f064 -> be6ca8412


addition of reverse-engineering-config support in modelMap.xsd, addition of 
header in reverse engineering file


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

Branch: refs/heads/master
Commit: bf001f56c00284aa355b8cc3ef99ca330f38daba
Parents: fdfeb3a
Author: Olya Bondareva <[email protected]>
Authored: Sat Feb 27 00:39:46 2016 +0100
Committer: Olya Bondareva <[email protected]>
Committed: Sun Feb 28 22:51:26 2016 +0100

----------------------------------------------------------------------
 .../cayenne/project/ConfigurationSaver.java     |   3 +-
 .../DefaultReverseEngineeringWriter.java        |   6 +-
 .../cayenne/dbimport/ReverseEngineering.java    |  10 ++
 .../org/apache/cayenne/schema/7/modelMap.xsd    |   7 +
 .../cayenne/schema/7/reverseEngineering.xsd     | 139 +++++++++++++++++++
 .../dbimport/reverseEngineering-expected.xml    |   4 +-
 .../src/main/resources/reverseEngineering.xsd   | 139 -------------------
 .../dialog/db/ReverseEngineeringView.java       |   6 +-
 8 files changed, 167 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/cayenne-project/src/main/java/org/apache/cayenne/project/ConfigurationSaver.java
----------------------------------------------------------------------
diff --git 
a/cayenne-project/src/main/java/org/apache/cayenne/project/ConfigurationSaver.java
 
b/cayenne-project/src/main/java/org/apache/cayenne/project/ConfigurationSaver.java
index d6b9c97..01d3989 100644
--- 
a/cayenne-project/src/main/java/org/apache/cayenne/project/ConfigurationSaver.java
+++ 
b/cayenne-project/src/main/java/org/apache/cayenne/project/ConfigurationSaver.java
@@ -57,7 +57,8 @@ class ConfigurationSaver extends 
BaseConfigurationNodeVisitor<Void> {
 
     @Override
     public Void visitReverseEngineering(ReverseEngineering node) {
-        XMLEncoder encoder = new XMLEncoder(printWriter);
+        XMLEncoder encoder = new XMLEncoder(printWriter, "\t", version);
+        printXMLHeader(encoder);
         node.encodeAsXML(encoder);
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/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
index be9c7d5..d72f2b8 100644
--- 
a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java
+++ 
b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/DefaultReverseEngineeringWriter.java
@@ -42,15 +42,13 @@ public class DefaultReverseEngineeringWriter implements 
ReverseEngineeringWriter
             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_FRAGMENT, true);
             marshaller.marshal(reverseEngineering, writer);
             writer.close();
             return reverseEngineering.getConfigurationSource();
-        } catch (JAXBException e) {
-            LOGGER.error(e.getMessage(), e);
-            throw new CayenneRuntimeException(e);
-        } catch (IOException e) {
+        } catch (JAXBException | IOException e) {
             LOGGER.error(e.getMessage(), e);
             throw new CayenneRuntimeException(e);
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/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 7fa0a12..8d4e2a8 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
@@ -39,6 +39,16 @@ public class ReverseEngineering extends FilterContainer 
implements Configuration
 
     private static final Log LOG = LogFactory.getLog(ReverseEngineering.class);
 
+    @XmlAttribute(name="xmlns")
+    private static final String xmlns = 
"http://cayenne.apache.org/schema/8/reverseEngineering";;
+
+    @XmlAttribute(name="xmlns:xsi")
+    private static final String xmlns_xsi = 
"http://www.w3.org/2001/XMLSchema-instance";;
+
+    @XmlAttribute(name="xsi:schemaLocation")
+    private static final String xsi_schemaLocation =
+            "http://cayenne.apache.org/schema/8/reverseEngineering 
http://cayenne.apache.org/schema/8/reverseEngineering.xsd";;
+
     public ReverseEngineering(String name) {
         this.name = name;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/modelMap.xsd
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/modelMap.xsd 
b/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/modelMap.xsd
index df665ea..37f0f91 100644
--- a/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/modelMap.xsd
+++ b/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/modelMap.xsd
@@ -31,6 +31,7 @@
        <xs:element name="data-map">
                <xs:complexType>
                        <xs:sequence>
+                               <xs:element minOccurs="0" maxOccurs="1" 
ref="cay:reverse-engineering-config"/>
                                <xs:element minOccurs="0" maxOccurs="unbounded" 
ref="cay:property"/>
                                <xs:element minOccurs="0" maxOccurs="unbounded" 
ref="cay:embeddable"/>
                                <xs:element minOccurs="0" maxOccurs="unbounded" 
ref="cay:procedure"/>
@@ -206,6 +207,12 @@
 
        <xs:element name="ejbql" type="xs:string"/>
 
+       <xs:element name="reverse-engineering-config">
+               <xs:complexType>
+                       <xs:attribute name="name" use="required" 
type="xs:string"/>
+               </xs:complexType>
+       </xs:element>
+
        <xs:element name="property">
                <xs:annotation>
                        <xs:documentation>A generic property used by other 
elements.</xs:documentation>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/reverseEngineering.xsd
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/reverseEngineering.xsd
 
b/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/reverseEngineering.xsd
new file mode 100644
index 0000000..6905386
--- /dev/null
+++ 
b/cayenne-server/src/main/resources/org/apache/cayenne/schema/7/reverseEngineering.xsd
@@ -0,0 +1,139 @@
+<?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.
+  -->
+<xs:schema attributeFormDefault="unqualified"
+           elementFormDefault="qualified"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema";>
+
+    <xs:complexType name="PatternParamType" mixed="true">
+        <xs:annotation>
+            <xs:documentation>
+                At least one of 3 options ot fill pattern information should 
be used
+                1) &lt;tag>pattarn&lt;tag>
+                2) &lt;tag pattern="pattern" />
+                3) &lt;tag>
+                      &lt;pattern>pattern&lt;/pattern>
+                   &lt;/tag>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:sequence>
+            <xs:element type="xs:string" name="pattern" minOccurs="0"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="pattern" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="IncludeTableType" mixed="true">
+        <xs:complexContent>
+            <xs:extension base="PatternParamType">
+                <xs:sequence>
+                    <xs:choice minOccurs="0" maxOccurs="unbounded">
+                        <xs:element name="includeColumn" 
type="PatternParamType" />
+                        <xs:element name="excludeColumn" 
type="PatternParamType" />
+                    </xs:choice>
+                </xs:sequence>
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+    <xs:complexType name="FilterContainerType">
+        <xs:sequence>
+            <xs:choice minOccurs="1" maxOccurs="unbounded">
+                <xs:element name="includeTable" type="IncludeTableType" />
+                <xs:element name="excludeTable" type="PatternParamType" />
+                <xs:element name="includeColumn" type="PatternParamType" />
+                <xs:element name="excludeColumn" type="PatternParamType" />
+                <xs:element name="includeProcedure" type="PatternParamType" />
+                <xs:element name="excludeProcedure" type="PatternParamType" />
+            </xs:choice>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="SchemaType" mixed="true">
+        <xs:annotation>
+            <xs:documentation>
+                At least one of 3 options to provide schema name can be used:
+                1) &lt;schema>name&lt;schema>
+                2) &lt;schema name="name" />
+                3) &lt;schema>
+                &lt;name>name&lt;/name>
+                &lt;/schema>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FilterContainerType">
+                <xs:sequence>
+                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
+                </xs:sequence>
+                <xs:attribute type="xs:string" name="name" use="optional" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+    <xs:complexType name="CatalogType" mixed="true">
+        <xs:annotation>
+            <xs:documentation>
+                At least one of 3 options to provide schema name can be used:
+                1) &lt;catalog>name&lt;catalog>
+                2) &lt;catalog name="name" />
+                3) &lt;catalog>
+                &lt;name>name&lt;/name>
+                &lt;/catalog>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FilterContainerType">
+                <xs:sequence>
+                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
+                    <xs:choice minOccurs="0" maxOccurs="unbounded">
+                        <xs:element name="schema" type="SchemaType" />
+                    </xs:choice>
+                </xs:sequence>
+                <xs:attribute type="xs:string" name="name" use="optional" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+    <xs:complexType name="ReverseEngineeringType">
+        <xs:annotation>
+            <xs:documentation>
+                <!-- TODO -->
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FilterContainerType">
+                <xs:sequence>
+                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
+                    <xs:choice minOccurs="0" maxOccurs="unbounded">
+                        <xs:element name="catalog" type="CatalogType" />
+                        <xs:element name="schema" type="SchemaType" />
+                    </xs:choice>
+                </xs:sequence>
+                <xs:attribute type="xs:string" name="name" use="optional" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+    <xs:element name="reverseEngineering" type="ReverseEngineeringType">
+        <xs:annotation>
+            <!-- TODO -->
+            <xs:documentation> </xs:documentation>
+        </xs:annotation>
+    </xs:element>
+
+</xs:schema>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/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
index 4f3f928..ba4a31a 100644
--- 
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
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<reverseEngineering>
+<reverseEngineering 
xmlns="http://cayenne.apache.org/schema/8/reverseEngineering";
+                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+                    
xsi:schemaLocation="http://cayenne.apache.org/schema/8/reverseEngineering 
http://cayenne.apache.org/schema/8/reverseEngineering.xsd";>
     <catalog name="catalog1">
         <includeTable pattern="includedTable1"/>
         <includeTable pattern="includedTable2"/>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/cayenne-tools/src/main/resources/reverseEngineering.xsd
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/reverseEngineering.xsd 
b/cayenne-tools/src/main/resources/reverseEngineering.xsd
deleted file mode 100644
index 6905386..0000000
--- a/cayenne-tools/src/main/resources/reverseEngineering.xsd
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-<xs:schema attributeFormDefault="unqualified"
-           elementFormDefault="qualified"
-           xmlns:xs="http://www.w3.org/2001/XMLSchema";>
-
-    <xs:complexType name="PatternParamType" mixed="true">
-        <xs:annotation>
-            <xs:documentation>
-                At least one of 3 options ot fill pattern information should 
be used
-                1) &lt;tag>pattarn&lt;tag>
-                2) &lt;tag pattern="pattern" />
-                3) &lt;tag>
-                      &lt;pattern>pattern&lt;/pattern>
-                   &lt;/tag>
-            </xs:documentation>
-        </xs:annotation>
-        <xs:sequence>
-            <xs:element type="xs:string" name="pattern" minOccurs="0"/>
-        </xs:sequence>
-        <xs:attribute type="xs:string" name="pattern" use="optional"/>
-    </xs:complexType>
-
-    <xs:complexType name="IncludeTableType" mixed="true">
-        <xs:complexContent>
-            <xs:extension base="PatternParamType">
-                <xs:sequence>
-                    <xs:choice minOccurs="0" maxOccurs="unbounded">
-                        <xs:element name="includeColumn" 
type="PatternParamType" />
-                        <xs:element name="excludeColumn" 
type="PatternParamType" />
-                    </xs:choice>
-                </xs:sequence>
-            </xs:extension>
-        </xs:complexContent>
-    </xs:complexType>
-
-    <xs:complexType name="FilterContainerType">
-        <xs:sequence>
-            <xs:choice minOccurs="1" maxOccurs="unbounded">
-                <xs:element name="includeTable" type="IncludeTableType" />
-                <xs:element name="excludeTable" type="PatternParamType" />
-                <xs:element name="includeColumn" type="PatternParamType" />
-                <xs:element name="excludeColumn" type="PatternParamType" />
-                <xs:element name="includeProcedure" type="PatternParamType" />
-                <xs:element name="excludeProcedure" type="PatternParamType" />
-            </xs:choice>
-        </xs:sequence>
-    </xs:complexType>
-
-    <xs:complexType name="SchemaType" mixed="true">
-        <xs:annotation>
-            <xs:documentation>
-                At least one of 3 options to provide schema name can be used:
-                1) &lt;schema>name&lt;schema>
-                2) &lt;schema name="name" />
-                3) &lt;schema>
-                &lt;name>name&lt;/name>
-                &lt;/schema>
-            </xs:documentation>
-        </xs:annotation>
-        <xs:complexContent>
-            <xs:extension base="FilterContainerType">
-                <xs:sequence>
-                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
-                </xs:sequence>
-                <xs:attribute type="xs:string" name="name" use="optional" />
-            </xs:extension>
-        </xs:complexContent>
-    </xs:complexType>
-
-    <xs:complexType name="CatalogType" mixed="true">
-        <xs:annotation>
-            <xs:documentation>
-                At least one of 3 options to provide schema name can be used:
-                1) &lt;catalog>name&lt;catalog>
-                2) &lt;catalog name="name" />
-                3) &lt;catalog>
-                &lt;name>name&lt;/name>
-                &lt;/catalog>
-            </xs:documentation>
-        </xs:annotation>
-        <xs:complexContent>
-            <xs:extension base="FilterContainerType">
-                <xs:sequence>
-                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
-                    <xs:choice minOccurs="0" maxOccurs="unbounded">
-                        <xs:element name="schema" type="SchemaType" />
-                    </xs:choice>
-                </xs:sequence>
-                <xs:attribute type="xs:string" name="name" use="optional" />
-            </xs:extension>
-        </xs:complexContent>
-    </xs:complexType>
-
-    <xs:complexType name="ReverseEngineeringType">
-        <xs:annotation>
-            <xs:documentation>
-                <!-- TODO -->
-            </xs:documentation>
-        </xs:annotation>
-        <xs:complexContent>
-            <xs:extension base="FilterContainerType">
-                <xs:sequence>
-                    <xs:element name="name" type="xs:string" minOccurs="0" 
maxOccurs="1" />
-                    <xs:choice minOccurs="0" maxOccurs="unbounded">
-                        <xs:element name="catalog" type="CatalogType" />
-                        <xs:element name="schema" type="SchemaType" />
-                    </xs:choice>
-                </xs:sequence>
-                <xs:attribute type="xs:string" name="name" use="optional" />
-            </xs:extension>
-        </xs:complexContent>
-    </xs:complexType>
-
-    <xs:element name="reverseEngineering" type="ReverseEngineeringType">
-        <xs:annotation>
-            <!-- TODO -->
-            <xs:documentation> </xs:documentation>
-        </xs:annotation>
-    </xs:element>
-
-</xs:schema>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bf001f56/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ReverseEngineeringView.java
----------------------------------------------------------------------
diff --git 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ReverseEngineeringView.java
 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ReverseEngineeringView.java
index 80e0070..26b871d 100644
--- 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ReverseEngineeringView.java
+++ 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ReverseEngineeringView.java
@@ -72,9 +72,11 @@ public class ReverseEngineeringView extends JPanel {
 
     protected Map<String, DataMapViewModel> reverseEngineeringViewMap;
 
-
     private String template =
-            "<reverseEngineering>\n" +
+            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
+                    "<reverseEngineering 
xmlns=\"http://cayenne.apache.org/schema/8/reverseEngineering\"\n"; +
+                    "                    
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; +
+                    "                    
xsi:schemaLocation=\"http://cayenne.apache.org/schema/8/reverseEngineering 
http://cayenne.apache.org/schema/8/reverseEngineering.xsd\";>\n" +
                     "    
<skipRelationshipsLoading>false</skipRelationshipsLoading>\n" +
                     "    
<skipPrimaryKeyLoading>false</skipPrimaryKeyLoading>\n" +
                     "\n" +

Reply via email to