Skip to content

Commit a903680

Browse files
authored
Merge pull request #11 from xcomart/devel
Devel
2 parents f273d56 + d9226a1 commit a903680

File tree

20 files changed

+1029
-142
lines changed

20 files changed

+1029
-142
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# jdbgen
2-
Create sources easily from database information.
2+
3+
jdbgen is a tool for generating text(source) files from database table
4+
informations, using in-house template engine.
35

46
## Introduction
57

docs/README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Introduction
44

55
jdbgen is a tool for generating text(source) files from database table
6-
informations.
6+
informations, using in-house template engine.
77

88
If you want to create model class in java or table headers in html
99
from database table, this tool will fit perfectly as you need.
@@ -356,26 +356,32 @@ Contol statements branchs process with condition or iterates items.
356356
`if` statement branchs process with conditional statement.
357357

358358
```
359-
${if:item=<field>, <condition>}
359+
${if:item=<field>, <condition>[, <condition>]}
360360
... // conditions met
361-
[${elif:item=<field>, <conditions>} ...]
361+
[${elif:item=<field>, <conditions>[, <condition>]} ...]
362362
... // another condition met, multiple elif can be used
363363
[${else}]
364364
... // condition not met
365365
${endif}
366366
```
367367

368-
Where `field` is a member of current object(table or column).
368+
Where `field` is a member of current object(table or column) [decorator](#item-statement)(like .camel, .suffix etc) can be used.
369+
`conditions` can be added multiple times, in this case all conditions must met to execute `true` part.
370+
369371
`conditions` can be one of -
370372

371373
|Condition|Description|
372374
|:---:|:---|
373375
|`[value\|equals]=<value>`|When item value is equals `<value>`|
374376
|`notEquals=<value>`|When item value is not equals `<value>`|
375377
|`startsWith=<prefix>`|When item value starts with `<prefix>`|
378+
|`notStartsWith=<prefix>`|When item value not starts with `<prefix>`|
376379
|`endsWith=<suffix>`|When item value ends with `<suffix>`|
380+
|`notEndsWith=<suffix>`|When item value ends with `<suffix>`|
377381
|`contains=<item>`|When item collection contains `<item>` or when item is string and `<item>` is `,` separated string then item contained in `<item>`|
378382
|`notContains=<item>`|When item collection not contains `<item>` or when item is string and `<item>` is `,` separated string then item not contained in `<item>`|
383+
|`matches=<regex>`|When item value matches with regular expression `<regex>`, regex conformant with [Java Regex](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)|
384+
|`notMatches=<regex>`|When item value not matches with regular expression `<regex>`, regex conformant with [Java Regex](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)|
379385

380386
Like many other language, multiple `elif` statement can be used and `else` statement is optional.
381387
`if` statement must be closed with `endif` statement.
@@ -384,7 +390,7 @@ Examples:
384390
```
385391
This is ${if:item="type", startsWith="TABLE"}physical table${else}not table${endif}.
386392
This is
387-
${if:item="type", equals="albumId"}
393+
${if:item="type", equals="TABLE"}
388394
pysical table
389395
${elif:item="type", equals="VIEW"}
390396
virtual view
@@ -470,9 +476,16 @@ is user supplied variable in [Generator Main Window](#generator-main-window).
470476
|`.prefix`|&#x25EF;|Remove suffix including last `_` in value(ex. `SAMPLE_ALBUM_T` -> `SAMPLE_ALBUM`)|
471477
|`.camel`|&#x2715;|Change value to camel case(ex. `SAMPLE_ALBUM` -> `sampleAlbum`)|
472478
|`.pascal`|&#x2715;|Change value to pascal case(ex. `SAMPLE_ALBUM` -> `SampleAlbum`)|
479+
|`.snake`|&#x2715;|Change value to snake case(ex. `SAMPLE_ALBUM` -> `sample_album`)|
480+
|`.screaming`|&#x2715;|Change value to screaming snake case(ex. `sample_album` -> `SAMPLE_ALBUM`)|
481+
|`.skewer`|&#x2715;|Change value to skewer case(ex. `sample_album` -> `sample-album`)|
482+
|`.kebab`|&#x2715;|Alias of `.skewer`|
473483
|`.lower`|&#x2715;|Change value to lower case(ex. `SAMPLE_ALBUM` -> `sample_album`)|
474484
|`.upper`|&#x2715;|Change value to upper case(ex. `sample_album` -> `SAMPLE_ALBUM`)|
475-
|`.replace('X','Y')`|&#x2715;|Replace `X` string to 'Y' string(ex. `sample_album` `name.replace('album', 'music')` -> `sample_music`)|
485+
|`.replace('X','Y')`|&#x25EF;|Replace `X` string to 'Y' string(ex. `sample_album` `name.replace('album', 'music')` -> `sample_music`)|
486+
487+
> Note! multiple decorators are processed in pipelined manner,
488+
> in the other words, former decorator result will be the input of latter decorator.
476489
477490
`extra decorators` can be a combination of -
478491

@@ -508,9 +521,9 @@ Databse table object member fields:
508521
|`table`|String|Alias of `name`|
509522
|`type`|String|JDBC compliant table type(`TABLE`, `VIEW`)|
510523
|`remark`|String|Table comments|
511-
|`columns`|Collection|All columns in current table|
512-
|`keys`|Collection|Primary keys of current table|
513-
|`notKeys`|Collection|All columns of current table except primary keys.|
524+
|`columns`|Collection of column object|All columns in current table|
525+
|`keys`|Collection of column object|Primary key columns of current table|
526+
|`notKeys`|Collection of column object|All columns of current table except primary keys.|
514527

515528
Database column object member fields:
516529

@@ -543,7 +556,8 @@ There are several utility statements for convenience like,
543556
|`author`|`${author[:<extra decorator>]}`|User supplied `Author Name` field in [Generator Main Window](#generator-main-window).|
544557
|`date`|`${date[:format=<date format>]}`|Current date with `date format` which compliant with [SimpleDateFormat](https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/java/text/SimpleDateFormat.html).|
545558
|`user`|`${user[:<extra decorator>]}`|OS login user ID.|
546-
|Text|`${"any string can include '${' or '}'"}`|Any text can escape `${` or `}`|
559+
|`super`|`${super:key=<table member field>[<decorators>][, <extra decorator>]}`|Only available inside of `for` statement, you can access table object using this statement|
560+
|Text|`${"any string can include '${' or '}'"}`|Statement for escaping `${` or `}`|
547561

548562

549563
## Custom Queries

pom.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
<artifactId>jdbgen</artifactId>
66
<name>jdbgen</name>
77
<packaging>jar</packaging>
8-
<version>0.1.4</version>
8+
<version>0.2.0</version>
99
<build>
1010
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
1111
<outputDirectory>${basedir}/target/classes</outputDirectory>
1212
<resources>
1313
<resource>
1414
<directory>${basedir}/src/main/resources</directory>
1515
</resource>
16+
<resource>
17+
<directory>src/main/configs</directory>
18+
<filtering>true</filtering>
19+
</resource>
1620
</resources>
1721
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
1822
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
@@ -132,8 +136,8 @@
132136
<artifactId>maven-compiler-plugin</artifactId>
133137
<version>3.13.0</version>
134138
<configuration>
135-
<source>11</source>
136-
<target>11</target>
139+
<source>1.8</source>
140+
<target>1.8</target>
137141
<encoding>UTF-8</encoding>
138142
</configuration>
139143
</plugin>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=${project.version}

src/main/java/comart/tools/jdbgen/JDBGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import comart.tools.jdbgen.types.JDBGenConfig;
2727
import comart.tools.jdbgen.ui.JDBGeneratorMain;
28+
import comart.utils.PlatformUtils;
2829
import comart.utils.UIUtils;
2930
import java.awt.Font;
3031
import javax.swing.UIManager;
@@ -35,10 +36,10 @@
3536
*/
3637
public class JDBGenerator {
3738
public static void main(final String[] args) {
39+
UIUtils.setFlatLightLaf();
40+
PlatformUtils.updateCheck();
3841
if (JDBGenConfig.getInstance().isDarkUI()) {
3942
UIUtils.setFlatDarkLaf();
40-
} else {
41-
UIUtils.setFlatLightLaf();
4243
}
4344
UIManager.put("ToolTip.font", new Font("Monospaced", Font.PLAIN, 13));
4445
JDBGeneratorMain win = new JDBGeneratorMain();

0 commit comments

Comments
 (0)