Nitrohammer:
Introduction
What is Nitrohammer?
Nitrohammer is a command line tool and a collection of Java
classes which facillate the development of the full stack
development of Software Applications.
- Generates a database model from existing schemas, or can
create database model manually.
- From database model, generates java source for database
beans, DAO layer, Rest services, test cases.
- Generates rest services for CRUD in JSON/XML
- Generates rest services in JSON compitable with AGGrid,
Alpaca, DataTables, C3 and Plotly.
- Gennerates Junit test cases
- Generates resource files for human language translations
- Allows for custom templates, which will tailor your code
generation.
- Easy and productive to use in new applications
- Compatiable with existing databases
Nitrohammer is Open Source
Nitrohammer is under the MIT license.
Nitro-Hammer (Command Line Arguments)
Nitrohammer is a command line tool which has the following
main arguments.
- -model2database Given the database model, generate
the database schema into the database.
schematool
-model2database <database-url> <packagename>
<vendor> <outfile> <model filename/directory>
...
- <database-url> The database url, see the database
provider, MySql, Oracle, etc. Typically starts with jdbc:
- <packagename> The full name of the java package
inwhich the database was built.
- <vendor> Vendor such as mysql, oracle, h2, etc.
- <outfile> Filename where the SQL output can be
written which is what is used to build the database.
- <model filename/directory> filename(s) and/or
directory name(s) where the model files exist, use all xml files,
in directory and subdirectories.
- -sql2database Read SQL files and write them to
database instance, similiar to using the mysql < input.sql
command.
schematool -sql <source>
<directory/filename>
- <source> Either the name of the source database
located in the databases.xml file or the database url, see the
database provider, MySql, Oracle, etc. Typically starts with
jdbc:
- <filename/directory> filename(s) and/or directory
name(s) where the sql files exist, use all sql files, in
directory and subdirectories.
- -database2sql Access the database and generate SQL
files, similiar to mysqldump
schematool
-database2sql <source> <schema> <filename>
- <source> Either the name of the source database
located in the databases.xml file or the database url, see the
database provider, MySql, Oracle, etc. Typically starts with
jdbc:
- <schema> the name of the schema in the database
from which the SQL is to be generated.
- <filename> filename where the sql commands are to
be written.
- -database2model Read the database and generate the
model into a single mode file .xml
schematool
-database2model <source> <schema> <filename>
- <source> Either the name of the source database
located in the databases.xml file or the database url, see the
database provider, MySql, Oracle, etc. Typically starts with
jdbc:
- <schema> the name of the schema in the database for
which the model is to be generated.
- <filename> filename where the model file is to be
written.
- -model2sql Read the database model and generate
sqlfile to build the database
schematool
-model2sql <model directory> <schema> <vendor>
<outfile>
- <model directory> The directory where the model
files exists, ending im .xml.
- <schema> the name of the schema in the database for
which the sql is to be generated.
- <vendor> Vendor such as mysql, oracle, h2, etc.
- <outfile> Filename where the SQL output can be
written which can be used to build the database.
- -generate Given the model directory and the
translation template, generate source coce
schematool
-generate <model directory> <output directory>
<templagte> <packageName>
- <model directory> The directory where the model
files exists, ending im .xml.
- <output directory> directory where the resulant
files are to be placed
- <template> the filename of the template fileto be
used for the resulting file generation.
- <packageNam> java package name to be used for the
results, (to be removed).
Database Model
The Database Model is defined by a collection of XML tags
which define the database connections, the database, the database
tables, and all objects which make up the database. The database
model can be entered manually by text editing or by the Nitrogen
tool (schematool) which will read an existing database and generate
the XML model.
The following is a basic model of a database table for "users"
data.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 |
<?xml version='1.0' encoding='UTF-8'?>
<database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.vipersoftwareservices.com/schemas/database.xsd"
name='test' package-name="com.viper.unit.model">
<table name='User' table-type='table' is-rest-service="true" is-schema-updatable="true">
<column name='username' java-type='String' size='32' required='true' primary-key='true' id-method="assigned" logical-type="email:email.txt" />
<column name='password' java-type='String' size='32' required='false' logical-type="password:" />
<column name='name' java-type='String' size='255' required='false' logical-type="name:firstnames.txt" />
<column name='rolw' java-type='String' size='32' required='false' />
<column name='job' java-type='String' size='32' required='false' />
<column name='school' java-type='String' size='255' required='false' />
<column name='email' java-type='String' size='255' required='false' logical-type="email:email.txt" />
<column name='lastProblem' java-type='String' size='255' required='false' logical-type="name:nouns.csv" />
<column name='grade' java-type='int' required='true' logical-type="int:0,12" />
<column name='friends' java-type='java.util.List' generic-type="String" required='true' logical-type="email:email.txt" />
</table>
</database>
|
- database (element) Database
- user (element)
User
- privilege (element) Privilege
- name (attribute)
xsd:string The name of the database,
used in code and database creation.
- catalog (attribute) xsd:string
An alternate name for the database, but not used when generating
code.
- charset-name (attribute) xsd:string
The default character set name for the database, see the actual
database MySql, Oracle, etc for the actual possible character set
values.
- collation-name (attribute) xsd:string
The default collation name for the database, see the actual
database MySql, Oracle, etc for the actual possible collation
values.
- default-base-class (attribute) xsd:string
When generating java code use this value for extending the
underlying class for the Java beans. This value is optional.
- default-java-naming-method (attribute) JavaNamingMethodType
Various naming conventions are used to convert database names into
Java class, and property names.
- filename (attribute) xsd:string
The filename where the xml for this database definition is written.
Deprecated.
- package-name (attribute) xsd:string
The base package name tobe used when generating Java code from this
database model. The package name can be supplied on the command
line of the Nitrogen tool as well, which will replace this value.
- version (attribute) xsd:string
- table (element)
Table An nested element defining a
table within this database. See below, for the complete definition
of the table element.
- procedure (element) Procedure
- trigger (element) Trigger
- name (attribute)
xsd:string
- table-name (attribute) xsd:string
- java-name (attribute) xsd:string
- database-name (attribute) xsd:string
- table-type (attribute) TableType
- base-class (attribute) xsd:string
- charset-name (attribute) xsd:string
- collation-name (attribute) xsd:string
- data-directory (attribute) xsd:string
- description (attribute) xsd:string
- delay-key-write (attribute) xsd:boolean
- engine (attribute) EngineType
- has-checksum (attribute) xsd:boolean
- index-directory (attribute) xsd:string
- interface (attribute) xsd:string
- is-schema-updatable (attribute) xsd:boolean
- is-rest-service (attribute) xsd:boolean
- is-report-table (attribute) xsd:boolean
- is-abstract (attribute) xsd:boolean
- is-default (attribute) xsd:boolean
- is-final (attribute) xsd:boolean
- is-large-table (attribute) xsd:boolean
- is-monitor-changes (attribute) xsd:boolean
- fields-all-nullable (attribute) xsd:boolean
- maximum-rows (attribute) xsd:int
- minimum-rows (attribute) xsd:int
- pack-keys (attribute) PackKeysType
- password (attribute) xsd:string
- raid-type (attribute) RaidType
- raid-chunks (attribute) xsd:string
- raid-chunk-size (attribute) xsd:int
- row-format (attribute) RowFormatType
- skip-sql (attribute) xsd:boolean
- union (attribute) xsd:string
- iterations (attribute) xsd:int
- column (element)
Column
- import-table (element) xsd:string
- foreign-key (element) ForeignKey
- validator (element) xsd:string
- converter (element) xsd:string
- sql-generator (element) xsd:string
- bean-generator (element) xsd:string
- filter (element)
xsd:string
- seed-filename (element) xsd:string
- access (element)
AccessPrivilege
- index (element)
Index
- sql-select (element) xsd:string
- sql-update (element) xsd:string
- sql-insert (element) xsd:string
- sql-delete (element) xsd:string
- sql-size (element) xsd:string
- query-class-name (element) xsd:string
- param (element)
Param
- row (element)
Row
- name (attribute)
xsd:string
- table-name (attribute) xsd:string
- database-name (attribute) xsd:string
- description (attribute) xsd:string
- index-name (attribute) xsd:string
- id-method (attribute) IdMethodType
- java-type (attribute) xsd:string
- field (attribute) xsd:string
- generic-type (attribute) xsd:string
- logical-type (attribute) xsd:string
- data-type (attribute) xsd:string
- extra-data-type (attribute) xsd:string
- decimal-size (attribute) xsd:int
- default-value (attribute) xsd:string
- size (attribute)
xsd:long
- order (attribute) xsd:int
- columnVisibility (attribute) ColumnVisibilityType
- pattern (attribute) xsd:string
- natural-key (attribute) xsd:boolean
- primary-key (attribute) xsd:boolean
- persistent (attribute) xsd:boolean
- optional (attribute) xsd:boolean
- required (attribute) xsd:boolean
- secure (attribute) xsd:boolean
- unique (attribute) xsd:boolean
- unsigned (attribute) xsd:boolean
- zero-fill (attribute) xsd:boolean
- binary (attribute) xsd:boolean
- ascii (attribute) xsd:boolean
- unicode (attribute) xsd:boolean
- is-nullable (attribute) xsd:boolean
- enum-value (element) EnumItem
- validator (element) xsd:string
- converter (element) xsd:string
- renderer (element) xsd:string
- action (element)
xsd:string
- minimum-value (element) xsd:string
- maximum-value (element) xsd:string
- options (element) xsd:string
- component-type (element) xsd:string
- values-classname (element) xsd:string
- validation-message (element) xsd:string
- tooltip-message (element) xsd:string
- privilege (element) Privilege
- grantor (attribute) xsd:string
- grantee (attribute) xsd:string
- name (attribute)
xsd:string
- is-grantable (attribute) xsd:boolean
- read (attribute)
xsd:string
- create (attribute) xsd:string
- update (attribute) xsd:string
- delete (attribute) xsd:string
- name (attribute)
xsd:string
- password (attribute) xsd:string
- host (attribute)
xsd:string
- name (attribute)
xsd:string
- type (attribute)
xsd:string
- name (attribute)
xsd:string
- name (attribute)
xsd:string
- orderBy (attribute) SortType
- aggregation (attribute) AggregationType
- groupBy (attribute) xsd:boolean
- visible (attribute) xsd:boolean
- columnOrder (attribute) xsd:int
- pageno (attribute) xsd:int
- pagesize (attribute) xsd:int
- name (attribute)
xsd:string
- database-name (attribute) xsd:string
- filename (attribute) xsd:string
- sql-characteristics (attribute) xsd:string
- sql-security (attribute) xsd:string
- description (attribute) xsd:string
- vendor (attribute) xsd:string
- source (element)
xsd:string
- column (element)
Column
- name (attribute)
xsd:string
- local-database (attribute) xsd:string
- local-table (attribute) xsd:string
- foreign-database (attribute) xsd:string
- foreign-table (attribute) xsd:string
- constraint-name (attribute) xsd:string
- unique (attribute) xsd:boolean
- deferrability (attribute) xsd:string
- on-update (attribute) UpdateType
- on-delete (attribute) UpdateType
- foreign-key-reference (element) ForeignKeyReference
- local-column (attribute) xsd:string
- foreign-column (attribute) xsd:string
- sequence-number (attribute) xsd:int
- name (attribute)
xsd:string
- table-name (attribute) xsd:string
- database-name (attribute) xsd:string
- column-name (attribute) xsd:string
- index-class (attribute) IndexClassType
- index-type (attribute) IndexType
- editable (attribute) xsd:boolean
- primary (attribute) xsd:boolean
- description (attribute) xsd:string
- name (attribute)
xsd:string
- table-name (attribute) xsd:string
- database-name (attribute) xsd:string
- username (attribute) xsd:string
- time (attribute)
TimeType
- event (attribute) EventType
- statement (attribute) xsd:string
- drop-if-exists (attribute) xsd:boolean
- TransactionSerializable (element) xsd:boolean
- TransactionRepeatableRead (element) xsd:boolean
- TransactionReadCommitted (element) xsd:boolean
- TransactionReadUncommitted (element) xsd:boolean
- TransactionNone (element) xsd:boolean
- ForwardOnly (element) xsd:boolean
- ScrollInsensitive (element) xsd:boolean
- ScrollSensitive (element) xsd:boolean
- enum-values (element) EnumItem
- name (attribute)
xsd:string
- name (attribute)
xsd:string
- filename (attribute) xsd:string
- resource (attribute) xsd:string
- project-state (attribute) ProjectStateType
- definition (element) Definition
- connection (element) DatabaseConnection
- name (attribute)
xsd:string
- ssh (element)
SSHConnection
- database-timeout (element) xsd:int
- show-errors (element) xsd:boolean
- show-drop-errors (element) xsd:boolean
- create-database (element) xsd:boolean
- auto-commit (element) xsd:boolean
- verbose (element) xsd:boolean
- number-of-rows-limit (element) xsd:int
- cache-timeout (element) xsd:int
- connection-kind (element) ConnectionKind
- database-url (element) xsd:string
- driver (element)
xsd:string
- username (element) xsd:string
- password (element) xsd:string
- model (element)
xsd:string
- jndi-name (element) xsd:string
- datasource (element) xsd:string
- datasource-class (element) xsd:string
- description (element) xsd:string
- server-filename (element) xsd:string
- resource-filename (element) xsd:string
- initial-sql-filename (element) xsd:string
- package-name (element) xsd:string
- schema-alias (element) Param
- param (element)
Param
- name-case (element) CaseType
- vendor (element)
xsd:string
- pool-validation-query (element) xsd:string
- pool-max-total (element) xsd:int
- pool-max-idle (element) xsd:int
- pool-min-idle (element) xsd:int
- pool-max-wait-millis (element) xsd:int
- pool-time-between-eviction-runs-millis
(element) xsd:int
- pool-min-evictable-idle-time-millis
(element) xsd:int
- pool-test-while-idle (element) xsd:boolean
- pool-test-on-borrow (element) xsd:boolean
- pool-remove-abandoned (element) xsd:boolean
- pool-remove-abandoned-timeout-seconds
(element) xsd:int
- pool-log-abandoned (element) xsd:boolean
- ssh-username (element) xsd:string
- ssh-password (element) xsd:string
- ssh-host (element) xsd:string
- ssh-port (element) xsd:int
- remote-host (element) xsd:string
- remote-port (element) xsd:int
- local-port (element) xsd:int
- name (attribute)
xsd:string
- filename (attribute) xsd:string
- database (element) Database
Sample Code
Make it as simple as possible, but not simpler.
Albert Einstein