1 package fr.ifremer.quadrige3.synchro.service.client; 2 3 /*- 4 * #%L 5 * Quadrige3 Core :: Quadrige3 Client 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.SynchroResult; 27 import fr.ifremer.quadrige3.core.ProgressionCoreModel; 28 import fr.ifremer.quadrige3.core.exception.BadUpdateDtException; 29 import fr.ifremer.quadrige3.core.exception.DataLockedException; 30 import fr.ifremer.quadrige3.core.exception.QuadrigeBusinessException; 31 import fr.ifremer.quadrige3.core.exception.QuadrigeTechnicalException; 32 import fr.ifremer.quadrige3.core.security.AuthenticationInfo; 33 import fr.ifremer.quadrige3.core.vo.administration.program.ProgramVO; 34 import fr.ifremer.quadrige3.core.vo.administration.user.QuserVO; 35 import fr.ifremer.quadrige3.core.vo.data.survey.CampaignVO; 36 import fr.ifremer.quadrige3.core.vo.system.generalCondition.GeneralConditionVO; 37 import fr.ifremer.quadrige3.core.vo.system.rule.RuleListVO; 38 import fr.ifremer.quadrige3.synchro.vo.SynchroExportContextVO; 39 import fr.ifremer.quadrige3.synchro.vo.SynchroImportContextVO; 40 import fr.ifremer.quadrige3.synchro.vo.SynchroProgressionVO; 41 import org.springframework.transaction.annotation.Propagation; 42 import org.springframework.transaction.annotation.Transactional; 43 44 import java.io.File; 45 import java.util.Collection; 46 import java.util.Date; 47 import java.util.List; 48 import java.util.Set; 49 50 /** 51 * <p> 52 * SynchroRestClientService interface. 53 * </p> 54 */ 55 @Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED) 56 public interface SynchroRestClientService { 57 58 /** 59 * Return data on the authenticated person 60 * 61 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 62 * @return could be null if network error 63 * @throws QuadrigeTechnicalException if network problem 64 */ 65 QuserVO getUser(AuthenticationInfo authenticationInfo) throws QuadrigeTechnicalException; 66 67 /** 68 * Return user's programs (programs with read access rights) 69 * 70 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 71 * @return could be null if network error 72 * @throws QuadrigeTechnicalException if network problem 73 */ 74 List<ProgramVO> getReadableProgramsForUser(AuthenticationInfo authenticationInfo) throws QuadrigeTechnicalException; 75 76 /** 77 * Return user's programs (programs with read/write access rights) 78 * 79 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 80 * @return could be null if network error 81 * @throws QuadrigeTechnicalException if network problem 82 */ 83 List<ProgramVO> getWritableProgramsForUser(AuthenticationInfo authenticationInfo) throws QuadrigeTechnicalException; 84 85 /** 86 * Return the list of programs configured by the synchro server 87 * 88 * @param authenticationInfo the authentication info 89 * @return the compatible program codes 90 * @throws QuadrigeTechnicalException if network problem 91 */ 92 Set<String> getCompatibleProgramCodes(AuthenticationInfo authenticationInfo) throws QuadrigeTechnicalException; 93 94 /** 95 * Return a remote programs 96 * 97 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 98 * @param progCd program code 99 * @return could be null if network error 100 * @throws QuadrigeTechnicalException if network problem 101 */ 102 ProgramVO getProgramByCode(AuthenticationInfo authenticationInfo, String progCd) throws QuadrigeTechnicalException; 103 104 /** 105 * Check is there is updates on referential data 106 * 107 * @param authenticationInfo User authentication data 108 * @param importContextVO the context to check 109 * @return a new context with updated attributes (<code>withReferential</code> and <code>withData</code>) 110 * @throws QuadrigeTechnicalException if network problem 111 */ 112 SynchroImportContextVO checkImportContext(AuthenticationInfo authenticationInfo, SynchroImportContextVO importContextVO) 113 throws QuadrigeTechnicalException; 114 115 /** 116 * Check is there is updates on data 117 * 118 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 119 * @param importContextVO a {@link fr.ifremer.quadrige3.synchro.vo.SynchroImportContextVO} object. 120 * @return a new context with updated attributes <code>withData</code> 121 * @throws QuadrigeTechnicalException if any. 122 */ 123 SynchroImportContextVO checkImportDataContext(AuthenticationInfo authenticationInfo, 124 SynchroImportContextVO importContextVO) throws QuadrigeTechnicalException; 125 126 /** 127 * Check that the given version is compatible with the synchronization server version. If not, throw a 128 * QuadrigeBusinessException 129 * 130 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 131 * @throws QuadrigeBusinessException if version is not compatible 132 * @throws QuadrigeTechnicalException if network problem 133 */ 134 void checkVersion(AuthenticationInfo authenticationInfo) throws QuadrigeTechnicalException, QuadrigeBusinessException; 135 136 /** 137 * Send an acknowledge to the remote server (e.g. to delete temporary files, ...) 138 * 139 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 140 * @param importContextVO a {@link fr.ifremer.quadrige3.synchro.vo.SynchroImportContextVO} object. 141 * @throws QuadrigeTechnicalException if any. 142 */ 143 void acknowledgeImport(AuthenticationInfo authenticationInfo, SynchroImportContextVO importContextVO) throws QuadrigeTechnicalException; 144 145 /** 146 * Send a file to server 147 * 148 * @param authenticationInfo a {@link AuthenticationInfo} object. 149 * @param fileToUpload a {@link File} object. 150 * @param progressionModel a {@link ProgressionCoreModel} object. 151 * @throws QuadrigeTechnicalException if any. 152 */ 153 void uploadExportFile(AuthenticationInfo authenticationInfo, File fileToUpload, ProgressionCoreModel progressionModel) 154 throws QuadrigeTechnicalException; 155 156 /** 157 * Start a new importation on the server 158 * 159 * @param authenticationInfo a {@link AuthenticationInfo} object. 160 * @param importContextVO a {@link SynchroImportContextVO} object. 161 * @param progressionModel a {@link ProgressionCoreModel} object. 162 * @return a {@link fr.ifremer.quadrige3.synchro.vo.SynchroProgressionVO} object. 163 */ 164 SynchroProgressionVO startImport(AuthenticationInfo authenticationInfo, 165 SynchroImportContextVO importContextVO, 166 ProgressionCoreModel progressionModel); 167 168 /** 169 * Stop a importation running on server 170 * 171 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 172 * @param importJobId a {@link java.lang.String} object. 173 */ 174 void stopImport(AuthenticationInfo authenticationInfo, String importJobId); 175 176 /** 177 * <p> 178 * start export on server, then wait the end. 179 * </p> 180 * 181 * @param authenticationInfo a {@link AuthenticationInfo} object. 182 * @param exportContextVO a {@link SynchroExportContextVO} object. 183 * @param progressionModel a {@link ProgressionCoreModel} object. 184 * @return a {@link fr.ifremer.quadrige3.synchro.vo.SynchroProgressionVO} object. 185 */ 186 SynchroProgressionVO startExport(AuthenticationInfo authenticationInfo, 187 SynchroExportContextVO exportContextVO, 188 ProgressionCoreModel progressionModel) 189 ; 190 191 /** 192 * <p> 193 * Wait end of a started export on server. 194 * </p> 195 * 196 * @param authenticationInfo a {@link AuthenticationInfo} object. 197 * @param exportJobId the job id 198 * @param progressionModel a {@link ProgressionCoreModel} object. 199 * @return a {@link fr.ifremer.quadrige3.synchro.vo.SynchroProgressionVO} object. 200 */ 201 SynchroProgressionVO getExportLastStatus(AuthenticationInfo authenticationInfo, 202 String exportJobId, 203 ProgressionCoreModel progressionModel) throws Exception; 204 205 /** 206 * <p> 207 * downloadExportResult. 208 * </p> 209 * 210 * @param authenticationInfo a {@link AuthenticationInfo} object. 211 * @param context a {@link SynchroExportContextVO} object. 212 * @param progressionModel a {@link ProgressionCoreModel} object. 213 * @return a {@link fr.ifremer.common.synchro.service.SynchroResult} object. 214 * @throws java.lang.Exception if any. 215 */ 216 SynchroResult downloadExportResult(AuthenticationInfo authenticationInfo, 217 SynchroExportContextVO context, 218 ProgressionCoreModel progressionModel) throws Exception; 219 220 /** 221 * Download photo 222 * 223 * @param authenticationInfo authentication info 224 * @param photoRemoteId the photo remote id 225 * @param targetFile the target file 226 * @param progressionModel progression model 227 * @return true if successfully downloaded 228 * @throws Exception if any 229 */ 230 boolean downloadPhoto(AuthenticationInfo authenticationInfo, 231 int photoRemoteId, 232 String targetFile, 233 ProgressionCoreModel progressionModel) throws Exception; 234 235 /** 236 * Stop a exportation running on server 237 * 238 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 239 * @param exportJobId a {@link java.lang.String} object. 240 * @throws java.lang.Exception if any. 241 */ 242 void stopExport(AuthenticationInfo authenticationInfo, String exportJobId); 243 244 /** 245 * <p> 246 * acknowledgeExport. 247 * </p> 248 * 249 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 250 * @param context a {@link fr.ifremer.quadrige3.synchro.vo.SynchroExportContextVO} object. 251 */ 252 void acknowledgeExport(AuthenticationInfo authenticationInfo, SynchroExportContextVO context); 253 254 /** 255 * Save programs remotely 256 * 257 * @param programs a {@link java.util.List} object. 258 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 259 * @return a {@link java.util.List} object. 260 */ 261 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) 262 List<ProgramVO> savePrograms(AuthenticationInfo authenticationInfo, List<ProgramVO> programs); 263 264 /** 265 * Clean referential updateDt cache, on remote server. 266 * This is useful to force importation without waiting cache time duration 267 * 268 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 269 */ 270 void clearReferentialUpdateDateCache(AuthenticationInfo authenticationInfo); 271 272 Date getReferentialUpdateDate(AuthenticationInfo authenticationInfo); 273 274 /** 275 * Save campaign remotely 276 * 277 * @param campaigns a {@link java.util.List} object. 278 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 279 * @return a {@link java.util.List} object. 280 * @throws BadUpdateDtException if any. 281 * @throws fr.ifremer.quadrige3.core.exception.DataLockedException if any. 282 */ 283 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) 284 List<CampaignVO> saveCampaigns(AuthenticationInfo authenticationInfo, Collection<CampaignVO> campaigns); 285 286 /** 287 * Delete campaign remotely 288 * 289 * @param campaignIds a {@link java.util.List} object. 290 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 291 * @throws DataLockedException if any. 292 */ 293 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) 294 void deleteCampaigns(AuthenticationInfo authenticationInfo, Collection<Integer> campaignIds); 295 296 /** 297 * Save rule lists remotely 298 * 299 * @param ruleLists a {@link java.util.List} object. 300 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 301 * @return a {@link java.util.List} object. 302 * @throws BadUpdateDtException if any. 303 * @throws DataLockedException if any. 304 */ 305 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) 306 List<RuleListVO> saveRuleLists(AuthenticationInfo authenticationInfo, Collection<RuleListVO> ruleLists); 307 308 /** 309 * Delete rule lists remotely 310 * 311 * @param ruleListCds a {@link java.util.List} object. 312 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 313 * @throws DataLockedException if any. 314 */ 315 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) 316 void deleteRuleLists(AuthenticationInfo authenticationInfo, Collection<String> ruleListCds); 317 318 /** 319 * Get the rule list by its code 320 * 321 * @param authenticationInfo a {@link fr.ifremer.quadrige3.core.security.AuthenticationInfo} object. 322 * @param ruleListCode the rule list code 323 * @return the existing rule list 324 */ 325 RuleListVO getRuleListByCode(AuthenticationInfo authenticationInfo, String ruleListCode); 326 327 GeneralConditionVO getLastNonAcceptedGeneralCondition(AuthenticationInfo authenticationInfo); 328 329 void acceptGeneralCondition(AuthenticationInfo authenticationInfo, int id); 330 }