Package org.compiere.dbPort
Class Convert
- java.lang.Object
-
- 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, Teo Sarca, www.arhipac.ro
- BF [ 2782095 ] Do not log *Access records https://sourceforge.net/p/adempiere/bugs/1867/
- TODO: BF [ 2782611 ] Migration scripts are not UTF8 https://sourceforge.net/p/adempiere/bugs/1869/, Teo Sarca
- BF [ 3137355 ] PG query not valid when contains quotes and backslashes https://sourceforge.net/p/adempiere/bugs/2560/
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_conversionErrorLast Conversion Errorprotected Exceptionm_exceptionLast Execution Errorprotected Statementm_stmtStatement usedprotected booleanm_verboseVerbose Messagesstatic intREGEX_FLAGSRegEx: insensitive and dot to include line end characters
-
Constructor Summary
Constructors Constructor Description Convert()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringcleanUpStatement(String statement)Clean up Statement.String[]convert(String sqlStatements)Convert SQL Statement (stops at first error).StringconvertAll(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 Statementsprotected StringconvertWithConvertMap(String sqlStatement)do convert map base conversionprotected StringescapeQuotedString(String in)hook for database specific escape of quoted string ( if needed )booleanexecute(String sqlStatements, Connection conn)Execute SQL Statement (stops at first error).StringgetConversionError()Return last conversion error or null.protected Map<String,String>getConvertMap()Get convert map for use in sql convertionExceptiongetException()Return last execution exceptionbooleanhasError()Returns true if a conversion or execution error had occured.static booleanisLogMigrationScript()abstract booleanisOracle()True if the database support native oracle dialect, false otherwise.static voidlogMigrationScript(String oraStatement, String pgStatement)protected StringrecoverQuotedStrings(String retValue, Vector<String> retVars, String nonce)Utility method to recover quoted string store in retVarsprotected StringreplaceQuotedStrings(String inputValue, Vector<String> retVars, String nonce)Utility method to replace quoted string with a predefined markervoidsetVerbose(boolean verbose)Set Verbose
-
-
-
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
-
-
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, String nonce)
Utility method to replace quoted string with a predefined marker- Parameters:
inputValue-retVars-nonce-- Returns:
- string
-
recoverQuotedStrings
protected String recoverQuotedStrings(String retValue, Vector<String> retVars, String nonce)
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<String,String> 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
-
isLogMigrationScript
public static boolean isLogMigrationScript()
- Returns:
- true if it is in log migration script mode
-
-