This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See http://git.codelutin.com/tutti.git from 08f99eb Fixes #7930 Merge branch 'feature/7930' into develop new 4ff1062 Simplification du code de calcul du raising factor final new e5b5506 Ajout d'un test pour vérifier le calcul du raising factor final new b68bfe7 Ajout méthode pour récupérer la dernière catégorie renseignée new 8521235 Utilisation des bonnes catégories pour compléter le sampleWeight (utilisé pour le calcul du raising factor final) new 1fe175a Fixes #7992 Merge branch 'feature/7992_erreur_calcul_coef_final' into develop The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 1fe175a67e58c2c85ac00ef249bea1767202a47c Merge: 08f99eb 8521235 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:35:11 2016 +0100 Fixes #7992 Merge branch 'feature/7992_erreur_calcul_coef_final' into develop commit 8521235ff2f6fc8bb6a1a5926419137495f3acf5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:34:54 2016 +0100 Utilisation des bonnes catégories pour compléter le sampleWeight (utilisé pour le calcul du raising factor final) commit b68bfe7b914f1b9021740fc1d2337e9242c92e38 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:34:23 2016 +0100 Ajout méthode pour récupérer la dernière catégorie renseignée commit e5b55063fcc8fe59bbe2289438bf179d852437fe Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:33:58 2016 +0100 Ajout d'un test pour vérifier le calcul du raising factor final commit 4ff106228c6baa37e75465ce10bb42f2ce33f93b Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Feb 19 07:01:27 2016 +0100 Simplification du code de calcul du raising factor final Summary of changes: .../tutti/service/genericformat/csv/CatchRow.java | 7 ++++ .../producer/CsvProducerForCatch.java | 28 ++++++++++---- ... => GenericFormatExportServiceAno7992Test.java} | 44 ++++++++++++---------- .../resources/genericFormat/ano7992.tuttiProtocol | 22 +++++++++++ 4 files changed, 75 insertions(+), 26 deletions(-) copy tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/{GenericFormatExportServiceAno5804Test.java => GenericFormatExportServiceAno7992Test.java} (53%) create mode 100644 tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 4ff106228c6baa37e75465ce10bb42f2ce33f93b Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Feb 19 07:01:27 2016 +0100 Simplification du code de calcul du raising factor final --- .../producer/CsvProducerForCatch.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java index cbcd40f..cd0e728 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java @@ -84,7 +84,9 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { // see http://forge.codelutin.com/issues/5110 for (CatchRow row : rows) { - float finalRaisingFactor = computeFinalRaisingFactor(row, speciesCatchRaisingFactor, benthosCatchRaisingFactor); + Float raisingFactor = row.isBenthos() ? benthosCatchRaisingFactor : speciesCatchRaisingFactor; + + float finalRaisingFactor = computeFinalRaisingFactor(row, raisingFactor); row.setFinalRaisingFactor(finalRaisingFactor); } @@ -105,6 +107,13 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { addBenthosBatches(operationExportContext, rootBenthosBatch, benthosCatchRaisingFactor, batchWeightUnit, rows); + for (CatchRow row : rows) { + + float finalRaisingFactor = computeFinalRaisingFactor(row, benthosCatchRaisingFactor); + row.setFinalRaisingFactor(finalRaisingFactor); + + } + return rows; } @@ -121,6 +130,13 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { addSpeciesBatches(operationExportContext, rootSpeciesBatch, speciesCatchRaisingFactor, batchWeightUnit, rows); + for (CatchRow row : rows) { + + float finalRaisingFactor = computeFinalRaisingFactor(row, speciesCatchRaisingFactor); + row.setFinalRaisingFactor(finalRaisingFactor); + + } + return rows; } @@ -466,13 +482,13 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { } } - protected float computeFinalRaisingFactor(CatchRow row, Float speciesCatchRaisingFactor, Float benthosCatchRaisingFactor) { + protected float computeFinalRaisingFactor(CatchRow row, Float raisingFactor) { float finalRaisingFactor; if (row.isVrac()) { - finalRaisingFactor = row.isBenthos() ? benthosCatchRaisingFactor : speciesCatchRaisingFactor; + finalRaisingFactor = raisingFactor; } else { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit e5b55063fcc8fe59bbe2289438bf179d852437fe Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:33:58 2016 +0100 Ajout d'un test pour vérifier le calcul du raising factor final --- .../GenericFormatExportServiceAno7992Test.java | 131 +++++++++++++++++++++ .../resources/genericFormat/ano7992.tuttiProtocol | 22 ++++ 2 files changed, 153 insertions(+) diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java new file mode 100644 index 0000000..2455ee0 --- /dev/null +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java @@ -0,0 +1,131 @@ +package fr.ifremer.tutti.service.genericformat; + +/* + * #%L + * Tutti :: Service + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.io.Files; +import fr.ifremer.tutti.persistence.ProgressionModel; +import fr.ifremer.tutti.persistence.model.ProgramDataModel; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.ServiceDbResource; +import fr.ifremer.tutti.service.TuttiServiceContext; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import java.io.File; +import java.nio.file.Path; + +/** + * Created on 9/22/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 4.5 + */ +public class GenericFormatExportServiceAno7992Test { + + @ClassRule + public static final ServiceDbResource dbResource = ServiceDbResource.readDb("dbAno7992"); + + public static final String CATCH_FILE_CONTENT + = "Annee;Serie;Serie_Partielle;Code_Station;Id_Operation;Poche;Code_Taxon;Code_Espece_Campagne;Nom_Scientifique;Benthos;Lot_A_Confirmer;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Commentaire_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;Commentaire_Class_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Commentaire [...] + + "2015;Campagne EVHOE;;T0696;1;1;949;NEPH-NOR;Nephrops norvegicus;N;N;Vrac;1;3.2;;Poids;kg;;NA;;;;;kg;;Male;1;2.54;;Poids;kg;;NA;;;;;kg;;NA;;;;;kg;;;;;;;;;;?;2.54;2.519685;2.3188405;CAM-EVHOE;311;100004;NA;;300;100005;NA;;NA;\n" + + "2015;Campagne EVHOE;;T0696;1;1;949;NEPH-NOR;Nephrops norvegicus;N;N;Vrac;1;3.2;;Poids;kg;;NA;;;;;kg;;Femelle;2;0.22;;Poids;kg;;NA;;;;;kg;;NA;;;;;kg;;;;;;;;;;?;0.22;29.09091;2.3188405;CAM-EVHOE;311;100004;NA;;301;100006;NA;;NA;\n"; + + protected GenericFormatExportService service; + + protected PersistenceService persistenceService; + + protected ServiceDbResource.DataContext dataContext; + + protected ProgressionModel progressionModel; + + protected File dataDirectory; + + public static final String PROGRAM_ID = "CAM-EVHOE"; + + public static final String CRUISE_ID = "100000"; + + public static final String OPERATION_1_ID = "100000"; + + @Before + public void setUp() throws Exception { + + dataDirectory = dbResource.getConfig().getDataDirectory(); + + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + + persistenceService = serviceContext.getService(PersistenceService.class); + + dbResource.loadInternalProtocolFile("genericFormat", "ano7992"); + + dbResource.setCountryInConfig("12"); + dbResource.openDataContext(); + + service = serviceContext.getService(GenericFormatExportService.class); + + dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1, OPERATION_1_ID); + + progressionModel = new ProgressionModel(); + + } + + @Test + public void exportCruise() throws Exception { + + File exportFile = new File(dataDirectory, "exportCruise.zip"); + + Files.createParentDirs(exportFile); + + Assert.assertFalse(exportFile.exists()); + + String programId = dataContext.program.getId(); + String cruiseId = dataContext.cruise.getId(); + + ProgramDataModel dataToExport = persistenceService.loadCruises(programId, true, cruiseId); + + GenericFormatExportConfiguration exportConfiguration = new GenericFormatExportConfiguration(); + exportConfiguration.setExportFile(exportFile); + exportConfiguration.setExportAttachments(false); + exportConfiguration.setExportSpecies(true); + exportConfiguration.setExportBenthos(false); + exportConfiguration.setExportMarineLitter(false); + exportConfiguration.setExportAccidentalCatch(false); + exportConfiguration.setExportIndividualObservation(false); + exportConfiguration.setDataToExport(dataToExport); + + int nbSteps = service.getExportNbSteps(exportConfiguration); + progressionModel.setTotal(nbSteps); + + GenericFormatExportResult exportResult = service.export(exportConfiguration, progressionModel); + Path catchPath = exportResult.getArchive().getCatchPath(); + String catchFileContent = new String(java.nio.file.Files.readAllBytes(catchPath)); + System.out.println("Catch file:\n" + catchFileContent); + + Assert.assertEquals(CATCH_FILE_CONTENT, catchFileContent); + + } + +} diff --git a/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol b/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol new file mode 100644 index 0000000..1f39308 --- /dev/null +++ b/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol @@ -0,0 +1,22 @@ +id: 8dd7864b-c72c-4fef-834e-c2c3bd419abb +name: ano7992 +lengthClassesPmfmId: +- 41 +programId: CAM-EVHOE +species: +- !SpeciesProtocol + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 41 + mandatorySampleCategoryId: + - 198 + - 196 + - 1682 + - 1702 + - 1478 + - 1418 + - 101 + speciesReferenceTaxonId: 949 + speciesSurveyCode: NEPH-NOR + weightEnabled: true +version: 3 -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit b68bfe7b914f1b9021740fc1d2337e9242c92e38 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:34:23 2016 +0100 Ajout méthode pour récupérer la dernière catégorie renseignée --- .../java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java index 7dc6dc1..f5fb734 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java @@ -30,6 +30,8 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * A row in a catch export. @@ -177,6 +179,11 @@ public class CatchRow extends RowWithOperationContextSupport { return sampleCategory; } + public ExportSampleCategory getLastSampleCategoryFilled() { + List<ExportSampleCategory> list = sampleCategory.stream().filter(Objects::nonNull).collect(Collectors.toList()); + return list.isEmpty() ? null:list.get(list.size()-1); + } + public Float getFinalRaisingFactor() { return finalRaisingFactor; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 8521235ff2f6fc8bb6a1a5926419137495f3acf5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:34:54 2016 +0100 Utilisation des bonnes catégories pour compléter le sampleWeight (utilisé pour le calcul du raising factor final) --- .../tutti/service/genericformat/producer/CsvProducerForCatch.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java index cd0e728..13501b2 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java @@ -320,8 +320,6 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { } else { - int categoryIndex = currentRow.getSampleCategory().size(); - float sampleComputedWeight = 0f; for (SpeciesBatch childBatch : speciesBatch.getChildBatchs()) { @@ -333,7 +331,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { childBatch, totalBatchWeight); - ExportSampleCategory exportSampleCategory = childRow.getSampleCategory().get(categoryIndex); + ExportSampleCategory exportSampleCategory = childRow.getLastSampleCategoryFilled(); if (exportSampleCategory != null) { Float categoryWeight = Numbers.getValueOrComputedValue( exportSampleCategory.getCategoryWeight(), @@ -351,7 +349,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { sampleComputedWeight += categoryWeight; } } - currentRow.getSampleCategory().get(categoryIndex - 1).setSampleComputedWeight(sampleComputedWeight); + currentRow.getLastSampleCategoryFilled().setSampleComputedWeight(sampleComputedWeight); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 1fe175a67e58c2c85ac00ef249bea1767202a47c Merge: 08f99eb 8521235 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:35:11 2016 +0100 Fixes #7992 Merge branch 'feature/7992_erreur_calcul_coef_final' into develop .../tutti/service/genericformat/csv/CatchRow.java | 7 ++ .../producer/CsvProducerForCatch.java | 28 +++-- .../GenericFormatExportServiceAno7992Test.java | 131 +++++++++++++++++++++ .../resources/genericFormat/ano7992.tuttiProtocol | 22 ++++ 4 files changed, 181 insertions(+), 7 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm