Author: kmorin Date: 2013-05-21 12:06:05 +0200 (Tue, 21 May 2013) New Revision: 967 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/967 Log: fixes #2420 [EXPORT SUMATRA] intitul?\195?\169 ?\195?\160 revoir et erreur Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-05-21 10:01:49 UTC (rev 966) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-05-21 10:06:05 UTC (rev 967) @@ -136,11 +136,11 @@ } CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(fishingOperationId); - BatchContainer<SpeciesBatch> rootSpeciesBatch; - rootSpeciesBatch = tuttiWeightComputingService.getComputedSpeciesBatches(fishingOperation); + BatchContainer<SpeciesBatch> rootSpeciesBatch = + tuttiWeightComputingService.getComputedSpeciesBatches(fishingOperation); - BatchContainer<BenthosBatch> rootBenthosBatch; - rootBenthosBatch = tuttiWeightComputingService.getComputedBenthosBatches(fishingOperation); + BatchContainer<BenthosBatch> rootBenthosBatch = + tuttiWeightComputingService.getComputedBenthosBatches(fishingOperation); tuttiWeightComputingService.computeCatchBatchWeights(catchBatch, rootSpeciesBatch, rootBenthosBatch, null); @@ -162,17 +162,21 @@ Float ratio = totalWeight / totalSortedWeight; // create catches rows - List<SpeciesBatch> speciesBatches = rootSpeciesBatch.getChildren(); - for (SpeciesBatch batch : speciesBatches) { - createSpeciesCatch(batch, catches, ratio, totalWeight); + if (rootSpeciesBatch != null) { + List<SpeciesBatch> speciesBatches = rootSpeciesBatch.getChildren(); + for (SpeciesBatch batch : speciesBatches) { + createSpeciesCatch(batch, catches, ratio, totalWeight); + } } List<Map<String, Object>> catchList = Lists.newArrayList(catches.values()); // add the benthos row - if (CollectionUtils.isNotEmpty(rootBenthosBatch.getChildren())) { - Map<String, Object> benthosCatch = - createBenthosCatch(rootBenthosBatch, catchBatch.getBenthosTotalComputedWeight(), totalWeight); - catchList.add(benthosCatch); + if (rootBenthosBatch != null) { + if (CollectionUtils.isNotEmpty(rootBenthosBatch.getChildren())) { + Map<String, Object> benthosCatch = + createBenthosCatch(rootBenthosBatch, catchBatch.getBenthosTotalComputedWeight(), totalWeight); + catchList.add(benthosCatch); + } } op.put("catches", catchList); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-05-21 10:01:49 UTC (rev 966) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-05-21 10:06:05 UTC (rev 967) @@ -336,15 +336,18 @@ public BatchContainer<SpeciesBatch> getComputedSpeciesBatches(FishingOperation operation) { - BatchContainer<SpeciesBatch> rootSpeciesBatch = - persistenceService.getRootSpeciesBatch(operation.getId()); + BatchContainer<SpeciesBatch> rootSpeciesBatch = null; - currentSpeciesRowIndex = 0; - if (rootSpeciesBatch != null) { - List<SpeciesBatch> roots = rootSpeciesBatch.getChildren(); + if (persistenceService.isFishingOperationWithCatchBatch(operation.getId())) { + rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId()); - for (SpeciesBatch batch : roots) { - computeSpeciesBatch(batch); + currentSpeciesRowIndex = 0; + if (rootSpeciesBatch != null) { + List<SpeciesBatch> roots = rootSpeciesBatch.getChildren(); + + for (SpeciesBatch batch : roots) { + computeSpeciesBatch(batch); + } } } @@ -469,15 +472,18 @@ public BatchContainer<BenthosBatch> getComputedBenthosBatches(FishingOperation operation) { - BatchContainer<BenthosBatch> rootBenthosBatch = - persistenceService.getRootBenthosBatch(operation.getId()); + BatchContainer<BenthosBatch> rootBenthosBatch = null; - currentBenthosRowIndex = 0; - if (rootBenthosBatch != null) { - List<BenthosBatch> roots = rootBenthosBatch.getChildren(); + if (persistenceService.isFishingOperationWithCatchBatch(operation.getId())) { + rootBenthosBatch = persistenceService.getRootBenthosBatch(operation.getId()); - for (BenthosBatch batch : roots) { - computeBenthosBatch(batch); + currentBenthosRowIndex = 0; + if (rootBenthosBatch != null) { + List<BenthosBatch> roots = rootBenthosBatch.getChildren(); + + for (BenthosBatch batch : roots) { + computeBenthosBatch(batch); + } } } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-05-21 10:01:49 UTC (rev 966) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-05-21 10:06:05 UTC (rev 967) @@ -96,39 +96,41 @@ tuttiWeightComputingService.getComputedSpeciesBatches(operation); Map<Species, CatchRow> rowMap = Maps.newHashMap(); - List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren(); - for (SpeciesBatch batch : speciesBatches) { - Species sp = batch.getSpecies(); + if (speciesBatchContainer != null) { + List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren(); + for (SpeciesBatch batch : speciesBatches) { + Species sp = batch.getSpecies(); - Float weight = batch.getSampleCategoryWeight(); - if (weight == null) { - weight = batch.getSampleCategoryComputedWeight(); - } + Float weight = batch.getSampleCategoryWeight(); + if (weight == null) { + weight = batch.getSampleCategoryComputedWeight(); + } - Integer nb = batch.getNumber(); - if (nb == null) { - nb = batch.getComputedNumber(); - } - if (nb == null) { - nb = 0; - } + Integer nb = batch.getNumber(); + if (nb == null) { + nb = batch.getComputedNumber(); + } + if (nb == null) { + nb = 0; + } - CatchRow row = rowMap.get(sp); - if (row == null) { - row = new CatchRow(); - row.setFishingOperation(operation); - row.setSpecies(sp); - row.setWeight(weight); - row.setNumber(nb); + CatchRow row = rowMap.get(sp); + if (row == null) { + row = new CatchRow(); + row.setFishingOperation(operation); + row.setSpecies(sp); + row.setWeight(weight); + row.setNumber(nb); - } else { - row.setWeight(row.getWeight() + weight); - row.setNumber(row.getNumber() + nb); + } else { + row.setWeight(row.getWeight() + weight); + row.setNumber(row.getNumber() + nb); + } + rowMap.put(sp, row); } - rowMap.put(sp, row); + rows.addAll(rowMap.values()); } - rows.addAll(rowMap.values()); // add benthos rows Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-05-21 10:01:49 UTC (rev 966) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-05-21 10:06:05 UTC (rev 967) @@ -179,25 +179,22 @@ protected Float computeSpeciesBatches(BatchContainer<SpeciesBatch> computedSpeciesBatches) { Float totalSortedWeight = 0f; - List<SpeciesBatchRowModel> rows = Lists.newArrayList(); - List<SpeciesBatch> children = computedSpeciesBatches.getChildren(); - int rowIndex = 0; - for (SpeciesBatch batch : children) { - SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows); - Float weight = row.getSortedUnsortedCategoryWeight(); - if (weight == null) { - weight = row.getSortedUnsortedCategoryComputedWeight(); + if (computedSpeciesBatches != null) { + List<SpeciesBatchRowModel> rows = Lists.newArrayList(); + List<SpeciesBatch> children = computedSpeciesBatches.getChildren(); + for (SpeciesBatch batch : children) { + SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows); + Float weight = row.getSortedUnsortedCategoryWeight(); + if (weight == null) { + weight = row.getSortedUnsortedCategoryComputedWeight(); + } + if (SortedUnsortedEnum.SORTED.matchValue( + row.getSortedUnsortedCategoryValue())) { + totalSortedWeight += weight; + } } - if (SortedUnsortedEnum.SORTED.matchValue( - row.getSortedUnsortedCategoryValue())) { - totalSortedWeight += weight; - } - rowIndex++; - if (row.getChildBatch() != null) { - rowIndex += row.getChildBatch().size(); - } + getUI().getSpeciesTabContent().getModel().setRows(rows); } - getUI().getSpeciesTabContent().getModel().setRows(rows); return totalSortedWeight; } @@ -205,27 +202,24 @@ protected Float computeBenthosBatches(BatchContainer<BenthosBatch> computedBenthosBatches) { Float totalSortedWeight = 0f; - List<BenthosBatchRowModel> rows = Lists.newArrayList(); - List<BenthosBatch> children = computedBenthosBatches.getChildren(); - int rowIndex = 0; - for (BenthosBatch batch : children) { - BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows); - Float weight = row.getSortedUnsortedCategoryWeight(); - if (weight == null) { - weight = row.getSortedUnsortedCategoryComputedWeight(); + if (computedBenthosBatches != null) { + List<BenthosBatchRowModel> rows = Lists.newArrayList(); + List<BenthosBatch> children = computedBenthosBatches.getChildren(); + for (BenthosBatch batch : children) { + BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows); + Float weight = row.getSortedUnsortedCategoryWeight(); + if (weight == null) { + weight = row.getSortedUnsortedCategoryComputedWeight(); + } + if (SortedUnsortedEnum.SORTED.matchValue( + row.getSortedUnsortedCategoryValue())) { + totalSortedWeight += weight; + } } - if (SortedUnsortedEnum.SORTED.matchValue( - row.getSortedUnsortedCategoryValue())) { - totalSortedWeight += weight; - } - rowIndex++; - if (row.getChildBatch() != null) { - rowIndex += row.getChildBatch().size(); - } - } - getUI().getBenthosTabContent().getModel().setRows(rows); + getUI().getBenthosTabContent().getModel().setRows(rows); + } return totalSortedWeight; } }