1 package fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule;
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 fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
27 import fr.ifremer.reefdb.dto.ErrorDTO;
28 import fr.ifremer.reefdb.dto.FunctionDTO;
29 import fr.ifremer.reefdb.dto.ReefDbBeanFactory;
30 import fr.ifremer.reefdb.dto.ReefDbBeans;
31 import fr.ifremer.reefdb.dto.configuration.control.*;
32 import fr.ifremer.reefdb.dto.enums.ControlFunctionValues;
33 import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbRowUIModel;
34 import org.nuiton.util.beans.Binder;
35 import org.nuiton.util.beans.BinderFactory;
36
37 import java.util.Collection;
38 import java.util.Date;
39 import java.util.function.Predicate;
40
41
42
43
44
45
46 public class ControlRuleRowModel extends AbstractReefDbRowUIModel<ControlRuleDTO, ControlRuleRowModel> implements ControlRuleDTO {
47
48 private static final Binder<ControlRuleDTO, ControlRuleRowModel> FROM_BEAN_BINDER =
49 BinderFactory.newBinder(ControlRuleDTO.class, ControlRuleRowModel.class);
50
51 private static final Binder<ControlRuleRowModel, ControlRuleDTO> TO_BEAN_BINDER =
52 BinderFactory.newBinder(ControlRuleRowModel.class, ControlRuleDTO.class);
53
54 static final Predicate<ControlRuleRowModel> qualitativeValuePredicate = ReefDbBeans::isQualitativeControlRule;
55
56 static final Predicate<ControlRuleRowModel> preconditionQualitativePredicate = rule -> ControlFunctionValues.PRECONDITION_QUALITATIVE.equals(rule.getFunction());
57
58 static final Predicate<ControlRuleRowModel> preconditionNumericalPredicate = rule -> ControlFunctionValues.PRECONDITION_NUMERICAL.equals(rule.getFunction());
59
60 public static final String PROPERTY_PMFM_VALID = "pmfmValid";
61 private boolean pmfmValid;
62
63
64
65
66 public ControlRuleRowModel() {
67 super(FROM_BEAN_BINDER, TO_BEAN_BINDER);
68 }
69
70 public boolean isPmfmValid() {
71 return pmfmValid;
72 }
73
74 public void setPmfmValid(boolean pmfmValid) {
75 boolean oldValue = isPmfmValid();
76 this.pmfmValid = pmfmValid;
77 firePropertyChange(PROPERTY_PMFM_VALID, oldValue, pmfmValid);
78 }
79
80
81 @Override
82 protected ControlRuleDTO newBean() {
83 return ReefDbBeanFactory.newControlRuleDTO();
84 }
85
86
87 @Override
88 public String getCode() {
89 return delegateObject.getCode();
90 }
91
92
93 @Override
94 public void setCode(String code) {
95 delegateObject.setCode(code);
96 }
97
98
99 @Override
100 public FunctionDTO getFunction() {
101 return delegateObject.getFunction();
102 }
103
104
105 @Override
106 public void setFunction(FunctionDTO Function) {
107 delegateObject.setFunction(Function);
108 }
109
110
111 @Override
112 public ErrorDTO getErrors(int index) {
113 return delegateObject.getErrors(index);
114 }
115
116
117 @Override
118 public boolean isErrorsEmpty() {
119 return delegateObject.isErrorsEmpty();
120 }
121
122
123 @Override
124 public int sizeErrors() {
125 return delegateObject.sizeErrors();
126 }
127
128
129 @Override
130 public void addErrors(ErrorDTO errors) {
131 delegateObject.addErrors(errors);
132 }
133
134
135 @Override
136 public void addAllErrors(Collection<ErrorDTO> errors) {
137 delegateObject.addAllErrors(errors);
138 }
139
140
141 @Override
142 public boolean removeErrors(ErrorDTO errors) {
143 return delegateObject.removeErrors(errors);
144 }
145
146
147 @Override
148 public boolean removeAllErrors(Collection<ErrorDTO> errors) {
149 return delegateObject.removeAllErrors(errors);
150 }
151
152
153 @Override
154 public boolean containsErrors(ErrorDTO errors) {
155 return delegateObject.containsErrors(errors);
156 }
157
158
159 @Override
160 public boolean containsAllErrors(Collection<ErrorDTO> errors) {
161 return delegateObject.containsAllErrors(errors);
162 }
163
164
165 @Override
166 public Collection<ErrorDTO> getErrors() {
167 return delegateObject.getErrors();
168 }
169
170
171 @Override
172 public void setErrors(Collection<ErrorDTO> errors) {
173 delegateObject.setErrors(errors);
174 }
175
176 @Override
177 public PreconditionRuleDTO getPreconditions(int index) {
178 return delegateObject.getPreconditions(index);
179 }
180
181 @Override
182 public boolean isPreconditionsEmpty() {
183 return delegateObject.isPreconditionsEmpty();
184 }
185
186 @Override
187 public int sizePreconditions() {
188 return delegateObject.sizePreconditions();
189 }
190
191 @Override
192 public void addPreconditions(PreconditionRuleDTO preconditions) {
193 delegateObject.addPreconditions(preconditions);
194 }
195
196 @Override
197 public void addAllPreconditions(Collection<PreconditionRuleDTO> preconditions) {
198 delegateObject.addAllPreconditions(preconditions);
199 }
200
201 @Override
202 public boolean removePreconditions(PreconditionRuleDTO preconditions) {
203 return delegateObject.removePreconditions(preconditions);
204 }
205
206 @Override
207 public boolean removeAllPreconditions(Collection<PreconditionRuleDTO> preconditions) {
208 return delegateObject.removeAllPreconditions(preconditions);
209 }
210
211 @Override
212 public boolean containsPreconditions(PreconditionRuleDTO preconditions) {
213 return delegateObject.containsPreconditions(preconditions);
214 }
215
216 @Override
217 public boolean containsAllPreconditions(Collection<PreconditionRuleDTO> preconditions) {
218 return delegateObject.containsAllPreconditions(preconditions);
219 }
220
221 @Override
222 public Collection<PreconditionRuleDTO> getPreconditions() {
223 return delegateObject.getPreconditions();
224 }
225
226 @Override
227 public void setPreconditions(Collection<PreconditionRuleDTO> preconditions) {
228 delegateObject.setPreconditions(preconditions);
229 }
230
231 @Override
232 public RuleGroupDTO getGroups(int index) {
233 return delegateObject.getGroups(index);
234 }
235
236 @Override
237 public boolean isGroupsEmpty() {
238 return delegateObject.isGroupsEmpty();
239 }
240
241 @Override
242 public int sizeGroups() {
243 return delegateObject.sizeGroups();
244 }
245
246 @Override
247 public void addGroups(RuleGroupDTO groups) {
248 delegateObject.addGroups(groups);
249 }
250
251 @Override
252 public void addAllGroups(Collection<RuleGroupDTO> groups) {
253 delegateObject.addAllGroups(groups);
254 }
255
256 @Override
257 public boolean removeGroups(RuleGroupDTO groups) {
258 return delegateObject.removeGroups(groups);
259 }
260
261 @Override
262 public boolean removeAllGroups(Collection<RuleGroupDTO> groups) {
263 return delegateObject.removeAllGroups(groups);
264 }
265
266 @Override
267 public boolean containsGroups(RuleGroupDTO groups) {
268 return delegateObject.containsGroups(groups);
269 }
270
271 @Override
272 public boolean containsAllGroups(Collection<RuleGroupDTO> groups) {
273 return delegateObject.containsAllGroups(groups);
274 }
275
276 @Override
277 public Collection<RuleGroupDTO> getGroups() {
278 return delegateObject.getGroups();
279 }
280
281 @Override
282 public void setGroups(Collection<RuleGroupDTO> groups) {
283 delegateObject.setGroups(groups);
284 }
285
286
287 @Override
288 public ControlElementDTO getControlElement() {
289 return delegateObject.getControlElement();
290 }
291
292
293 @Override
294 public void setControlElement(ControlElementDTO controlElement) {
295
296
297 final ControlElementDTO oldValue = delegateObject.getControlElement();
298 if (oldValue != null && (controlElement == null || !oldValue.getName().equals(controlElement.getName()))) {
299 setControlFeature(null);
300 }
301 delegateObject.setControlElement(controlElement);
302 }
303
304
305 @Override
306 public ControlFeatureDTO getControlFeature() {
307 return delegateObject.getControlFeature();
308 }
309
310
311 @Override
312 public void setControlFeature(ControlFeatureDTO ControlFeature) {
313 delegateObject.setControlFeature(ControlFeature);
314 }
315
316
317 @Override
318 public boolean isActive() {
319 return delegateObject.isActive();
320 }
321
322
323 @Override
324 public void setActive(boolean Active) {
325 delegateObject.setActive(Active);
326 }
327
328
329 @Override
330 public boolean isBlocking() {
331 return delegateObject.isBlocking();
332 }
333
334
335 @Override
336 public void setBlocking(boolean Blocking) {
337 delegateObject.setBlocking(Blocking);
338 }
339
340
341 @Override
342 public Object getMin() {
343 return delegateObject.getMin();
344 }
345
346
347 @Override
348 public void setMin(Object min) {
349 delegateObject.setMin(min);
350 }
351
352
353 @Override
354 public Object getMax() {
355 return delegateObject.getMax();
356 }
357
358
359 @Override
360 public void setMax(Object max) {
361 delegateObject.setMax(max);
362 }
363
364
365 @Override
366 public String getAllowedValues() {
367 return delegateObject.getAllowedValues();
368 }
369
370
371 @Override
372 public void setAllowedValues(String allowedValues) {
373 delegateObject.setAllowedValues(allowedValues);
374 }
375
376
377 @Override
378 public RulePmfmDTO getRulePmfms(int index) {
379 return delegateObject.getRulePmfms(index);
380 }
381
382
383 @Override
384 public boolean isRulePmfmsEmpty() {
385 return delegateObject.isRulePmfmsEmpty();
386 }
387
388
389 @Override
390 public int sizeRulePmfms() {
391 return delegateObject.sizeRulePmfms();
392 }
393
394
395 @Override
396 public void addRulePmfms(RulePmfmDTO rulePmfm) {
397 delegateObject.addRulePmfms(rulePmfm);
398 }
399
400
401 @Override
402 public void addAllRulePmfms(Collection<RulePmfmDTO> rulePmfms) {
403 delegateObject.addAllRulePmfms(rulePmfms);
404 }
405
406
407 @Override
408 public boolean removeRulePmfms(RulePmfmDTO rulePmfm) {
409 return delegateObject.removeRulePmfms(rulePmfm);
410 }
411
412
413 @Override
414 public boolean removeAllRulePmfms(Collection<RulePmfmDTO> rulePmfms) {
415 return delegateObject.removeAllRulePmfms(rulePmfms);
416 }
417
418
419 @Override
420 public boolean containsRulePmfms(RulePmfmDTO rulePmfm) {
421 return delegateObject.containsRulePmfms(rulePmfm);
422 }
423
424
425 @Override
426 public boolean containsAllRulePmfms(Collection<RulePmfmDTO> rulePmfms) {
427 return delegateObject.containsAllRulePmfms(rulePmfms);
428 }
429
430
431 @Override
432 public Collection<RulePmfmDTO> getRulePmfms() {
433 return delegateObject.getRulePmfms();
434 }
435
436
437 @Override
438 public void setRulePmfms(Collection<RulePmfmDTO> rulePmfms) {
439 delegateObject.setRulePmfms(rulePmfms);
440 }
441
442
443 @Override
444 public String getMessage() {
445 return delegateObject.getMessage();
446 }
447
448
449 @Override
450 public void setMessage(String Message) {
451 delegateObject.setMessage(Message);
452 }
453
454
455 @Override
456 public String getDescription() {
457 return delegateObject.getDescription();
458 }
459
460
461 @Override
462 public void setDescription(String description) {
463 delegateObject.setDescription(description);
464 }
465
466
467 @Override
468 public boolean isNewCode() {
469 return delegateObject.isNewCode();
470 }
471
472
473 @Override
474 public void setNewCode(boolean newCode) {
475 delegateObject.setNewCode(newCode);
476 }
477
478 @Override
479 public String getName() {
480 return delegateObject.getName();
481 }
482
483 @Override
484 public void setName(String name) {
485 delegateObject.setName(name);
486 }
487
488 @Override
489 public boolean isDirty() {
490 return delegateObject.isDirty();
491 }
492
493 @Override
494 public void setDirty(boolean dirty) {
495 delegateObject.setDirty(dirty);
496 }
497
498 @Override
499 public boolean isReadOnly() {
500 return delegateObject.isReadOnly();
501 }
502
503 @Override
504 public void setReadOnly(boolean readOnly) {
505 delegateObject.setReadOnly(readOnly);
506 }
507
508 @Override
509 public StatusDTO getStatus() {
510 return delegateObject.getStatus();
511 }
512
513 @Override
514 public void setStatus(StatusDTO status) {
515 delegateObject.setStatus(status);
516 }
517
518 @Override
519 public Date getCreationDate() {
520 return delegateObject.getCreationDate();
521 }
522
523 @Override
524 public void setCreationDate(Date date) {
525 delegateObject.setCreationDate(date);
526 }
527
528 @Override
529 public Date getUpdateDate() {
530 return delegateObject.getUpdateDate();
531 }
532
533 @Override
534 public void setUpdateDate(Date date) {
535 delegateObject.setUpdateDate(date);
536 }
537
538 }