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