1 package net.sumaris.importation.service; 2 3 /*- 4 * #%L 5 * SUMARiS:: Core Importation 6 * %% 7 * Copyright (C) 2018 - 2019 SUMARiS Consortium 8 * %% 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation, either version 3 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public 20 * License along with this program. If not, see 21 * <http://www.gnu.org/licenses/gpl-3.0.html>. 22 * #L% 23 */ 24 25 import net.sumaris.core.dao.technical.schema.DatabaseTableEnum; 26 import net.sumaris.importation.exception.FileValidationException; 27 import org.springframework.transaction.annotation.Transactional; 28 29 import java.io.File; 30 import java.io.IOException; 31 32 @Transactional 33 public interface DataLoaderService { 34 35 /** 36 * Validate file format 37 * @param inputFile 38 * @param fileType 39 * @return 40 * @throws IOException 41 */ 42 void remove(DatabaseTableEnum table, String[] filteredColumns, Object[] filteredValues) throws IOException; 43 44 /** 45 * Validate file format 46 * @param inputFile 47 * @param fileType 48 * @return 49 * @throws IOException 50 */ 51 @Transactional(readOnly = true) 52 void validate(File inputFile, DatabaseTableEnum table) throws IOException, FileValidationException; 53 54 /** 55 * Import a file into the database 56 * 57 * @param table the table to fill 58 * @param country the country data to import (null=all countries) 59 * @param validate Should apply a validation before importation ? 60 * @param appendData Should append data, or remove previous before (using the country) ? 61 * @return 62 * @throws IOException 63 */ 64 void load(File inputFile, DatabaseTableEnum table, boolean validate) throws IOException, 65 FileValidationException; 66 67 }