r1371 - in trunk: . tutti-persistence tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities tutti-service tutti-service/src/main/java/fr/ifremer/tutti/service/export tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf tutti-ui-swing tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos tutti-ui-swing
Author: tchemit Date: 2013-11-21 17:09:10 +0100 (Thu, 21 Nov 2013) New Revision: 1371 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1371 Log: - update to version 3.0-rc-1 - round number in sumatra export - prepare release Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java Removed: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java Modified: trunk/pom.xml trunk/tutti-persistence/pom.xml trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java trunk/tutti-service/pom.xml trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java trunk/tutti-ui-swing/pom.xml trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/pom.xml 2013-11-21 16:09:10 UTC (rev 1371) @@ -32,7 +32,7 @@ <groupId>fr.ifremer</groupId> <artifactId>tutti</artifactId> - <version>2.10-SNAPSHOT</version> + <version>3.0-rc-1-SNAPSHOT</version> <packaging>pom</packaging> <name>Tutti</name> Modified: trunk/tutti-persistence/pom.xml =================================================================== --- trunk/tutti-persistence/pom.xml 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-persistence/pom.xml 2013-11-21 16:09:10 UTC (rev 1371) @@ -27,7 +27,7 @@ <parent> <groupId>fr.ifremer</groupId> <artifactId>tutti</artifactId> - <version>2.10-SNAPSHOT</version> + <version>3.0-rc-1-SNAPSHOT</version> </parent> <groupId>fr.ifremer.tutti</groupId> Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -337,7 +337,7 @@ * * @param value the float to round. * @return the rounded value - * @since 2.10 + * @since 3.0-rc-1 */ public static float roundKiloGram(float value) { BigDecimal sumB = new BigDecimal(value); Modified: trunk/tutti-service/pom.xml =================================================================== --- trunk/tutti-service/pom.xml 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/pom.xml 2013-11-21 16:09:10 UTC (rev 1371) @@ -27,7 +27,7 @@ <parent> <groupId>fr.ifremer</groupId> <artifactId>tutti</artifactId> - <version>2.10-SNAPSHOT</version> + <version>3.0-rc-1-SNAPSHOT</version> </parent> <groupId>fr.ifremer.tutti</groupId> Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -1,13 +1,36 @@ package fr.ifremer.tutti.service.export; +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; /** * To store a species or batch entry within his speices informations, - * his sorted weight, total weight and percentage amoong the total catch - * weight. + * his sorted weight, total weight and optional his total number. * - * @since 2.10 + * @since 3.0-rc-1 */ public class ExportBatchEntry { Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java (from rev 1370, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java) =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java (rev 0) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -0,0 +1,362 @@ +package fr.ifremer.tutti.service.export; + +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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.base.Predicate; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.BatchContainer; +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.CatchBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.catches.WeightComputingService; + +import java.util.List; +import java.util.Map; + +/** + * Contains the global context for a catch export. + * <p/> + * Created on 11/21/13. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.0-rc-1 + */ +public class ExportCatchContext { + + final FishingOperation fishingOperation; + + final CatchBatch catchBatch; + + final BatchContainer<SpeciesBatch> rootSpeciesBatch; + + final BatchContainer<BenthosBatch> rootBenthosBatch; + + final BatchContainer<MarineLitterBatch> marineLitterBatches; + + final Predicate<SpeciesAbleBatch> vracPredicate; + + public static ExportCatchContext newExportContext(PersistenceService persistenceService, + WeightComputingService weightComputingService, + String fishingOperationId) { + + FishingOperation fishingOperation = + persistenceService.getFishingOperation(fishingOperationId); + + CatchBatch catchBatch = + persistenceService.getCatchBatchFromFishingOperation(fishingOperationId); + + BatchContainer<SpeciesBatch> rootSpeciesBatch = + weightComputingService.getComputedSpeciesBatches(fishingOperationId); + + BatchContainer<BenthosBatch> rootBenthosBatch = + weightComputingService.getComputedBenthosBatches(fishingOperationId); + + BatchContainer<MarineLitterBatch> marineLitterBatches = + weightComputingService.getComputedMarineLitterBatches( + fishingOperationId, + catchBatch.getMarineLitterTotalWeight()); + weightComputingService.computeCatchBatchWeights(catchBatch, + rootSpeciesBatch, + rootBenthosBatch, + marineLitterBatches); + + Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate(); + + ExportCatchContext result = new ExportCatchContext(vracPredicate, + fishingOperation, + catchBatch, + rootSpeciesBatch, + rootBenthosBatch, + marineLitterBatches); + return result; + + } + + private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate, + FishingOperation fishingOperation, + CatchBatch catchBatch, + BatchContainer<SpeciesBatch> rootSpeciesBatch, + BatchContainer<BenthosBatch> rootBenthosBatch, + BatchContainer<MarineLitterBatch> marineLitterBatches) { + this.vracPredicate = vracPredicate; + this.fishingOperation = fishingOperation; + this.catchBatch = catchBatch; + this.rootSpeciesBatch = rootSpeciesBatch; + this.rootBenthosBatch = rootBenthosBatch; + this.marineLitterBatches = marineLitterBatches; + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public float getCatchTotalWeight() { + float result = TuttiEntities.getValueOrComputedValue( + catchBatch.getCatchTotalWeight(), + catchBatch.getCatchTotalComputedWeight()); + return result; + } + + public float getCatchTotalSortedWeight() { + return catchBatch.getSpeciesTotalSampleSortedComputedWeight() + + catchBatch.getBenthosTotalSampleSortedComputedWeight(); + } + + public boolean withSpeciesBatches() { + return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren(); + } + + public boolean withBenthosBatches() { + return rootBenthosBatch != null && !rootBenthosBatch.isEmptyChildren(); + } + + public List<ExportBatchEntry> getSpeciesBatchEntry(boolean computeNumber) { + List<ExportBatchEntry> catchList = Lists.newArrayList(); + + if (withSpeciesBatches()) { + + Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap(); + + // ratio total species weight / total sorted sampled species weight + float rate = getSpeciesElevationRate(); + + List<SpeciesBatch> batches = rootSpeciesBatch.getChildren(); + for (SpeciesBatch batch : batches) { + + createExportBatchCatch( + batch, + catches, + rate, + computeNumber); + } + catchList.addAll(catches.values()); + } + return catchList; + } + + public List<ExportBatchEntry> getBenthosBatchEntry(boolean computeNumber) { + List<ExportBatchEntry> catchList = Lists.newArrayList(); + + if (withBenthosBatches()) { + + Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap(); + + // ratio total species weight / total sorted sampled species weight + float rate = getBenthosElevationRate(); + + List<BenthosBatch> batches = rootBenthosBatch.getChildren(); + for (BenthosBatch batch : batches) { + + createExportBatchCatch( + batch, + catches, + rate, + computeNumber); + } + + catchList.addAll(catches.values()); + } + return catchList; + } + + public ExportBatchEntry getInertAndLivingNotItemizedCatch() { + + ExportBatchEntry result = new ExportBatchEntry(null); + + float speciesRatio = getSpeciesElevationRate(); + float benthosRatio = getBenthosElevationRate(); + + Float speciesInterWeight = TuttiEntities.getValueOrComputedValue( + catchBatch.getSpeciesTotalInertWeight(), + catchBatch.getSpeciesTotalInertComputedWeight()); + + if (speciesInterWeight != null) { + result.addSortedWeight(speciesInterWeight); + result.addTotalWeight(speciesInterWeight * speciesRatio); + } + + Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue( + catchBatch.getSpeciesTotalLivingNotItemizedWeight(), + catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); + + if (speciesLivingNotItemizedWeigth != null) { + result.addSortedWeight(speciesLivingNotItemizedWeigth); + result.addTotalWeight(speciesLivingNotItemizedWeigth * speciesRatio); + } + + Float benthosInterWeight = TuttiEntities.getValueOrComputedValue( + catchBatch.getBenthosTotalInertWeight(), + catchBatch.getBenthosTotalInertComputedWeight()); + + if (benthosInterWeight != null) { + result.addSortedWeight(benthosInterWeight); + result.addTotalWeight(benthosInterWeight * benthosRatio); + } + + Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue( + catchBatch.getBenthosTotalLivingNotItemizedWeight(), + catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); + + if (benthosLivingNotItemizedWeight != null) { + result.addSortedWeight(benthosLivingNotItemizedWeight); + result.addTotalWeight(benthosLivingNotItemizedWeight * benthosRatio); + } + + return result; + } + + public boolean isVracBatch(SpeciesAbleBatch batch) { + return vracPredicate.apply(batch); + } + + protected float getSpeciesElevationRate() { + + float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight(); + + float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue( + catchBatch.getSpeciesTotalSortedWeight(), + catchBatch.getSpeciesTotalSortedComputedWeight()); + + // ratio total species weight / total sorted sampled species weight + float result = globalRatio * speciesTotalSortedWeight; + if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) { + result /= catchBatch.getSpeciesTotalSampleSortedComputedWeight(); + } + return result; + } + + protected float getBenthosElevationRate() { + + float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight(); + + float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue( + catchBatch.getBenthosTotalSortedWeight(), + catchBatch.getBenthosTotalSortedComputedWeight()); + + // ratio total benthos weight / total sorted sampled benthos weight + float result = globalRatio * benthosTotalSortedWeight; + if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) { + result /= catchBatch.getBenthosTotalSampleSortedComputedWeight(); + } + return result; + } + + protected void createExportBatchCatch(SpeciesAbleBatch batch, + Map<Species, ExportBatchEntry> catches, + float ratio, + boolean computeNumber) { + + Species species = batch.getSpecies(); + + ExportBatchEntry ktch = catches.get(species); + if (ktch == null) { + ktch = new ExportBatchEntry(batch); + catches.put(species, ktch); + } + + float sortedWeight = TuttiEntities.getValueOrComputedValue( + batch.getSampleCategoryWeight(), + batch.getSampleCategoryComputedWeight()); + + ktch.addSortedWeight(sortedWeight); + + boolean isVracBatch = isVracBatch(batch); + float speciesTotalWeight = sortedWeight; + if (isVracBatch) { + speciesTotalWeight *= ratio; + } + ktch.addTotalWeight(speciesTotalWeight); + + if (computeNumber) { + float number = Math.round(computeNumber(batch, 1.0f)); + if (isVracBatch) { + number *= ratio; + } + ktch.addNumber(Math.round(number)); + } + } + + protected float computeNumber(SpeciesAbleBatch batch, float rf) { + float result; + + float weight = TuttiEntities.getValueOrComputedValue( + batch.getSampleCategoryWeight(), + batch.getSampleCategoryComputedWeight()); + + if (batch.isChildBatchsEmpty()) { + + // on a leaf, get his weight + + Integer number = TuttiEntities.getValueOrComputedValue( + batch.getNumber(), + batch.getComputedNumber()); + if (number == null) { + + // no count + number = 0; + } + + // get the sample weight + Float subweight = TuttiEntities.getValueOrComputedValue( + batch.getWeight(), + batch.getComputedWeight()); + + if (subweight != null) { + + // with sub sample, update the raising factor + rf *= weight / subweight; + } + + result = number.floatValue() * rf; + } else { + + // get total weight of all childs + float totalWeight = 0.f; + for (SpeciesAbleBatch child : batch.getChildBatchs()) { + totalWeight += TuttiEntities.getValueOrComputedValue( + child.getSampleCategoryWeight(), + child.getSampleCategoryComputedWeight()); + } + + result = 0f; + + float rf2 = rf * weight / totalWeight; + // sum result of each child + for (SpeciesAbleBatch child : batch.getChildBatchs()) { + + result += computeNumber(child, rf2); + } + + } + return result; + } +} Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -36,6 +36,7 @@ import fr.ifremer.tutti.service.TuttiServiceContext; import fr.ifremer.tutti.service.catches.WeightComputingService; import fr.ifremer.tutti.service.export.ExportBatchEntry; +import fr.ifremer.tutti.service.export.ExportCatchContext; import freemarker.cache.ClassTemplateLoader; import freemarker.ext.beans.BeansWrapper; import freemarker.template.Configuration; Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/ExportCatchContext.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -1,337 +0,0 @@ -package fr.ifremer.tutti.service.export.pdf; - -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.CatchBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.service.catches.WeightComputingService; -import fr.ifremer.tutti.service.export.ExportBatchEntry; - -import java.util.List; -import java.util.Map; - -/** - * Created on 11/21/13. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since XXX - */ -public class ExportCatchContext { - - final FishingOperation fishingOperation; - - final CatchBatch catchBatch; - - final BatchContainer<SpeciesBatch> rootSpeciesBatch; - - final BatchContainer<BenthosBatch> rootBenthosBatch; - - final BatchContainer<MarineLitterBatch> marineLitterBatches; - - final Predicate<SpeciesAbleBatch> vracPredicate; - - public static ExportCatchContext newExportContext(PersistenceService persistenceService, - WeightComputingService weightComputingService, - String fishingOperationId) { - - FishingOperation fishingOperation = - persistenceService.getFishingOperation(fishingOperationId); - - CatchBatch catchBatch = - persistenceService.getCatchBatchFromFishingOperation(fishingOperationId); - - BatchContainer<SpeciesBatch> rootSpeciesBatch = - weightComputingService.getComputedSpeciesBatches(fishingOperationId); - - BatchContainer<BenthosBatch> rootBenthosBatch = - weightComputingService.getComputedBenthosBatches(fishingOperationId); - - BatchContainer<MarineLitterBatch> marineLitterBatches = - weightComputingService.getComputedMarineLitterBatches( - fishingOperationId, - catchBatch.getMarineLitterTotalWeight()); - weightComputingService.computeCatchBatchWeights(catchBatch, - rootSpeciesBatch, - rootBenthosBatch, - marineLitterBatches); - - Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate(); - - ExportCatchContext result = new ExportCatchContext(vracPredicate, - fishingOperation, - catchBatch, - rootSpeciesBatch, - rootBenthosBatch, - marineLitterBatches); - return result; - - } - - private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate, - FishingOperation fishingOperation, - CatchBatch catchBatch, - BatchContainer<SpeciesBatch> rootSpeciesBatch, - BatchContainer<BenthosBatch> rootBenthosBatch, - BatchContainer<MarineLitterBatch> marineLitterBatches) { - this.vracPredicate = vracPredicate; - this.fishingOperation = fishingOperation; - this.catchBatch = catchBatch; - this.rootSpeciesBatch = rootSpeciesBatch; - this.rootBenthosBatch = rootBenthosBatch; - this.marineLitterBatches = marineLitterBatches; - } - - public FishingOperation getFishingOperation() { - return fishingOperation; - } - - public float getCatchTotalWeight() { - float result = TuttiEntities.getValueOrComputedValue( - catchBatch.getCatchTotalWeight(), - catchBatch.getCatchTotalComputedWeight()); - return result; - } - - public float getCatchTotalSortedWeight() { - return catchBatch.getSpeciesTotalSampleSortedComputedWeight() + - catchBatch.getBenthosTotalSampleSortedComputedWeight(); - } - - public boolean withSpeciesBatches() { - return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren(); - } - - public boolean withBenthosBatches() { - return rootBenthosBatch != null && !rootBenthosBatch.isEmptyChildren(); - } - - public List<ExportBatchEntry> getSpeciesBatchEntry(boolean computeNumber) { - List<ExportBatchEntry> catchList = Lists.newArrayList(); - - if (withSpeciesBatches()) { - - Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap(); - - // ratio total species weight / total sorted sampled species weight - float speciesRatio = getSpeciesElevationRate(); - - List<SpeciesBatch> batches = rootSpeciesBatch.getChildren(); - for (SpeciesBatch batch : batches) { - - createExportBatchCatch( - batch, - catches, - speciesRatio, - computeNumber); - } - catchList.addAll(catches.values()); - } - return catchList; - } - - public List<ExportBatchEntry> getBenthosBatchEntry(boolean computeNumber) { - List<ExportBatchEntry> catchList = Lists.newArrayList(); - - if (withBenthosBatches()) { - - Map<Species, ExportBatchEntry> catches = Maps.newLinkedHashMap(); - - // ratio total species weight / total sorted sampled species weight - float speciesRatio = getBenthosElevationRate(); - - List<BenthosBatch> batches = rootBenthosBatch.getChildren(); - for (BenthosBatch batch : batches) { - - createExportBatchCatch( - batch, - catches, - speciesRatio, - computeNumber); - } - - catchList.addAll(catches.values()); - } - return catchList; - } - - public ExportBatchEntry getInertAndLivingNotItemizedCatch() { - - ExportBatchEntry result = new ExportBatchEntry(null); - - float speciesRatio = getSpeciesElevationRate(); - float benthosRatio = getBenthosElevationRate(); - - Float speciesInterWeight = TuttiEntities.getValueOrComputedValue( - catchBatch.getSpeciesTotalInertWeight(), - catchBatch.getSpeciesTotalInertComputedWeight()); - - if (speciesInterWeight != null) { - result.addSortedWeight(speciesInterWeight); - result.addTotalWeight(speciesInterWeight * speciesRatio); - } - - Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue( - catchBatch.getSpeciesTotalLivingNotItemizedWeight(), - catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); - - if (speciesLivingNotItemizedWeigth != null) { - result.addSortedWeight(speciesLivingNotItemizedWeigth); - result.addTotalWeight(speciesLivingNotItemizedWeigth * speciesRatio); - } - - Float benthosInterWeight = TuttiEntities.getValueOrComputedValue( - catchBatch.getBenthosTotalInertWeight(), - catchBatch.getBenthosTotalInertComputedWeight()); - - if (benthosInterWeight != null) { - result.addSortedWeight(benthosInterWeight); - result.addTotalWeight(benthosInterWeight * benthosRatio); - } - - Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue( - catchBatch.getBenthosTotalLivingNotItemizedWeight(), - catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); - - if (benthosLivingNotItemizedWeight != null) { - result.addSortedWeight(benthosLivingNotItemizedWeight); - result.addTotalWeight(benthosLivingNotItemizedWeight * benthosRatio); - } - - return result; - } - - public boolean isVracBatch(SpeciesAbleBatch batch) { - return vracPredicate.apply(batch); - } - - protected float getSpeciesElevationRate() { - - float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight(); - - float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue( - catchBatch.getSpeciesTotalSortedWeight(), - catchBatch.getSpeciesTotalSortedComputedWeight()); - - // ratio total species weight / total sorted sampled species weight - float result = globalRatio * speciesTotalSortedWeight; - if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) { - result /= catchBatch.getSpeciesTotalSampleSortedComputedWeight(); - } - return result; - } - - protected float getBenthosElevationRate() { - - float globalRatio = (getCatchTotalWeight() - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight(); - - float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue( - catchBatch.getBenthosTotalSortedWeight(), - catchBatch.getBenthosTotalSortedComputedWeight()); - - // ratio total benthos weight / total sorted sampled benthos weight - float result = globalRatio * benthosTotalSortedWeight; - if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) { - result /= catchBatch.getBenthosTotalSampleSortedComputedWeight(); - } - return result; - } - - protected void createExportBatchCatch(SpeciesAbleBatch batch, - Map<Species, ExportBatchEntry> catches, - float ratio, - boolean computeNumber) { - - Species species = batch.getSpecies(); - - ExportBatchEntry ktch = catches.get(species); - if (ktch == null) { - ktch = new ExportBatchEntry(batch); - catches.put(species, ktch); - } - - float sortedWeight = TuttiEntities.getValueOrComputedValue( - batch.getSampleCategoryWeight(), - batch.getSampleCategoryComputedWeight()); - - ktch.addSortedWeight(sortedWeight); - - boolean isVracBatch = isVracBatch(batch); - float speciesTotalWeight = sortedWeight; - if (isVracBatch) { - speciesTotalWeight *= ratio; - } - ktch.addTotalWeight(speciesTotalWeight); - - if (computeNumber) { - int number = Math.round(computeNumber(batch, 1.0f)); - if (isVracBatch) { - number *= ratio; - } - ktch.addNumber(number); - } - } - - protected float computeNumber(SpeciesAbleBatch batch, float rf) { - float result; - - float weight = TuttiEntities.getValueOrComputedValue( - batch.getSampleCategoryWeight(), - batch.getSampleCategoryComputedWeight()); - - if (batch.isChildBatchsEmpty()) { - - // on a leaf, get his weight - - Integer number = TuttiEntities.getValueOrComputedValue( - batch.getNumber(), - batch.getComputedNumber()); - if (number == null) { - - // no count - number = 0; - } - - // get the sample weight - Float subweight = TuttiEntities.getValueOrComputedValue( - batch.getWeight(), - batch.getComputedWeight()); - - if (subweight != null) { - - // with sub sample, update the raising factor - rf *= weight / subweight; - } - - result = number.floatValue() * rf; - } else { - - // get total weight of all childs - float totalWeight = 0.f; - for (SpeciesAbleBatch child : batch.getChildBatchs()) { - totalWeight += TuttiEntities.getValueOrComputedValue( - child.getSampleCategoryWeight(), - child.getSampleCategoryComputedWeight()); - } - - result = 0f; - - float rf2 = rf * weight / totalWeight; - // sum result of each child - for (SpeciesAbleBatch child : batch.getChildBatchs()) { - - result += computeNumber(child, rf2); - } - - } - return result; - } -} Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -1,5 +1,29 @@ package fr.ifremer.tutti.service.export.pdf; +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.service.export.ExportBatchEntry; /** @@ -7,7 +31,7 @@ * his sorted weight, total weight and percentage amoong the total catch * weight. * - * @since 2.10 + * @since 3.0-rc-1 */ public class PdfExportBatchEntry extends ExportBatchEntry { Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/PdfExportBatchEntry.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportService.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -36,7 +36,7 @@ import fr.ifremer.tutti.service.TuttiServiceContext; import fr.ifremer.tutti.service.catches.WeightComputingService; import fr.ifremer.tutti.service.export.ExportBatchEntry; -import fr.ifremer.tutti.service.export.pdf.ExportCatchContext; +import fr.ifremer.tutti.service.export.ExportCatchContext; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -1,5 +1,29 @@ package fr.ifremer.tutti.service.export.pdf; +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; import fr.ifremer.tutti.service.TuttiServiceContext; @@ -16,7 +40,7 @@ * Created on 11/19/13. * * @author Tony Chemit <chemit@codelutin.com> - * @since 2.10 + * @since 3.0-rc-1 */ public class CatchesPdfExportServiceTest { Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportServiceTest.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/tutti-ui-swing/pom.xml =================================================================== --- trunk/tutti-ui-swing/pom.xml 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-ui-swing/pom.xml 2013-11-21 16:09:10 UTC (rev 1371) @@ -27,7 +27,7 @@ <parent> <groupId>fr.ifremer</groupId> <artifactId>tutti</artifactId> - <version>2.10-SNAPSHOT</version> + <version>3.0-rc-1-SNAPSHOT</version> </parent> <groupId>fr.ifremer.tutti</groupId> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -56,7 +56,7 @@ /** * Rows to delete after all. * - * @since 2.10 + * @since 3.0-rc-1 */ protected Set<BenthosBatchRowModel> rowToRemove; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -56,14 +56,14 @@ /** * Rows to delete after all. * - * @since 2.10 + * @since 3.0-rc-1 */ protected Set<BenthosBatchRowModel> rowToRemove; /** * Parent batch of rows to delete. * - * @since 2.10 + * @since 3.0-rc-1 */ protected BenthosBatchRowModel parentBatch; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -49,7 +49,7 @@ /** * Rows to delete after all. * - * @since 2.10 + * @since 3.0-rc-1 */ protected Set<SpeciesBatchRowModel> rowToRemove; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-21 15:41:34 UTC (rev 1370) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-21 16:09:10 UTC (rev 1371) @@ -56,14 +56,14 @@ /** * Rows to delete after all. * - * @since 2.10 + * @since 3.0-rc-1 */ protected Set<SpeciesBatchRowModel> rowToRemove; /** * Parent batch of rows to delete. * - * @since 2.10 + * @since 3.0-rc-1 */ protected SpeciesBatchRowModel parentBatch;
participants (1)
-
tchemit@users.forge.codelutin.com