Author: tchemit Date: 2013-09-25 19:03:03 +0200 (Wed, 25 Sep 2013) New Revision: 1227 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1227 Log: fixes #3313: [EXPORT GENERIQUE] Ne pas bloquer l'export en cas de probl?\195?\168me sur l'?\195?\169l?\195?\169vation refs #3314: [EXPORT GENERIQUE] erreur ?\195?\160 l'export si pas d'engin affect?\195?\169 sur l'op?\195?\169ration Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -74,7 +74,7 @@ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR); newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME); newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART); - newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME); + newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?"); newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER); newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER); newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -67,7 +67,7 @@ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR); newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME); newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART); - newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME); + newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?"); newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER); newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER); newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION); @@ -80,27 +80,6 @@ addSampleCategory(entry.getLabel(), entry.getOrder()); } -// for (SampleCategoryEnum sampleCategoryEnum : samplingOrder) { -// switch (sampleCategoryEnum) { -// -// case sortedUnsorted: -// addSampleCategory("VracHorsVrac", CatchExportRow.SORTED_UNSORTED_SAMPLE_CATEGORY); -// break; -// case size: -// addSampleCategory("Cat_Tri", CatchExportRow.SIZE_SAMPLE_CATEGORY); -// break; -// case sex: -// addSampleCategory("Sexe", CatchExportRow.SEX_SAMPLE_CATEGORY); -// break; -// case maturity: -// addSampleCategory("Maturite", CatchExportRow.MATURITY_SAMPLE_CATEGORY); -// break; -// case age: -// addSampleCategory("Age", CatchExportRow.AGE_SAMPLE_CATEGORY); -// break; -// } -// } - // mensuration newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID); @@ -139,12 +118,12 @@ // compute species total weight in catch - float sortedBatchWeight = TuttiEntities.getValueOrComputedValue( + Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue( speciesBatch.getSampleCategoryWeight(), speciesBatch.getSampleCategoryComputedWeight()); - float totalBatchWeight = speciesCatchRaisingFactor * - sortedBatchWeight; + float totalBatchWeight = sortedBatchWeight == null ? 0 : speciesCatchRaisingFactor * + sortedBatchWeight; prepareSortedRows(persistenceService, row, @@ -167,12 +146,12 @@ // compute species total weight in catch - float sortedBatchWeight = TuttiEntities.getValueOrComputedValue( + Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue( benthosBatch.getSampleCategoryWeight(), benthosBatch.getSampleCategoryComputedWeight()); - float totalBatchWeight = benthosCatchRaisingFactor * - sortedBatchWeight; + float totalBatchWeight = sortedBatchWeight == null ? 0 : benthosCatchRaisingFactor * + sortedBatchWeight; prepareSortedRows(persistenceService, row, @@ -422,7 +401,7 @@ CatchExportRow row = currentRow.copy(); row.addComment(benthosBatch.getComment()); - float referenceWeight = TuttiEntities.getValueOrComputedValue( + Float referenceWeight = TuttiEntities.getValueOrComputedValue( benthosBatch.getSampleCategoryWeight(), benthosBatch.getSampleCategoryComputedWeight()); @@ -433,9 +412,9 @@ protected void setRaisingFactor(CatchExportRow row, float totalBatchWeight, - float referenceWeight) { + Float referenceWeight) { row.setReferenceWeight(referenceWeight); - row.setRaisingFactor(totalBatchWeight / referenceWeight); + row.setRaisingFactor(referenceWeight == null ? 1.0f : (totalBatchWeight / referenceWeight)); } protected void prepareBatch(CatchExportRow currentRow, @@ -465,15 +444,7 @@ } protected void addSampleCategory(String headerPrefix, int categoryOrder) { -// String categoryName = CatchExportRow.SAMPLE_CATEGORY + "[" + categoryOrder + "]"; -// newNullableColumnForExport(headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER); -// newNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName + "." + ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER); -// newNullableColumnForExport("Tot_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT); -// newNullableColumnForExport("Ech_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT); -// newNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE); -// newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT); - String categoryName = CatchExportRow.SAMPLE_CATEGORY; newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER); newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -88,7 +88,7 @@ protected Species species; - protected float referenceWeight; + protected Float referenceWeight; protected float raisingFactor; @@ -106,7 +106,7 @@ this.fishingOperation = fishingOperation; } - public void setReferenceWeight(float referenceWeight) { + public void setReferenceWeight(Float referenceWeight) { this.referenceWeight = referenceWeight; } @@ -186,7 +186,7 @@ this.species = species; } - public float getReferenceWeight() { + public Float getReferenceWeight() { return referenceWeight; } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -73,7 +73,7 @@ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR); newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME); newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART); - newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME); + newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?"); newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER); newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER); newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -51,7 +51,7 @@ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR); newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME); newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART); - newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME); + newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?"); newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER); newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER); newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -196,7 +196,16 @@ } // check cruise fishing operations - checkCruise(progressionModel, cruise); + TuttiBusinessException checkError = null; + try { + checkCruise(progressionModel, cruise); + } catch (TuttiBusinessException e) { + // error while checking cruise + if (log.isDebugEnabled()) { + log.debug("Got a check cruise error", e); + } + checkError = e; + } File basedir = new File(context.getConfig().newTempFile( "exportCruise"), "exportCruise-" + cruiseId); @@ -217,6 +226,11 @@ } finally { IOUtils.closeQuietly(exportContext); } + + if (checkError != null) { + // rethrow error + throw checkError; + } } protected ExportContext createExportContext(File basedir, @@ -277,6 +291,7 @@ String cruiseStr = cruiseDecorator.toString(cruise); throw new TuttiBusinessException( _("tutti.service.export.invalid.cruise", cruiseStr, sb.toString())); +// _("tutti.service.export.invalid.cruise2", cruiseStr, sb.toString())); } } @@ -514,7 +529,7 @@ catchBatch.getCatchTotalWeight(), catchBatch.getCatchTotalComputedWeight()); - float totalUnsortedWeight = + Float totalUnsortedWeight = catchBatch.getCatchTotalUnsortedComputedWeight(); @@ -537,10 +552,10 @@ //FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée) // (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale) - Float catchRaisingFactor = (totalWeight - totalUnsortedWeight) / totalSortedWeight; + Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight; - Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor; - Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor; + Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor); + Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor); if (log.isDebugEnabled()) { String message = "\ncatchTotalWeight : " + totalWeight + @@ -552,7 +567,7 @@ "\nspeciesCatchRaisingFactor : " + speciesCatchRaisingFactor + "\nbenthosCatchRaisingFactor : " + benthosCatchRaisingFactor; - log.info(message); + log.debug(message); } List<CatchExportRow> rows = Lists.newArrayList(); @@ -665,6 +680,8 @@ Map<String, Species> speciesById; + String checkError; + ExportContext(File basedir, char csvSeparator, DecoratorService decoratorService, @@ -784,6 +801,14 @@ IOUtils.closeQuietly(speciesWriter); } + public String getCheckError() { + return checkError; + } + + public void setCheckError(String checkError) { + this.checkError = checkError; + } + public void addSpecies(Species species) { String speciesId = species.getId(); if (!speciesToExport.containsKey(speciesId)) { @@ -816,12 +841,13 @@ private final CatchBatch catchBatch; - private final BatchContainer<MarineLitterBatch> rootMarineLitterBatch; + private BatchContainer<MarineLitterBatch> rootMarineLitterBatch; - private final BatchContainer<SpeciesBatch> rootSpeciesBatch; + private BatchContainer<SpeciesBatch> rootSpeciesBatch; - private final BatchContainer<BenthosBatch> rootBenthosBatch; + private BatchContainer<BenthosBatch> rootBenthosBatch; + protected boolean withCatchBatch; public OperationContext(FishingOperation operation, @@ -844,22 +870,43 @@ persistenceService.getCatchBatchFromFishingOperation( operationId); - rootSpeciesBatch = - tuttiWeightComputingService.getComputedSpeciesBatches(operation); + boolean withError = false; - rootBenthosBatch = - tuttiWeightComputingService.getComputedBenthosBatches(operation); + try { + rootSpeciesBatch = tuttiWeightComputingService.getComputedSpeciesBatches(operation); + } catch (Exception e) { + withError = true; + rootSpeciesBatch = + persistenceService.getRootSpeciesBatch(operationId, null); + } - rootMarineLitterBatch = - tuttiWeightComputingService.getComputedMarineLitterBatches(operation, catchBatch.getMarineLitterTotalWeight()); + try { + rootBenthosBatch = + tuttiWeightComputingService.getComputedBenthosBatches(operation); + } catch (Exception e) { + withError = true; + rootBenthosBatch = + persistenceService.getRootBenthosBatch(operationId, null); + } + try { + rootMarineLitterBatch = + tuttiWeightComputingService.getComputedMarineLitterBatches(operation, catchBatch.getMarineLitterTotalWeight()); + } catch (Exception e) { + withError = true; + rootMarineLitterBatch = + persistenceService.getRootMarineLitterBatch(operationId); + } + // apply compute weights - tuttiWeightComputingService.computeCatchBatchWeights( - catchBatch, - rootSpeciesBatch, - rootBenthosBatch, - rootMarineLitterBatch); + if (!withError) { + tuttiWeightComputingService.computeCatchBatchWeights( + catchBatch, + rootSpeciesBatch, + rootBenthosBatch, + rootMarineLitterBatch); + } } else { if (log.isWarnEnabled()) { log.warn("Skip fishing operation " + operationId + Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties =================================================================== --- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-09-25 17:03:03 UTC (rev 1227) @@ -57,6 +57,7 @@ tutti.service.export.closeContext.error= tutti.service.export.context.error= tutti.service.export.invalid.cruise= +tutti.service.export.invalid.cruise2= tutti.service.export.invalid.fishingOperation= tutti.service.export.operations.error= tutti.service.export.parameters.error= Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties =================================================================== --- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-09-25 17:03:03 UTC (rev 1227) @@ -56,7 +56,8 @@ tutti.service.export.catches.error=Erreur lors de l'export des captures tutti.service.export.closeContext.error=Erreur lors de la fermeture du contexte d'export tutti.service.export.context.error=Erreur lors de la création des fichiers pour l'export -tutti.service.export.invalid.cruise=L'export de la campagne %s ne peut pas être réalisé suite aux erreurs rencontrées sur ses traits lors de l'élévation des poids \:<ul>%s</ul> +tutti.service.export.invalid.cruise=Erreur d'élévation de poids sur les traits de la campagne %s \:<ul>%s</ul> +tutti.service.export.invalid.cruise2=L'export de la campagne %s ne peut pas être réalisé suite aux erreurs rencontrées sur ses traits lors de l'élévation des poids \:<ul>%s</ul> tutti.service.export.invalid.fishingOperation=<li>L'élévation des poids ne peut pas être réalisée sur le trait %s, pour la raison suivante \:<ul><li>%s</li></ul></li> tutti.service.export.operations.error=Erreur lors de l'export des traits tutti.service.export.parameters.error=Erreur lors de l'export des paramètres Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -52,6 +52,8 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.util.List; import java.util.Locale; import java.util.Map; @@ -100,6 +102,21 @@ } } + public static void assertFileContent(String message, + URL actualFile, + String expectedContent) throws IOException { + + Assert.assertNotNull(actualFile); + InputStream inputStream = actualFile.openStream(); + Assert.assertNotNull(inputStream); + String fileContent = IOUtils.toString(inputStream, Charsets.UTF_8).trim(); + Assert.assertEquals(expectedContent, fileContent); + + if (log.isInfoEnabled()) { + log.info(message + fileContent); + } + } + protected TuttiServiceContext createServiceContext(RessourceClassLoader loader, TuttiServiceConfig config) { return new TuttiServiceContext(loader, config) { Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -24,13 +24,22 @@ * #L% */ +import com.google.common.io.Files; +import fr.ifremer.tutti.TuttiBusinessException; +import fr.ifremer.tutti.persistence.ProgressionModel; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; import fr.ifremer.tutti.service.TuttiServiceContext; +import fr.ifremer.tutti.service.catches.TuttiWeightComputingService; +import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; import java.io.File; +import java.net.URL; +import java.util.List; /** * Test export of catches. @@ -52,27 +61,7 @@ public static final String OPERATION_2_ID = "100113"; - public static final String CATCH_CONTENT = - "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" + - "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" + - "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" + - "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" + - "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" + - "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" + - "\n" + - "avec \n" + - "\n" + - "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" + - "\n" + - "avec \n" + - "\n" + - "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;"; + public static final String OPERATION_3_ID = "100114"; protected TuttiExportService service; @@ -93,22 +82,184 @@ service = serviceContext.getService(TuttiExportService.class); - dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID); } @Test - public void exportCatches() throws Exception { + public void exportWithErrors() throws Exception { - TuttiExportService.ExportContext exportContext = - service.createExportContext(dataDirectory, null); + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + + PersistenceService persistenceService = serviceContext.getService(PersistenceService.class); + + // check there is a error while compute weight for a cruise + boolean errorDetected = false; + TuttiWeightComputingService computingService = serviceContext.getService(TuttiWeightComputingService.class); + List<FishingOperation> allFishingOperation = persistenceService.getAllFishingOperation(CRUISE_ID); + for (FishingOperation fishingOperation : allFishingOperation) { + try { + computingService.getComputedSpeciesBatches(fishingOperation); + } catch (Exception e) { + errorDetected = true; + break; + } + } + + Assert.assertTrue(errorDetected); + + File exportFile = new File(dataDirectory, "exportCruise.zip"); + + Files.createParentDirs(exportFile); + + Assert.assertFalse(exportFile.exists()); + + ProgressionModel progressionModel = new ProgressionModel(); + progressionModel.setTotal(9); try { - service.exportCatches(exportContext, dataContext.cruise, dataContext.operations); - } finally { - exportContext.close(); + service.exportCruise(CRUISE_ID, null, exportFile, progressionModel); + // got an error after but export was still performed + Assert.fail(); + } catch (TuttiBusinessException e) { + // got an error + Assert.assertTrue(true); } - ServiceDbResource.assertFileContent("Catch export:\n", - exportContext.catchFile, - CATCH_CONTENT); + // export perform, file exist + Assert.assertTrue(exportFile.exists()); + + String urlPrefix = "jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/"; + { + // check species file content + + URL url = new URL(urlPrefix + "species.csv"); + ServiceDbResource.assertFileContent("species export:\n", + url, + "Id;Code_Rubin;Nom Scientifique;Code campagne\n" + + "380;ACANECH;Acanthocardia echinata;;\n" + + "1358;ALOSALO;Alosa alosa;;\n" + + "1938;AGONCAT;Agonus cataphractus;;\n" + + "4622;ABIEABI;Abietinaria abietina;;\n" + + "11183;;Brissopsis atlantica;;"); + + } + + { + // check accidentalCatch file content + + URL url = new URL(urlPrefix + "accidentalCatch.csv"); + ServiceDbResource.assertFileContent("accidentalCatch export:\n", + url, + "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue"); + + } + + { + // check operation file content + + URL url = new URL(urlPrefix + "operation.csv"); + ServiceDbResource.assertFileContent("operation export:\n", + url, + "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" + + "2013;test elevation;1;B;2;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;\"Commentaire sur le trait B-2-1\n" + + "\n" + + "avec\n" + + "saut\n" + + "de \n" + + "ligne\";1000.0;Y;280.0;Y;20.0;Y;700.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;100.0;Y;100.0;N;50.0;Y;0.0;Y;2.0;N;0.0;Y;100.0;N;\n" + + "2013;test elevation;1;A;1;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;\"commentaire trait A-1-1\n" + + "Avec \n" + + "saut\n" + + "de\n" + + "ligne\n" + + "...\";1000.0;Y;180.0;Y;20.0;Y;800.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;\n" + + "2013;test elevation;1;C;3;1;?;278970;25/09/2013 00:00:00;;;25/09/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;"); + + } + + { + // check survey file content + + URL url = new URL(urlPrefix + "survey.csv"); + ServiceDbResource.assertFileContent("survey export:\n", + url, + "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" + + "2013;test elevation;1;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;test elevation_2013_1;;01/07/2013 00:00:00;La Barbotière (Gujan-Mestras);04/07/2013 00:00:00;La Barbotière (Gujan-Mestras);Adrian LEVREL;Alain BISEAU;;"); + + } + + { + // check individualObservation file content + + URL url = new URL(urlPrefix + "individualObservation.csv"); + ServiceDbResource.assertFileContent("individualObservation export:\n", + url, + "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue"); + + } + + { + // check catch file content + + URL url = new URL("jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/catch.csv"); + ServiceDbResource.assertFileContent("Catch export:\n", + url, + "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" + + "\n" + + "avec \n" + + "\n" + + "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" + + "\n" + + "avec \n" + + "\n" + + "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;\n" + + "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" + + "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" + + "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" + + "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" + + "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" + + "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;UNK - Indéterminé;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;0.0;\n" + + "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Mâle;2;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;0.0;\n" + + "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Femelle;3;;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;;1.0;"); + + } + + { + // check gearCaracteristics file content + + URL url = new URL(urlPrefix + "gearCaracteristics.csv"); + ServiceDbResource.assertFileContent("gearCaracteristics export:\n", + url, + "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur"); + + } + + { + // check marineLitter file content + + URL url = new URL(urlPrefix + "marineLitter.csv"); + ServiceDbResource.assertFileContent("marineLitter export:\n", + url, + "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;10;;\"Trait B-2-1 Macro dechet L1 Plastique (nb 10)\n" + + "\n" + + "avec \n" + + "\n" + + "commentaire...\";"); + + } + { + // check parameter file content + + URL url = new URL(urlPrefix + "parameter.csv"); + ServiceDbResource.assertFileContent("parameter export:\n", + url, + "Annee;Serie;Serie_Partielle;Id_Operation;NumOrdre_Station;Poche;Code_PMFM;Libelle_PMFm;Valeur"); + + } } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -25,10 +25,12 @@ */ import com.google.common.base.Preconditions; +import fr.ifremer.tutti.TuttiBusinessException; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.service.export.TuttiExportService; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -107,7 +109,12 @@ } TuttiExportService service = getContext().getTuttiExportService(); - service.exportCruise(cruise.getId(), protocol, file, progressionModel); + try { + service.exportCruise(cruise.getId(), protocol, file, progressionModel); + } catch (TuttiBusinessException e) { + String message = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage()); + TuttiUIContext.getErrorHelper().showErrorDialog(message); + } getHandler().resetEditCruiseAction(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 17:03:03 UTC (rev 1227) @@ -25,11 +25,13 @@ */ import com.google.common.base.Preconditions; +import fr.ifremer.tutti.TuttiBusinessException; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.service.export.TuttiExportService; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -109,7 +111,12 @@ } } TuttiExportService service = getContext().getTuttiExportService(); - service.exportProgram(program.getId(), protocol, file, progressionModel); + try { + service.exportProgram(program.getId(), protocol, file, progressionModel); + } catch (TuttiBusinessException e) { + TuttiBusinessException e2 = new TuttiBusinessException("Des erreurs sont apparues pendant l'élévation des poids<hr/>L'export a cependant été réalisé.", e.getCause()); + TuttiUIContext.getErrorHelper().showErrorDialog(null, e2); + } getHandler().resetEditProgramAction(); } Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 17:03:03 UTC (rev 1227) @@ -1020,6 +1020,7 @@ tutti.error.update.could.not.found.url= tutti.error.update.could.not.reach.url= tutti.error.write.startActionFile=could not write action content to file %s +tutti.exportCruise.action.exportErrors= tutti.exportCruise.action.success= tutti.exportCruiseForSumatra.action.chooseFile= tutti.exportCruiseForSumatra.action.success= Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 16:36:22 UTC (rev 1226) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 17:03:03 UTC (rev 1227) @@ -1022,6 +1022,7 @@ tutti.error.update.could.not.found.url=Mise à jour impossible (l'url <strong>%s</strong> n'existe pas) tutti.error.update.could.not.reach.url=Mise à jour impossible (l'url <strong>%s</strong> n'est pas joignable) tutti.error.write.startActionFile=impossible d'écrire dans le fichier %s +tutti.exportCruise.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids de la campagne <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s tutti.exportCruise.action.success=La campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>. tutti.exportCruiseForSumatra.action.chooseFile=Choisir le fichier d'export tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s