Class SchemaPrinter
- java.lang.Object
-
- org.linuxforhealth.fhir.schema.app.SchemaPrinter
-
public class SchemaPrinter extends java.lang.Object
The SchemaPrinter outputs the DDL into three files - schema.sql, grants.sql, stored-procedures.sql.
These files are generated using Mock java.sql objects. These mock objects follow through the code to
capture the SQL as it flows to the prospective database:
- Build a JDBCTarget with PrintConnection
- The Database Tools builds the schema retrieving a PreparedStatement, CallableStatement or Statement from the PrintConnection
- The PrintConnection passes a PrintPreparedStatement, PrintCallableStatement, PrintStatement
- As the prepareStatement, execute or executeQuery are executed, the SQL passed is put into the commands or stored procedures map.
- the results, after the full schema generation, is printed out to console or files
For real work, useMain
.
To run this code, build the jar (fhir-database-utils and fhir-persistence-schema)
java -cp ./fhir-database-utils.jar:fhir-persistence-schema.jar org.linuxforhealth.fhir.schema.app.SchemaPrinter [--to-file]
Without to-file, the output is the current System.out else it's schema.sql, grants.sql and stored-procedures.sql of
the current directory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
SchemaPrinter.PrintCallableStatement
(package private) class
SchemaPrinter.PrintConnection
(package private) class
SchemaPrinter.PrintPreparedStatement
(package private) class
SchemaPrinter.PrintResultSet
(package private) class
SchemaPrinter.PrintStatement
-
Field Summary
Fields Modifier and Type Field Description java.io.PrintStream
out
java.io.PrintStream
outGrants
java.io.PrintStream
outStoredProcedure
-
Constructor Summary
Constructors Constructor Description SchemaPrinter(boolean toFile, SchemaType schemaType)
constructor that switches behavior toFile our output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(java.lang.String sql)
process each sql so it can be 'cleaned' before putting into the linked map.static void
main(java.lang.String[] args)
void
print()
prints the schema out to two locations (sometimes the same printstreamvoid
printGrants()
prints the grantsvoid
process()
processes through using a fake connection.void
processApplyGrants()
-
-
-
Constructor Detail
-
SchemaPrinter
public SchemaPrinter(boolean toFile, SchemaType schemaType) throws java.io.FileNotFoundException
constructor that switches behavior toFile our output stream.- Parameters:
toFile
-schemaType
-- Throws:
java.io.FileNotFoundException
-
-
Method Detail
-
addCommand
public void addCommand(java.lang.String sql)
process each sql so it can be 'cleaned' before putting into the linked map.
-
process
public void process()
processes through using a fake connection.
-
processApplyGrants
public void processApplyGrants()
-
printGrants
public void printGrants()
prints the grants
-
print
public void print()
prints the schema out to two locations (sometimes the same printstream
-
main
public static void main(java.lang.String[] args)
-
-