View Javadoc
1   package fr.ifremer.quadrige2.synchro.meta.referential;
2   
3   /*-
4    * #%L
5    * Quadrige2 Core :: Quadrige2 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.quadrige2.core.config.Quadrige2Configuration;
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 	MON_LOC_ORDER_ITEM,
113 	MON_LOC_POINT,
114 	MON_LOC_LINE,
115 	MON_LOC_AREA,
116 
117 	// Taxon & taxon group
118 	REFERENCE_TAXON,
119 	TAXONOMIC_LEVEL,
120 	TAXON_GROUP_TYPE,
121 	TAXON_GROUP,
122 	CITATION,
123 	TAXON_NAME,
124 	TAXON_NAME_HISTORY,
125 	TAXON_GROUP_HISTORICAL_RECORD,
126 	TAXON_GROUP_INFORMATION,
127 	RESOURCE_TYPE,
128 	TAXON_GROUP_POSITION,
129 	TAXON_INFORMATION,
130 	TAXON_INFORMATION_HISTORY,
131 	TAXON_POSITION,
132 	ALTERNATIVE_TAXON_ORIGIN,
133 	ALTERNATIVE_TAXON,
134 	VIRTUAL_COMPONENT,
135 	REFERENCE_DOCUMENT,
136 	AUTHOR,
137 	AUTHOR_REF_DOC,
138 
139 	// PMFM
140 	FRACTION,
141 	MATRIX,
142 	FRACTION_MATRIX, // Should be after FRACTION and MATRIX
143 	METHOD,
144 	PARAMETER_GROUP,
145 	PARAMETER,
146 	COMPUTE_FUNCTION,
147 	COMPUTE_FUNCTION_PROG,
148 	DEPENDANT_PARAMETER,
149 	QUALITATIVE_VALUE, // Mantis #0029631: QUALITATIVE_VALUE moved before PMFM because of PMFM_QUAL_VALUE is a child of
150 						// PMFM and is evaluate before
151 	PMFM, // Should be after PARAMETER, FRACTION, MATRIX, METHOD and UNIT (to be able to replace FK, during importation
152 			// from file - mantis #26721)
153 	PMFM_QUAL_VALUE,
154 
155 	// Program & Strategy ...
156 	PROGRAMME,
157 	MON_LOC_PROG,
158 	STRATEGY,
159 	FREQUENCY,
160 	APPLIED_STRATEGY,
161 	APPLIED_PERIOD,
162 	PRECISION_TYPE,
163 	PMFM_STRATEGY,
164 	PMFM_APPLIED_STRATEGY,
165 	ACQUISITION_LEVEL,
166 	PMFM_STRAT_ACQUIS_LEVEL,
167 	UI_FUNCTION,
168 	PMFM_STRAT_UI_FUNCTION,
169 	RESP_QUSER_STRAT, // need to allow deletion import (mantis #28389)
170 	RESP_DEP_STRAT, // need to allow deletion import (mantis #28389)
171 
172 	/* privileges */
173 	PRIVILEGE,
174 	PRIVILEGE_TRANSFER,
175 	QUSER_PRIVILEGE,
176 	DEPARTMENT_PRIVILEGE,
177 	PROGRAMME_PRIVILEGE,
178 	PROG_DEP_PROG_PRIV,
179 	PROG_QUSER_PROG_PRIV,
180 
181 	/* CAMPAIGN */
182 	CAMPAIGN,
183 	CAMPAIGN_PROG,
184 	CAMPAIGN_AREA,
185 	CAMPAIGN_LINE,
186 	CAMPAIGN_POINT,
187 
188 	/* OCCASION */
189 	OCCASION,
190 	OCCAS_QUSER,
191 	OCCAS_AREA,
192 	OCCAS_LINE,
193 	OCCAS_POINT,
194 
195 	/* EVENT */
196 	EVENT_TYPE,
197 	EVENT,
198 	EVENT_AREA,
199 	EVENT_LINE,
200 	EVENT_POINT,
201 
202 	/* TRANSCRIBING */
203 	OBJECT_TYPE,
204 	TRANSCRIBING_SIDE,
205 	TRANSCRIBING_ITEM_TYPE,
206 	TRANSCRIBING_ITEM,
207 
208 	/* HISTORY */
209 	DELETED_ITEM_HISTORY,
210 
211 	/* EXTRACTION */
212 	EXTRACT_TABLE_TYPE,
213 	EXTRACT_FILE_TYPE,
214 	EXTRACT_GROUP_TYPE_PMFM;
215 
216 	/** Constant <code>tableNames</code> */
217 	private static Set<String> tableNames = null;
218 
219 	/**
220 	 * <p>
221 	 * tableNames.
222 	 * </p>
223 	 * 
224 	 * @return a {@link java.util.Set} object.
225 	 */
226 	public static Set<String> tableNames() {
227 		if (tableNames != null) {
228 			return tableNames;
229 		}
230 
231 		tableNames = Sets.newLinkedHashSet();
232 		for (ReferentialSynchroTables value : values()) {
233 			tableNames.add(value.name());
234 		}
235 
236 		tableNames = ImmutableSet.copyOf(tableNames);
237 		return tableNames;
238 	}
239 
240 	/**
241 	 * Return the list of table names to import. Will use the configuration, or if empty the default list
242 	 * defined in enumeration ReferentialSynchroTables.
243 	 * 
244 	 * @return a {@link java.util.Set} object.
245 	 */
246 	public static Set<String> getImportTablesIncludes() {
247 		Set<String> tableNames = Quadrige2Configuration.getInstance().getImportReferentialTablesIncludes();
248 		if (CollectionUtils.isNotEmpty(tableNames)) {
249 			return tableNames;
250 		}
251 
252 		return tableNames();
253 	}
254 
255 }