View Javadoc
1   package fr.ifremer.quadrige2.synchro.meta.data;
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   * 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  	// TODO
78  	// PHOTO
79  
80  	QUALIFICATION_HISTORY,
81  	VALIDATION_HISTORY,
82  	DELETED_ITEM_HISTORY;
83  
84  	/** Constant <code>tableNames</code> */
85  	private static Set<String> tableNames = null;
86  
87  	/**
88  	 * <p>
89  	 * tableNames.
90  	 * </p>
91  	 * 
92  	 * @return a {@link java.util.Set} object.
93  	 */
94  	public static Set<String> tableNames() {
95  		if (tableNames != null) {
96  			return tableNames;
97  		}
98  
99  		tableNames = Sets.newLinkedHashSet();
100 		for (DataSynchroTables value : values()) {
101 			tableNames.add(value.name());
102 		}
103 
104 		tableNames = ImmutableSet.copyOf(tableNames);
105 		return tableNames;
106 	}
107 
108 	/**
109 	 * Return the list of table names to import. Will use the configuration is property exists,
110 	 * or the enumeration values
111 	 * 
112 	 * @return a {@link java.util.Set} object.
113 	 */
114 	public static Set<String> getImportTablesIncludes() {
115 
116 		Set<String> tableNames = Quadrige2Configuration.getInstance().getImportDataTablesIncludes();
117 		if (CollectionUtils.isNotEmpty(tableNames)) {
118 			return tableNames;
119 		}
120 
121 		return tableNames();
122 	}
123 }