1 package fr.ifremer.quadrige3.synchro.intercept.system;
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.eventbus.Subscribe;
27 import fr.ifremer.common.synchro.meta.SynchroTableMetadata;
28 import fr.ifremer.common.synchro.meta.event.LoadTableEvent;
29 import fr.ifremer.quadrige3.synchro.intercept.referential.AbstractReferentialInterceptor;
30 import fr.ifremer.quadrige3.synchro.meta.system.TechnicalSynchroTables;
31 import fr.ifremer.quadrige3.synchro.service.SynchroDirection;
32
33 /**
34 * Manage table SYSTEM_VERSION
35 *
36 * @author Benoit Lavenier <benoit.lavenier@e-is.pro>
37 * @since 1.0
38 */
39 public class SystemVersionInterceptor extends AbstractReferentialInterceptor {
40
41 /**
42 * <p>
43 * Constructor for SystemVersionInterceptor.
44 * </p>
45 */
46 public SystemVersionInterceptor() {
47 // Only export SYSTEM_VERSION when creating a file with all referential
48 super(TechnicalSynchroTables.SYSTEM_VERSION.name(),
49 SynchroDirection.EXPORT_LOCAL2FILE);
50 }
51
52 /**
53 * <p>
54 * handleTableLoad.
55 * </p>
56 *
57 * @param e
58 * a {@link fr.ifremer.common.synchro.meta.event.LoadTableEvent} object.
59 */
60 @Subscribe
61 public void handleTableLoad(LoadTableEvent e) {
62
63 SynchroTableMetadata table = e.table;
64
65 // Set isRoot :
66 if (!table.isRoot()) {
67 table.setRoot(true);
68 }
69 }
70
71 /* -- Internal methods -- */
72 }