1 package fr.ifremer.quadrige3.synchro.meta.referential;
2
3 /*-
4 * #%L
5 * Quadrige3 Core :: Quadrige3 Synchro Core
6 * $Id:$
7 * $HeadURL:$
8 * %%
9 * Copyright (C) 2017 Ifremer
10 * %%
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Affero General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * #L%
24 */
25
26 import com.google.common.collect.ImmutableSet;
27 import com.google.common.collect.Sets;
28 import fr.ifremer.quadrige3.core.config.QuadrigeConfiguration;
29 import org.apache.commons.collections4.CollectionUtils;
30
31 import java.util.Set;
32
33 /**
34 * Referential tables to synchronize.
35 * <p/>
36 * this table list include :
37 * <ul>
38 * <li>Basic referential tables,</li>
39 * <li>Programs and strategies tables,</li>
40 * <li>Campaign and occasion.</li>
41 * </ul>
42 * but exclude :
43 * <ul>
44 * <li>Rule tables</li>
45 * <li>Context and filter tables (except xxx_TYPE tables)</li>
46 * </ul>
47 *
48 * @author Benoit Lavenier <benoit.lavenier@e-is.pro>
49 * @since 1.0
50 */
51 public enum ReferentialSynchroTables {
52
53 // Tables ignored
54 // SEXTANT_LAYER, EXTRACT_SELECTED_GEOMETRY, MAP_PROJECT, EUNIS_EQUIVALENCE, EUNIS_EQUIV_CODE_TYPOLOGY,
55 // EUNIS_TYPOLOGY, EUNIS_VERSION, EXTRACT_FILT_EXTR_FILE_TYPE
56
57 // Rules Tables (national) should not be synchronized (see mantis #25824) - see enum RuleSynchroTables
58 // RULE, RULE_LIST, RULE_PARAMETER, RULE_PMFM,RULE_LIST_CONTROLED_DEP, RULE_LIST_RESP_DEP, RULE_LIST_RESP_QUSER,
59 // RULE_LIST_PROG,
60
61 // Context & Filter tables (national) should not be synchronized - see enum ContextAndFilterSynchroTables
62 // CONTEXT, CONTEXT_DEP, CONTEXT_FILTER, DEFAULT_VALUE, PMFM_CONTEXT_ORDER
63 // FILTER, FILTER_BLOCK, FILTER_CRITERIA, FILTER_CRITERIA_VALUE
64
65 // Moratorium tables - not used in ReefDB
66 // MORATORIUM, MOR_MON_LOC_PROG, MOR_PERIOD, PMFM_MOR, MOR_CAMP, MOR_OCCAS,
67
68 // Metaprogram tables - not used in ReefDB
69 // METAPROGRAMME, PMFM_MET, MON_LOC_MET, MON_LOC_PMFM_MET,
70
71 // Ordered table names by level of hierarchical depth (desc) and grouped by category (when possible)
72 // Basic referential
73 STATUS,
74 DEPARTMENT,
75 POSITIONNING_TYPE,
76 POSITIONNING_SYSTEM,
77 QUSER,
78 UNIT,
79 AGE_GROUP,
80 DREDGING_AREA_TYPE,
81 DREDGING_TARGET_AREA,
82 PLOIDY,
83 PROJECTION_SYSTEM,
84 COORDINATES_TRANSFORMATION,
85 QUALITY_FLAG,
86 BREEDING_STRUCTURE,
87 BREEDING_SYSTEM,
88 BREEDING_PHASE_TYPE,
89 DEPTH_LEVEL,
90 FILTER_TYPE,
91 FILTER_CRITERIA_TYPE,
92 FILTER_OPERATOR_TYPE,
93 SAMPLING_EQUIPMENT,
94 ANALYSIS_INSTRUMENT,
95 // CODE_SIZE,
96 COMPLIANT_OS,
97 DOCUMENT_TYPE,
98 FUNCTION,
99 FUNCTION_PARAMETER,
100 NUMERICAL_PRECISION,
101 // LOCATION,
102 OBSERVATION_TYPOLOGY,
103 // ORIGINAL_BATCH,
104 PHOTO_TYPE,
105 SHIP,
106
107 // Monitoring location
108 HARBOUR,
109 MONITORING_LOCATION,
110 ORDER_ITEM_TYPE,
111 ORDER_ITEM,
112 // ORDER_ITEM_AREA, // not synchronized for the moment
113 MON_LOC_ORDER_ITEM,
114 MON_LOC_POINT,
115 MON_LOC_LINE,
116 MON_LOC_AREA,
117
118 // Taxon & taxon group
119 REFERENCE_TAXON,
120 TAXONOMIC_LEVEL,
121 TAXON_GROUP_TYPE,
122 TAXON_GROUP,
123 CITATION,
124 TAXON_NAME,
125 TAXON_NAME_HISTORY,
126 TAXON_GROUP_HISTORICAL_RECORD,
127 TAXON_GROUP_INFORMATION,
128 RESOURCE_TYPE,
129 TAXON_GROUP_POSITION,
130 TAXON_INFORMATION,
131 TAXON_INFORMATION_HISTORY,
132 TAXON_POSITION,
133 // ALTERNATIVE_TAXON_ORIGIN,
134 // ALTERNATIVE_TAXON,
135 VIRTUAL_COMPONENT,
136 REFERENCE_DOCUMENT,
137 AUTHOR,
138 AUTHOR_REF_DOC,
139
140 // PMFM
141 FRACTION,
142 MATRIX,
143 FRACTION_MATRIX, // Should be after FRACTION and MATRIX
144 METHOD,
145 PARAMETER_GROUP,
146 PARAMETER,
147 // COMPUTE_FUNCTION,
148 // COMPUTE_FUNCTION_PROG,
149 // DEPENDANT_PARAMETER,
150 QUALITATIVE_VALUE, // Mantis #0029631: QUALITATIVE_VALUE moved before PMFM because of PMFM_QUAL_VALUE is a child of
151 // PMFM and is evaluate before
152 PMFM, // Should be after PARAMETER, FRACTION, MATRIX, METHOD and UNIT (to be able to replace FK, during importation
153 // from file - mantis #26721)
154 PMFM_QUAL_VALUE,
155
156 // Program & Strategy ...
157 PROGRAMME,
158 MON_LOC_PROG,
159 STRATEGY,
160 FREQUENCY,
161 APPLIED_STRATEGY,
162 APPLIED_PERIOD,
163 PRECISION_TYPE,
164 PMFM_STRATEGY,
165 PMFM_STRAT_PMFM_QUAL_VALUE,
166 PMFM_APPLIED_STRATEGY,
167 ACQUISITION_LEVEL,
168 PMFM_STRAT_ACQUIS_LEVEL,
169 UI_FUNCTION,
170 PMFM_STRAT_UI_FUNCTION,
171 RESP_QUSER_STRAT, // need to allow deletion import (mantis #28389)
172 RESP_DEP_STRAT, // need to allow deletion import (mantis #28389)
173
174 /* privileges */
175 PRIVILEGE,
176 PRIVILEGE_TRANSFER,
177 QUSER_PRIVILEGE,
178 DEPARTMENT_PRIVILEGE,
179 PROGRAMME_PRIVILEGE,
180 PROG_DEP_PROG_PRIV,
181 PROG_QUSER_PROG_PRIV,
182
183 // MORATORIUM
184 MORATORIUM,
185 MOR_MON_LOC_PROG,
186 MOR_PERIOD,
187 PMFM_MOR,
188 MOR_CAMP,
189 MOR_OCCAS,
190
191 /* CAMPAIGN */
192 CAMPAIGN,
193 CAMPAIGN_PROG,
194 CAMPAIGN_AREA,
195 CAMPAIGN_LINE,
196 CAMPAIGN_POINT,
197
198 /* OCCASION */
199 OCCASION,
200 OCCAS_QUSER,
201 OCCAS_AREA,
202 OCCAS_LINE,
203 OCCAS_POINT,
204
205 /* EVENT */
206 EVENT_TYPE,
207 EVENT,
208 EVENT_AREA,
209 EVENT_LINE,
210 EVENT_POINT,
211
212 /* TRANSCRIBING */
213 OBJECT_TYPE,
214 TRANSCRIBING_SIDE,
215 TRANSCRIBING_ITEM_TYPE,
216 TRANSCRIBING_ITEM,
217
218 /* HISTORY */
219 DELETED_ITEM_HISTORY,
220 UPDATED_ITEM_HISTORY,
221
222 /* EXTRACTION */
223 EXTRACT_TABLE_TYPE,
224 EXTRACT_FILE_TYPE,
225 EXTRACT_GROUP_TYPE_PMFM;
226
227 /** Constant <code>tableNames</code> */
228 private static Set<String> tableNames = null;
229
230 /**
231 * <p>
232 * tableNames.
233 * </p>
234 *
235 * @return a {@link java.util.Set} object.
236 */
237 public static Set<String> tableNames() {
238 if (tableNames != null) {
239 return tableNames;
240 }
241
242 tableNames = Sets.newLinkedHashSet();
243 for (ReferentialSynchroTables value : values()) {
244 tableNames.add(value.name());
245 }
246
247 tableNames = ImmutableSet.copyOf(tableNames);
248 return tableNames;
249 }
250
251 /**
252 * Return the list of table names to import. Will use the configuration, or if empty the default list
253 * defined in enumeration ReferentialSynchroTables.
254 *
255 * @return a {@link java.util.Set} object.
256 */
257 public static Set<String> getImportTablesIncludes() {
258 Set<String> tableNames = QuadrigeConfiguration.getInstance().getImportReferentialTablesIncludes();
259 if (CollectionUtils.isNotEmpty(tableNames)) {
260 return tableNames;
261 }
262
263 return tableNames();
264 }
265
266 }