-
Notifications
You must be signed in to change notification settings - Fork 7
/
JournalEntry.java
171 lines (142 loc) · 4.88 KB
/
JournalEntry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.biz.protocol;
import sirius.biz.elastic.SearchContent;
import sirius.biz.elastic.SearchableEntity;
import sirius.db.es.annotations.ESOption;
import sirius.db.es.annotations.IndexMode;
import sirius.db.mixing.BaseEntity;
import sirius.db.mixing.EntityDescriptor;
import sirius.db.mixing.Mapping;
import sirius.kernel.async.TaskContext;
import sirius.kernel.commons.Strings;
import sirius.kernel.commons.Tuple;
import sirius.kernel.di.std.Framework;
import java.time.LocalDateTime;
/**
* Records the changes recorded by a {@link JournalData}.
*/
@Framework(Protocols.FRAMEWORK_JOURNAL)
public class JournalEntry extends SearchableEntity {
/**
* Contains the timestamp of the change.
*/
public static final Mapping TOD = Mapping.named("tod");
private LocalDateTime tod;
/**
* Contains the name of the user which was active when the change occurred.
*/
public static final Mapping USERNAME = Mapping.named("username");
@SearchContent
private String username;
/**
* Contains the id of the user which was active when the change occurred.
*/
public static final Mapping USER_ID = Mapping.named("userId");
private String userId;
/**
* Contains the system string, which indicates where the change occurred.
*
* @see TaskContext#getSystemString()
*/
public static final Mapping SUBSYSTEM = Mapping.named("subsystem");
@SearchContent
private String subsystem;
/**
* Contains the type name of the entity which owns this change record.
*/
public static final Mapping TARGET_TYPE = Mapping.named("targetType");
@SearchContent
private String targetType;
/**
* Contains the ID of entity which owns this change record.
*/
public static final Mapping TARGET_ID = Mapping.named("targetId");
@SearchContent
private String targetId;
/**
* Contains the identifier of the changed entity.
* <p>
* The identifier is composed of {@link EntityDescriptor#getType()}-{@link BaseEntity#getIdAsString()}
* For entities using {@link JournalData}, it is equal to the {@link #TARGET_TYPE}-{@link #TARGET_ID}
* For entities using {@link DelegateJournalData}, it will contain the type and if of the entity which
* caused the journal entry, since the target fields contains the parent entity owning this record.
*/
public static final Mapping CONTENT_IDENTIFIER = Mapping.named("contentIdentifier");
@SearchContent
private String contentIdentifier;
/**
* Contains all changed fields as <tt>name: value</tt>.
* <p>
* The old values are not recorded, as these are in the previous protocol entry.
*/
public static final Mapping CHANGES = Mapping.named("changes");
@SearchContent
@IndexMode(indexed = ESOption.FALSE, docValues = ESOption.FALSE)
private String changes;
/**
* Splits the {@link #CONTENT_IDENTIFIER} into its two original parts.
* <p>
* This can be used for entities {@link DelegateJournalData} as the {@link #TARGET_TYPE} and {@link #TARGET_ID} contain
* the type and ID of the parent entity in those cases. So this method returns the actual type and ID of the entity
* using {@link DelegateJournalData} instead, the same as for entities using {@link JournalData}.
*
* @return a <tt>Tuple</tt> containing the type and ID of the changed entity
*/
public Tuple<String, String> splitContentIdentifierParts() {
return Strings.split(contentIdentifier, "-");
}
public LocalDateTime getTod() {
return tod;
}
public void setTod(LocalDateTime tod) {
this.tod = tod;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getSubsystem() {
return subsystem;
}
public void setSubsystem(String subsystem) {
this.subsystem = subsystem;
}
public String getTargetType() {
return targetType;
}
public void setTargetType(String targetType) {
this.targetType = targetType;
}
public String getTargetId() {
return targetId;
}
public void setTargetId(String targetId) {
this.targetId = targetId;
}
public String getContentIdentifier() {
return contentIdentifier;
}
public void setContentIdentifier(String contentIdentifier) {
this.contentIdentifier = contentIdentifier;
}
public String getChanges() {
return changes;
}
public void setChanges(String changes) {
this.changes = changes;
}
}