Author: tchemit Date: 2012-03-29 23:24:34 +0200 (Thu, 29 Mar 2012) New Revision: 452 Url: http://forge.codelutin.com/repositories/revision/echobase/452 Log: fixes #1060 (Faire tous les imports de r?\195?\169sultats esdu en une seule fois) , refs #1059 (S?\195?\169lectionner un dataProcessing pour l'import des r?\195?\169sultats esdu) Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsdu-validation.xml Removed: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotype-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotypeAndSpeciesCategory-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndAgeCategory-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndSizeCategory-validation.xml Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/CategoryImpl.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategoryImpl.java trunk/echobase-entities/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/ResultsImportConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportMode.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResults.java trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeVoyage-validation.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResults.jsp trunk/echobase-ui/src/main/webapp/js/gridHelper.js Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDecoratorProvider.java 2012-03-29 21:24:34 UTC (rev 452) @@ -213,7 +213,7 @@ registerJXPathDecorator(locale, Species.class, "${genusSpecies}$s (${baracoudaCode}$s)"); // SpeciesCategory decorator - registerJXPathDecorator(locale, SpeciesCategory.class, "${species/genusSpecies}$s - (size:: ${sizeCategoryName}$s) - (age: ${ageCategoryLabel}$s) - (sex: ${sexCategoryLabel}$s)"); + registerJXPathDecorator(locale, SpeciesCategory.class, "${species/genusSpecies}$s ${sizeCategoryLabel}$s ${ageCategoryLabel}$s ${sexCategoryLabel}$s"); // Strata decorator registerJXPathDecorator(locale, Strata.class, "Latitude <${minLatitude}$s - ${maxLatitude}$s>, Longitude <${minLongitude}$s - ${maxLongitude}$s>"); @@ -237,12 +237,11 @@ // Data decorator registerJXPathDecorator(locale, Data.class, "${dataValue}$s"); - //TODO // DataAcquisition decorator - registerJXPathDecorator(locale, DataAcquisition.class, ""); + registerJXPathDecorator(locale, DataAcquisition.class, "${acousticInstrument/id}$s "); // DataProcessing decorator - registerJXPathDecorator(locale, DataProcessing.class, "${id} "); + registerJXPathDecorator(locale, DataProcessing.class, "${id}$s"); // Operation decorator registerJXPathDecorator(locale, Operation.class, "${startDate}$td/%1$tm/%1$tY - ${endDate}$td/%2$tm/%2$tY"); @@ -260,7 +259,7 @@ registerJXPathDecorator(locale, SampleData.class, "${resultvalue}$s"); // Transect decorator - registerJXPathDecorator(locale, Transect.class, "${title}$s - Vessel ${vessel}$s"); + registerJXPathDecorator(locale, Transect.class, "${title}$s - Vessel ${vessel/name}$s"); // Transit decorator registerJXPathDecorator(locale, Transit.class, "${startTime}$td/%1$tm/%1$tY - ${endTime}$td/%2$tm/%2$tY"); Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/CategoryImpl.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/CategoryImpl.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/CategoryImpl.java 2012-03-29 21:24:34 UTC (rev 452) @@ -42,13 +42,13 @@ @Override public String getProcessedAgeLabel() { return speciesCategory == null || speciesCategory.getAgeCategory() == null ? "" : - ("ageCategory: " + speciesCategory.getAgeCategoryName()); + speciesCategory.getAgeCategoryLabel(); } @Override public String getProcessedLengthLabel() { return speciesCategory == null || speciesCategory.getSizeCategory() == null ? "" : - ("sizeCategory: " + speciesCategory.getSizeCategoryName()); + speciesCategory.getSizeCategoryLabel(); } } //CategoryImpl Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategoryImpl.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategoryImpl.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategoryImpl.java 2012-03-29 21:24:34 UTC (rev 452) @@ -25,38 +25,23 @@ public class SpeciesCategoryImpl extends SpeciesCategoryAbstract { - private static final long serialVersionUID = 4063203856528794213L; + private static final long serialVersionUID = 1L; @Override - public String getSizeCategoryName() { - String result; - if (sizeCategory == null) { - result = ""; - } else { - result = sizeCategory.getName(); - } - return result; + public String getSizeCategoryLabel() { + return sizeCategory == null ? "" : + ("sizeCategory: " + sizeCategory.getName()); } @Override - public String getAgeCategoryName() { - String result; - if (ageCategory == null) { - result = ""; - } else { - result = ageCategory.getName(); - } - return result; + public String getAgeCategoryLabel() { + return ageCategory == null ? "" : + ("ageCategory: " + ageCategory.getName()); } @Override - public String getSexCategoryName() { - String result; - if (sexCategory == null) { - result = ""; - } else { - result = sexCategory.getName(); - } - return result; + public String getSexCategoryLabel() { + return sexCategory == null ? "" : + ("sexCategory: " + sexCategory.getName()); } } //SpeciesCategoryImpl Modified: trunk/echobase-entities/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 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java 2012-03-29 21:24:34 UTC (rev 452) @@ -26,7 +26,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ifremer.echobase.EchoBaseFunctions; -import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.InputFile; import fr.ifremer.echobase.csv.CsvFileImportResult; import fr.ifremer.echobase.csv.EchoBaseImport; @@ -36,6 +35,7 @@ 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.DataProcessing; import fr.ifremer.echobase.entities.data.Echotype; import fr.ifremer.echobase.entities.data.Result; import fr.ifremer.echobase.entities.data.ResultDAO; @@ -93,8 +93,6 @@ ResultsImportConfiguration configuration, EchoBaseUser user) throws ImportException { - ResultsImportMode importMode = configuration.getImportMode(); - Map<String, Species> speciesMap = getEntitiesMap( Species.class, EchoBaseFunctions.SPECIES_BARACOUDA_CODE); @@ -113,83 +111,70 @@ Voyage voyage = getEntityById(Voyage.class, configuration.getVoyageId()); + // get selected dataProcessing + DataProcessing dataProcessing = getEntityById(DataProcessing.class, + configuration.getDataProcessingId()); + // index all echotypes of thi voyage Map<String, Echotype> echotypeMap = Maps.uniqueIndex( voyage.getEchotype(), EchoBaseFunctions.ECHOTYPE_NAME); + List<CsvFileImportResult> result = Lists.newLinkedList(); + InputFile inputFile; - CsvFileImportResult importResult; - switch (importMode) { + inputFile = configuration.getEsduByEchotypeFile(); + if (inputFile.hasFile()) { + CsvFileImportResult importResult = importByEchotypeFile( + configuration, + inputFile, + voyage, + echotypeMap, + dataMetadataMap + ); + addResultAndLog(result, inputFile, importResult, user); + } - case ESDU_BY_ECHOTYPE: { + inputFile = configuration.getEsduByEchotypeAndSpeciesCategoryFile(); + if (inputFile.hasFile()) { + CsvFileImportResult importResult = importByEchotypeAndSpeciesCategoryFile( + configuration, + inputFile, + voyage, + echotypeMap, + dataMetadataMap, + speciesMap, + sizeCategoryMap + ); + addResultAndLog(result, inputFile, importResult, user); + } - inputFile = configuration.getEsduByEchotypeFile(); + inputFile = configuration.getEsduBySpeciesAndSizeCategoryFile(); + if (inputFile.hasFile()) { + CsvFileImportResult importResult = importBySpeciesAndSizeCategoryFile( + configuration, + inputFile, + voyage, + dataMetadataMap, + speciesMap, + sizeCategoryMap + ); + addResultAndLog(result, inputFile, importResult, user); + } - importResult = importByEchotypeFile( - configuration, - inputFile, - voyage, - echotypeMap, - dataMetadataMap - ); - } - break; + inputFile = configuration.getEsduBySpeciesAndAgeCategoryFile(); - case ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY: { - - inputFile = - configuration.getEsduByEchotypeAndSpeciesCategoryFile(); - importResult = importByEchotypeAndSpeciesCategoryFile( - configuration, - inputFile, - voyage, - echotypeMap, - dataMetadataMap, - speciesMap, - sizeCategoryMap - ); - } - break; - - case ESDU_BY_SPECIES_AND_SIZE_CATEGORY: { - - inputFile = - configuration.getEsduBySpeciesAndSizeCategoryFile(); - importResult = importBySpeciesAndSizeCategoryFile( - configuration, - inputFile, - voyage, - dataMetadataMap, - speciesMap, - sizeCategoryMap - ); - } - break; - - case ESDU_BY_SPECIES_AND_AGE_CATEGORY: { - - inputFile = - configuration.getEsduBySpeciesAndAgeCategoryFile(); - - importResult = importBySpeciesAndAgeCategoryFile( - configuration, - inputFile, - voyage, - dataMetadataMap, - speciesMap, - ageCategoryMap - ); - } - break; - default: - throw new EchoBaseTechnicalException( - "Can not use this importMode " + importMode + - " for this service " + this); + if (inputFile.hasFile()) { + CsvFileImportResult importResult = importBySpeciesAndAgeCategoryFile( + configuration, + inputFile, + voyage, + dataMetadataMap, + speciesMap, + ageCategoryMap + ); + addResultAndLog(result, inputFile, importResult, user); } - - List<CsvFileImportResult> result = Lists.newLinkedList(); - addResultAndLog(result, inputFile, importResult, user); return result; } @@ -201,7 +186,7 @@ Map<String, DataMetadata> dataMetadataMap) throws ImportException { if (log.isInfoEnabled()) { - log.info("Starts import of acoustic result by echotype from file " + + log.info("Starts import of esdu result by echotype from file " + inputFile.getFileName()); } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java 2012-03-29 21:24:34 UTC (rev 452) @@ -42,6 +42,9 @@ /** Selected voyage id where to import datas. */ protected String voyageId; + /** Selected dataProcessing id where to search esdu or elementary cells. */ + protected String dataProcessingId; + /** Selected vessel id to find out transect where to import datas. */ protected String vesselId; @@ -125,6 +128,14 @@ this.vesselId = vesselId; } + public String getDataProcessingId() { + return dataProcessingId; + } + + public void setDataProcessingId(String dataProcessingId) { + this.dataProcessingId = dataProcessingId; + } + public ResultsImportMode getImportMode() { return importMode; } @@ -185,6 +196,21 @@ return esduBySpeciesAndAgeCategoryFile; } + public boolean isOneEsduImportFile() { + return esduByEchotypeFile.hasFile() || + esduByEchotypeAndSpeciesCategoryFile.hasFile() || + esduBySpeciesAndSizeCategoryFile.hasFile() || + esduBySpeciesAndAgeCategoryFile.hasFile(); + + } + + public boolean isOneVoyageImportFile() { + return echotypeFile.hasFile() || + lengthAgeKeyFile.hasFile() || + lengthWeightKeyFile.hasFile(); + + } + @Override public InputFile[] getInputFiles() { return new InputFile[]{regionsFile, regionAssociationFile, Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportMode.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportMode.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportMode.java 2012-03-29 21:24:34 UTC (rev 452) @@ -45,17 +45,8 @@ MAP(n_("echobase.common.resultsImportMode.map")), /** Import esdu results by echotype. */ - ESDU_BY_ECHOTYPE(n_("echobase.common.resultsImportMode.esdu.byEchotype")), + ESDU(n_("echobase.common.resultsImportMode.esdu")); - /** Import esdu results by echotype and species category. */ - ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY(n_("echobase.common.resultsImportMode.esdu.byEchotypeAndSpeciesCategory")), - - /** Import esdu results by species and size category. */ - ESDU_BY_SPECIES_AND_SIZE_CATEGORY(n_("echobase.common.resultsImportMode.esdu.bySpeciesAndSizeCategory")), - - /** Import esdu results by species and age category. */ - ESDU_BY_SPECIES_AND_AGE_CATEGORY(n_("echobase.common.resultsImportMode.esdu.bySpeciesAndAgeCategory")); - private final String i18nKey; ResultsImportMode(String i18nKey) { 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 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java 2012-03-29 21:24:34 UTC (rev 452) @@ -23,12 +23,21 @@ */ package fr.ifremer.echobase.services.importdata; +import com.google.common.collect.Maps; import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.csv.CsvFileImportResult; import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.data.DataAcquisition; +import fr.ifremer.echobase.entities.data.DataProcessing; +import fr.ifremer.echobase.entities.data.Transect; +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.DecoratorService; import fr.ifremer.echobase.services.ImportException; +import org.nuiton.util.decorator.Decorator; import java.util.List; +import java.util.Map; import static org.nuiton.i18n.I18n.l_; @@ -59,10 +68,7 @@ service = getService(ResultsVoyageImportService.class); break; - case ESDU_BY_ECHOTYPE: - case ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY: - case ESDU_BY_SPECIES_AND_SIZE_CATEGORY: - case ESDU_BY_SPECIES_AND_AGE_CATEGORY: + case ESDU: service = getService(ResultsEsduCellImportService.class); break; @@ -86,4 +92,48 @@ return result; } + public Map<String, String> getDataProcessings(Voyage voyage) { + + Map<String, String> result = Maps.newLinkedHashMap(); + + DecoratorService service = getService(DecoratorService.class); + + Decorator<Transit> transitDecorator = service.getDecorator(getLocale(), Transit.class, null); + Decorator<Transect> transectDecorator = service.getDecorator(getLocale(), Transect.class, null); + Decorator<DataAcquisition> dataAcquisitionDecorator = service.getDecorator(getLocale(), DataAcquisition.class, null); + Decorator<DataProcessing> dataProcessingDecorator = service.getDecorator(getLocale(), DataProcessing.class, null); + + if (!voyage.isTransitEmpty()) { + + for (Transit transit : voyage.getTransit()) { + + String transitStr = transitDecorator.toString(transit); + + if (!transit.isTransectEmpty()) { + for (Transect transect : transit.getTransect()) { + + String transectStr = transitStr + " / " + transectDecorator.toString(transect); + + if (!transect.isDataAcquisitionEmpty()) { + + for (DataAcquisition dataAcquisition : transect.getDataAcquisition()) { + + String dataAcquisitionStr = transectStr + " / " + dataAcquisitionDecorator.toString(dataAcquisition); + + + if (!dataAcquisition.isDataProcessingEmpty()) { + for (DataProcessing dataProcessing : dataAcquisition.getDataProcessing()) { + + String value = dataAcquisitionStr + dataProcessingDecorator.toString(dataProcessing); + result.put(dataProcessing.getTopiaId(), value); + } + } + } + } + } + } + } + } + return result; + } } Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties =================================================================== --- trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties 2012-03-29 21:24:34 UTC (rev 452) @@ -25,10 +25,7 @@ echobase.common.moviesFile= echobase.common.operationFile= echobase.common.operationMetadataFile= -echobase.common.resultsImportMode.esdu.byEchotype= -echobase.common.resultsImportMode.esdu.byEchotypeAndSpeciesCategory= -echobase.common.resultsImportMode.esdu.bySpeciesAndAgeCategory= -echobase.common.resultsImportMode.esdu.bySpeciesAndSizeCategory= +echobase.common.resultsImportMode.esdu= echobase.common.resultsImportMode.map= echobase.common.resultsImportMode.region= echobase.common.resultsImportMode.voyage= Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties =================================================================== --- trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2012-03-29 21:24:34 UTC (rev 452) @@ -9,10 +9,10 @@ echobase.common.commonDataImportMode.all=Import Voyage / Transit / Transects echobase.common.commonDataImportMode.transect=Import Transects echobase.common.echotypeFile=Fichier echotype -echobase.common.esduByEchotypeAndSpeciesCategoryFile=Fichier d'import -echobase.common.esduByEchotypeFile=Fichier d'import -echobase.common.esduBySpeciesAndAgeCategoryFile=Fichier d'import -echobase.common.esduBySpeciesAndSizeCategoryFile=Fichier d'import +echobase.common.esduByEchotypeAndSpeciesCategoryFile=Fichier ESDU / Echotype / Catégorie Espèce +echobase.common.esduByEchotypeFile=Fichier ESDU / Echotype +echobase.common.esduBySpeciesAndAgeCategoryFile=Fichier ESDU / Espèce / Catégorie Age +echobase.common.esduBySpeciesAndSizeCategoryFile=Fichier ESDU / Espèce / Catégorie Taille echobase.common.gearMetadataFile=Fichier Méta-données d'engin echobase.common.importDataMode.accousticData=Import des données accoustiques echobase.common.importDataMode.catchesData=Import des données de pêche @@ -25,10 +25,7 @@ echobase.common.moviesFile=Fichier Movies echobase.common.operationFile=Fichier Opérations echobase.common.operationMetadataFile=Fichier Méta-données opération -echobase.common.resultsImportMode.esdu.byEchotype=Import des résultats de cellule esdu par echotype -echobase.common.resultsImportMode.esdu.byEchotypeAndSpeciesCategory=Import des résultats de cellule esdu par echotype et catégorie d'espèce -echobase.common.resultsImportMode.esdu.bySpeciesAndAgeCategory=Import des résultats de cellule esdu par espèce et catégorie d'age -echobase.common.resultsImportMode.esdu.bySpeciesAndSizeCategory=Import des résultats de cellule esdu par espèce et catégorie de taille +echobase.common.resultsImportMode.esdu=Import des résultats de cellules de type esdu echobase.common.resultsImportMode.map=Import des cellules de type Carte echobase.common.resultsImportMode.region=Import des cellules de type Région echobase.common.resultsImportMode.voyage=Import des résultats du voyage Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-03-29 21:24:34 UTC (rev 452) @@ -67,7 +67,7 @@ conf.setResultLabel("resultLabel"); conf.setVoyageId(getVoyageId()); - conf.setImportMode(ResultsImportMode.ESDU_BY_ECHOTYPE); + conf.setImportMode(ResultsImportMode.ESDU); InputFile inputFile = conf.getEsduByEchotypeFile(); prepareInputFile(inputFile, getImportPath("byEchotype.csv.gz")); @@ -96,7 +96,7 @@ conf.setResultLabel("resultLabel"); conf.setVoyageId(getVoyageId()); - conf.setImportMode(ResultsImportMode.ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY); + conf.setImportMode(ResultsImportMode.ESDU); InputFile inputFile = conf.getEsduByEchotypeAndSpeciesCategoryFile(); prepareInputFile(inputFile, @@ -125,7 +125,7 @@ conf.setResultLabel("resultLabel"); conf.setVoyageId(getVoyageId()); - conf.setImportMode(ResultsImportMode.ESDU_BY_SPECIES_AND_SIZE_CATEGORY); + conf.setImportMode(ResultsImportMode.ESDU); InputFile intputFile = conf.getEsduBySpeciesAndSizeCategoryFile(); prepareInputFile(intputFile, @@ -157,7 +157,7 @@ conf.setResultLabel("resultLabel"); conf.setVoyageId(getVoyageId()); - conf.setImportMode(ResultsImportMode.ESDU_BY_SPECIES_AND_AGE_CATEGORY); + conf.setImportMode(ResultsImportMode.ESDU); InputFile inputFile = conf.getEsduBySpeciesAndAgeCategoryFile(); prepareInputFile(inputFile, Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResults.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResults.java 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureResults.java 2012-03-29 21:24:34 UTC (rev 452) @@ -89,30 +89,12 @@ } @InputConfig(methodName = "input") - public String modeEsduByEchotype() throws Exception { + public String modeEsdu() throws Exception { return execute(); } @InputConfig(methodName = "input") - public String modeEsduByEchotypeAndSpeciesCategory() throws Exception { - - return execute(); - } - - @InputConfig(methodName = "input") - public String modeEsduBySpeciesAndSizeCategory() throws Exception { - - return execute(); - } - - @InputConfig(methodName = "input") - public String modeEsduBySpeciesAndAgeCategory() throws Exception { - - return execute(); - } - - @InputConfig(methodName = "input") public String modeRegion() throws Exception { return execute(); Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java 2012-03-29 21:24:34 UTC (rev 452) @@ -0,0 +1,80 @@ +/* + * #%L + * EchoBase :: UI + * + * $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.ui.actions.importData; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.importdata.ResultsImportService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + +/** + * Gets all dataProcessings of the selected voyage. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.4 + */ +public class GetDataProcessingsForVoyage extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Selected voyage id. */ + protected String voyageId; + + protected Map<String, String> dataProcessings; + + public void setVoyageId(String voyageId) { + this.voyageId = voyageId; + } + + public Map<String, String> getDataProcessings() { + return dataProcessings; + } + + @Override + public String execute() throws Exception { + + if (StringUtils.isEmpty(voyageId)) { + dataProcessings = Maps.newLinkedHashMap(); + + } else { + + ResultsImportService service = + newService(ResultsImportService.class); + + Voyage voyage = service.getEntityById(Voyage.class, voyageId); + + Preconditions.checkNotNull( + voyage, + "Could not find voyage with id " + voyageId); + + dataProcessings = service.getDataProcessings(voyage); + } + + return SUCCESS; + } +} \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/GetDataProcessingsForVoyage.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsdu-validation.xml (from rev 438, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotype-validation.xml) =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsdu-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsdu-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -0,0 +1,53 @@ +<!-- + #%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://www.opensymphony.com/xwork/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.dataProcessingId"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.dataProcessing.required"/> + </field-validator> + </field> + + <field name="model.resultLabel"> + <field-validator type="nrequiredstring"> + <message key="echobase.error.import.resultLabel.required"/> + </field-validator> + </field> + + <field name="esduByEchotypeFile"> + <field-validator type="nfieldexpression"> + <param name="expression">model.oneEsduImportFile</param> + <message key="echobase.error.import.resultImportFile.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/ConfigureResults-ConfigureResults-modeEsdu-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotype-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotype-validation.xml 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotype-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -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://www.opensymphony.com/xwork/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="esduByEchotypeFile"> - <field-validator type="nfieldexpression"> - <param name="expression">model.esduByEchotypeFile.file!=null</param> - <message key="echobase.error.import.esduByEchotypeFile.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotypeAndSpeciesCategory-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotypeAndSpeciesCategory-validation.xml 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduByEchotypeAndSpeciesCategory-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -1,50 +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://www.opensymphony.com/xwork/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="esduByEchotypeAndSpeciesCategoryFile"> - <field-validator type="nfieldexpression"> - <param name="expression"> - model.esduByEchotypeAndSpeciesCategoryFile.file!=null - </param> - <message - key="echobase.error.import.esduByEchotypeAndSpeciesCategoryFile.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndAgeCategory-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndAgeCategory-validation.xml 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndAgeCategory-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -1,50 +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://www.opensymphony.com/xwork/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="esduBySpeciesAndAgeCategoryFile"> - <field-validator type="nfieldexpression"> - <param name="expression"> - model.esduBySpeciesAndAgeCategoryFile.file!=null - </param> - <message - key="echobase.error.import.esduBySpeciesAndAgeCategoryFile.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndSizeCategory-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndSizeCategory-validation.xml 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeEsduBySpeciesAndSizeCategory-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -1,50 +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://www.opensymphony.com/xwork/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="esduBySpeciesAndSizeCategoryFile"> - <field-validator type="nfieldexpression"> - <param name="expression"> - model.esduBySpeciesAndSizeCategoryFile.file!=null - </param> - <message - key="echobase.error.import.esduBySpeciesAndSizeCategoryFile.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeVoyage-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeVoyage-validation.xml 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureResults-ConfigureResults-modeVoyage-validation.xml 2012-03-29 21:24:34 UTC (rev 452) @@ -33,9 +33,7 @@ <field name="lengthAgeKeyFile"> <field-validator type="nfieldexpression"> - <param name="expression">model.lengthAgeKeyFile.file!=null || - model.lengthWeightKeyFile.file!=null || model.echotypeFile.file!=null - </param> + <param name="expression">model.oneVoyageImportFile</param> <message key="echobase.error.import.resultImportFile.required"/> </field-validator> </field> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResults.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResults.jsp 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResults.jsp 2012-03-29 21:24:34 UTC (rev 452) @@ -28,6 +28,9 @@ Configuration <s:text name="echobase.common.importDataMode.results"/> </title> +<script type="text/javascript" + src="<s:url value='/js/gridHelper.js' />"></script> + <script type="text/javascript"> jQuery(document).ready(function () { @@ -42,6 +45,14 @@ // show incoming mode var incomingVal = $('[name="model.importMode"][checked="checked"]').val(); $('#' + incomingVal).show(); + + $.autoSelectVoyageAndDataProcessing( + $('#voyageSelectBox'), + $('#dataProcessingSelectBox'), + '<s:url action="getDataProcessingsForVoyage" namespace="/importData"/>', + '<s:property value="model.voyageId"/>', + '<s:property value="model.dataProcessingId"/>' + ); }); </script> @@ -77,7 +88,7 @@ <s:submit action="ConfigureResults-modeVoyage" key='echobase.action.import'/> </s:form> -<s:form id="ESDU_BY_ECHOTYPE" namespace="/importData" method="POST" +<s:form id="ESDU" namespace="/importData" method="POST" enctype="multipart/form-data" cssClass="hidden importMode"> <fieldset> @@ -85,99 +96,33 @@ <s:text name="echobase.legend.importData.configure"/> </legend> - <s:hidden key="model.importMode" value="ESDU_BY_ECHOTYPE" label=''/> + <s:hidden key="model.importMode" value="ESDU" label=''/> - <s:select key="model.voyageId" required="true" + <s:select id='voyageSelectBox' key="model.voyageId" required="true" label='%{getText("echobase.common.voyage")}' list="voyages" headerKey="" headerValue=""/> + <sj:select id='dataProcessingSelectBox' key="model.dataProcessingId" + required="true" + label='%{getText("echobase.common.dataProcessing")}'/> + <s:textfield key="model.resultLabel" size="40" required="true" label='%{getText("echobase.common.resultLabel")}'/> <s:file key="esduByEchotypeFile" required="true" label='%{getText("echobase.common.esduByEchotypeFile")}'/> - </fieldset> - <br/> - <s:submit action="ConfigureResults-modeEsduByEchotype" - key='echobase.action.import'/> -</s:form> -<s:form id="ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY" cssClass="hidden importMode" - namespace="/importData" method="POST" enctype="multipart/form-data"> - - <fieldset> - <legend> - <s:text name="echobase.legend.importData.configure"/> - </legend> - - <s:hidden key="model.importMode" - value="ESDU_BY_ECHOTYPE_AND_SPECIES_CATEGORY" label=''/> - - <s:select key="model.voyageId" required="true" - label='%{getText("echobase.common.voyage")}' - list="voyages" headerKey="" headerValue=""/> - - <s:textfield key="model.resultLabel" size="40" required="true" - label='%{getText("echobase.common.resultLabel")}'/> - <s:file key="esduByEchotypeAndSpeciesCategoryFile" required="true" label='%{getText("echobase.common.esduByEchotypeAndSpeciesCategoryFile")}'/> - </fieldset> - <br/> - <s:submit action="ConfigureResults-modeEsduByEchotypeAndSpeciesCategory" - key='echobase.action.import'/> -</s:form> -<s:form id="ESDU_BY_SPECIES_AND_SIZE_CATEGORY" enctype="multipart/form-data" - namespace="/importData" method="POST" cssClass="hidden importMode"> - - <fieldset> - <legend> - <s:text name="echobase.legend.importData.configure"/> - </legend> - - <s:hidden key="model.importMode" - value="ESDU_BY_SPECIES_AND_SIZE_CATEGORY" label=''/> - - <s:select key="model.voyageId" required="true" - label='%{getText("echobase.common.voyage")}' - list="voyages" headerKey="" headerValue=""/> - - <s:textfield key="model.resultLabel" size="40" required="true" - label='%{getText("echobase.common.resultLabel")}'/> - <s:file key="esduBySpeciesAndSizeCategoryFile" required="true" label='%{getText("echobase.common.esduBySpeciesAndSizeCategoryFile")}'/> - </fieldset> - <br/> - <s:submit action="ConfigureResults-modeEsduBySpeciesAndSizeCategory" - key='echobase.action.import'/> -</s:form> -<s:form id="ESDU_BY_SPECIES_AND_AGE_CATEGORY" cssClass="hidden importMode" - namespace="/importData" method="POST" enctype="multipart/form-data"> - - <fieldset> - <legend> - <s:text name="echobase.legend.importData.configure"/> - </legend> - - <s:hidden key="model.importMode" - value="ESDU_BY_SPECIES_AND_AGE_CATEGORY" label=''/> - - <s:select key="model.voyageId" required="true" - label='%{getText("echobase.common.voyage")}' - list="voyages" headerKey="" headerValue=""/> - - <s:textfield key="model.resultLabel" size="40" required="true" - label='%{getText("echobase.common.resultLabel")}'/> - <s:file key="esduBySpeciesAndAgeCategoryFile" required="true" label='%{getText("echobase.common.esduBySpeciesAndAgeCategoryFile")}'/> </fieldset> <br/> - <s:submit action="ConfigureResults-modeEsduBySpeciesAndAgeCategory" - key='echobase.action.import'/> + <s:submit action="ConfigureResults-modeEsdu" key='echobase.action.import'/> </s:form> <s:form id="REGION" namespace="/importData" method="POST" Modified: trunk/echobase-ui/src/main/webapp/js/gridHelper.js =================================================================== --- trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-03-29 21:17:47 UTC (rev 451) +++ trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-03-29 21:24:34 UTC (rev 452) @@ -56,8 +56,7 @@ addAddRowTopic:function (gridId, url) { $.subscribe(gridId + '-rowAdd', function (event) { - var url = event.data.url; - window.location = url; + window.location = event.data.url; }, {id:gridId, url:url}); }, @@ -68,13 +67,13 @@ if (opts && opts['selectedRow']) { var selectedId = opts['selectedRow']; var parameterName = event.data.parameterName; - var params = {} + var params = {}; params[parameterName] = selectedId; - var url = $.prepareUrl(event.data.url, params); - window.location = url; + window.location = $.prepareUrl(event.data.url, params); } }, {id:gridId, url:url, parameterName:parameterName}); }, + addMultiRowTopic:function (gridId, action, target, checkboxName, callback) { $.subscribe(gridId + '-row' + action, function (event) { var gridId = event.data.id; @@ -169,12 +168,12 @@ }, // auto-selection des voyages - vessel - autoSelectVoyageAndVessel:function (voyageSelectBox, vesselSelectBox, getVesselsUrl, voyageId, vesselId) { + autoSelectVoyageAndVessel:function (voyageSelectBox, vesselSelectBox, getUrl, voyageId, vesselId) { voyageSelectBox.change({vesselSelectBox:vesselSelectBox, - getVesselsUrl:getVesselsUrl}, function (event) { + getUrl:getUrl}, function (event) { - $.updateSelectBoxContent(event.data.getVesselsUrl, + $.updateSelectBoxContent(event.data.getUrl, {voyageId:this.value}, 'vessels', event.data.vesselSelectBox @@ -185,7 +184,7 @@ voyageSelectBox.change(voyageId); - $.updateSelectBoxContent(getVesselsUrl, + $.updateSelectBoxContent(getUrl, {voyageId:voyageId}, 'vessels', vesselSelectBox, function () { @@ -197,6 +196,37 @@ } ); } + }, + + // auto-selection des voyages - dataProcessing + autoSelectVoyageAndDataProcessing:function (voyageSelectBox, datapPocessingSelectBox, getUrl, voyageId, dataProcessingId) { + + voyageSelectBox.change({datapPocessingSelectBox:datapPocessingSelectBox, + getUrl:getUrl}, function (event) { + + $.updateSelectBoxContent(event.data.getUrl, + {voyageId:this.value}, + 'dataProcessings', + event.data.datapPocessingSelectBox + ); + }); + + if (voyageId) { + + voyageSelectBox.change(voyageId); + + $.updateSelectBoxContent(getUrl, + {voyageId:voyageId}, + 'dataProcessings', + datapPocessingSelectBox, function () { + + if (dataProcessingId) { + + datapPocessingSelectBox.val(dataProcessingId); + } + } + ); + } } }); @@ -232,8 +262,11 @@ addEvenAndOddClasses:function (gridId) { return $(document).addEvenAndOddClasses(gridId); }, - autoSelectVoyageAndVessel:function (voyageSelectBox, vesselSelectBox, getVesselsUrl, voyageId, vesselId) { - return $(document).autoSelectVoyageAndVessel(voyageSelectBox, vesselSelectBox, getVesselsUrl, voyageId, vesselId); + autoSelectVoyageAndVessel:function (voyageSelectBox, vesselSelectBox, getUrl, voyageId, vesselId) { + return $(document).autoSelectVoyageAndVessel(voyageSelectBox, vesselSelectBox, getUrl, voyageId, vesselId); + }, + autoSelectVoyageAndDataProcessing:function (voyageSelectBox, dataProcessingSelectBox, getUrl, voyageId, dataProcessingId) { + return $(document).autoSelectVoyageAndDataProcessing(voyageSelectBox, dataProcessingSelectBox, getUrl, voyageId, dataProcessingId); } }); })(jQuery);