r827 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/entities echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb echobase-domain/src/main/resources/META-INF/services echobase-domain/src/main/resources/i18n echobase-domain/src/main/xmi echobase-services echobase-services/src/main/java/fr/ifremer/echobase/services/importdata echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/csv echobase-services/src/main/java/fr/ifremer/echo
Author: tchemit Date: 2013-08-01 10:24:28 +0200 (Thu, 01 Aug 2013) New Revision: 827 Url: http://forge.codelutin.com/projects/echobase/repository/revisions/827 Log: fixes #3029: Import de cartes avec param?\195?\168tres non rattach?\195?\169s ?\195?\160 une esp?\195?\168ce de poissons (physique...) refs #3028: Permettre l'import s?\195?\169par?\195?\169 des voyages, transits, transects (ajout fichier validation) Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapFishRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapOtherRemoveDataStrategy.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportServiceIT.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportServiceIT.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveFishDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveOtherDataServiceTest.java trunk/echobase-services/src/test/resources/import-data/result/map/mapsFish.csv.gz trunk/echobase-services/src/test/resources/import-data/result/map/mapsOther.csv.gz trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeTransit-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeVoyage-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapFish-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapOther-validation.xml Removed: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java trunk/echobase-services/src/test/resources/import-data/result/map/maps.csv.gz trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMap-validation.xml Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties trunk/echobase-domain/src/main/xmi/echobase-internal.properties trunk/echobase-domain/src/main/xmi/echobase.properties trunk/echobase-domain/src/main/xmi/echobase.zargo trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/csv/MapCellImportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransitRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonVoyageRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransitRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonVoyageRemoveDataServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java trunk/echobase-services/update-import-data-db.sh trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport.java trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2013-08-01 08:24:28 UTC (rev 827) @@ -79,20 +79,24 @@ RESULT_REGION(n_("echobase.common.importType.resultsRegion"), n_("echobase.common.importType.resultsRegion.short")), - /** Import cells Map. */ - RESULT_MAP(n_("echobase.common.importType.resultsMap"), - n_("echobase.common.importType.resultsMap.short")); + /** Import cells Map Fish. */ + RESULT_MAP_FISH(n_("echobase.common.importType.resultsMapFish"), + n_("echobase.common.importType.resultsMapFish.short")), + /** Import cells Map Other. */ + RESULT_MAP_OTHER(n_("echobase.common.importType.resultsMapOther"), + n_("echobase.common.importType.resultsMapOther.short")); + /** * All common import types. * * @since 1.2 */ protected static final ImportType[] COMMON_IMPORT_TYPES = new ImportType[]{ - ImportType.COMMON_ALL, - ImportType.COMMON_VOYAGE, - ImportType.COMMON_TRANSIT, - ImportType.COMMON_TRANSECT}; + COMMON_ALL, + COMMON_VOYAGE, + COMMON_TRANSIT, + COMMON_TRANSECT}; /** * All result import types. @@ -100,10 +104,11 @@ * @since 1.2 */ protected static final ImportType[] RESULT_IMPORT_TYPES = new ImportType[]{ - ImportType.RESULT_VOYAGE, - ImportType.RESULT_ESDU, - ImportType.RESULT_REGION, - ImportType.RESULT_MAP}; + RESULT_VOYAGE, + RESULT_ESDU, + RESULT_REGION, + RESULT_MAP_FISH, + RESULT_MAP_OTHER}; private final String i18nKey; Added: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java (rev 0) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,59 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.util.Version; + +import java.util.List; + +/** + * Migrate workgin db to version {@code 2.2}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class MigrationCallBackForVersion2_2 extends MigrationCallBackForVersion { + @Override + public Version getVersion() { + return new Version("2.2"); + } + + @Override + protected void prepareMigrationScript(TopiaContextImplementor tx, + List<String> queries, + boolean showSql, + boolean showProgression) throws TopiaException { + + // remove result category NotNull Constrainst (http://forge.codelutin.com/issues/3029) + removeResultCategoryNotNullConstrainst(queries); + + } + + protected void removeResultCategoryNotNullConstrainst(List<String> queries) { + queries.add("ALTER TABLE Result ALTER COLUMN category DROP NOT NULL;"); + } + +} \ No newline at end of file Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion =================================================================== --- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1 @@ +fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_2 \ No newline at end of file Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties =================================================================== --- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -18,6 +18,10 @@ echobase.common.importType.resultsEsdu.short=R ESDU echobase.common.importType.resultsMap=Import the “map” cells results echobase.common.importType.resultsMap.short=Map +echobase.common.importType.resultsMapFish= +echobase.common.importType.resultsMapFish.short= +echobase.common.importType.resultsMapOther= +echobase.common.importType.resultsMapOther.short= echobase.common.importType.resultsRegion=Import the “region” cells results echobase.common.importType.resultsRegion.short=Region echobase.common.importType.resultsVoyage=Import the voyage-related results Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties =================================================================== --- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -16,8 +16,10 @@ echobase.common.importType.operation.short=Opérations echobase.common.importType.resultsEsdu=Import des résultats des cellules de type "ESDU" echobase.common.importType.resultsEsdu.short=R ESDU -echobase.common.importType.resultsMap=Import des cellules de type Carte -echobase.common.importType.resultsMap.short=Carte +echobase.common.importType.resultsMapFish=Import des cellules de type Carte (Poisson) +echobase.common.importType.resultsMapFish.short=Carte (Poisson) +echobase.common.importType.resultsMapOther=Import des cellules de type Carte (Autres) +echobase.common.importType.resultsMapOther.short=Carte (Autres) echobase.common.importType.resultsRegion=Import des cellules de type Région echobase.common.importType.resultsRegion.short=Région echobase.common.importType.resultsVoyage=Import des résultats du voyage Modified: trunk/echobase-domain/src/main/xmi/echobase-internal.properties =================================================================== --- trunk/echobase-domain/src/main/xmi/echobase-internal.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/xmi/echobase-internal.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -71,6 +71,5 @@ fr.ifremer.echobase.entities.ExportQuery.attribute.lastModifiedUser.tagValue.notNull=true fr.ifremer.echobase.entities.WorkingDbConfiguration.attribute.url.tagValue.notNull=true -fr.ifremer.echobase.entities.WorkingDbConfiguration.attribute.login.tagValue.notNull=true fr.ifremer.echobase.entities.WorkingDbConfiguration.attribute.description.tagValue.notNull=true fr.ifremer.echobase.entities.WorkingDbConfiguration.attribute.driverType.tagValue.notNull=true Modified: trunk/echobase-domain/src/main/xmi/echobase.properties =================================================================== --- trunk/echobase-domain/src/main/xmi/echobase.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-domain/src/main/xmi/echobase.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -25,7 +25,7 @@ model.tagValue.generateOperatorForDAOHelper=true model.tagValue.generateStandaloneEnumForDAOHelper=true model.tagValue.constantPrefix=PROPERTY_ -model.tagValue.version=1.3 +model.tagValue.version=2.2 model.tagValue.noPCS=true model.tagValue.doNotGenerateBooleanGetMethods=true model.tagValue.indexForeignKeys=true @@ -319,7 +319,6 @@ fr.ifremer.echobase.entities.data.OperationMetadataValue.attribute.operationMetadata.tagValue.notNull=true fr.ifremer.echobase.entities.data.OperationMetadataValue.attribute.dataValue.tagValue.notNull=true -fr.ifremer.echobase.entities.data.Result.attribute.category.tagValue.notNull=true fr.ifremer.echobase.entities.data.Result.attribute.dataMetadata.tagValue.notNull=true fr.ifremer.echobase.entities.data.Result.attribute.resultLabel.tagValue.notNull=true fr.ifremer.echobase.entities.data.Result.attribute.resultValue.tagValue.notNull=true Modified: trunk/echobase-domain/src/main/xmi/echobase.zargo =================================================================== (Binary files differ) Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -212,7 +212,7 @@ header); EsduResultByEchotypeImportModel csvModel = new EsduResultByEchotypeImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, echotypeMap, voyage, @@ -292,7 +292,7 @@ ResultDAO dao = getDAO(Result.class, ResultDAO.class); EsduResultByEchotypeAndSpeciesCategoryImportModel csvModel = new EsduResultByEchotypeAndSpeciesCategoryImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, echotypeMap, speciesMap, @@ -373,7 +373,7 @@ ResultDAO dao = getDAO(Result.class, ResultDAO.class); EsduResultBySpeciesAndSizeCategoryImportModel csvModel = new EsduResultBySpeciesAndSizeCategoryImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, speciesMap, voyage, @@ -476,7 +476,7 @@ ResultDAO dao = getDAO(Result.class, ResultDAO.class); EsduResultBySpeciesAndAgeCategoryImportModel csvModel = new EsduResultBySpeciesAndAgeCategoryImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, speciesMap, voyage, Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -69,10 +69,15 @@ service = getService(ResultsRegionCellImportService.class); break; - case RESULT_MAP: + case RESULT_MAP_FISH: - service = getService(ResultsMapCellImportService.class); + service = getService(ResultsMapFishCellImportService.class); break; + + case RESULT_MAP_OTHER: + + service = getService(ResultsMapOtherCellImportService.class); + break; default: throw new EchoBaseTechnicalException( "Can not treate import result of type " + importMode); Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -1,271 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services.importdata; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; -import fr.ifremer.echobase.EchoBaseFunctions; -import fr.ifremer.echobase.entities.EchoBaseEntityEnum; -import fr.ifremer.echobase.entities.EchoBaseUser; -import fr.ifremer.echobase.entities.data.Category; -import fr.ifremer.echobase.entities.data.CategoryDAO; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.CellDAO; -import fr.ifremer.echobase.entities.data.Data; -import fr.ifremer.echobase.entities.data.DataDAO; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.entities.data.ResultDAO; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.AgeCategory; -import fr.ifremer.echobase.entities.references.CellType; -import fr.ifremer.echobase.entities.references.DataMetadata; -import fr.ifremer.echobase.entities.references.DataQuality; -import fr.ifremer.echobase.entities.references.SizeCategory; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.entities.references.SpeciesCategory; -import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO; -import fr.ifremer.echobase.io.InputFile; -import fr.ifremer.echobase.services.importdata.csv.MapCellImportModel; -import fr.ifremer.echobase.services.importdata.csv.MapCellImportRow; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.csv.Import; -import org.nuiton.csv.ImportRuntimeException; -import org.nuiton.csv.ext.CsvReaders; - -import java.io.Reader; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * To import map results attached to a voyage. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class ResultsMapCellImportService extends AbstractImportDataService<ResultsImportConfiguration> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ResultsMapCellImportService.class); - - @Override - public void startImport( - ResultsImportConfiguration configuration, - EchoBaseUser user) throws ImportException { - - // get selected voyage - Voyage voyage = getEntityById(Voyage.class, - configuration.getVoyageId()); - - EchoBaseCsvFileImportResult importResult; - importResult = importMapFile(configuration, voyage); - configuration.addResult(importResult); - } - - protected EchoBaseCsvFileImportResult importMapFile( - ResultsImportConfiguration configuration, - Voyage voyage) throws ImportException { - - InputFile inputFile = configuration.getMapsFile(); - - if (log.isInfoEnabled()) { - log.info("Starts import of Map cells from file " + - inputFile.getFileName()); - } - - String resultLabel = configuration.getResultLabel(); - - CellType cellType = getEntityByProperty( - CellType.class, CellType.PROPERTY_ID, "Map"); - Preconditions.checkNotNull(cellType); - - DataMetadata dataLongitudeMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLongitude"); - Preconditions.checkNotNull(dataLongitudeMeta); - - DataMetadata dataLatitudeMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLatitude"); - Preconditions.checkNotNull(dataLatitudeMeta); - - DataMetadata dataDepthMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellDepth"); - Preconditions.checkNotNull(dataDepthMeta); - - DataMetadata dataLongitudeLagMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLongitudeLag"); - Preconditions.checkNotNull(dataLongitudeLagMeta); - - DataMetadata dataLatitudeLagMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLatitudeLag"); - Preconditions.checkNotNull(dataLatitudeLagMeta); - - DataMetadata dataDepthLagMeta = getEntityByProperty( - DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridDepthLag"); - Preconditions.checkNotNull(dataDepthLagMeta); - - // authorize only the selected voyage to be imported - Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList( - voyage), EchoBaseFunctions.VOYAGE_NAME); - - Map<String, Species> speciesMap = getEntitiesMap( - Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE); - - Map<String, SizeCategory> sizeCategoryMap = Maps.newTreeMap(); - sizeCategoryMap.putAll(getEntitiesMap( - SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME)); - - Map<String, AgeCategory> ageCategoryMap = Maps.newTreeMap(); - ageCategoryMap.putAll(getEntitiesMap( - AgeCategory.class, EchoBaseFunctions.AGE_CATEGORY_NAME)); - - Map<String, DataMetadata> dataMetadataMap = getEntitiesMap( - DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME); - - Map<String, DataQuality> dataQualityMap = getEntitiesMap( - DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME); - - // first get header of file to detect which results to import - String[] header = CsvReaders.getHeader(inputFile.getFile(), - getCsvSeparator()); - - List<DataMetadata> metas = getMetas( - MapCellImportModel.COLUMN_NAMES_TO_EXCLUDE, - dataMetadataMap, - header); - - MapCellImportModel csvModel = new MapCellImportModel( - serviceContext.getConfiguration().getCsvSeparator(), - cellType, - voyageMap, - speciesMap, - sizeCategoryMap, - ageCategoryMap, - metas, - dataQualityMap); - - EchoBaseCsvFileImportResult importResult = newImportResult(inputFile); - - CellDAO dao = getDAO(Cell.class, CellDAO.class); - DataDAO dataDao = getDAO(Data.class, DataDAO.class); - ResultDAO resultDao = getDAO(Result.class, ResultDAO.class); - SpeciesCategoryDAO speciesCategoryDAO = - getDAO(SpeciesCategory.class, SpeciesCategoryDAO.class); - CategoryDAO categoryDAO = getDAO(Category.class, CategoryDAO.class); - - Reader reader = getInputFileReader(inputFile); - try { - Import<MapCellImportRow> importer = - Import.newImport(csvModel, reader); - - configuration.incrementsProgress(); - - int rowNumber = 0; - for (MapCellImportRow row : importer) { - - doFlushTransaction(++rowNumber, inputFile, configuration); - - Cell cell = create(dao, row.getCell()); - voyage.addPostCell(cell); - - // collect ids - importResult.addId(EchoBaseEntityEnum.Cell, cell); - - DataQuality dataQuality = row.getDataQuality(); - - // add gridCellLongitude data - createCellData(dataDao, - cell, - dataLongitudeMeta, - String.valueOf(row.getGridCellLongitude()), - dataQuality, - importResult - ); - - // add gridCellLatitude data - createCellData(dataDao, - cell, - dataLatitudeMeta, - String.valueOf(row.getGridCellLatitude()), - dataQuality, - importResult - ); - - // add gridCellDepth data - createCellData(dataDao, - cell, - dataDepthMeta, - String.valueOf(row.getGridCellDepth()), - dataQuality, - importResult - ); - - // add gridLongitudeLag data - createCellData(dataDao, - cell, - dataLongitudeLagMeta, - String.valueOf(row.getGridLongitudeLag()), - dataQuality, - importResult - ); - - // add gridLatitudeLag data - createCellData(dataDao, - cell, - dataLatitudeLagMeta, - String.valueOf(row.getGridLatitudeLag()), - dataQuality, - importResult - ); - - // add gridDepthLag data - createCellData(dataDao, - cell, - dataDepthLagMeta, - String.valueOf(row.getGridDepthLag()), - dataQuality, - importResult - ); - - Category category = getResultCategory(categoryDAO, - speciesCategoryDAO, - null, - row.getSpecies(), - row.getSizeCategory(), - row.getAgeCategory(), - importResult); - - addResults(row, cell, category, resultLabel, resultDao, importResult, false); - } - - return importResult; - } catch (ImportRuntimeException e) { - throw new ImportException(getLocale(), inputFile, e); - } finally { - closeReader(reader, inputFile); - } - } - -} Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportService.java (from rev 824, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java) =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportService.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,271 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.importdata; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; +import fr.ifremer.echobase.EchoBaseFunctions; +import fr.ifremer.echobase.entities.EchoBaseEntityEnum; +import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.data.Category; +import fr.ifremer.echobase.entities.data.CategoryDAO; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.CellDAO; +import fr.ifremer.echobase.entities.data.Data; +import fr.ifremer.echobase.entities.data.DataDAO; +import fr.ifremer.echobase.entities.data.Result; +import fr.ifremer.echobase.entities.data.ResultDAO; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.references.AgeCategory; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.DataMetadata; +import fr.ifremer.echobase.entities.references.DataQuality; +import fr.ifremer.echobase.entities.references.SizeCategory; +import fr.ifremer.echobase.entities.references.Species; +import fr.ifremer.echobase.entities.references.SpeciesCategory; +import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO; +import fr.ifremer.echobase.io.InputFile; +import fr.ifremer.echobase.services.importdata.csv.MapCellImportModel; +import fr.ifremer.echobase.services.importdata.csv.MapCellImportRow; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.csv.Import; +import org.nuiton.csv.ImportRuntimeException; +import org.nuiton.csv.ext.CsvReaders; + +import java.io.Reader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * To import map fish results attached to a voyage. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class ResultsMapFishCellImportService extends AbstractImportDataService<ResultsImportConfiguration> { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(ResultsMapFishCellImportService.class); + + @Override + public void startImport( + ResultsImportConfiguration configuration, + EchoBaseUser user) throws ImportException { + + // get selected voyage + Voyage voyage = getEntityById(Voyage.class, + configuration.getVoyageId()); + + EchoBaseCsvFileImportResult importResult; + importResult = importMapFile(configuration, voyage); + configuration.addResult(importResult); + } + + protected EchoBaseCsvFileImportResult importMapFile( + ResultsImportConfiguration configuration, + Voyage voyage) throws ImportException { + + InputFile inputFile = configuration.getMapsFile(); + + if (log.isInfoEnabled()) { + log.info("Starts import of Map cells from file " + + inputFile.getFileName()); + } + + String resultLabel = configuration.getResultLabel(); + + CellType cellType = getEntityByProperty( + CellType.class, CellType.PROPERTY_ID, "Map"); + Preconditions.checkNotNull(cellType); + + DataMetadata dataLongitudeMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLongitude"); + Preconditions.checkNotNull(dataLongitudeMeta); + + DataMetadata dataLatitudeMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLatitude"); + Preconditions.checkNotNull(dataLatitudeMeta); + + DataMetadata dataDepthMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellDepth"); + Preconditions.checkNotNull(dataDepthMeta); + + DataMetadata dataLongitudeLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLongitudeLag"); + Preconditions.checkNotNull(dataLongitudeLagMeta); + + DataMetadata dataLatitudeLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLatitudeLag"); + Preconditions.checkNotNull(dataLatitudeLagMeta); + + DataMetadata dataDepthLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridDepthLag"); + Preconditions.checkNotNull(dataDepthLagMeta); + + // authorize only the selected voyage to be imported + Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList( + voyage), EchoBaseFunctions.VOYAGE_NAME); + + Map<String, Species> speciesMap = getEntitiesMap( + Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE); + + Map<String, SizeCategory> sizeCategoryMap = Maps.newTreeMap(); + sizeCategoryMap.putAll(getEntitiesMap( + SizeCategory.class, EchoBaseFunctions.SIZE_CATEGORY_NAME)); + + Map<String, AgeCategory> ageCategoryMap = Maps.newTreeMap(); + ageCategoryMap.putAll(getEntitiesMap( + AgeCategory.class, EchoBaseFunctions.AGE_CATEGORY_NAME)); + + Map<String, DataMetadata> dataMetadataMap = getEntitiesMap( + DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME); + + Map<String, DataQuality> dataQualityMap = getEntitiesMap( + DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME); + + // first get header of file to detect which results to import + String[] header = CsvReaders.getHeader(inputFile.getFile(), + getCsvSeparator()); + + List<DataMetadata> metas = getMetas( + MapCellImportModel.COLUMN_NAMES_TO_EXCLUDE, + dataMetadataMap, + header); + + MapCellImportModel csvModel = new MapCellImportModel( + getCsvSeparator(), + cellType, + voyageMap, + speciesMap, + sizeCategoryMap, + ageCategoryMap, + metas, + dataQualityMap); + + EchoBaseCsvFileImportResult importResult = newImportResult(inputFile); + + CellDAO dao = getDAO(Cell.class, CellDAO.class); + DataDAO dataDao = getDAO(Data.class, DataDAO.class); + ResultDAO resultDao = getDAO(Result.class, ResultDAO.class); + SpeciesCategoryDAO speciesCategoryDAO = + getDAO(SpeciesCategory.class, SpeciesCategoryDAO.class); + CategoryDAO categoryDAO = getDAO(Category.class, CategoryDAO.class); + + Reader reader = getInputFileReader(inputFile); + try { + Import<MapCellImportRow> importer = + Import.newImport(csvModel, reader); + + configuration.incrementsProgress(); + + int rowNumber = 0; + for (MapCellImportRow row : importer) { + + doFlushTransaction(++rowNumber, inputFile, configuration); + + Cell cell = create(dao, row.getCell()); + voyage.addPostCell(cell); + + // collect ids + importResult.addId(EchoBaseEntityEnum.Cell, cell); + + DataQuality dataQuality = row.getDataQuality(); + + // add gridCellLongitude data + createCellData(dataDao, + cell, + dataLongitudeMeta, + String.valueOf(row.getGridCellLongitude()), + dataQuality, + importResult + ); + + // add gridCellLatitude data + createCellData(dataDao, + cell, + dataLatitudeMeta, + String.valueOf(row.getGridCellLatitude()), + dataQuality, + importResult + ); + + // add gridCellDepth data + createCellData(dataDao, + cell, + dataDepthMeta, + String.valueOf(row.getGridCellDepth()), + dataQuality, + importResult + ); + + // add gridLongitudeLag data + createCellData(dataDao, + cell, + dataLongitudeLagMeta, + String.valueOf(row.getGridLongitudeLag()), + dataQuality, + importResult + ); + + // add gridLatitudeLag data + createCellData(dataDao, + cell, + dataLatitudeLagMeta, + String.valueOf(row.getGridLatitudeLag()), + dataQuality, + importResult + ); + + // add gridDepthLag data + createCellData(dataDao, + cell, + dataDepthLagMeta, + String.valueOf(row.getGridDepthLag()), + dataQuality, + importResult + ); + + Category category = getResultCategory(categoryDAO, + speciesCategoryDAO, + null, + row.getSpecies(), + row.getSizeCategory(), + row.getAgeCategory(), + importResult); + + addResults(row, cell, category, resultLabel, resultDao, importResult, false); + } + + return importResult; + } catch (ImportRuntimeException e) { + throw new ImportException(getLocale(), inputFile, e); + } finally { + closeReader(reader, inputFile); + } + } + +} Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportService.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,239 @@ +package fr.ifremer.echobase.services.importdata; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; +import fr.ifremer.echobase.EchoBaseFunctions; +import fr.ifremer.echobase.entities.EchoBaseEntityEnum; +import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.CellDAO; +import fr.ifremer.echobase.entities.data.Data; +import fr.ifremer.echobase.entities.data.DataDAO; +import fr.ifremer.echobase.entities.data.Result; +import fr.ifremer.echobase.entities.data.ResultDAO; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.DataMetadata; +import fr.ifremer.echobase.entities.references.DataQuality; +import fr.ifremer.echobase.io.InputFile; +import fr.ifremer.echobase.services.importdata.csv.MapCellImportModel; +import fr.ifremer.echobase.services.importdata.csv.MapCellImportRow; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.csv.Import; +import org.nuiton.csv.ImportRuntimeException; +import org.nuiton.csv.ext.CsvReaders; + +import java.io.Reader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * To import map other results attached to a voyage. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class ResultsMapOtherCellImportService extends AbstractImportDataService<ResultsImportConfiguration> { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(ResultsMapOtherCellImportService.class); + + @Override + public void startImport( + ResultsImportConfiguration configuration, + EchoBaseUser user) throws ImportException { + + // get selected voyage + Voyage voyage = getEntityById(Voyage.class, + configuration.getVoyageId()); + + EchoBaseCsvFileImportResult importResult; + importResult = importMapFile(configuration, voyage); + configuration.addResult(importResult); + } + + protected EchoBaseCsvFileImportResult importMapFile( + ResultsImportConfiguration configuration, + Voyage voyage) throws ImportException { + + InputFile inputFile = configuration.getMapsFile(); + + if (log.isInfoEnabled()) { + log.info("Starts import of Map Other cells from file " + + inputFile.getFileName()); + } + + String resultLabel = configuration.getResultLabel(); + + CellType cellType = getEntityByProperty( + CellType.class, CellType.PROPERTY_ID, "Map"); + Preconditions.checkNotNull(cellType); + + DataMetadata dataLongitudeMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLongitude"); + Preconditions.checkNotNull(dataLongitudeMeta); + + DataMetadata dataLatitudeMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellLatitude"); + Preconditions.checkNotNull(dataLatitudeMeta); + + DataMetadata dataDepthMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridCellDepth"); + Preconditions.checkNotNull(dataDepthMeta); + + DataMetadata dataLongitudeLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLongitudeLag"); + Preconditions.checkNotNull(dataLongitudeLagMeta); + + DataMetadata dataLatitudeLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridLatitudeLag"); + Preconditions.checkNotNull(dataLatitudeLagMeta); + + DataMetadata dataDepthLagMeta = getEntityByProperty( + DataMetadata.class, DataMetadata.PROPERTY_NAME, "GridDepthLag"); + Preconditions.checkNotNull(dataDepthLagMeta); + + // authorize only the selected voyage to be imported + Map<String, Voyage> voyageMap = Maps.uniqueIndex(Arrays.asList( + voyage), EchoBaseFunctions.VOYAGE_NAME); + + Map<String, DataMetadata> dataMetadataMap = getEntitiesMap( + DataMetadata.class, EchoBaseFunctions.DATA_METADATA_NAME); + + Map<String, DataQuality> dataQualityMap = getEntitiesMap( + DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME); + + // first get header of file to detect which results to import + String[] header = CsvReaders.getHeader(inputFile.getFile(), + getCsvSeparator()); + + List<DataMetadata> metas = getMetas( + MapCellImportModel.COLUMN_NAMES_TO_EXCLUDE, + dataMetadataMap, + header); + + MapCellImportModel csvModel = new MapCellImportModel( + getCsvSeparator(), + cellType, + voyageMap, + metas, + dataQualityMap); + + EchoBaseCsvFileImportResult importResult = newImportResult(inputFile); + + CellDAO dao = getDAO(Cell.class, CellDAO.class); + DataDAO dataDao = getDAO(Data.class, DataDAO.class); + ResultDAO resultDao = getDAO(Result.class, ResultDAO.class); + + Reader reader = getInputFileReader(inputFile); + try { + Import<MapCellImportRow> importer = + Import.newImport(csvModel, reader); + + configuration.incrementsProgress(); + + int rowNumber = 0; + for (MapCellImportRow row : importer) { + + doFlushTransaction(++rowNumber, inputFile, configuration); + + Cell cell = create(dao, row.getCell()); + voyage.addPostCell(cell); + + // collect ids + importResult.addId(EchoBaseEntityEnum.Cell, cell); + + DataQuality dataQuality = row.getDataQuality(); + + // add gridCellLongitude data + createCellData(dataDao, + cell, + dataLongitudeMeta, + String.valueOf(row.getGridCellLongitude()), + dataQuality, + importResult + ); + + // add gridCellLatitude data + createCellData(dataDao, + cell, + dataLatitudeMeta, + String.valueOf(row.getGridCellLatitude()), + dataQuality, + importResult + ); + + // add gridCellDepth data + createCellData(dataDao, + cell, + dataDepthMeta, + String.valueOf(row.getGridCellDepth()), + dataQuality, + importResult + ); + + // add gridLongitudeLag data + createCellData(dataDao, + cell, + dataLongitudeLagMeta, + String.valueOf(row.getGridLongitudeLag()), + dataQuality, + importResult + ); + + // add gridLatitudeLag data + createCellData(dataDao, + cell, + dataLatitudeLagMeta, + String.valueOf(row.getGridLatitudeLag()), + dataQuality, + importResult + ); + + // add gridDepthLag data + createCellData(dataDao, + cell, + dataDepthLagMeta, + String.valueOf(row.getGridDepthLag()), + dataQuality, + importResult + ); + + addResults(row, cell, null, resultLabel, resultDao, importResult, false); + } + + return importResult; + } catch (ImportRuntimeException e) { + throw new ImportException(getLocale(), inputFile, e); + } finally { + closeReader(reader, inputFile); + } + } + +} \ No newline at end of file Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -133,7 +133,7 @@ EchoBaseFunctions.CELL_TYPE_ID); RegionCellImportModel csvModel = new RegionCellImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, cellTypeMap, dataQualityMap @@ -219,7 +219,7 @@ voyage.getRegionCells(), EchoBaseFunctions.CELL_BY_NAME); RegionCellAssociationImportModel csvModel = new RegionCellAssociationImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyage, voyageMap, regionsMap, @@ -296,7 +296,7 @@ header); RegionCellResultImportModel csvModel = new RegionCellResultImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, regionsMap, echotypeMap, Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -153,7 +153,7 @@ EchoBaseFunctions.SIZE_CATEGORY_NAME); LengthWeightKeyImportModel csvModel = new LengthWeightKeyImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, strataMap, sizeCategoryMap, @@ -227,7 +227,7 @@ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile); LengthAgeKeyImportModel csvModel = new LengthAgeKeyImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, strataMap, speciesMap); @@ -284,7 +284,7 @@ EchoBaseFunctions.DEPTH_STRATUM_ID); EchotypeImportModel csvModel = new EchotypeImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), voyageMap, depthStratumMap, speciesMap); Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/csv/MapCellImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/csv/MapCellImportModel.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/csv/MapCellImportModel.java 2013-08-01 08:24:28 UTC (rev 827) @@ -64,6 +64,33 @@ public MapCellImportModel(char separator, CellType cellType, Map<String, Voyage> voyageMap, + List<DataMetadata> dataMetadatas, + Map<String, DataQuality> dataQualityMap) { + super(separator); + this.cellType = cellType; + + newForeignKeyColumn(MapCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, voyageMap); + newMandatoryColumn(MapCellImportRow.PROPERTY_NAME); + newForeignKeyColumn(MapCellImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, dataQualityMap); + + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_CELL_LONGITUDE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_CELL_LATITUDE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_CELL_DEPTH, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_LONGITUDE_LAG, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_LATITUDE_LAG, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(MapCellImportRow.PROPERTY_DATA_GRID_DEPTH_LAG, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + + for (DataMetadata metadata : dataMetadatas) { + newMandatoryColumn( + metadata.getName(), + EchoBaseCsvUtil.newResultValueParser(metadata, false), + EchoBaseCsvUtil.<MapCellImportRow>newResultValueSetter()); + } + } + + public MapCellImportModel(char separator, + CellType cellType, + Map<String, Voyage> voyageMap, Map<String, Species> speciesMap, Map<String, SizeCategory> sizeCategoryMap, Map<String, AgeCategory> ageCategoryMap, Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2013-08-01 08:24:28 UTC (rev 827) @@ -44,7 +44,8 @@ import fr.ifremer.echobase.services.removedata.strategy.LegacyVoyageRemoveDataStrategy; import fr.ifremer.echobase.services.removedata.strategy.OperationRemoveDataStrategy; import fr.ifremer.echobase.services.removedata.strategy.ResultEsduRemoveDataStrategy; -import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy; +import fr.ifremer.echobase.services.removedata.strategy.ResultMapFishRemoveDataStrategy; +import fr.ifremer.echobase.services.removedata.strategy.ResultMapOtherRemoveDataStrategy; import fr.ifremer.echobase.services.removedata.strategy.ResultRegionRemoveDataStrategy; import fr.ifremer.echobase.services.removedata.strategy.ResultVoyageRemoveDataStrategy; import org.apache.commons.logging.Log; @@ -256,7 +257,8 @@ strategies.put(ImportType.ACOUSTIC, AcousticRemoveDataStrategy.class); strategies.put(ImportType.RESULT_VOYAGE, ResultVoyageRemoveDataStrategy.class); strategies.put(ImportType.RESULT_ESDU, ResultEsduRemoveDataStrategy.class); - strategies.put(ImportType.RESULT_MAP, ResultMapRemoveDataStrategy.class); + strategies.put(ImportType.RESULT_MAP_FISH, ResultMapFishRemoveDataStrategy.class); + strategies.put(ImportType.RESULT_MAP_OTHER, ResultMapOtherRemoveDataStrategy.class); strategies.put(ImportType.RESULT_REGION, ResultRegionRemoveDataStrategy.class); Preconditions.checkState( ImportType.values().length == strategies.size(), Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -142,7 +142,8 @@ public Set<ImportType> getPossibleSubImportType() { Set<ImportType> result = Sets.newHashSet(ImportType.RESULT_VOYAGE, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -95,7 +95,8 @@ ImportType.ACOUSTIC, ImportType.RESULT_VOYAGE, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -127,7 +127,8 @@ ImportType.CATCHES, ImportType.ACOUSTIC, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransitRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransitRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransitRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -129,7 +129,8 @@ ImportType.CATCHES, ImportType.ACOUSTIC, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonVoyageRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonVoyageRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonVoyageRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -96,7 +96,8 @@ ImportType.ACOUSTIC, ImportType.RESULT_VOYAGE, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -95,7 +95,8 @@ ImportType.ACOUSTIC, ImportType.RESULT_VOYAGE, ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapFishRemoveDataStrategy.java (from rev 823, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java) =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapFishRemoveDataStrategy.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapFishRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,87 @@ +package fr.ifremer.echobase.services.removedata.strategy; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.entities.ImportLog; +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Voyage; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.TopiaException; + +import java.util.Collections; +import java.util.Set; + +/** + * Remove a {@link ImportType#RESULT_MAP_FISH} import. + * <p/> + * Can remove only {@link Cell}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2 + */ +public class ResultMapFishRemoveDataStrategy extends AbstractRemoveDataStrategy { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(ResultMapFishRemoveDataStrategy.class); + + @Override + public long computeNbSteps(Voyage voyage, ImportLog importLog) { + + long result = importLog.sizeImportId(); + return result; + } + + @Override + protected void removeImportData(Voyage voyage, String id) throws TopiaException { + + if (id.startsWith(Cell.class.getName())) { + + // get cell + Cell cell = cellDAO.findByTopiaId(id); + + // dettach cell childs, we do not want to delete them from here ? + cell.clearChilds(); + + // remove it from voyage + voyage.removePostCell(cell); + + // remove cell + delete(cellDAO, cell); + if (log.isDebugEnabled()) { + log.debug(cell.getTopiaId() + " was removed"); + } + } else { + canNotDealWithId(id); + } + } + + @Override + public Set<ImportType> getPossibleSubImportType() { + Set<ImportType> result = Collections.emptySet(); + return result; + } +} Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapOtherRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapOtherRemoveDataStrategy.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapOtherRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,87 @@ +package fr.ifremer.echobase.services.removedata.strategy; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.entities.ImportLog; +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Voyage; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.TopiaException; + +import java.util.Collections; +import java.util.Set; + +/** + * Remove a {@link ImportType#RESULT_MAP_OTHER} import. + * <p/> + * Can remove only {@link Cell}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class ResultMapOtherRemoveDataStrategy extends AbstractRemoveDataStrategy { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(ResultMapFishRemoveDataStrategy.class); + + @Override + public long computeNbSteps(Voyage voyage, ImportLog importLog) { + + long result = importLog.sizeImportId(); + return result; + } + + @Override + protected void removeImportData(Voyage voyage, String id) throws TopiaException { + + if (id.startsWith(Cell.class.getName())) { + + // get cell + Cell cell = cellDAO.findByTopiaId(id); + + // dettach cell childs, we do not want to delete them from here ? + cell.clearChilds(); + + // remove it from voyage + voyage.removePostCell(cell); + + // remove cell + delete(cellDAO, cell); + if (log.isDebugEnabled()) { + log.debug(cell.getTopiaId() + " was removed"); + } + } else { + canNotDealWithId(id); + } + } + + @Override + public Set<ImportType> getPossibleSubImportType() { + Set<ImportType> result = Collections.emptySet(); + return result; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapOtherRemoveDataStrategy.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -1,87 +0,0 @@ -package fr.ifremer.echobase.services.removedata.strategy; - -/* - * #%L - * EchoBase :: Services - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import fr.ifremer.echobase.entities.ImportLog; -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Voyage; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.topia.TopiaException; - -import java.util.Collections; -import java.util.Set; - -/** - * Remove a {@link ImportType#RESULT_MAP} import. - * <p/> - * Can remove only {@link Cell}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.2 - */ -public class ResultMapRemoveDataStrategy extends AbstractRemoveDataStrategy { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ResultMapRemoveDataStrategy.class); - - @Override - public long computeNbSteps(Voyage voyage, ImportLog importLog) { - - long result = importLog.sizeImportId(); - return result; - } - - @Override - protected void removeImportData(Voyage voyage, String id) throws TopiaException { - - if (id.startsWith(Cell.class.getName())) { - - // get cell - Cell cell = cellDAO.findByTopiaId(id); - - // dettach cell childs, we do not want to delete them from here ? - cell.clearChilds(); - - // remove it from voyage - voyage.removePostCell(cell); - - // remove cell - delete(cellDAO, cell); - if (log.isDebugEnabled()) { - log.debug(cell.getTopiaId() + " was removed"); - } - } else { - canNotDealWithId(id); - } - } - - @Override - public Set<ImportType> getPossibleSubImportType() { - Set<ImportType> result = Collections.emptySet(); - return result; - } -} Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2013-08-01 08:24:28 UTC (rev 827) @@ -142,7 +142,8 @@ @Override public Set<ImportType> getPossibleSubImportType() { Set<ImportType> result = Sets.newHashSet(ImportType.RESULT_ESDU, - ImportType.RESULT_MAP, + ImportType.RESULT_MAP_FISH, + ImportType.RESULT_MAP_OTHER, ImportType.RESULT_REGION); return result; } Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2013-08-01 08:24:28 UTC (rev 827) @@ -218,7 +218,7 @@ } ResultEdsuImportMockImportModel csvModel = new ResultEdsuImportMockImportModel( - serviceContext.getConfiguration().getCsvSeparator(), + getCsvSeparator(), esduColumnName, inputFile.getFile()); Deleted: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2013-08-01 08:24:28 UTC (rev 827) @@ -1,83 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services.importdata; - -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Category; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Data; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; -import org.junit.Test; - -import java.util.List; - -/** - * To test the {@link ResultsMapCellImportService} service. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class ResultsMapCellImportServiceIT extends AbstractImportDataServiceIT { - - protected FakeEchoBaseServiceContext initContext() { - return new FakeEchoBaseServiceContext( - fixtures.IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT()); - } - - protected String[] getImportPath(String filename) { - return new String[]{"/import-data", "result", "map", filename}; - } - - @Test - public void doImportMap() throws Exception { - - assertImportCommonData(); - assertImportOperations(); - assertImportSampleDatas(); - assertImportVoyageResult(); - - assertNoEntities(Result.class, Data.class); - - ResultsImportConfiguration conf = - new ResultsImportConfiguration(getLocale()); - - conf.setResultLabel("resultLabel"); - conf.setVoyageId(getVoyageId()); - conf.setImportType(ImportType.RESULT_MAP); - - prepareInputFile(conf.getMapsFile(), getImportPath("maps.csv.gz")); - - List<EchoBaseCsvFileImportResult> result; - result = doImport(conf, ResultsMapCellImportService.class, 1); - - assertNbIDs(result, 0, 380); - - assertCsvImportResult(result, 0, Cell.class, 380); - assertCsvImportResult(result, 0, Data.class, 2280); - assertCsvImportResult(result, 0, Result.class, 380); - assertCsvImportResult(result, 0, Category.class, 1); - } - -} \ No newline at end of file Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportServiceIT.java (from rev 823, trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java) =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportServiceIT.java (rev 0) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapFishCellImportServiceIT.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,83 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.importdata; + +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Category; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Data; +import fr.ifremer.echobase.entities.data.Result; +import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; +import org.junit.Test; + +import java.util.List; + +/** + * To test the {@link ResultsMapFishCellImportService} service. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class ResultsMapFishCellImportServiceIT extends AbstractImportDataServiceIT { + + protected FakeEchoBaseServiceContext initContext() { + return new FakeEchoBaseServiceContext( + fixtures.IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT()); + } + + protected String[] getImportPath(String filename) { + return new String[]{"/import-data", "result", "map", filename}; + } + + @Test + public void doImportMap() throws Exception { + + assertImportCommonData(); + assertImportOperations(); + assertImportSampleDatas(); + assertImportVoyageResult(); + + assertNoEntities(Result.class, Data.class); + + ResultsImportConfiguration conf = + new ResultsImportConfiguration(getLocale()); + + conf.setResultLabel("resultLabel"); + conf.setVoyageId(getVoyageId()); + conf.setImportType(ImportType.RESULT_MAP_FISH); + + prepareInputFile(conf.getMapsFile(), getImportPath("mapsFish.csv.gz")); + + List<EchoBaseCsvFileImportResult> result; + result = doImport(conf, ResultsMapFishCellImportService.class, 1); + + assertNbIDs(result, 0, 380); + + assertCsvImportResult(result, 0, Cell.class, 380); + assertCsvImportResult(result, 0, Data.class, 2280); + assertCsvImportResult(result, 0, Result.class, 380); + assertCsvImportResult(result, 0, Category.class, 1); + } + +} \ No newline at end of file Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportServiceIT.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportServiceIT.java (rev 0) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportServiceIT.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,81 @@ +package fr.ifremer.echobase.services.importdata; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Data; +import fr.ifremer.echobase.entities.data.Result; +import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; +import org.junit.Test; + +import java.util.List; + +/** + * To test the {@link ResultsMapOtherCellImportService} service. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class ResultsMapOtherCellImportServiceIT extends AbstractImportDataServiceIT { + + protected FakeEchoBaseServiceContext initContext() { + return new FakeEchoBaseServiceContext( + fixtures.IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT()); + } + + protected String[] getImportPath(String filename) { + return new String[]{"/import-data", "result", "map", filename}; + } + + @Test + public void doImportMap() throws Exception { + + assertImportCommonData(); + assertImportOperations(); + assertImportSampleDatas(); + assertImportVoyageResult(); + + assertNoEntities(Result.class, Data.class); + + ResultsImportConfiguration conf = + new ResultsImportConfiguration(getLocale()); + + conf.setResultLabel("resultLabel"); + conf.setVoyageId(getVoyageId()); + conf.setImportType(ImportType.RESULT_MAP_OTHER); + + prepareInputFile(conf.getMapsFile(), getImportPath("mapsOther.csv.gz")); + + List<EchoBaseCsvFileImportResult> result; + result = doImport(conf, ResultsMapOtherCellImportService.class, 1); + + assertNbIDs(result, 0, 380); + + assertCsvImportResult(result, 0, Cell.class, 380); + assertCsvImportResult(result, 0, Data.class, 2280); + assertCsvImportResult(result, 0, Result.class, 380); + } + +} Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapOtherCellImportServiceIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -88,7 +88,8 @@ import fr.ifremer.echobase.services.importdata.OperationImportService; import fr.ifremer.echobase.services.importdata.ResultsEsduCellImportService; import fr.ifremer.echobase.services.importdata.ResultsImportConfiguration; -import fr.ifremer.echobase.services.importdata.ResultsMapCellImportService; +import fr.ifremer.echobase.services.importdata.ResultsMapFishCellImportService; +import fr.ifremer.echobase.services.importdata.ResultsMapOtherCellImportService; import fr.ifremer.echobase.services.importdata.ResultsRegionCellImportService; import fr.ifremer.echobase.services.importdata.ResultsVoyageImportService; import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration; @@ -136,8 +137,10 @@ protected String importResultRegion1Id; - protected String importResultMap1Id; + protected String importResultMapFish1Id; + protected String importResultMapOther1Id; + protected static final String voyage1Id = "fr.ifremer.echobase.entities.data.Voyage#1#1"; protected static final String transit1Id = "fr.ifremer.echobase.entities.data.Transit#1#1"; @@ -158,8 +161,10 @@ protected static final String cellEsdu1Id = "fr.ifremer.echobase.entities.data.Cell#1#esdu1"; - protected static final String cellMap1Id = "fr.ifremer.echobase.entities.data.Cell#1#map1"; + protected static final String cellMapFish1Id = "fr.ifremer.echobase.entities.data.Cell#1#mapfish1"; + protected static final String cellMapOther1Id = "fr.ifremer.echobase.entities.data.Cell#1#mapOther1"; + protected static final String cellRegion1Id = "fr.ifremer.echobase.entities.data.Cell#1#region1"; protected static final String cellElementary1Id = "fr.ifremer.echobase.entities.data.Cell#1#elementary1"; @@ -170,8 +175,10 @@ protected static final String resultEsdu1Id = "fr.ifremer.echobase.entities.data.Result#1#esdu1"; - protected static final String resultMap1Id = "fr.ifremer.echobase.entities.data.Result#1#map1"; + protected static final String resultMapFish1Id = "fr.ifremer.echobase.entities.data.Result#1#mapFish1"; + protected static final String resultMapOther1Id = "fr.ifremer.echobase.entities.data.Result#1#mapOther1"; + protected static final String resultRegion1Id = "fr.ifremer.echobase.entities.data.Result#1#region1"; protected static final String resultEsdu1_2Id = "fr.ifremer.echobase.entities.data.Result#1#esdu2"; @@ -270,7 +277,8 @@ createResultVoyageImportV1(); createResultEsduImportV1(); createResultRegionImportV1(); - createResultMapImportV1(); + createResultMapFishImportV1(); + createResultMapOtherImportV1(); // create imports for voyage 2 createCommonVoyageImportV2(); @@ -297,7 +305,8 @@ importResultVoyage1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id, + importResultMapFish1Id, + importResultMapOther1Id, importCommonVoyage2Id, importCommonTransit2Id, importCommonTransect2Id, @@ -306,7 +315,8 @@ totalSample1Id, subSample1Id, biometrySample1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id, cellRegion1Id, resultRegion1Id, - cellMap1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id, voyage2Id, transit2Id, transect2Id, transect2_2Id ); @@ -798,11 +808,11 @@ region); } - private void createResultMapImportV1() throws TopiaException { + private void createResultMapFishImportV1() throws TopiaException { // create map Cell map = create(cellDAO, - TopiaEntity.PROPERTY_TOPIA_ID, cellMap1Id, + TopiaEntity.PROPERTY_TOPIA_ID, cellMapFish1Id, Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class), Cell.PROPERTY_NAME, "cellMap1"); @@ -812,23 +822,53 @@ // create result (on map) Category category = create(categoryDAO); Result result = create(resultDAO, - TopiaEntity.PROPERTY_TOPIA_ID, resultMap1Id, + TopiaEntity.PROPERTY_TOPIA_ID, resultMapFish1Id, Result.PROPERTY_CATEGORY, category, Result.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class), - Result.PROPERTY_RESULT_VALUE, "resultValueMap1", - Result.PROPERTY_RESULT_LABEL, "resultLabelMap1" + Result.PROPERTY_RESULT_VALUE, "resultValueMapFish1", + Result.PROPERTY_RESULT_LABEL, "resultLabelMapFish1" ); map.addResult(result); - importResultMap1Id = createImport( - ResultsMapCellImportService.class, + importResultMapFish1Id = createImport( + ResultsMapFishCellImportService.class, new ResultsImportConfiguration(getLocale()), - ImportType.RESULT_MAP, - "ResultsMap1", + ImportType.RESULT_MAP_FISH, + "ResultsMapFish1", voyage1Id, map); } + private void createResultMapOtherImportV1() throws TopiaException { + + // create map + Cell map = create(cellDAO, + TopiaEntity.PROPERTY_TOPIA_ID, cellMapOther1Id, + Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class), + Cell.PROPERTY_NAME, "cellMapOther1"); + + Voyage voyage = getEntity(voyage1Id); + voyage.addPostCell(map); + + // create result (on map) + Result result = create(resultDAO, + TopiaEntity.PROPERTY_TOPIA_ID, resultMapOther1Id, + Result.PROPERTY_CATEGORY, null, + Result.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class), + Result.PROPERTY_RESULT_VALUE, "resultValueMapOther1", + Result.PROPERTY_RESULT_LABEL, "resultLabelMapOther1" + ); + map.addResult(result); + + importResultMapOther1Id = createImport( + ResultsMapOtherCellImportService.class, + new ResultsImportConfiguration(getLocale()), + ImportType.RESULT_MAP_OTHER, + "ResultsMapOther1", + voyage1Id, + map); + } + private <C extends AbstractImportConfiguration, S extends AbstractImportDataService<C>> String createImport( Class<S> serviceType, C importConf, Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -42,13 +42,16 @@ importAcoustic1Id, // data that should be removed dataAcquisition1Id, cellEsdu1Id, cellElementary1Id, - cellRegion1Id, cellMap1Id, - resultEsdu1Id, resultRegion1Id, resultMap1Id, + cellRegion1Id, resultRegion1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, + resultEsdu1Id, // importLog that should be removed importAcoustic1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id + importResultMapFish1Id, + importResultMapOther1Id ); } Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -42,11 +42,12 @@ removeImport(// import to remove importCommonVoyage1Id, // data that should be removed - voyage1Id, transit1Id , transect1Id, operation1Id, transect1_2Id, + voyage1Id, transit1Id, transect1Id, operation1Id, transect1_2Id, totalSample1Id, subSample1Id, biometrySample1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id, cellRegion1Id, resultRegion1Id, - cellMap1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id, // importLog that should be removed importCommonVoyage1Id, @@ -58,7 +59,9 @@ importResultVoyage1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id); + importResultMapFish1Id, + importResultMapOther1Id + ); } @Test @@ -67,7 +70,7 @@ removeImport(// import to remove importCommonVoyage2Id, // data that should be removed - voyage2Id, transit2Id , transect2Id, transect2_2Id, + voyage2Id, transit2Id, transect2Id, transect2_2Id, // importLog that should be removed importCommonVoyage2Id, importCommonTransit2Id, Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -46,14 +46,16 @@ totalSample1Id, subSample1Id, biometrySample1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id, cellRegion1Id, resultRegion1Id, - cellMap1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, // importLog that should be removed importCommonTransect1Id, importOperation1Id, importCatches1Id, importAcoustic1Id, importResultEsdu1Id, - importResultMap1Id, + importResultMapFish1Id, + importResultMapOther1Id, importResultRegion1Id); } Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransitRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransitRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransitRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -48,7 +48,8 @@ totalSample1Id, subSample1Id, biometrySample1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id, cellRegion1Id, resultRegion1Id, - cellMap1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, // importLog that should be removed importCommonTransit1Id, importCommonTransect1Id, @@ -57,7 +58,9 @@ importAcoustic1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id); + importResultMapFish1Id, + importResultMapOther1Id + ); } @Test Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonVoyageRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonVoyageRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonVoyageRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -46,7 +46,8 @@ totalSample1Id, subSample1Id, biometrySample1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id, cellRegion1Id, resultRegion1Id, - cellMap1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id, // importLog that should be removed importCommonVoyage1Id, @@ -58,7 +59,9 @@ importResultVoyage1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id); + importResultMapFish1Id, + importResultMapOther1Id + ); } @Test Deleted: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -1,49 +0,0 @@ -package fr.ifremer.echobase.ui.actions.removedata; - -/* - * #%L - * EchoBase :: Services - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import fr.ifremer.echobase.services.removedata.RemoveDataService; -import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy; -import org.junit.Test; -import org.nuiton.topia.TopiaException; - -/** - * Test{@link RemoveDataService} with {@link ResultMapRemoveDataStrategy}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.3 - */ -public class ResultMapRemoveDataServiceTest extends AbstractRemoveDataServiceTest { - - @Test - public void removeImport() throws TopiaException { - - removeImport(// import to remove - importResultMap1Id, - // data that should be removed - cellMap1Id, resultMap1Id, - // importLog that should be removed - importResultMap1Id); - } -} Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveFishDataServiceTest.java (from rev 823, trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java) =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveFishDataServiceTest.java (rev 0) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveFishDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,49 @@ +package fr.ifremer.echobase.ui.actions.removedata; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.services.removedata.RemoveDataService; +import fr.ifremer.echobase.services.removedata.strategy.ResultMapFishRemoveDataStrategy; +import org.junit.Test; +import org.nuiton.topia.TopiaException; + +/** + * Test {@link RemoveDataService} with {@link ResultMapFishRemoveDataStrategy}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.3 + */ +public class ResultMapRemoveFishDataServiceTest extends AbstractRemoveDataServiceTest { + + @Test + public void removeImport() throws TopiaException { + + removeImport(// import to remove + importResultMapFish1Id, + // data that should be removed + cellMapFish1Id, resultMapFish1Id, + // importLog that should be removed + importResultMapFish1Id); + } +} Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveOtherDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveOtherDataServiceTest.java (rev 0) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveOtherDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,49 @@ +package fr.ifremer.echobase.ui.actions.removedata; + +/* + * #%L + * EchoBase :: Services + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.services.removedata.RemoveDataService; +import fr.ifremer.echobase.services.removedata.strategy.ResultMapOtherRemoveDataStrategy; +import org.junit.Test; +import org.nuiton.topia.TopiaException; + +/** + * Test {@link RemoveDataService} with {@link ResultMapOtherRemoveDataStrategy}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class ResultMapRemoveOtherDataServiceTest extends AbstractRemoveDataServiceTest { + + @Test + public void removeImport() throws TopiaException { + + removeImport(// import to remove + importResultMapOther1Id, + // data that should be removed + cellMapOther1Id, resultMapOther1Id, + // importLog that should be removed + importResultMapOther1Id); + } +} Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveOtherDataServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java 2013-08-01 08:24:28 UTC (rev 827) @@ -43,12 +43,14 @@ importResultVoyage1Id, // data that should be removed echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id, - cellRegion1Id, cellMap1Id, - resultEsdu1Id, resultRegion1Id, resultMap1Id, + cellMapFish1Id, resultMapFish1Id, + cellMapOther1Id, resultMapOther1Id, + cellRegion1Id, resultEsdu1Id, resultRegion1Id, // importLog that should be removed importResultVoyage1Id, importResultEsdu1Id, importResultRegion1Id, - importResultMap1Id); + importResultMapFish1Id, + importResultMapOther1Id); } } Deleted: trunk/echobase-services/src/test/resources/import-data/result/map/maps.csv.gz =================================================================== (Binary files differ) Copied: trunk/echobase-services/src/test/resources/import-data/result/map/mapsFish.csv.gz (from rev 823, trunk/echobase-services/src/test/resources/import-data/result/map/maps.csv.gz) =================================================================== (Binary files differ) Copied: trunk/echobase-services/src/test/resources/import-data/result/map/mapsOther.csv.gz (from rev 823, trunk/echobase-services/src/test/resources/import-data/result/map/maps.csv.gz) =================================================================== (Binary files differ) Modified: trunk/echobase-services/update-import-data-db.sh =================================================================== --- trunk/echobase-services/update-import-data-db.sh 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-services/update-import-data-db.sh 2013-08-01 08:24:28 UTC (rev 827) @@ -52,4 +52,4 @@ #executeMaven fr.ifremer.echobase.services.importdata.ResultsRegionCellImportServiceIT -#executeMaven fr.ifremer.echobase.services.importdata.ResultsMapCellImportServiceIT +#executeMaven fr.ifremer.echobase.services.importdata.ResultsMapFishCellImportServiceIT Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport.java 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport.java 2013-08-01 08:24:28 UTC (rev 827) @@ -93,11 +93,17 @@ } @InputConfig(methodName = "input") - public String modeMap() throws Exception { + public String modeMapFish() throws Exception { return execute(); } + @InputConfig(methodName = "input") + public String modeMapOther() throws Exception { + + return execute(); + } + public Map<String, String> getVoyages() { return voyages; } Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeTransit-validation.xml (from rev 823, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeAll-validation.xml) =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeTransit-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeTransit-validation.xml 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,47 @@ +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="model.voyageId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.voyage.required"/> + </field-validator> + </field> + + <field name="model.transitRelatedActivity"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.transitRelatedActivity.required"/> + </field-validator> + </field> + + <field name="transitFile"> + <field-validator type="nfieldexpression"> + <param name="expression">model.transitFile.file!=null</param> + <message key="echobase.error.import.transitFile.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeVoyage-validation.xml (from rev 823, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeAll-validation.xml) =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeVoyage-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureCommonImport-configureCommon-modeVoyage-validation.xml 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,59 @@ +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="model.missionId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.mission.required"/> + </field-validator> + </field> + + <field name="model.areaOfOperationId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.areaOfOperation.required"/> + </field-validator> + </field> + + <field name="model.voyageDescription"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.voyageDescription.required"/> + </field-validator> + </field> + + <field name="model.datum"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.datum.required"/> + </field-validator> + </field> + + <field name="voyageFile"> + <field-validator type="nfieldexpression"> + <param name="expression">model.voyageFile.file!=null</param> + <message key="echobase.error.import.voyageFile.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMap-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMap-validation.xml 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMap-validation.xml 2013-08-01 08:24:28 UTC (rev 827) @@ -1,47 +0,0 @@ -<!-- - #%L - EchoBase :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2011 Ifremer, Codelutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="model.voyageId"> - <field-validator type="nrequiredstring"> - <message key="echobase.error.import.voyage.required"/> - </field-validator> - </field> - - <field name="model.resultLabel"> - <field-validator type="nrequiredstring"> - <message key="echobase.error.import.resultLabel.required"/> - </field-validator> - </field> - - <field name="mapsFile"> - <field-validator type="nfieldexpression"> - <param name="expression">model.mapsFile.file!=null</param> - <message key="echobase.error.import.mapsFile.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapFish-validation.xml (from rev 823, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMap-validation.xml) =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapFish-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapFish-validation.xml 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,47 @@ +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="model.voyageId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.voyage.required"/> + </field-validator> + </field> + + <field name="model.resultLabel"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.resultLabel.required"/> + </field-validator> + </field> + + <field name="mapsFile"> + <field-validator type="nfieldexpression"> + <param name="expression">model.mapsFile.file!=null</param> + <message key="echobase.error.import.mapsFile.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapOther-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapOther-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapOther-validation.xml 2013-08-01 08:24:28 UTC (rev 827) @@ -0,0 +1,47 @@ +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="model.voyageId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.voyage.required"/> + </field-validator> + </field> + + <field name="model.resultLabel"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.resultLabel.required"/> + </field-validator> + </field> + + <field name="mapsFile"> + <field-validator type="nfieldexpression"> + <param name="expression">model.mapsFile.file!=null</param> + <message key="echobase.error.import.mapsFile.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResultsImport-configureResults-modeMapOther-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -51,7 +51,8 @@ echobase.common.author=Author echobase.common.authorEmail=Author email echobase.common.biometrySampleFile= -echobase.common.cellMapsFile= +echobase.common.cellMapsFishFile=Map cells file (Fishes) +echobase.common.cellMapsOtherFile=Map cells file (Other) echobase.common.cellPositionReference=cellPositionReference echobase.common.cellRegionAssociationFile= echobase.common.cellRegionResultFile= Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2013-08-01 08:24:28 UTC (rev 827) @@ -52,6 +52,8 @@ echobase.common.authorEmail=Courriel de l'auteur echobase.common.biometrySampleFile= echobase.common.cellMapsFile= +echobase.common.cellMapsFishFile=Fichier des cellules Cartes (Poisson) +echobase.common.cellMapsOtherFile=Fichier des cellules Cartes (Autre) echobase.common.cellPositionReference=Référentiel géographique des cellules des cartes echobase.common.cellRegionAssociationFile= echobase.common.cellRegionResultFile= Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2013-08-01 06:26:47 UTC (rev 826) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2013-08-01 08:24:28 UTC (rev 827) @@ -190,7 +190,7 @@ <s:submit action="configureResults-modeRegion" key='echobase.action.import'/> </s:form> -<s:form id="RESULT_MAP" namespace="/importData" method="POST" +<s:form id="RESULT_MAP_FISH" namespace="/importData" method="POST" enctype="multipart/form-data" cssClass="hidden importType"> <fieldset> @@ -205,7 +205,7 @@ </div> <br/> - <s:hidden key="model.importType" value="RESULT_MAP" label=''/> + <s:hidden key="model.importType" value="RESULT_MAP_FISH" label=''/> <s:select key="model.voyageId" requiredLabel="true" label='%{getText("echobase.common.voyage")}' @@ -215,11 +215,45 @@ label='%{getText("echobase.common.resultLabel")}'/> <s:file key="mapsFile" requiredLabel="true" - label='%{getText("echobase.common.cellMapsFile")}'/> + label='%{getText("echobase.common.cellMapsFishFile")}'/> <s:textarea key="model.importNotes" cols="80" rows="5" label='%{getText("echobase.common.importNotes")}'/> </fieldset> <br/> - <s:submit action="configureResults-modeMap" key='echobase.action.import'/> + <s:submit action="configureResults-modeMapFish" key='echobase.action.import'/> </s:form> + +<s:form id="RESULT_MAP_OTHER" namespace="/importData" method="POST" + enctype="multipart/form-data" cssClass="hidden importType"> + + <fieldset> + <legend> + <s:text name="echobase.legend.importData.configure"/> + </legend> + + <div class="cleanBoth help"> + <s:a href="%{getDocumentation('importData.html', null)}" target="doc"> + <s:text name="echobase.action.show.import.documentation"/> + </s:a> + </div> + <br/> + + <s:hidden key="model.importType" value="RESULT_MAP_OTHER" label=''/> + + <s:select key="model.voyageId" requiredLabel="true" + label='%{getText("echobase.common.voyage")}' + list="voyages" headerKey="" headerValue=""/> + + <s:textfield key="model.resultLabel" size="40" requiredLabel="true" + label='%{getText("echobase.common.resultLabel")}'/> + + <s:file key="mapsFile" requiredLabel="true" + label='%{getText("echobase.common.cellMapsOtherFile")}'/> + + <s:textarea key="model.importNotes" cols="80" rows="5" + label='%{getText("echobase.common.importNotes")}'/> + </fieldset> + <br/> + <s:submit action="configureResults-modeMapOther" key='echobase.action.import'/> +</s:form> \ No newline at end of file
participants (1)
-
tchemit@users.forge.codelutin.com