• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trydofor / professional-wings / #131

16 Jan 2025 02:20PM UTC coverage: 63.526% (+0.03%) from 63.495%
#131

push

trydofor
⬆️ 💥 up deps, boot 3.3, mirana new i18n #309

30 of 68 new or added lines in 28 files covered. (44.12%)

36 existing lines in 3 files now uncovered.

12920 of 20338 relevant lines covered (63.53%)

0.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.83
/wings/warlock/src/main/java/pro/fessional/wings/warlock/service/event/TableChangePublisher.java
1
package pro.fessional.wings.warlock.service.event;
2

3
import org.jetbrains.annotations.NotNull;
4
import org.jooq.Record;
5
import org.jooq.Table;
6
import org.jooq.TableField;
7
import pro.fessional.mirana.best.AssertArgs;
8
import pro.fessional.wings.warlock.event.cache.TableChangeEvent;
9

10
import java.util.HashMap;
11
import java.util.List;
12
import java.util.Map;
13

14
import static java.util.Collections.singletonMap;
15
import static pro.fessional.wings.warlock.event.cache.TableChangeEvent.DELETE;
16
import static pro.fessional.wings.warlock.event.cache.TableChangeEvent.INSERT;
17
import static pro.fessional.wings.warlock.event.cache.TableChangeEvent.UPDATE;
18

19
/**
20
 * Publish table record change (insert, update, delete) events (default and recommended asynchronous)
21
 *
22
 * @author trydofor
23
 * @since 2021-06-10
24
 */
25
public interface TableChangePublisher {
26

27
    default void publishInsert(@NotNull Class<?> source, @NotNull String table, @NotNull Map<String, List<?>> field) {
28
        publish(INSERT, source, table, field);
1✔
29
    }
1✔
30

31
    default <R extends Record, F> void publishInsert(@NotNull Class<?> source, @NotNull TableField<R, F> field, @NotNull List<F> value) {
32
        publish(INSERT, source, field, value);
×
33
    }
×
34

35
    default <R extends Record> void publishInsert(@NotNull Class<?> source, @NotNull Table<R> table, @NotNull Map<TableField<R, ?>, List<?>> field) {
36
        publish(INSERT, source, table, field);
×
37
    }
×
38

39
    //
40
    default void publishUpdate(@NotNull Class<?> source, @NotNull String table, @NotNull Map<String, List<?>> field) {
41
        publish(UPDATE, source, table, field);
1✔
42
    }
1✔
43

44
    default <R extends Record, F> void publishUpdate(@NotNull Class<?> source, @NotNull TableField<R, F> field, @NotNull List<F> value) {
45
        publish(UPDATE, source, field, value);
×
46
    }
×
47

48
    default <R extends Record> void publishUpdate(@NotNull Class<?> source, @NotNull Table<R> table, @NotNull Map<TableField<R, ?>, List<?>> field) {
49
        publish(UPDATE, source, table, field);
×
50
    }
×
51

52
    //
53
    default void publishDelete(@NotNull Class<?> source, @NotNull String table, @NotNull Map<String, List<?>> field) {
54
        publish(DELETE, source, table, field);
×
55
    }
×
56

57
    default <R extends Record, F> void publishDelete(@NotNull Class<?> source, @NotNull TableField<R, F> field, @NotNull List<F> value) {
58
        publish(DELETE, source, field, value);
×
59
    }
×
60

61
    default <R extends Record> void publishDelete(@NotNull Class<?> source, @NotNull Table<R> table, @NotNull Map<TableField<R, ?>, List<?>> field) {
62
        publish(DELETE, source, table, field);
×
63
    }
×
64

65
    //
66
    default void publishAllCud(@NotNull Class<?> source, @NotNull String table, @NotNull Map<String, List<?>> field) {
67
        publish(INSERT | UPDATE | DELETE, source, table, field);
×
68
    }
×
69

70
    default <R extends Record, F> void publishAllCud(@NotNull Class<?> source, @NotNull TableField<R, F> field, @NotNull List<F> value) {
71
        publish(INSERT | UPDATE | DELETE, source, field, value);
×
72
    }
×
73

74
    default <R extends Record> void publishAllCud(@NotNull Class<?> source, @NotNull Table<R> table, @NotNull Map<TableField<R, ?>, List<?>> field) {
75
        publish(INSERT | UPDATE | DELETE, source, table, field);
×
76
    }
×
77

78
    //
79
    default <R extends Record, F> void publish(int cud, @NotNull Class<?> source, @NotNull TableField<R, F> field, @NotNull List<F> value) {
80
        final Table<R> table = field.getTable();
×
NEW
81
        AssertArgs.notNull(table, "tableField", "field's table is null. field=" + field);
×
82
        publish(cud, source, table.getName(), singletonMap(field.getName(), value));
×
83
    }
×
84

85
    default <R extends Record> void publish(int cud, @NotNull Class<?> source, @NotNull Table<R> table, @NotNull Map<TableField<R, ?>, List<?>> field) {
86
        Map<String, List<?>> map = new HashMap<>();
×
87
        for (Map.Entry<TableField<R, ?>, List<?>> en : field.entrySet()) {
×
88
            map.put(en.getKey().getName(), en.getValue());
×
89
        }
×
90
        publish(cud, source, table.getName(), map);
×
91
    }
×
92

93
    default void publish(int cud, @NotNull Class<?> source, @NotNull String table, @NotNull Map<String, List<?>> field) {
94
        TableChangeEvent event = new TableChangeEvent();
1✔
95
        event.setChange(cud);
1✔
96
        event.addSource(source.getName());
1✔
97
        event.setTable(table);
1✔
98
        event.setField(field);
1✔
99
        publish(event);
1✔
100
    }
1✔
101

102
    void publish(@NotNull TableChangeEvent event);
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc