-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
PropertyAuditingData.java
278 lines (238 loc) · 6.46 KB
/
PropertyAuditingData.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.envers.configuration.internal.metadata.reader;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.AuditOverride;
import org.hibernate.envers.AuditOverrides;
import org.hibernate.envers.ModificationStore;
import org.hibernate.envers.RelationTargetAuditMode;
import org.hibernate.envers.internal.entities.PropertyData;
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
/**
* @author Adam Warski (adam at warski dot org)
* @author Michal Skowronek (mskowr at o2 dot pl)
* @author Chris Cranford
*/
public class PropertyAuditingData {
private String name;
private String beanName;
private ModificationStore store;
private String mapKey;
private AuditJoinTable joinTable;
private String accessType;
private final List<AuditOverride> auditJoinTableOverrides = new ArrayList<>( 0 );
private RelationTargetAuditMode relationTargetAuditMode;
private String auditMappedBy;
private String relationMappedBy;
private String positionMappedBy;
private boolean forceInsertable;
private boolean usingModifiedFlag;
private String modifiedFlagName;
private Value value;
// Synthetic properties are ones which are not part of the actual java model.
// They're properties used for bookkeeping by Hibernate
private boolean syntheic;
public PropertyAuditingData() {
}
public PropertyAuditingData(
String name, String accessType, ModificationStore store,
RelationTargetAuditMode relationTargetAuditMode,
String auditMappedBy, String positionMappedBy,
boolean forceInsertable) {
this(
name,
accessType,
store,
relationTargetAuditMode,
auditMappedBy,
positionMappedBy,
forceInsertable,
false,
null
);
}
public PropertyAuditingData(
String name,
String accessType,
ModificationStore store,
RelationTargetAuditMode relationTargetAuditMode,
String auditMappedBy,
String positionMappedBy,
boolean forceInsertable,
boolean syntheic,
Value value) {
this.name = name;
this.beanName = name;
this.accessType = accessType;
this.store = store;
this.relationTargetAuditMode = relationTargetAuditMode;
this.auditMappedBy = auditMappedBy;
this.positionMappedBy = positionMappedBy;
this.forceInsertable = forceInsertable;
this.syntheic = syntheic;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBeanName() {
return beanName;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
/**
* @deprecated since 5.2, to be removed in 6.0 with no replacement.
*/
@Deprecated
public ModificationStore getStore() {
return store;
}
/**
* @deprecated since 5.2, to be removed in 6.0 with no replacement.
*/
@Deprecated
public void setStore(ModificationStore store) {
this.store = store;
}
public String getMapKey() {
return mapKey;
}
public void setMapKey(String mapKey) {
this.mapKey = mapKey;
}
public AuditJoinTable getJoinTable() {
return joinTable;
}
public void setJoinTable(AuditJoinTable joinTable) {
this.joinTable = joinTable;
}
public String getAccessType() {
return accessType;
}
public void setAccessType(String accessType) {
this.accessType = accessType;
}
// todo (6.0) - remove this and use #resolvePropertyData instead
public PropertyData getPropertyData() {
return resolvePropertyData( null );
}
public PropertyData resolvePropertyData(Type propertyType) {
return new PropertyData(
name,
beanName,
accessType,
store,
usingModifiedFlag,
modifiedFlagName,
syntheic,
propertyType
);
}
public PropertyData resolvePropertyData(Type propertyType, Type virtualType) {
return new PropertyData(
name,
beanName,
accessType,
store,
usingModifiedFlag,
modifiedFlagName,
syntheic,
propertyType,
virtualType.getReturnedClass()
);
}
public List<AuditOverride> getAuditingOverrides() {
return auditJoinTableOverrides;
}
public String getAuditMappedBy() {
return auditMappedBy;
}
public void setAuditMappedBy(String auditMappedBy) {
this.auditMappedBy = auditMappedBy;
}
public String getRelationMappedBy() {
return relationMappedBy;
}
public void setRelationMappedBy(String relationMappedBy) {
this.relationMappedBy = relationMappedBy;
}
public String getPositionMappedBy() {
return positionMappedBy;
}
public void setPositionMappedBy(String positionMappedBy) {
this.positionMappedBy = positionMappedBy;
}
public boolean isForceInsertable() {
return forceInsertable;
}
public void setForceInsertable(boolean forceInsertable) {
this.forceInsertable = forceInsertable;
}
public boolean isUsingModifiedFlag() {
return usingModifiedFlag;
}
public void setUsingModifiedFlag(boolean usingModifiedFlag) {
this.usingModifiedFlag = usingModifiedFlag;
}
public String getModifiedFlagName() {
return modifiedFlagName;
}
public void setModifiedFlagName(String modifiedFlagName) {
this.modifiedFlagName = modifiedFlagName;
}
public void addAuditingOverride(AuditOverride annotation) {
if ( annotation != null ) {
final String overrideName = annotation.name();
boolean present = false;
for ( AuditOverride current : auditJoinTableOverrides ) {
if ( current.name().equals( overrideName ) ) {
present = true;
break;
}
}
if ( !present ) {
auditJoinTableOverrides.add( annotation );
}
}
}
public void addAuditingOverrides(AuditOverrides annotationOverrides) {
if ( annotationOverrides != null ) {
for ( AuditOverride annotation : annotationOverrides.value() ) {
addAuditingOverride( annotation );
}
}
}
/**
* Get the relationTargetAuditMode property.
*
* @return the relationTargetAuditMode property value
*/
public RelationTargetAuditMode getRelationTargetAuditMode() {
return relationTargetAuditMode;
}
/**
* Set the relationTargetAuditMode property value.
*
* @param relationTargetAuditMode the relationTargetAuditMode to set
*/
public void setRelationTargetAuditMode(RelationTargetAuditMode relationTargetAuditMode) {
this.relationTargetAuditMode = relationTargetAuditMode;
}
public boolean isSyntheic() {
return syntheic;
}
public Value getValue() {
return value;
}
}