View Javadoc
1   package fr.ifremer.quadrige3.synchro.meta.data;
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   * Data tables to synchronize
35   * 
36   * @author Benoit Lavenier <benoit.lavenier@e-is.pro>
37   * @since 1.0
38   */
39  public enum DataSynchroTables {
40  
41  	// ignore :
42  	// - ignore (see mantis #23970): OBSERVED_HABITAT
43  
44  	SURVEY,
45  	SURVEY_PROG,
46  	SURVEY_QUSER,
47  
48  	EVENT_SURVEY,
49  
50  	SURVEY_POINT,
51  	SURVEY_LINE,
52  	SURVEY_AREA,
53  
54  	SAMPLING_OPERATION,
55  	SAMPLING_OPER_PROG,
56  	SAMPLING_OPER_AREA,
57  	SAMPLING_OPER_LINE,
58  	SAMPLING_OPER_POINT,
59  
60  	SAMPLE,
61  	SAMPLE_PROG,
62  
63  	FIELD_OBSERVATION,
64  
65  	MEASUREMENT,
66  	PROG_MEAS,
67  
68  	TAXON_MEASUREMENT,
69  	PROG_TAXON_MEAS,
70  
71  	MEASUREMENT_FILE,
72  	PROG_MEAS_FILE,
73  
74  	MEASURED_PROFILE,
75  	MEAS_PROF_PROG,
76  
77  	PHOTO,
78  
79  	QUALIFICATION_HISTORY,
80  	VALIDATION_HISTORY,
81  	DELETED_ITEM_HISTORY;
82  
83  	/** Constant <code>tableNames</code> */
84  	private static Set<String> tableNames = null;
85  
86  	/**
87  	 * <p>
88  	 * tableNames.
89  	 * </p>
90  	 * 
91  	 * @return a {@link java.util.Set} object.
92  	 */
93  	public static Set<String> tableNames() {
94  		if (tableNames != null) {
95  			return tableNames;
96  		}
97  
98  		tableNames = Sets.newLinkedHashSet();
99  		for (DataSynchroTables value : values()) {
100 			tableNames.add(value.name());
101 		}
102 
103 		tableNames = ImmutableSet.copyOf(tableNames);
104 		return tableNames;
105 	}
106 
107 	/**
108 	 * Return the list of table names to import. Will use the configuration is property exists,
109 	 * or the enumeration values
110 	 * 
111 	 * @return a {@link java.util.Set} object.
112 	 */
113 	public static Set<String> getImportTablesIncludes() {
114 
115 		Set<String> tableNames = QuadrigeConfiguration.getInstance().getImportDataTablesIncludes();
116 		if (CollectionUtils.isNotEmpty(tableNames)) {
117 			return tableNames;
118 		}
119 
120 		return tableNames();
121 	}
122 }