SQL processor generator
The general focus of this generator is to create SQLProcessor
classes from a given SQL code.
The next simple example shows the mechanism:
Input file:
SELECT TIMESTAMP, LOG_LEVEL, THREAD_NAME, CONTEXT_NAME, METHOD_NAME, LINE_NUMBER, VERSION, HIERARCHY_LEVEL, LOG_INFORMATION, FORMATED_MESSAGE FROM jptoolsLogTable WHERE TIMESTAMP BETWEEN &1 AND &2;
The generator will create the following file (depending on the configuration):
Package declaration
The packagename of the processor classes can be defined in two different ways:
- The package name is declared in the header comment of the SQL statement. The @package tag
defines the package name like the following example:
# @package jptools.sql.tests SELECT TIMESTAMP, LOG_LEVEL, THREAD_NAME, CONTEXT_NAME, METHOD_NAME, LINE_NUMBER, VERSION, HIERARCHY_LEVEL, LOG_INFORMATION, FORMATED_MESSAGE FROM jptoolsLogTable WHERE TIMESTAMP BETWEEN &1 AND &2;
- The alternative way to define a package name is you define as input a path. After the path definition
you can define a list of sql statements. The path is relativ to the starting path like the next example:
java ... -i sql testdata/testFooBar.sql
This example creates a packagenametestdata
. If after the input path definition follows nothing the user can select the file with a GUI. If a selected file is in a subdirectory of the starting path the package will correspond to this structure.
Using processor generator
To use te processor generator you can use the script file sqlgenerator.bat or sqlgenerator.sh. You have probably some hands on the files to work with your environment.
The usage is the following:
Usage:jptools.database.generator.ProcessorGenerator [OPTIONS] OPTIONS: -o [path] Sets the output path -i [path or file] Sets the input file (directory or a file) -d [database configuration] Defines the database configuration file OPTIONAL OPTIONS: -c [configuration.properties] Reads the generator and formatter base configuration. This file defines the global settings. -pc [configuration.properties] Reads the additional or project specific generator and formatter configuration. -verbose Sets on the verbose mode -t [testcase configuration] Sets the testcase file -m Adds a main method to the processor
The input definition defines either one or multiple files or a directory followed by the
names of the files in the directory to consider.
Configuration
The generator can be configured over a properties file. Additional the javadoc will be used to define some special behavior. The description of the configuration is here available.