1
1
package com .eternalcode .parcellockers .database .wrapper ;
2
2
3
3
import com .eternalcode .commons .scheduler .Scheduler ;
4
+ import com .eternalcode .parcellockers .ParcelLockers ;
4
5
import com .eternalcode .parcellockers .database .DatabaseManager ;
5
6
import com .j256 .ormlite .dao .Dao ;
6
7
import panda .std .function .ThrowingFunction ;
@@ -21,34 +22,56 @@ protected AbstractRepositoryOrmLite(DatabaseManager databaseManager, Scheduler s
21
22
}
22
23
23
24
protected <T > CompletableFuture <Dao .CreateOrUpdateStatus > save (Class <T > type , T entity ) {
24
- return this .action (type , dao -> dao .createOrUpdate (entity ));
25
+ return this .action (type , dao -> {
26
+ ParcelLockers .DEBUG_LOGGER .info ("Saving entity: {}" , entity );
27
+ return dao .createOrUpdate (entity );
28
+ });
25
29
}
26
30
27
31
protected <T > CompletableFuture <T > saveIfNotExist (Class <T > type , T entity ) {
28
- return this .action (type , dao -> dao .createIfNotExists (entity ));
32
+ return this .action (type , dao -> {
33
+ ParcelLockers .DEBUG_LOGGER .info ("Saving entity (IF NOT EXIST mode): {}" , entity );
34
+ return dao .createIfNotExists (entity );
35
+ });
29
36
}
30
37
31
38
protected <T , ID > CompletableFuture <T > select (Class <T > type , ID id ) {
32
- return this .action (type , dao -> dao .queryForId (id ));
39
+ return this .action (type , dao -> {
40
+ ParcelLockers .DEBUG_LOGGER .info ("Selecting: {}" , id );
41
+ return dao .queryForId (id );
42
+ });
33
43
}
34
44
35
45
protected <T , ID > CompletableFuture <Optional <T >> selectSafe (Class <T > type , ID id ) {
36
- return this .action (type , dao -> Optional .ofNullable (dao .queryForId (id )));
46
+ return this .action (type , dao -> {
47
+ ParcelLockers .DEBUG_LOGGER .info ("Selecting (safe mode): {}" , id );
48
+ return Optional .ofNullable (dao .queryForId (id ));
49
+ });
37
50
}
38
51
39
52
protected <T > CompletableFuture <Integer > delete (Class <T > type , T entity ) {
40
- return this .action (type , dao -> dao .delete (entity ));
53
+ return this .action (type , dao -> {
54
+ ParcelLockers .DEBUG_LOGGER .info ("Deleting: {}" , entity );
55
+ return dao .delete (entity );
56
+ });
41
57
}
42
58
43
59
protected <T > CompletableFuture <Integer > deleteAll (Class <T > type ) {
44
- return this .action (type , dao -> dao .deleteBuilder ().delete ());
60
+ return this .action (type , dao -> {
61
+ ParcelLockers .DEBUG_LOGGER .info ("Deleting all entities of type: {}" , type .getSimpleName ());
62
+ return dao .deleteBuilder ().delete ();
63
+ });
45
64
}
46
65
47
66
protected <T , ID > CompletableFuture <Integer > deleteById (Class <T > type , ID id ) {
48
- return this .action (type , dao -> dao .deleteById (id ));
67
+ return this .action (type , dao -> {
68
+ ParcelLockers .DEBUG_LOGGER .info ("Deleting: {}" , id );
69
+ return dao .deleteById (id );
70
+ });
49
71
}
50
72
51
73
protected <T > CompletableFuture <List <T >> selectAll (Class <T > type ) {
74
+ ParcelLockers .DEBUG_LOGGER .info ("Selecting all entities of type: {}" , type .getSimpleName ());
52
75
return this .action (type , Dao ::queryForAll );
53
76
}
54
77
0 commit comments