1 package fr.ifremer.reefdb.ui.swing.content.observation.shared;
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.ArrayListMultimap;
27 import com.google.common.collect.Multimap;
28 import fr.ifremer.reefdb.dto.configuration.control.ControlRuleDTO;
29 import fr.ifremer.reefdb.dto.configuration.control.PreconditionRuleDTO;
30 import fr.ifremer.reefdb.dto.configuration.control.RuleGroupDTO;
31 import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
32 import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
33 import fr.ifremer.reefdb.dto.referential.TaxonDTO;
34 import fr.ifremer.reefdb.dto.referential.TaxonGroupDTO;
35 import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
36 import fr.ifremer.reefdb.ui.swing.content.observation.ObservationUIHandler;
37 import fr.ifremer.reefdb.ui.swing.content.observation.ObservationUIModel;
38 import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableUIModel;
39 import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
40
41 import java.util.Collection;
42 import java.util.List;
43 import java.util.Map;
44
45
46
47
48 public abstract class AbstractMeasurementsGroupedTableUIModel<
49 B extends MeasurementDTO,
50 R extends AbstractMeasurementsGroupedRowModel<B, R>,
51 M extends AbstractMeasurementsGroupedTableUIModel<B, R, M>>
52 extends AbstractReefDbTableUIModel<B, R, M> {
53
54 public static final String PROPERTY_SURVEY = "survey";
55 public static final String PROPERTY_MEASUREMENT_FILTER = "measurementFilter";
56 public static final String EVENT_INDIVIDUAL_MEASUREMENTS_LOADED = "individualMeasurementsLoaded";
57
58
59 private ObservationUIModel survey;
60 private ObservationUIHandler observationHandler;
61
62 private List<PmfmDTO> uniquePmfms;
63
64 private MeasurementsFilter measurementFilter;
65
66 private Multimap<Integer, PreconditionRuleDTO> preconditionRulesByPmfmIdMap;
67
68 private Multimap<ControlRuleDTO, Map.Entry<RuleGroupDTO, ? extends ReefDbColumnIdentifier<R>>> identifiersByGroupedRuleMap;
69 private boolean adjusting;
70
71
72
73
74
75
76 public ObservationUIModel getSurvey() {
77 return survey;
78 }
79
80
81
82
83
84
85 public void setSurvey(ObservationUIModel survey) {
86 this.survey = survey;
87 firePropertyChange(PROPERTY_SURVEY, null, survey);
88 }
89
90 public ObservationUIHandler getObservationUIHandler() {
91 return observationHandler;
92 }
93
94 public void setObservationHandler(ObservationUIHandler observationHandler) {
95 this.observationHandler = observationHandler;
96 }
97
98
99
100
101
102
103 public List<PmfmDTO> getUniquePmfms() {
104 return uniquePmfms;
105 }
106
107
108
109
110
111
112 public void setUniquePmfms(List<PmfmDTO> uniquePmfms) {
113 this.uniquePmfms = uniquePmfms;
114 }
115
116
117
118
119
120
121 public void setMeasurementFilter(MeasurementsFilter measurementFilter) {
122 this.measurementFilter = measurementFilter;
123 firePropertyChange(PROPERTY_MEASUREMENT_FILTER, null, measurementFilter);
124 }
125
126
127
128
129
130
131 public TaxonGroupDTO getTaxonGroupFilter() {
132 return measurementFilter == null ? null : measurementFilter.getTaxonGroup();
133 }
134
135
136
137
138
139
140 public TaxonDTO getTaxonFilter() {
141 return measurementFilter == null ? null : measurementFilter.getTaxon();
142 }
143
144
145
146
147
148
149 public SamplingOperationDTO getSamplingFilter() {
150 return measurementFilter == null ? null : measurementFilter.getSamplingOperation();
151 }
152
153 public Multimap<Integer, PreconditionRuleDTO> getPreconditionRulesByPmfmIdMap() {
154 if (preconditionRulesByPmfmIdMap == null) preconditionRulesByPmfmIdMap = ArrayListMultimap.create();
155 return preconditionRulesByPmfmIdMap;
156 }
157
158 public void addPreconditionRuleByPmfmId(Integer pmfmId, PreconditionRuleDTO precondition) {
159 getPreconditionRulesByPmfmIdMap().put(pmfmId, precondition);
160 }
161
162 public boolean isPmfmIdHasPreconditions(int pmfmId) {
163 return getPreconditionRulesByPmfmIdMap().containsKey(pmfmId);
164 }
165
166 public Collection<PreconditionRuleDTO> getPreconditionRulesByPmfmId(int pmfmId) {
167 return getPreconditionRulesByPmfmIdMap().get(pmfmId);
168 }
169
170 public Multimap<ControlRuleDTO, Map.Entry<RuleGroupDTO, ? extends ReefDbColumnIdentifier<R>>> getIdentifiersByGroupedRuleMap() {
171 if (identifiersByGroupedRuleMap == null) identifiersByGroupedRuleMap = ArrayListMultimap.create();
172 return identifiersByGroupedRuleMap;
173 }
174
175 public ReefDbColumnIdentifier<R> getIdentifierByGroup(RuleGroupDTO group) {
176 for (Map.Entry<RuleGroupDTO, ? extends ReefDbColumnIdentifier<R>> identifierByGroup : getIdentifiersByGroupedRuleMap().values()) {
177 if (identifierByGroup.getKey().equals(group))
178 return identifierByGroup.getValue();
179 }
180 return null;
181 }
182
183 public boolean isAdjusting() {
184 return adjusting;
185 }
186
187 public void setAdjusting(boolean adjusting) {
188 this.adjusting = adjusting;
189 }
190
191 public void fireMeasurementsLoaded() {
192 firePropertyChange(EVENT_INDIVIDUAL_MEASUREMENTS_LOADED, null, null);
193 }
194 }