Skip to content

Commit edb2ce9

Browse files
committed
update sorma2
1 parent 73ecd7f commit edb2ce9

File tree

18 files changed

+354
-284
lines changed

18 files changed

+354
-284
lines changed

android-refimpl-app/app/src/main/java/com/zoffcc/applications/sorm/OrmaDatabase.java

Lines changed: 131 additions & 137 deletions
Large diffs are not rendered by default.

sorma2/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,77 @@ this was solved by: https://github.com/xerial/sqlite-jdbc/pull/1178
1313
see: https://github.com/xerial/sqlite-jdbc/issues/1094<br>
1414
<br>
1515

16+
[![build](https://github.com/zoff99/iocipher_pack/actions/workflows/ci.yml/badge.svg)](https://github.com/zoff99/iocipher_pack/actions/workflows/ci.yml)
17+
18+
19+
# Usage
20+
21+
create one file for each database table that you need.
22+
<br>
23+
create file for db table `Person` as `./gen/_sorm_Person.java`
24+
<br>(don't worry it is not really Java, we just use the syntax here)
25+
```Java
26+
@Table
27+
public class Person
28+
{
29+
@PrimaryKey(autoincrement = true)
30+
public long id;
31+
@Column
32+
public String name;
33+
@Column
34+
public String address;
35+
@Column
36+
public int social_number;
37+
}
38+
```
39+
40+
now create the Java sources with the Java SORMA2 Generator. <b>you need at least java 17</b>.<br>
41+
```bash
42+
java -classpath ".:sqlite-jdbc-3.49.1.0.jar:sorma2.jar" \
43+
com/zoffcc/applications/sorm/Generator "gen"
44+
```
45+
46+
your project is now ready to start.<br>
47+
enter the generator directory:
48+
```bash
49+
cd ./gen/
50+
ls -al
51+
```
52+
53+
now move or copy all *.java files from the generator directory into your Android or Java project source tree
54+
```bash
55+
cd gen/
56+
# remove class files
57+
find . -name '*.class'|xargs rm -v
58+
cp -av ./com /home/user/your/project/source/tree/
59+
```
60+
61+
in your Java project you will need the `sqlite jdbc jar` and in your
62+
Android project you will need `com.github.zoff99:pkgs_zoffccAndroidJDBC` from [jitpack.io](https://jitpack.io/#zoff99/pkgs_zoffccAndroidJDBC)
63+
64+
65+
66+
Android Example App:
67+
------------------------
68+
69+
see: https://github.com/zoff99/sorma2/tree/master/example_android
70+
71+
<img src="https://github.com/zoff99/sorma2/releases/download/nightly/android_screen01_21.png" height="300"></a><img src="https://github.com/zoff99/sorma2/releases/download/nightly/android_screen01_29.png" height="300"></a><img src="https://github.com/zoff99/sorma2/releases/download/nightly/android_screen01_33.png" height="300"></a><img src="https://github.com/zoff99/sorma2/releases/download/nightly/android_screen01_35.png" height="300"></a>
72+
<br>
73+
74+
75+
Linux Java Example App:
76+
------------------------
77+
78+
see: https://github.com/zoff99/sorma2/tree/master/test
79+
80+
<img src="https://github.com/zoff99/sorma2/releases/download/nightly/console_screen.png" width="70%">
81+
82+
Use the `sorma_generated.jar` (that is generated in the `gen` directory) and `sqlite-jdbc-3.49.1.0.jar` for the Java project.<br>
83+
Check `TestSorma.java` for an Example usage.
84+
<br>
85+
86+
1687
<br>
1788
Any use of this project's code by GitHub Copilot, past or present, is done
1889
without our permission. We do not consent to GitHub's use of this project's

sorma2/com/zoffcc/applications/sorm/Generator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.nio.file.Path;
1111
import java.nio.file.StandardCopyOption;
1212
import java.util.ArrayList;
13+
import java.util.Arrays;
1314
import java.util.Iterator;
1415
import java.util.stream.Stream;
1516

@@ -88,7 +89,11 @@ public static void main(String[] args) {
8889
final String workdir = args[0];
8990
begin_orma(workdir, orma_global_out);
9091

91-
for (final File fileEntry : new File(workdir).listFiles()) {
92+
// HINT: sort order does not seem to be exactly identical everywhere. this is the aweful "fix" with sorting
93+
File[] files = new File(workdir).listFiles();
94+
Arrays.sort(files, (a, b) -> a.getName().compareTo(b.getName()));
95+
96+
for (final File fileEntry : files) {
9297
if (!fileEntry.isDirectory()) {
9398
if (fileEntry.getName().startsWith(prefix))
9499
{
@@ -166,7 +171,7 @@ static void begin_orma(final String workdir, final String outfilename)
166171
static void begin_table(final String workdir, final String tablename)
167172
{
168173
System.out.println("starting: " + workdir + File.separator + out_classdir + tablename + tbl_f_ext);
169-
tbl_deepcopy = " static "+tablename+" deep_copy("+tablename+" in)" + "\n";
174+
tbl_deepcopy = " public static "+tablename+" deep_copy("+tablename+" in)" + "\n";
170175
tbl_deepcopy += " {" + "\n";
171176
tbl_deepcopy += " "+tablename+" out = new "+tablename+"();" + "\n";
172177

sorma2/gen/com/zoffcc/applications/sorm/BootstrapNodeEntryDB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BootstrapNodeEntryDB
3737
@Column(indexed = true, helpers = Column.Helpers.ALL)
3838
public String key_hex;
3939

40-
static BootstrapNodeEntryDB deep_copy(BootstrapNodeEntryDB in)
40+
public static BootstrapNodeEntryDB deep_copy(BootstrapNodeEntryDB in)
4141
{
4242
BootstrapNodeEntryDB out = new BootstrapNodeEntryDB();
4343
out.id = in.id;

sorma2/gen/com/zoffcc/applications/sorm/ConferenceDB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ConferenceDB
4646
@Column(indexed = true, helpers = Column.Helpers.ALL)
4747
public boolean notification_silent;
4848

49-
static ConferenceDB deep_copy(ConferenceDB in)
49+
public static ConferenceDB deep_copy(ConferenceDB in)
5050
{
5151
ConferenceDB out = new ConferenceDB();
5252
out.conference_identifier = in.conference_identifier;

sorma2/gen/com/zoffcc/applications/sorm/ConferenceMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class ConferenceMessage
6161
@Column(indexed = true, helpers = Column.Helpers.ALL)
6262
public boolean was_synced;
6363

64-
static ConferenceMessage deep_copy(ConferenceMessage in)
64+
public static ConferenceMessage deep_copy(ConferenceMessage in)
6565
{
6666
ConferenceMessage out = new ConferenceMessage();
6767
out.id = in.id;

sorma2/gen/com/zoffcc/applications/sorm/ConferencePeerCacheDB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ConferencePeerCacheDB
3434
@Column(indexed = true, helpers = Column.Helpers.ALL)
3535
public long last_update_timestamp;
3636

37-
static ConferencePeerCacheDB deep_copy(ConferencePeerCacheDB in)
37+
public static ConferencePeerCacheDB deep_copy(ConferencePeerCacheDB in)
3838
{
3939
ConferencePeerCacheDB out = new ConferencePeerCacheDB();
4040
out.id = in.id;

sorma2/gen/com/zoffcc/applications/sorm/FileDB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class FileDB
4343
@Column(indexed = true, helpers = Column.Helpers.ALL)
4444
public boolean is_in_VFS;
4545

46-
static FileDB deep_copy(FileDB in)
46+
public static FileDB deep_copy(FileDB in)
4747
{
4848
FileDB out = new FileDB();
4949
out.id = in.id;

sorma2/gen/com/zoffcc/applications/sorm/Filetransfer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class Filetransfer
6767
@Column(indexed = true, helpers = Column.Helpers.ALL)
6868
public String tox_file_id_hex;
6969

70-
static Filetransfer deep_copy(Filetransfer in)
70+
public static Filetransfer deep_copy(Filetransfer in)
7171
{
7272
Filetransfer out = new Filetransfer();
7373
out.id = in.id;

sorma2/gen/com/zoffcc/applications/sorm/FriendList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class FriendList
9191
@Column(indexed = true, helpers = Column.Helpers.ALL)
9292
public long msgv3_capability;
9393

94-
static FriendList deep_copy(FriendList in)
94+
public static FriendList deep_copy(FriendList in)
9595
{
9696
FriendList out = new FriendList();
9797
out.tox_public_key_string = in.tox_public_key_string;

0 commit comments

Comments
 (0)