|
From: <tri...@us...> - 2007-12-20 13:42:52
|
Revision: 214
http://equanda.svn.sourceforge.net/equanda/?rev=214&view=rev
Author: triathlon98
Date: 2007-12-20 05:42:47 -0800 (Thu, 20 Dec 2007)
Log Message:
-----------
EQ-53 move some classes as part of this refactoring
Modified Paths:
--------------
trunk/equanda-generate/pom.xml
trunk/equanda-generate/src/main/java/org/equanda/generate/Generator.java
trunk/equanda-test/src/main/om/om.ini
trunk/src/site/wiki/config.wiki
Added Paths:
-----------
trunk/equanda-generate/src/main/java/org/equanda/domain/
trunk/equanda-generate/src/main/java/org/equanda/domain/db/
trunk/equanda-generate/src/main/java/org/equanda/domain/db/CodebaseConvert.java
trunk/equanda-generate/src/main/java/org/equanda/domain/db/Convert.java
trunk/equanda-generate/src/main/java/org/equanda/domain/db/Max31Convert.java
Modified: trunk/equanda-generate/pom.xml
===================================================================
--- trunk/equanda-generate/pom.xml 2007-12-20 12:44:19 UTC (rev 213)
+++ trunk/equanda-generate/pom.xml 2007-12-20 13:42:47 UTC (rev 214)
@@ -46,6 +46,10 @@
<artifactId>velocity-dep</artifactId>
</dependency>
<dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </dependency>
+ <dependency>
<groupId>jalopy</groupId>
<artifactId>jalopy</artifactId>
</dependency>
Copied: trunk/equanda-generate/src/main/java/org/equanda/domain/db/CodebaseConvert.java (from rev 201, trunk/equanda-generate/src/main/java/org/equanda/persistence/xml/CodebaseConvert.java)
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/db/CodebaseConvert.java (rev 0)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/db/CodebaseConvert.java 2007-12-20 13:42:47 UTC (rev 214)
@@ -0,0 +1,91 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.domain.db;
+
+import org.equanda.util.INIFile;
+import org.equanda.util.SaveException;
+
+import java.io.IOException;
+
+/**
+ * convert table and field names from given names to something acceptable for the specific database Codebase ODBC driver
+ * specific implementation The conversion reads/writes a name conversion table (in the shape of an ini file)
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class CodebaseConvert
+ extends Convert
+{
+ public static final String FILE = "CodebaseConversion.txt";
+ INIFile convert;
+
+ public void init()
+ {
+ try
+ {
+ convert = new INIFile( FILE, true );
+ }
+ catch ( IOException e )
+ {
+ convert = new INIFile( true );
+ }
+ }
+
+ public void done()
+ {
+ try
+ {
+ convert.save( FILE );
+ }
+ catch ( IOException e )
+ {
+ SaveException.saveException( e, "on CodeBaseConvert.done()" );
+ }
+ }
+
+ public String convertTable( String name )
+ {
+ String res = convert.getValue( "table", name );
+ if ( res == null || res.equals( "" ) )
+ {
+ res = name;
+ if ( res.length() > 8 ) res = res.substring( 0, 8 );
+ convert.addValue( "table", name, res );
+ }
+ return res;
+ }
+
+ public String convertField( String name )
+ {
+ String res = convert.getValue( "field", name );
+ if ( res == null || res.equals( "" ) )
+ {
+ res = name;
+ if ( res.length() > 10 ) res = res.substring( 0, 10 );
+ convert.addValue( "field", name, res );
+ }
+ return res;
+ }
+}
Copied: trunk/equanda-generate/src/main/java/org/equanda/domain/db/Convert.java (from rev 201, trunk/equanda-generate/src/main/java/org/equanda/persistence/xml/Convert.java)
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/db/Convert.java (rev 0)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/db/Convert.java 2007-12-20 13:42:47 UTC (rev 214)
@@ -0,0 +1,71 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.domain.db;
+
+/**
+ * convert table and field names from given names to something acceptable for the specific database Default
+ * implementation : no conversion
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class Convert
+{
+
+ /**
+ * initialise conversion routines, may read conversion tables
+ */
+ public void init()
+ {
+ }
+
+ /**
+ * finish off conversion routines, may be done to make conversions persistent
+ */
+ public void done()
+ {
+ }
+
+ /**
+ * convert a table name
+ *
+ * @param name
+ * @return
+ */
+ public String convertTable( String name )
+ {
+ return name;
+ }
+
+ /**
+ * convert a field name
+ *
+ * @param name
+ * @return
+ */
+ public String convertField( String name )
+ {
+ return name;
+ }
+}
Copied: trunk/equanda-generate/src/main/java/org/equanda/domain/db/Max31Convert.java (from rev 201, trunk/equanda-generate/src/main/java/org/equanda/persistence/xml/Max31Convert.java)
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/db/Max31Convert.java (rev 0)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/db/Max31Convert.java 2007-12-20 13:42:47 UTC (rev 214)
@@ -0,0 +1,62 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.domain.db;
+
+/**
+ * convert table and field names from given names to something acceptable for the specific database Firebird only allows
+ * metadata names to be 31 characters in length.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class Max31Convert
+ extends Convert
+{
+ public static final int MAX_LENGTH = 31;
+
+ public String convertTable( String name )
+ {
+ if ( name.length() > MAX_LENGTH )
+ {
+ name = name.substring( 0, MAX_LENGTH );
+ }
+ return name;
+ }
+
+ public String convertField( String name )
+ {
+ if ( name.length() > MAX_LENGTH )
+ {
+ if ( name.endsWith( "_UOID" ) )
+ {
+ name = name.substring( 0, MAX_LENGTH - 5 ) + "_UOID";
+ }
+ else
+ {
+ name = name.substring( 0, MAX_LENGTH );
+ }
+ }
+ return name;
+ }
+}
Modified: trunk/equanda-generate/src/main/java/org/equanda/generate/Generator.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/generate/Generator.java 2007-12-20 12:44:19 UTC (rev 213)
+++ trunk/equanda-generate/src/main/java/org/equanda/generate/Generator.java 2007-12-20 13:42:47 UTC (rev 214)
@@ -40,6 +40,7 @@
import org.equanda.util.xml.tree.Document;
import org.equanda.util.xml.tree.Node;
import org.equanda.util.xml.tree.NodeList;
+import org.equanda.domain.db.Convert;
import org.xml.sax.*;
import javax.xml.parsers.DocumentBuilder;
Modified: trunk/equanda-test/src/main/om/om.ini
===================================================================
--- trunk/equanda-test/src/main/om/om.ini 2007-12-20 12:44:19 UTC (rev 213)
+++ trunk/equanda-test/src/main/om/om.ini 2007-12-20 13:42:47 UTC (rev 214)
@@ -37,4 +37,4 @@
[database,test]
type=firebird
-convert=org.equanda.persistence.xml.Max31Convert
+convert=org.equanda.domain.db.Max31Convert
Modified: trunk/src/site/wiki/config.wiki
===================================================================
--- trunk/src/site/wiki/config.wiki 2007-12-20 12:44:19 UTC (rev 213)
+++ trunk/src/site/wiki/config.wiki 2007-12-20 13:42:47 UTC (rev 214)
@@ -50,7 +50,7 @@
[database,myapp]
type=firebird
-convert=org.equanda.persistence.xml.Max31Convert
+convert=org.equanda.domain.db.Max31Convert
{code}
The "config" and "extra" sections contain parameters which may be used by all templates.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|