You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ra...@apache.org on 2007/04/24 02:45:59 UTC
svn commit: r531667 - in /xmlbeans/trunk/samples/vxsdb: DdlUtils-1.0-RC1.jar
README.txt build.xml datamodel.vm property.vm run.xml
src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java
xml/datamodel.sample.xml
Author: radup
Date: Mon Apr 23 17:45:59 2007
New Revision: 531667
URL: http://svn.apache.org/viewvc?view=rev&rev=531667
Log:
Fix for XMLBEANS-227 - brought the VelocityXmlBeans example back into a working state.
Contributed by Philip Mark Donaghy and Radu Preotiuc.
Added:
xmlbeans/trunk/samples/vxsdb/DdlUtils-1.0-RC1.jar (with props)
Modified:
xmlbeans/trunk/samples/vxsdb/README.txt
xmlbeans/trunk/samples/vxsdb/build.xml
xmlbeans/trunk/samples/vxsdb/datamodel.vm
xmlbeans/trunk/samples/vxsdb/property.vm
xmlbeans/trunk/samples/vxsdb/run.xml
xmlbeans/trunk/samples/vxsdb/src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java
xmlbeans/trunk/samples/vxsdb/xml/datamodel.sample.xml
Added: xmlbeans/trunk/samples/vxsdb/DdlUtils-1.0-RC1.jar
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/DdlUtils-1.0-RC1.jar?view=auto&rev=531667
==============================================================================
Binary file - no diff available.
Propchange: xmlbeans/trunk/samples/vxsdb/DdlUtils-1.0-RC1.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: xmlbeans/trunk/samples/vxsdb/README.txt
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/README.txt?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/README.txt (original)
+++ xmlbeans/trunk/samples/vxsdb/README.txt Mon Apr 23 17:45:59 2007
@@ -1,7 +1,7 @@
Sample: VelocityXmlBeans
Category: sql
Author: Philip Mark Donaghy
-Last Updated: Dec. 4, 2004
+Last Updated: Apr. 23, 2007
Versions:
xmlbeans-v1 1.0.3
@@ -9,7 +9,7 @@
--------------------------------------------------------------------------------
-Vxsdb is a XmlBeans sample application which derives a Jakarta Commons SQL data
+Vxsdb is a XmlBeans sample application which derives a Apache DB DdlUtils data
model from an xml schema. It was conceived from things I have learned from using
XmlBeans and talking to people at the ASF conference. Vxsdb uses Jakarta
Velocity as its templating engine.
@@ -17,9 +17,9 @@
Features:
- Inputs a xml schema
- - Outputs an Commons SQL data model in xml
+ - Outputs an Apache DB DdlUtils data model in xml
-Building this sample requires Jakarta dependancies which are automatically
+Building this sample requires Apache dependancies which are automatically
downloaded to the lib directory when Ant is executed.
To try out this sample:
@@ -28,18 +28,18 @@
2. Ant must be on your PATH
3. To compile the sample source, run "ant"
4. To execute the sample, run "ant -f run.xml"
-5. The files xml/datamodel.xml and sql/create.sql are generated
+5. The files build/datamodel.xml and build/create.sql are generated
To build this sample without downloading dependencies
-----------------------------------------------------
ant -Ddeps.exist=true
-By default run creates a ddl for the Postgres RDBMS. To change the target
+By default run creates a ddl for the Derby RDBMS. To change the target
database add a directive on the command line.
Change database
---------------
-ant -f run.xml -DtargetDatabase=oracle
+ant -f run.xml -DtargetDatabase=postgresql
Postgres quickstart
-------------------
Modified: xmlbeans/trunk/samples/vxsdb/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/build.xml?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/build.xml (original)
+++ xmlbeans/trunk/samples/vxsdb/build.xml Mon Apr 23 17:45:59 2007
@@ -21,7 +21,7 @@
<property name="targetDatabase" value="postgresql" />
<description>
- Sample integration of Velocity and XmlBeans to produce a Jakarta commons-sql datamodel.xml file.
+ Sample integration of Velocity and XMLBeans that produces a Apache DB DddUtils datamodel.xml file from a xml schema.
</description>
<target name="build" depends="init,getdeps" description="Compile the sample code">
@@ -29,23 +29,30 @@
<classpath>
<pathelement location="lib/ant-1.6.2.jar" />
<pathelement location="lib/commons-logging-1.0.3.jar" />
- <pathelement location="lib/velocity-1.4.jar" />
+ <pathelement location="lib/velocity-1.5.jar" />
<path refid="xmlbeans.path" />
</classpath>
</javac>
+ <echo>Execute 'ant -f run.xml' to run the sample xml schema generator</echo>
</target>
- <target name="getdeps" unless="deps.exist">
+ <target name="getdeps" unless="deps.exist" description="Download dependencies">
<get dest="lib/ant-1.6.2.jar" src="http://www.ibiblio.org/maven/ant/jars/ant-1.6.2.jar" verbose="true" usetimestamp="true" />
<get dest="lib/commons-beanutils-1.7.0.jar" src="http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-1.7.0.jar" verbose="true" usetimestamp="true" />
- <get dest="lib/commons-betwixt-0.5.jar" src="http://www.ibiblio.org/maven/commons-betwixt/jars/commons-betwixt-0.5.jar" verbose="true" usetimestamp="true" />
+ <get dest="lib/commons-betwixt-0.8.jar" src="http://www.ibiblio.org/maven/commons-betwixt/jars/commons-betwixt-0.8.jar" verbose="true" usetimestamp="true" />
<get dest="lib/commons-collections-3.1.jar" src="http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-3.1.jar" verbose="true" usetimestamp="true" />
<get dest="lib/commons-digester-1.5.jar" src="http://www.ibiblio.org/maven/commons-digester/jars/commons-digester-1.5.jar" verbose="true" usetimestamp="true" />
<get dest="lib/commons-logging-1.0.3.jar" src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.3.jar" verbose="true" usetimestamp="true" />
- <get dest="lib/commons-sql-1.0-dev.jar" src="http://www.ibiblio.org/maven/commons-sql/jars/commons-sql-1.0-dev.jar" verbose="true" usetimestamp="true" />
+ <get dest="lib/commons-dbcp-1.2.1.jar" src="http://www.ibiblio.org/maven/commons-dbcp/jars/commons-dbcp-1.2.1.jar" verbose="true" usetimestamp="true" />
+ <get dest="lib/commons-pool-1.2.jar" src="http://www.ibiblio.org/maven/commons-pool/jars/commons-pool-1.2.jar" verbose="true" usetimestamp="true" />
+ <get dest="lib/commons-lang-2.1.jar" src="http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.1.jar" verbose="true" usetimestamp="true" />
+ <!-- Update this, using a alternative location because it does not exist on ibiblio
+ <get dest="lib/DdlUtils-1.0-dev.jar" src="http://www.ibiblio.org/maven/ddlutils/jars/DdlUtils-1.0-dev.jar" verbose="true" usetimestamp="true" /> -->
+ <copy todir="lib" file="DdlUtils-1.0-RC1.jar" />
+ <get dest="lib/derby-10.1.1.0.jar" src="http://www.ibiblio.org/maven/org.apache.derby/jars/derby-10.1.1.0.jar" verbose="true" usetimestamp="true" />
<get dest="lib/dom4j-1.4.jar" src="http://www.ibiblio.org/maven/dom4j/jars/dom4j-1.4.jar" verbose="true" usetimestamp="true" />
<get dest="lib/log4j-1.2.8.jar" src="http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.8.jar" verbose="true" usetimestamp="true" />
- <get dest="lib/velocity-1.4.jar" src="http://www.ibiblio.org/maven/velocity/jars/velocity-1.4.jar" verbose="true" usetimestamp="true" />
+ <get dest="lib/velocity-1.5.jar" src="http://www.ibiblio.org/maven/velocity/jars/velocity-1.5.jar" verbose="true" usetimestamp="true" />
</target>
<target name="init" description="Precompiler initialization">
Modified: xmlbeans/trunk/samples/vxsdb/datamodel.vm
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/datamodel.vm?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/datamodel.vm (original)
+++ xmlbeans/trunk/samples/vxsdb/datamodel.vm Mon Apr 23 17:45:59 2007
@@ -25,7 +25,7 @@
#foreach($global in $xsd.globalElements())## SchemaGlobalElement[]
<!-- Table $global.name -->
- <table name='$global.name.localPart.toUpperCase().replace("-","_")'>
+ <table name="$global.name.localPart.toUpperCase()">
#set($global = $global.type)
#parse("global.vm")
@@ -37,7 +37,7 @@
#foreach($global in $xsd.globalTypes())## SchemaType[]
<!-- Table $global.name -->
- <table name='$global.name.localPart.toUpperCase().replace("-","_")'>
+ <table name="$global.name.localPart.toUpperCase()">
#parse("global.vm")
Modified: xmlbeans/trunk/samples/vxsdb/property.vm
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/property.vm?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/property.vm (original)
+++ xmlbeans/trunk/samples/vxsdb/property.vm Mon Apr 23 17:45:59 2007
@@ -18,29 +18,29 @@
#if($property.type.simpleType)
<!-- $property.type -->
- <column name='$property.name.localPart.toUpperCase().replace("-","_")' type='#parse("type.vm")' />
+ <column name="$property.name.localPart.toUpperCase()" type='#parse("type.vm")' />
#elseif( $property.maxOccurs.intValue() == 1 && $property.minOccurs.intValue() == 0 )
<!-- $property.type -->
- <column name='FK_$property.name.localPart.toUpperCase().replace("-","_")' type="INTEGER" />
- <foreign-key foreignTable='$property.name.localPart.toUpperCase().replace("-","_")'>
- <reference local='FK_$property.name.localPart.toUpperCase().replace("-","_")' foreign="PK"/>
+ <column name="FK_$property.name.localPart.toUpperCase()" type="INTEGER" />
+ <foreign-key foreignTable='$property.name.localPart.toUpperCase()'>
+ <reference local='FK_$property.name.localPart.toUpperCase()' foreign="PK"/>
</foreign-key>
#elseif( $property.maxOccurs.intValue() == 1 )
<!-- $property.type -->
- <column name='FK_$property.name.localPart.toUpperCase().replace("-","_")' required="true" type="INTEGER" />
- <foreign-key foreignTable='$property.name.localPart.toUpperCase().replace("-","_")'>
- <reference local='FK_$property.name.localPart.toUpperCase().replace("-","_")' foreign="PK"/>
+ <column name='FK_$property.name.localPart.toUpperCase()' required="true" type="INTEGER" />
+ <foreign-key foreignTable='$property.name.localPart.toUpperCase()'>
+ <reference local='FK_$property.name.localPart.toUpperCase()' foreign="PK"/>
</foreign-key>
#elseif( $property.maxOccurs.intValue() > 1 || "$!property.maxOccurs" == "")## Greater than one or unbounded
- <!-- Foreign key imported from table named $property.name.localPart.toUpperCase().replace("-","_") -->
+ <!-- Foreign key imported from table named $property.name.localPart.toUpperCase() -->
#else
<!-- This is a debug line that provides information for properties -->
<!-- that are not handled in the property.vm template logic. -->
<!-- SimpleType:$property.type.simpleType -->
<!-- maxOccurs:"$property.maxOccurs" -->
- <!-- column name='$property.name.localPart.toUpperCase().replace("-","_")' type=""/ -->
+ <!-- column name='$property.name.localPart.toUpperCase()' type=""/ -->
#end
Modified: xmlbeans/trunk/samples/vxsdb/run.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/run.xml?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/run.xml (original)
+++ xmlbeans/trunk/samples/vxsdb/run.xml Mon Apr 23 17:45:59 2007
@@ -22,30 +22,36 @@
</description>
<property environment="env" />
- <property name="targetDatabase" value="postgresql" />
+ <property name="targetDatabase" value="derby" />
<property name="schema" value="schemas/easypo.xsd" />
<property name="template" value="datamodel.vm" />
- <property name="output" value="xml/datamodel.xml" />
- <property name="ddl" value="sql/create.sql" />
+ <property name="output" value="build/datamodel.xml" />
+ <property name="ddl" value="build/create.sql" />
<path id="vxsdb.runtime.classpath">
<pathelement path="build" />
<pathelement location="lib/ant-1.6.2.jar" />
<pathelement location="lib/commons-collections-3.1.jar" />
+ <pathelement location="lib/commons-lang-2.1.jar" />
<pathelement location="lib/commons-logging-1.0.3.jar" />
<pathelement location="lib/log4j-1.2.8.jar" />
- <pathelement location="lib/velocity-1.4.jar" />
+ <pathelement location="lib/velocity-1.5.jar" />
<path refid="xmlbeans.path" />
</path>
<path id="commons-sql.runtime.classpath">
<pathelement location="lib/commons-beanutils-1.7.0.jar" />
- <pathelement location="lib/commons-betwixt-0.5.jar" />
+ <pathelement location="lib/commons-betwixt-0.8.jar" />
<pathelement location="lib/commons-collections-3.1.jar" />
<pathelement location="lib/commons-digester-1.5.jar" />
<pathelement location="lib/commons-logging-1.0.3.jar" />
- <pathelement location="lib/commons-sql-1.0-dev.jar" />
+ <pathelement location="lib/commons-dbcp-1.2.1.jar" />
+ <pathelement location="lib/commons-pool-1.2.jar" />
+ <pathelement location="lib/commons-lang-2.1.jar" />
+ <pathelement location="lib/DdlUtils-1.0-RC1.jar" />
<pathelement location="lib/dom4j-1.4.jar" />
+ <pathelement location="lib/log4j-1.2.8.jar"/>
+ <pathelement location="lib/derby-10.1.1.0.jar" />
</path>
<target name="run" depends="init" description="Run the sample code">
@@ -65,9 +71,16 @@
</target>
<target name="create-db-sql" depends="runjava" description="Create an sql script (DDL) from the xml datamodel">
- <!-- Jakarta Commons SQL Task-->
- <taskdef name="ddl" classname="org.apache.commons.sql.task.DDLTask" description="The task used to create a ddl from the datamodel xml." classpathref="commons-sql.runtime.classpath" />
- <ddl xmlFile="${output}" targetDatabase="${targetDatabase}" output="${ddl}" />
+ <!-- DDLUtils Task-->
+ <taskdef name="ddl" classname="org.apache.ddlutils.task.DdlToDatabaseTask" description="The task used to create a ddl from the datamodel xml." classpathref="commons-sql.runtime.classpath" />
+ <ddl schemaFile="${output}" databaseType="${targetDatabase}">
+ <database url="jdbc:derby:build/db"
+ driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
+ username=""
+ password=""/>
+ <createDatabase failonerror="false"/>
+ <writeSchemaSqlToFile outputFile="${ddl}" />
+ </ddl>
</target>
<target name="clean" description="Delete the generated files">
Modified: xmlbeans/trunk/samples/vxsdb/src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java (original)
+++ xmlbeans/trunk/samples/vxsdb/src/java/org/apache/xmlbeans/samples/vxsdb/VelocityXmlBeansDB.java Mon Apr 23 17:45:59 2007
@@ -140,7 +140,7 @@
// Create a map of exported key lists
SchemaGlobalElement[] globals = sts.globalElements();
for (int i = 0; i < globals.length; i++) {
- processProperties(globals[i].getName().getLocalPart().toUpperCase().replace('-','_'), globals[i].getType().getProperties(), exportedKeyMap);
+ processProperties(globals[i].getName().getLocalPart().toUpperCase(), globals[i].getType().getProperties(), exportedKeyMap);
}
return exportedKeyMap;
}
Modified: xmlbeans/trunk/samples/vxsdb/xml/datamodel.sample.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/samples/vxsdb/xml/datamodel.sample.xml?view=diff&rev=531667&r1=531666&r2=531667
==============================================================================
--- xmlbeans/trunk/samples/vxsdb/xml/datamodel.sample.xml (original)
+++ xmlbeans/trunk/samples/vxsdb/xml/datamodel.sample.xml Mon Apr 23 17:45:59 2007
@@ -20,7 +20,7 @@
<!-- Global Elements -->
- <table name="PURCHASE_ORDER">
+ <table name="PURCHASE-ORDER">
<column name="PK" type="INTEGER" required="true" primaryKey="true"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org