1
2
3
4
5
6 package fr.ifremer.quadrige3.core.dao.system.rule;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 import java.io.Serializable;
29 import java.sql.Timestamp;
30 import java.util.Collection;
31 import java.util.HashSet;
32
33
34
35
36
37 public abstract class Rule
38 implements Serializable, Comparable<Rule>
39 {
40
41
42
43 private static final long serialVersionUID = 4559848545964014818L;
44
45
46 private String ruleCd;
47
48
49
50
51
52 public String getRuleCd()
53 {
54 return this.ruleCd;
55 }
56
57
58
59
60
61 public void setRuleCd(String ruleCdIn)
62 {
63 this.ruleCd = ruleCdIn;
64 }
65
66 private String ruleControledAttribut;
67
68
69
70
71
72 public String getRuleControledAttribut()
73 {
74 return this.ruleControledAttribut;
75 }
76
77
78
79
80
81 public void setRuleControledAttribut(String ruleControledAttributIn)
82 {
83 this.ruleControledAttribut = ruleControledAttributIn;
84 }
85
86 private String ruleDc;
87
88
89
90
91
92 public String getRuleDc()
93 {
94 return this.ruleDc;
95 }
96
97
98
99
100
101 public void setRuleDc(String ruleDcIn)
102 {
103 this.ruleDc = ruleDcIn;
104 }
105
106 private String ruleIsActive;
107
108
109
110
111
112 public String getRuleIsActive()
113 {
114 return this.ruleIsActive;
115 }
116
117
118
119
120
121 public void setRuleIsActive(String ruleIsActiveIn)
122 {
123 this.ruleIsActive = ruleIsActiveIn;
124 }
125
126 private String ruleIsBlocking;
127
128
129
130
131
132 public String getRuleIsBlocking()
133 {
134 return this.ruleIsBlocking;
135 }
136
137
138
139
140
141 public void setRuleIsBlocking(String ruleIsBlockingIn)
142 {
143 this.ruleIsBlocking = ruleIsBlockingIn;
144 }
145
146 private String ruleErrorMsg;
147
148
149
150
151
152 public String getRuleErrorMsg()
153 {
154 return this.ruleErrorMsg;
155 }
156
157
158
159
160
161 public void setRuleErrorMsg(String ruleErrorMsgIn)
162 {
163 this.ruleErrorMsg = ruleErrorMsgIn;
164 }
165
166 private Timestamp updateDt;
167
168
169
170
171
172 public Timestamp getUpdateDt()
173 {
174 return this.updateDt;
175 }
176
177
178
179
180
181 public void setUpdateDt(Timestamp updateDtIn)
182 {
183 this.updateDt = updateDtIn;
184 }
185
186
187 private RuleList ruleList;
188
189
190
191
192
193 public RuleList getRuleList()
194 {
195 return this.ruleList;
196 }
197
198
199
200
201
202 public void setRuleList(RuleList ruleListIn)
203 {
204 this.ruleList = ruleListIn;
205 }
206
207 private Collection<RuleParameter> ruleParameters = new HashSet<RuleParameter>();
208
209
210
211
212
213 public Collection<RuleParameter> getRuleParameters()
214 {
215 return this.ruleParameters;
216 }
217
218
219
220
221
222 public void setRuleParameters(Collection<RuleParameter> ruleParametersIn)
223 {
224 this.ruleParameters = ruleParametersIn;
225 }
226
227
228
229
230
231
232
233 public boolean addRuleParameters(RuleParameter elementToAdd)
234 {
235 return this.ruleParameters.add(elementToAdd);
236 }
237
238
239
240
241
242
243
244 public boolean removeRuleParameters(RuleParameter elementToRemove)
245 {
246 return this.ruleParameters.remove(elementToRemove);
247 }
248
249 private Function function;
250
251
252
253
254
255 public Function getFunction()
256 {
257 return this.function;
258 }
259
260
261
262
263
264 public void setFunction(Function functionIn)
265 {
266 this.function = functionIn;
267 }
268
269 private Collection<RulePmfm> rulePmfms = new HashSet<RulePmfm>();
270
271
272
273
274
275 public Collection<RulePmfm> getRulePmfms()
276 {
277 return this.rulePmfms;
278 }
279
280
281
282
283
284 public void setRulePmfms(Collection<RulePmfm> rulePmfmsIn)
285 {
286 this.rulePmfms = rulePmfmsIn;
287 }
288
289
290
291
292
293
294
295 public boolean addRulePmfms(RulePmfm elementToAdd)
296 {
297 return this.rulePmfms.add(elementToAdd);
298 }
299
300
301
302
303
304
305
306 public boolean removeRulePmfms(RulePmfm elementToRemove)
307 {
308 return this.rulePmfms.remove(elementToRemove);
309 }
310
311 private Collection<RulePrecondition> rulePreconditions = new HashSet<RulePrecondition>();
312
313
314
315
316
317 public Collection<RulePrecondition> getRulePreconditions()
318 {
319 return this.rulePreconditions;
320 }
321
322
323
324
325
326 public void setRulePreconditions(Collection<RulePrecondition> rulePreconditionsIn)
327 {
328 this.rulePreconditions = rulePreconditionsIn;
329 }
330
331
332
333
334
335
336
337 public boolean addRulePreconditions(RulePrecondition elementToAdd)
338 {
339 return this.rulePreconditions.add(elementToAdd);
340 }
341
342
343
344
345
346
347
348 public boolean removeRulePreconditions(RulePrecondition elementToRemove)
349 {
350 return this.rulePreconditions.remove(elementToRemove);
351 }
352
353 private Collection<RuleGroup> ruleGroups = new HashSet<RuleGroup>();
354
355
356
357
358
359 public Collection<RuleGroup> getRuleGroups()
360 {
361 return this.ruleGroups;
362 }
363
364
365
366
367
368 public void setRuleGroups(Collection<RuleGroup> ruleGroupsIn)
369 {
370 this.ruleGroups = ruleGroupsIn;
371 }
372
373
374
375
376
377
378
379 public boolean addRuleGroups(RuleGroup elementToAdd)
380 {
381 return this.ruleGroups.add(elementToAdd);
382 }
383
384
385
386
387
388
389
390 public boolean removeRuleGroups(RuleGroup elementToRemove)
391 {
392 return this.ruleGroups.remove(elementToRemove);
393 }
394
395
396
397
398
399 @Override
400 public boolean equals(Object object)
401 {
402 if (this == object)
403 {
404 return true;
405 }
406 if (!(object instanceof Rule))
407 {
408 return false;
409 }
410 final Rule that = (Rule)object;
411 if (this.ruleCd == null || that.getRuleCd() == null || !this.ruleCd.equals(that.getRuleCd()))
412 {
413 return false;
414 }
415 return true;
416 }
417
418
419
420
421 @Override
422 public int hashCode()
423 {
424 int hashCode = 0;
425 hashCode = 29 * hashCode + (this.ruleCd == null ? 0 : this.ruleCd.hashCode());
426
427 return hashCode;
428 }
429
430
431
432
433 public static final class Factory
434 {
435
436
437
438
439 public static Rule newInstance()
440 {
441 return new RuleImpl();
442 }
443
444
445
446
447
448
449
450
451 public static Rule newInstance(String ruleControledAttribut, Function function)
452 {
453 final Rule entity = new RuleImpl();
454 entity.setRuleControledAttribut(ruleControledAttribut);
455 entity.setFunction(function);
456 return entity;
457 }
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476 public static Rule newInstance(String ruleControledAttribut, String ruleDc, String ruleIsActive, String ruleIsBlocking, String ruleErrorMsg, Timestamp updateDt, RuleList ruleList, Collection<RuleParameter> ruleParameters, Function function, Collection<RulePmfm> rulePmfms, Collection<RulePrecondition> rulePreconditions, Collection<RuleGroup> ruleGroups)
477 {
478 final Rule entity = new RuleImpl();
479 entity.setRuleControledAttribut(ruleControledAttribut);
480 entity.setRuleDc(ruleDc);
481 entity.setRuleIsActive(ruleIsActive);
482 entity.setRuleIsBlocking(ruleIsBlocking);
483 entity.setRuleErrorMsg(ruleErrorMsg);
484 entity.setUpdateDt(updateDt);
485 entity.setRuleList(ruleList);
486 entity.setRuleParameters(ruleParameters);
487 entity.setFunction(function);
488 entity.setRulePmfms(rulePmfms);
489 entity.setRulePreconditions(rulePreconditions);
490 entity.setRuleGroups(ruleGroups);
491 return entity;
492 }
493 }
494
495
496
497
498 public int compareTo(Rule o)
499 {
500 int cmp = 0;
501 if (this.getRuleCd() != null)
502 {
503 cmp = this.getRuleCd().compareTo(o.getRuleCd());
504 }
505 else
506 {
507 if (this.getRuleControledAttribut() != null)
508 {
509 cmp = (cmp != 0 ? cmp : this.getRuleControledAttribut().compareTo(o.getRuleControledAttribut()));
510 }
511 if (this.getRuleDc() != null)
512 {
513 cmp = (cmp != 0 ? cmp : this.getRuleDc().compareTo(o.getRuleDc()));
514 }
515 if (this.getRuleIsActive() != null)
516 {
517 cmp = (cmp != 0 ? cmp : this.getRuleIsActive().compareTo(o.getRuleIsActive()));
518 }
519 if (this.getRuleIsBlocking() != null)
520 {
521 cmp = (cmp != 0 ? cmp : this.getRuleIsBlocking().compareTo(o.getRuleIsBlocking()));
522 }
523 if (this.getRuleErrorMsg() != null)
524 {
525 cmp = (cmp != 0 ? cmp : this.getRuleErrorMsg().compareTo(o.getRuleErrorMsg()));
526 }
527 if (this.getUpdateDt() != null)
528 {
529 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt()));
530 }
531 }
532 return cmp;
533 }
534
535
536 }