1 package fr.ifremer.quadrige2.synchro.service.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 fr.ifremer.common.synchro.service.RejectedRow;
27 import fr.ifremer.common.synchro.service.SynchroContext;
28 import fr.ifremer.common.synchro.service.SynchroResult;
29 import fr.ifremer.quadrige2.synchro.service.SynchroDirection;
30 import org.springframework.transaction.annotation.Propagation;
31 import org.springframework.transaction.annotation.Transactional;
32
33 import java.io.File;
34 import java.sql.Timestamp;
35 import java.util.Map;
36 import java.util.Properties;
37
38 /**
39 * <p>
40 * DataSynchroService interface.
41 * </p>
42 *
43 */
44 @Transactional(propagation = Propagation.SUPPORTS)
45 public interface DataSynchroService {
46
47 /**
48 * Create a synchro context, from a source database directory (HSQLDB only).
49 * This use local connection properties as source properties, but change JDBC URL to use the given directory
50 *
51 * @param sourceDbDirectory
52 * a directory with a HSQLDB directory.
53 * @param userId
54 * Id of the Quadrige2 user
55 * @return a new context for synchronization
56 * @deprecated use method with enableDetele and enableInsertUpdate args
57 * @param direction
58 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
59 */
60 @Deprecated
61 DataSynchroContext createSynchroContext(File sourceDbDirectory, SynchroDirection direction, int userId);
62
63 /**
64 * Same as createSynchroContext, but with a last synchronization date
65 *
66 * @param sourceDbDirectory
67 * a directory with a HSQLDB directory.
68 * @param userId
69 * Id of the Quadrige2 user
70 * @param lastSynchronizationDate
71 * the date of the last synchronization
72 * @return a new context for synchronization
73 * @deprecated use method with enableDetele and enableInsertUpdate args
74 * @param direction
75 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
76 */
77 @Deprecated
78 DataSynchroContext createSynchroContext(File sourceDbDirectory, SynchroDirection direction, int userId, Timestamp lastSynchronizationDate);
79
80 /**
81 * Same as createSynchroContext, but with a last synchronization date
82 *
83 * @param sourceDbDirectory
84 * a directory with a HSQLDB directory.
85 * @param userId
86 * Id of the Quadrige2 user
87 * @param lastSynchronizationDate
88 * the date of the last synchronization
89 * @param enableDelete
90 * need to synchronize deletion ?
91 * @param enableInsertUpdate
92 * need to synchronize insert/update ?
93 * @return a new context for synchronization
94 * @param direction
95 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
96 */
97 DataSynchroContext createSynchroContext(File sourceDbDirectory, SynchroDirection direction, int userId, Timestamp lastSynchronizationDate,
98 boolean enableDelete, boolean enableInsertUpdate);
99
100 /**
101 * Create a synchro context, using configuration properties for target and source properties.
102 *
103 * @param sourceConnectionProperties
104 * Properties to use as source connection (could be Oracle, HSQLDB...)
105 * @param userId
106 * Id of the Quadrige2 user
107 * @return a new context for synchronization
108 * @deprecated use method with lastSynchronizationDate,enableDelete and enableInsertUpdate args
109 * @param direction
110 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
111 */
112 @Deprecated
113 DataSynchroContext createSynchroContext(Properties sourceConnectionProperties, SynchroDirection direction, int userId);
114
115 /**
116 * Same as createSynchroContext, but with a last synchronization date
117 *
118 * @param sourceConnectionProperties
119 * Properties to use as source connection (could be Oracle, HSQLDB...)
120 * @param userId
121 * Id of the Quadrige2 user
122 * @param lastSynchronizationDate
123 * the date of the last synchronization
124 * @return a new context for synchronization
125 * @deprecated use method with lastSynchronizationDate,enableDetele and enableInsertUpdate args
126 * @param direction
127 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
128 */
129 @Deprecated
130 DataSynchroContext createSynchroContext(Properties sourceConnectionProperties, SynchroDirection direction, int userId,
131 Timestamp lastSynchronizationDate);
132
133 /**
134 * Same as createSynchroContext, but with a last synchronization date
135 *
136 * @param sourceConnectionProperties
137 * Properties to use as source connection (could be Oracle, HSQLDB...)
138 * @param userId
139 * Id of the Quadrige2 user
140 * @param lastSynchronizationDate
141 * the date of the last synchronization
142 * @param enableDelete
143 * need to synchronize deletion ?
144 * @param enableInsertUpdate
145 * need to synchronize insert/update ?
146 * @return a new context for synchronization
147 * @param direction
148 * a {@link fr.ifremer.quadrige2.synchro.service.SynchroDirection} object.
149 */
150 DataSynchroContext createSynchroContext(Properties sourceConnectionProperties, SynchroDirection direction, int userId,
151 Timestamp lastSynchronizationDate, boolean enableDelete, boolean enableInsertUpdate);
152
153 /**
154 * Prepare the synchronize operation from the target data database supported
155 * by this service, says just compute nb rows to update for each root table and
156 * update the result model.
157 *
158 * @param context
159 * Context of synchronization
160 */
161 @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
162 void prepare(SynchroContext context);
163
164 /**
165 * Launch the synchronize operation from the target data database supported
166 * by this service.
167 *
168 * @param context
169 * Context of synchronization
170 */
171 @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
172 void synchronize(SynchroContext context);
173
174 /**
175 * <p>
176 * finish.
177 * </p>
178 *
179 * @param synchroContext
180 * a {@link fr.ifremer.common.synchro.service.SynchroContext} object.
181 * @param resultWithPendingOperation
182 * a {@link fr.ifremer.common.synchro.service.SynchroResult} object.
183 * @param rejectStrategies
184 * a {@link java.util.Map} object.
185 */
186 @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
187 void finish(SynchroContext synchroContext, SynchroResult resultWithPendingOperation,
188 Map<RejectedRow.Cause, RejectedRow.ResolveStrategy> rejectStrategies);
189 }