Adempiere 3.5.2a

org.compiere.dbPort
Class Convert

java.lang.Object
  extended by org.compiere.dbPort.Convert
Direct Known Subclasses:
Convert_Oracle, Convert_SQL92

public abstract class Convert
extends Object

Convert SQL to Target DB

Version:
$Id: Convert.java,v 1.3 2006/07/30 00:55:04 jjanke Exp $
Author:
Jorg Janke, Victor Perez

Field Summary
protected  String m_conversionError
          Last Conversion Error
protected  Exception m_exception
          Last Execution Error
protected  Statement m_stmt
          Statement used
protected  boolean m_verbose
          Verbose Messages
static int REGEX_FLAGS
          RegEx: insensitive and dot to include line end characters
 
Constructor Summary
Convert()
           
 
Method Summary
protected  String cleanUpStatement(String statement)
          Clean up Statement.
 String[] convert(String sqlStatements)
          Convert SQL Statement (stops at first error).
 String convertAll(String sqlStatements)
          Convert SQL Statement (stops at first error).
protected  String[] convertIt(String sqlStatements)
          Conversion routine (stops at first error).
protected abstract  ArrayList<String> convertStatement(String sqlStatement)
          Convert single Statements
protected  String convertWithConvertMap(String sqlStatement)
          do convert map base conversion
protected  String escapeQuotedString(String in)
          hook for database specific escape of quoted string ( if needed )
 boolean execute(String sqlStatements, Connection conn)
          Execute SQL Statement (stops at first error).
 String getConversionError()
          Return last conversion error or null.
protected  Map getConvertMap()
          Get convert map for use in sql convertion
 Exception getException()
          Return last execution exception
 boolean hasError()
          Returns true if a conversion or execution error had occured.
abstract  boolean isOracle()
          True if the database support native oracle dialect, false otherwise.
static void logMigrationScript(String oraStatement, String pgStatement)
           
protected  String recoverQuotedStrings(String retValue, Vector<String> retVars)
          Utility method to recover quoted string store in retVars
protected  String replaceQuotedStrings(String inputValue, Vector<String> retVars)
          Utility method to replace quoted string with a predefined marker
 void setVerbose(boolean verbose)
          Set Verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGEX_FLAGS

public static final int REGEX_FLAGS
RegEx: insensitive and dot to include line end characters

See Also:
Constant Field Values

m_stmt

protected Statement m_stmt
Statement used


m_conversionError

protected String m_conversionError
Last Conversion Error


m_exception

protected Exception m_exception
Last Execution Error


m_verbose

protected boolean m_verbose
Verbose Messages

Constructor Detail

Convert

public Convert()
Method Detail

setVerbose

public void setVerbose(boolean verbose)
Set Verbose

Parameters:
verbose -

execute

public boolean execute(String sqlStatements,
                       Connection conn)
Execute SQL Statement (stops at first error). If an error occured hadError() returns true. You can get details via getConversionError() or getException()

Parameters:
sqlStatements -
conn - connection
Returns:
true if success
Throws:
IllegalStateException - if no connection

getException

public Exception getException()
Return last execution exception

Returns:
execution exception

hasError

public boolean hasError()
Returns true if a conversion or execution error had occured. Get more details via getConversionError() or getException()

Returns:
true if error had occured

convertAll

public String convertAll(String sqlStatements)
Convert SQL Statement (stops at first error). Statements are delimited by / If an error occured hadError() returns true. You can get details via getConversionError()

Parameters:
sqlStatements -
Returns:
converted statement as a string

convert

public String[] convert(String sqlStatements)
Convert SQL Statement (stops at first error). If an error occured hadError() returns true. You can get details via getConversionError()

Parameters:
sqlStatements -
Returns:
Array of converted Statements

getConversionError

public String getConversionError()
Return last conversion error or null.

Returns:
lst conversion error

convertIt

protected String[] convertIt(String sqlStatements)
Conversion routine (stops at first error).
  - convertStatement
      - convertWithConvertMap
      - convertComplexStatement
      - decode, sequence, exception
  

Parameters:
sqlStatements -
Returns:
array of converted statements

cleanUpStatement

protected String cleanUpStatement(String statement)
Clean up Statement. Remove trailing spaces, carrige return and tab

Parameters:
statement -
Returns:
sql statement

replaceQuotedStrings

protected String replaceQuotedStrings(String inputValue,
                                      Vector<String> retVars)
Utility method to replace quoted string with a predefined marker

Parameters:
retValue -
retVars -
Returns:
string

recoverQuotedStrings

protected String recoverQuotedStrings(String retValue,
                                      Vector<String> retVars)
Utility method to recover quoted string store in retVars

Parameters:
retValue -
retVars -
Returns:
string

escapeQuotedString

protected String escapeQuotedString(String in)
hook for database specific escape of quoted string ( if needed )

Parameters:
in -
Returns:
string

convertWithConvertMap

protected String convertWithConvertMap(String sqlStatement)
do convert map base conversion

Parameters:
sqlStatement -
Returns:
string

getConvertMap

protected Map getConvertMap()
Get convert map for use in sql convertion

Returns:
map

convertStatement

protected abstract ArrayList<String> convertStatement(String sqlStatement)
Convert single Statements. - remove comments - process FUNCTION/TRIGGER/PROCEDURE - process Statement

Parameters:
sqlStatement -
Returns:
converted statement

isOracle

public abstract boolean isOracle()
True if the database support native oracle dialect, false otherwise.

Returns:
boolean

logMigrationScript

public static void logMigrationScript(String oraStatement,
                                      String pgStatement)

Adempiere 3.5.2a

Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.