Package mondrian.test.loader
Class CsvDBLoader
- java.lang.Object
-
- mondrian.test.loader.DBLoader
-
- mondrian.test.loader.CsvDBLoader
-
public class CsvDBLoader extends DBLoader
Implementation ofDBLoaderwhich gets its Tables by reading CSV files using theCsvLoaderclass and is the loader use for CSV junit tests.CsvDBLoaderrequires that the CSV files have a specific format as defined:list_of_csv_files : (csv_file)+ csv_file: table_definitions table_definitions: (table_definition)+ table_definition: actions table_name column_names column_types (file_name or nos_of_rows or rows) actions: (action)* action: '##' (ActionBefore: | ActionAfter:) action_type action_type: DropIndex index_name | CreateIndex index_name column_name table_name: '##' TableName: table_name column_names: '##' ColumnNames: column_name (',' column_name)* column_types: '##' ColumnTypes: column_types ('.' column_types)* file_name:'##' FileName: relative_filename ? nos_of_rows:'##' NosOfRows: number column_types: type (':' null) type: "INTEGER" "DECIMAL(*,*)" "SMALLINT" "VARCHAR(*)" "REAL" "BOOLEAN" "BIGINT" "DATE" "TIMESTAMP" rows: (row)* row: value (',' value)* if FileName is given, then there is no NosOfRows the file can only contains rows else if NosOfRows is given, then there is no FileName the number of rows in current file are rows for table else the all remaining rows in current file are rows for table fi comment lines start with '#'See the testsrc/main/mondrian/rolap/aggmatcher/BUG_1541077.csv file for an example.
- Author:
- Richard M. Emberson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCsvDBLoader.CsvLoaderRowStreamstatic classCsvDBLoader.ListRowStream-
Nested classes/interfaces inherited from class mondrian.test.loader.DBLoader
DBLoader.Column, DBLoader.Row, DBLoader.RowDefault, DBLoader.RowStream, DBLoader.Table, DBLoader.Type
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTION_AFTER_TAGstatic StringACTION_BEFORE_TAGstatic StringCOLUMN_NAMES_TAGstatic StringCOLUMN_TYPES_TAGstatic StringCREATE_INDEX_TAGstatic StringDROP_INDEX_TAGstatic StringFILE_NAME_TAGstatic StringNOS_OF_ROWS_TAGstatic StringTABLE_NAME_TAG-
Fields inherited from class mondrian.test.loader.DBLoader
BATCH_SIZE_PROP, CREATE_TABLE_INDEX_PROP, CREATE_TABLE_INDEX_SUFFIX_DEFAULT, CREATE_TABLE_PROP, CREATE_TABLE_SUFFIX_DEFAULT, dateFormatString, dateFormatter, decimalDataTypeRegex, DROP_TABLE_INDEX_PROP, DROP_TABLE_INDEX_SUFFIX_DEFAULT, DROP_TABLE_PROP, DROP_TABLE_ROWS_PROP, DROP_TABLE_ROWS_SUFFIX_DEFAULT, DROP_TABLE_SUFFIX_DEFAULT, EMPTY_ROW_STREAM, FORCE_PROP, integerFormatter, JDBC_DRIVER_PROP, JDBC_PASSWORD_PROP, JDBC_URL_PROP, JDBC_USER_PROP, LOAD_TABLE_ROWS_PROP, LOAD_TABLE_ROWS_SUFFIX_DEFAULT, LOGGER, nl, oracleDateFormatString, OUTPUT_DIRECTORY_PROP, varcharDataTypeRegex
-
-
Constructor Summary
Constructors Constructor Description CsvDBLoader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheck()protected static FilecheckDirectory(String dirName)FilegetInputDirectory()StringgetInputDirectoryRegex()FilegetInputFile()File[]getInputFiles()DBLoader.Table[]getTables()DBLoader.Table[]getTables(File[] files)DBLoader.Table[]getTables(Reader reader)DBLoader.Table[]getTablesFromDirectory()DBLoader.Table[]getTablesFromFile()DBLoader.Table[]getTablesFromFiles()protected DBLoader.Column[]loadColumns(String[] columnNames, String[] columnTypes, int lineNos)voidloadTables(File file, List<DBLoader.Table> tableList)voidloadTables(Reader reader, List<DBLoader.Table> tableList)static voidmain(String[] args)voidsetInputDirectory(File inputDirectory)voidsetInputDirectoryRegex(String inputDirectoryRegex)voidsetInputFile(File inputFile)voidsetInputFiles(File[] inputFiles)protected static voidusage(String msg)-
Methods inherited from class mondrian.test.loader.DBLoader
clear, close, closeFileWriter, columnValue, createInsertStatement, decimalFormat, decimalFormat, dropTable, dropTables, embedQuotes, executeAfterActions, executeBeforeActions, executeCreateTable, executeDDL, executeDropTable, executeDropTableRows, executeLoadTableRows, executeStatements, executeStatements, generateAfterActions, generateBeforeActions, generateCreateTable, generateDropTable, generateDropTableRows, generateStatements, generateStatements, getBatchSize, getConnection, getForce, getJdbcDriver, getJdbcURL, getOutputDirectory, getPassword, getUserName, initialize, initializeColumns, makeFileWriter, quoteId, setBatchSize, setConnection, setForce, setJdbcDriver, setJdbcURL, setOutputDirectory, setPassword, setUserName, writeBatch, writeDDL
-
-
-
-
Field Detail
-
ACTION_BEFORE_TAG
public static final String ACTION_BEFORE_TAG
- See Also:
- Constant Field Values
-
ACTION_AFTER_TAG
public static final String ACTION_AFTER_TAG
- See Also:
- Constant Field Values
-
DROP_INDEX_TAG
public static final String DROP_INDEX_TAG
- See Also:
- Constant Field Values
-
CREATE_INDEX_TAG
public static final String CREATE_INDEX_TAG
- See Also:
- Constant Field Values
-
TABLE_NAME_TAG
public static final String TABLE_NAME_TAG
- See Also:
- Constant Field Values
-
COLUMN_NAMES_TAG
public static final String COLUMN_NAMES_TAG
- See Also:
- Constant Field Values
-
COLUMN_TYPES_TAG
public static final String COLUMN_TYPES_TAG
- See Also:
- Constant Field Values
-
FILE_NAME_TAG
public static final String FILE_NAME_TAG
- See Also:
- Constant Field Values
-
NOS_OF_ROWS_TAG
public static final String NOS_OF_ROWS_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
setInputDirectory
public void setInputDirectory(File inputDirectory)
-
getInputDirectory
public File getInputDirectory()
-
setInputDirectoryRegex
public void setInputDirectoryRegex(String inputDirectoryRegex)
-
getInputDirectoryRegex
public String getInputDirectoryRegex()
-
setInputFiles
public void setInputFiles(File[] inputFiles)
-
getInputFiles
public File[] getInputFiles()
-
setInputFile
public void setInputFile(File inputFile)
-
getInputFile
public File getInputFile()
-
getTables
public DBLoader.Table[] getTables() throws Exception
-
getTablesFromDirectory
public DBLoader.Table[] getTablesFromDirectory() throws Exception
- Throws:
Exception
-
getTablesFromFiles
public DBLoader.Table[] getTablesFromFiles() throws Exception
- Throws:
Exception
-
getTablesFromFile
public DBLoader.Table[] getTablesFromFile() throws Exception
- Throws:
Exception
-
getTables
public DBLoader.Table[] getTables(File[] files) throws Exception
- Throws:
Exception
-
getTables
public DBLoader.Table[] getTables(Reader reader) throws Exception
- Throws:
Exception
-
loadTables
public void loadTables(File file, List<DBLoader.Table> tableList) throws Exception
- Throws:
Exception
-
loadTables
public void loadTables(Reader reader, List<DBLoader.Table> tableList) throws Exception
- Throws:
Exception
-
loadColumns
protected DBLoader.Column[] loadColumns(String[] columnNames, String[] columnTypes, int lineNos) throws Exception
- Throws:
Exception
-
checkDirectory
protected static File checkDirectory(String dirName) throws Exception
- Throws:
Exception
-
usage
protected static void usage(String msg)
-
-