1 package fr.ifremer.quadrige3.synchro.service.data;
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 import com.google.common.collect.Multimap;
27 import fr.ifremer.common.synchro.service.SynchroContext;
28 import fr.ifremer.quadrige3.synchro.service.SynchroDirection;
29 import fr.ifremer.quadrige3.synchro.vo.SynchroDateOperatorVO;
30
31 import java.io.File;
32 import java.util.Date;
33 import java.util.Map;
34 import java.util.Set;
35
36
37
38
39
40
41
42 public class DataSynchroContext extends SynchroContext<DataSynchroDatabaseConfiguration> {
43
44 private Integer userId;
45
46 private SynchroDirection direction;
47
48 private Date dataStartDate;
49
50 private Date dataEndDate;
51
52
53
54
55 private SynchroDateOperatorVO dateOperator;
56
57
58
59
60 private boolean dirtyOnly;
61
62
63
64
65 private boolean enableDelete = true;
66
67
68
69
70 private boolean enableInsertOrUpdate = true;
71
72
73
74
75 private Multimap<String, String> pkIncludes;
76
77
78
79
80 private Set<String> programCodes;
81
82
83
84
85
86
87
88 private boolean forceEditedRowOverride = false;
89
90
91
92
93 private File changeLogFile;
94
95
96
97
98 private boolean forceDuplication = false;
99
100
101
102
103 private Map<String, Map<String, Map<String, Object>>> remapValues;
104
105
106
107
108 private boolean enablePhoto;
109
110
111
112
113
114
115 public DataSynchroContext() {
116 super();
117 this.userId = null;
118 this.direction = null;
119 }
120
121
122
123
124
125
126
127
128
129 public DataSynchroContext(DataSynchroContext otherBean) {
130 copy(otherBean);
131 }
132
133
134
135
136
137
138
139
140
141
142
143 public DataSynchroContext(SynchroDirection direction, Integer userId) {
144 super();
145 this.userId = userId;
146 this.direction = direction;
147 }
148
149
150
151
152
153
154
155
156 public Integer getUserId() {
157 return userId;
158 }
159
160
161
162
163
164
165
166
167
168 public void setUserId(Integer userId) {
169 this.userId = userId;
170 }
171
172
173
174
175
176
177
178
179 public SynchroDirection getDirection() {
180 return direction;
181 }
182
183
184
185
186
187
188
189
190
191 public void setDirection(SynchroDirection direction) {
192 this.direction = direction;
193 }
194
195
196
197
198
199
200
201
202 public Date getDataStartDate() {
203 return dataStartDate;
204 }
205
206
207
208
209
210
211
212
213
214 public void setDataStartDate(Date dataStartDate) {
215 this.dataStartDate = dataStartDate;
216 }
217
218
219
220
221
222
223
224
225 public Date getDataEndDate() {
226 return dataEndDate;
227 }
228
229
230
231
232
233
234
235
236
237 public void setDataEndDate(Date dataEndDate) {
238 this.dataEndDate = dataEndDate;
239 }
240
241
242
243
244
245
246
247
248
249 public void setPkIncludes(Multimap<String, String> pkIncludes) {
250 this.pkIncludes = pkIncludes;
251 }
252
253
254
255
256
257
258
259
260 public Multimap<String, String> getPkIncludes() {
261 return this.pkIncludes;
262 }
263
264
265
266
267
268
269
270
271 public Set<String> getProgramCodes() {
272 return programCodes;
273 }
274
275
276
277
278
279
280
281
282
283 public void setProgramCodes(Set<String> programCodes) {
284 this.programCodes = programCodes;
285 }
286
287
288
289
290
291
292
293
294 public boolean isEnableDelete() {
295 return enableDelete;
296 }
297
298
299
300
301
302
303
304
305
306 public void setEnableDelete(boolean enableDelete) {
307 this.enableDelete = enableDelete;
308 }
309
310
311
312
313
314
315
316
317 public boolean isEnableInsertOrUpdate() {
318 return enableInsertOrUpdate;
319 }
320
321
322
323
324
325
326
327
328
329 public void setEnableInsertOrUpdate(boolean enableInsertOrUpdate) {
330 this.enableInsertOrUpdate = enableInsertOrUpdate;
331 }
332
333
334
335
336
337
338
339
340 public boolean isForceEditedRowOverride() {
341 return forceEditedRowOverride;
342 }
343
344
345
346
347
348
349
350
351
352 public void setForceEditedRowOverride(boolean forceEditedRowOverride) {
353 this.forceEditedRowOverride = forceEditedRowOverride;
354 }
355
356
357
358
359
360
361
362
363 public File getChangeLogFile() {
364 return changeLogFile;
365 }
366
367
368
369
370
371
372
373
374
375 public void setChangeLogFile(File changeLogFile) {
376 this.changeLogFile = changeLogFile;
377 }
378
379
380
381
382
383
384
385
386 public boolean isForceDuplication() {
387 return forceDuplication;
388 }
389
390
391
392
393
394
395
396
397
398 public void setForceDuplication(boolean forceDuplication) {
399 this.forceDuplication = forceDuplication;
400 }
401
402
403
404
405
406
407
408
409 public Map<String, Map<String, Map<String, Object>>> getRemapValues() {
410 return remapValues;
411 }
412
413
414
415
416
417
418
419
420
421 public void setRemapValues(Map<String, Map<String, Map<String, Object>>> remapValues) {
422 this.remapValues = remapValues;
423 }
424
425
426
427
428
429
430
431
432 public SynchroDateOperatorVO getDateOperator() {
433 return dateOperator;
434 }
435
436
437
438
439
440
441
442
443
444 public void setDateOperator(SynchroDateOperatorVO dateOperator) {
445 this.dateOperator = dateOperator;
446 }
447
448
449
450
451
452
453
454
455 public boolean isDirtyOnly() {
456 return dirtyOnly;
457 }
458
459
460
461
462
463
464
465
466
467 public void setDirtyOnly(boolean dirtyOnly) {
468 this.dirtyOnly = dirtyOnly;
469 }
470
471 public boolean isEnablePhoto() {
472 return enablePhoto;
473 }
474
475 public void setEnablePhoto(boolean enablePhoto) {
476 this.enablePhoto = enablePhoto;
477 }
478
479
480 @SuppressWarnings("unchecked")
481 @Override
482 public void copy(SynchroContext otherBean) {
483 super.copy(otherBean);
484
485
486 if (otherBean.getTarget() != null) {
487 setTarget(new DataSynchroDatabaseConfiguration(this, otherBean.getTarget()));
488 }
489 if (otherBean.getSource() != null) {
490 setSource(new DataSynchroDatabaseConfiguration(this, otherBean.getSource()));
491 }
492
493 if (otherBean instanceof DataSynchroContext) {
494 this.userId = ((DataSynchroContext) otherBean).userId;
495 this.direction = ((DataSynchroContext) otherBean).direction;
496 this.dataStartDate = ((DataSynchroContext) otherBean).dataStartDate;
497 this.dataEndDate = ((DataSynchroContext) otherBean).dataEndDate;
498 this.dateOperator = ((DataSynchroContext) otherBean).dateOperator;
499 this.dirtyOnly = ((DataSynchroContext) otherBean).dirtyOnly;
500 this.pkIncludes = ((DataSynchroContext) otherBean).pkIncludes;
501 this.programCodes = ((DataSynchroContext) otherBean).programCodes;
502 this.enableDelete = ((DataSynchroContext) otherBean).enableDelete;
503 this.enableInsertOrUpdate = ((DataSynchroContext) otherBean).enableInsertOrUpdate;
504 this.forceEditedRowOverride = ((DataSynchroContext) otherBean).forceEditedRowOverride;
505 this.forceDuplication = ((DataSynchroContext) otherBean).forceDuplication;
506 this.remapValues = ((DataSynchroContext) otherBean).remapValues;
507 this.changeLogFile = ((DataSynchroContext) otherBean).changeLogFile;
508 this.enablePhoto = ((DataSynchroContext) otherBean).enablePhoto;
509 }
510 }
511
512
513 @Override
514 public String toString() {
515 StringBuilder sb = new StringBuilder(super.toString());
516 sb.append("\n direction: ").append(getDirection());
517 sb.append("\n user id: ").append(getUserId());
518 sb.append("\n enable insert: ").append(isEnableInsertOrUpdate());
519 sb.append("\n enable delete: ").append(isEnableDelete());
520 sb.append("\n override dirty")
521 .append("\n rows silently: ").append(forceEditedRowOverride);
522 sb.append("\n force duplicates: ").append(forceDuplication);
523 sb.append("\n only dirty data: ").append(dirtyOnly);
524 sb.append("\n enable photo: ").append(enablePhoto);
525
526 if (getDataStartDate() != null) {
527 sb.append("\n start date: ").append(getDataStartDate());
528 sb.append("\n end date: ").append(getDataEndDate());
529 if (getDateOperator() != null) {
530 sb.append("\n operator: ").append(getDateOperator());
531 }
532 }
533 if (getProgramCodes() != null) {
534 sb.append("\n programs: ").append(programCodes == null ? "all" : programCodes.toString());
535 }
536 if (getPkIncludes() != null) {
537 sb.append("\n PK includes: ").append(getPkIncludes().toString());
538 }
539
540 return sb.toString();
541 }
542
543 }