Author: tchemit Date: 2013-06-11 18:01:59 +0200 (Tue, 11 Jun 2013) New Revision: 1102 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1102 Log: fixes #2701: [EXPORT DONNEES] erreur suite export g?\195?\169n?\195?\169rique 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/OperationExportRow.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 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-06-11 15:14:17 UTC (rev 1101) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-06-11 16:01:59 UTC (rev 1102) @@ -261,7 +261,10 @@ speciesBatch.getRankOrder()); CatchExportRow row = currentRow.copy(); - row.setReferenceWeight(speciesBatch.getSampleCategoryWeight()); + float referenceWeight = TuttiExportService.getValueOrComputedValue( + speciesBatch.getSampleCategoryWeight(), + speciesBatch.getSampleCategoryComputedWeight()); + row.setReferenceWeight(referenceWeight); row.setRaisingFactor(1.f); rows.add(row); } @@ -372,7 +375,11 @@ benthosBatch.getRankOrder()); CatchExportRow row = currentRow.copy(); - row.setReferenceWeight(benthosBatch.getSampleCategoryWeight()); + + float referenceWeight = TuttiExportService.getValueOrComputedValue( + benthosBatch.getSampleCategoryWeight(), + benthosBatch.getSampleCategoryComputedWeight()); + row.setReferenceWeight(referenceWeight); row.setRaisingFactor(1.f); rows.add(row); } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-06-11 15:14:17 UTC (rev 1101) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportRow.java 2013-06-11 16:01:59 UTC (rev 1102) @@ -279,172 +279,214 @@ } public Float getCatchTotalWeight() { - return getValueOrComputedValue(catchBatch.getCatchTotalWeight(), catchBatch.getCatchTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getCatchTotalWeight(), + catchBatch.getCatchTotalComputedWeight()); } public Boolean getCatchTotalWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getCatchTotalWeight(), catchBatch.getCatchTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getCatchTotalWeight(), + catchBatch.getCatchTotalComputedWeight()); } public Float getCatchTotalSortedTremisWeight() { - return getValueOrComputedValue(catchBatch.getCatchTotalSortedTremisWeight(), null); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getCatchTotalSortedTremisWeight(), null); } public Boolean getCatchTotalSortedTremisWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getCatchTotalSortedTremisWeight(), null); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getCatchTotalSortedTremisWeight(), null); } public Float getCatchTotalSortedCarousselWeight() { - return getValueOrComputedValue(catchBatch.getCatchTotalSortedCarousselWeight(), null); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getCatchTotalSortedCarousselWeight(), null); } public Boolean getCatchTotalSortedCarousselWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getCatchTotalSortedCarousselWeight(), null); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getCatchTotalSortedCarousselWeight(), null); } public Float getCatchTotalSortedWeight() { - return getValueOrComputedValue(null, catchBatch.getCatchTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getCatchTotalSortedComputedWeight()); } public Boolean getCatchTotalSortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getCatchTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getCatchTotalSortedComputedWeight()); } public Float getCatchTotalUnsortedWeight() { - return getValueOrComputedValue(null, catchBatch.getCatchTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getCatchTotalUnsortedComputedWeight()); } public Boolean getCatchTotalUnsortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getCatchTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getCatchTotalUnsortedComputedWeight()); } public Float getCatchTotalRejectedWeight() { - return getValueOrComputedValue(catchBatch.getCatchTotalRejectedWeight(), catchBatch.getCatchTotalRejectedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getCatchTotalRejectedWeight(), + catchBatch.getCatchTotalRejectedComputedWeight()); } public Boolean getCatchTotalRejectedWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getCatchTotalRejectedWeight(), catchBatch.getCatchTotalRejectedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getCatchTotalRejectedWeight(), + catchBatch.getCatchTotalRejectedComputedWeight()); } public Float getSpeciesTotalWeight() { - return getValueOrComputedValue(null, catchBatch.getSpeciesTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getSpeciesTotalComputedWeight()); } public Boolean getSpeciesTotalWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getSpeciesTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getSpeciesTotalComputedWeight()); } public Float getSpeciesTotalSortedWeight() { - return getValueOrComputedValue(catchBatch.getSpeciesTotalSortedWeight(), catchBatch.getSpeciesTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getSpeciesTotalSortedWeight(), + catchBatch.getSpeciesTotalSortedComputedWeight()); } public Boolean getSpeciesTotalSortedWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getSpeciesTotalSortedWeight(), catchBatch.getSpeciesTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getSpeciesTotalSortedWeight(), + catchBatch.getSpeciesTotalSortedComputedWeight()); } public Float getSpeciesTotalUnsortedWeight() { - return getValueOrComputedValue(null, catchBatch.getSpeciesTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getSpeciesTotalUnsortedComputedWeight()); } public Boolean getSpeciesTotalUnsortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getSpeciesTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getSpeciesTotalUnsortedComputedWeight()); } public Float getSpeciesTotalSampleSortedWeight() { - return getValueOrComputedValue(null, catchBatch.getSpeciesTotalSampleSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getSpeciesTotalSampleSortedComputedWeight()); } public Boolean getSpeciesTotalSampleSortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getSpeciesTotalSampleSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getSpeciesTotalSampleSortedComputedWeight()); } public Float getSpeciesTotalInertWeight() { - return getValueOrComputedValue(catchBatch.getSpeciesTotalInertWeight(), catchBatch.getSpeciesTotalInertComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getSpeciesTotalInertWeight(), + catchBatch.getSpeciesTotalInertComputedWeight()); } public Boolean getSpeciesTotalInertWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getSpeciesTotalInertWeight(), catchBatch.getSpeciesTotalInertComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getSpeciesTotalInertWeight(), + catchBatch.getSpeciesTotalInertComputedWeight()); } public Float getSpeciesTotalLivingNotItemizedWeight() { - return getValueOrComputedValue(catchBatch.getSpeciesTotalLivingNotItemizedWeight(), catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getSpeciesTotalLivingNotItemizedWeight(), + catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); } public Boolean getSpeciesTotalLivingNotItemizedWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getSpeciesTotalLivingNotItemizedWeight(), catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getSpeciesTotalLivingNotItemizedWeight(), + catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight()); } public Float getBenthosTotalWeight() { - return getValueOrComputedValue(null, catchBatch.getBenthosTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getBenthosTotalComputedWeight()); } public Boolean getBenthosTotalWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getBenthosTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getBenthosTotalComputedWeight()); } public Float getBenthosTotalSortedWeight() { - return getValueOrComputedValue(catchBatch.getBenthosTotalSortedWeight(), catchBatch.getBenthosTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getBenthosTotalSortedWeight(), + catchBatch.getBenthosTotalSortedComputedWeight()); } public Boolean getBenthosTotalSortedWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getBenthosTotalSortedWeight(), catchBatch.getBenthosTotalSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getBenthosTotalSortedWeight(), + catchBatch.getBenthosTotalSortedComputedWeight()); } public Float getBenthosTotalUnsortedWeight() { - return getValueOrComputedValue(null, catchBatch.getBenthosTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getBenthosTotalUnsortedComputedWeight()); } public Boolean getBenthosTotalUnsortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getBenthosTotalUnsortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getBenthosTotalUnsortedComputedWeight()); } public Float getBenthosTotalSampleSortedWeight() { - return getValueOrComputedValue(null, catchBatch.getBenthosTotalSampleSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + null, catchBatch.getBenthosTotalSampleSortedComputedWeight()); } public Boolean getBenthosTotalSampleSortedWeightComputed() { - return getValueOrComputedValueComputed(null, catchBatch.getBenthosTotalSampleSortedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + null, catchBatch.getBenthosTotalSampleSortedComputedWeight()); } public Float getBenthosTotalInertWeight() { - return getValueOrComputedValue(catchBatch.getBenthosTotalInertWeight(), catchBatch.getBenthosTotalInertComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getBenthosTotalInertWeight(), + catchBatch.getBenthosTotalInertComputedWeight()); } public Boolean getBenthosTotalInertWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getBenthosTotalInertWeight(), catchBatch.getBenthosTotalInertComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getBenthosTotalInertWeight(), + catchBatch.getBenthosTotalInertComputedWeight()); } public Float getBenthosTotalLivingNotItemizedWeight() { - return getValueOrComputedValue(catchBatch.getBenthosTotalLivingNotItemizedWeight(), catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getBenthosTotalLivingNotItemizedWeight(), + catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); } public Boolean getBenthosTotalLivingNotItemizedWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getBenthosTotalLivingNotItemizedWeight(), catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getBenthosTotalLivingNotItemizedWeight(), + catchBatch.getBenthosTotalLivingNotItemizedComputedWeight()); } public Float getMarineLitterTotalWeight() { - return getValueOrComputedValue(catchBatch.getMarineLitterTotalWeight(), catchBatch.getMarineLitterTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValue( + catchBatch.getMarineLitterTotalWeight(), + catchBatch.getMarineLitterTotalComputedWeight()); } public Boolean getMarineLitterTotalWeightComputed() { - return getValueOrComputedValueComputed(catchBatch.getMarineLitterTotalWeight(), catchBatch.getMarineLitterTotalComputedWeight()); + return TuttiExportService.getValueOrComputedValueComputed( + catchBatch.getMarineLitterTotalWeight(), + catchBatch.getMarineLitterTotalComputedWeight()); + catchBatch.getMarineLitterTotalComputedWeight()); } - protected Float getValueOrComputedValue(Float value, Float computedValue) { - return value == null ? computedValue : value; - } - - protected Boolean getValueOrComputedValueComputed(Float value, Float computedValue) { - Boolean result; - if (value == null) { - - result = computedValue == null ? null : true; - } else { - result = true; - } - return result; - } - protected Serializable getGearUseFeature(Caracteristic caracteristic) { CaracteristicMap gearUseFeatures = fishingOperation.getGearUseFeatures(); Serializable serializable = gearUseFeatures == null ? null : gearUseFeatures.get(caracteristic); 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-06-11 15:14:17 UTC (rev 1101) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-06-11 16:01:59 UTC (rev 1102) @@ -116,6 +116,21 @@ protected Caracteristic pmfmIdCaracteristic; + public static Float getValueOrComputedValue(Float value, Float computedValue) { + return value == null ? computedValue : value; + } + + public static Boolean getValueOrComputedValueComputed(Float value, Float computedValue) { + Boolean result; + if (value == null) { + + result = computedValue == null ? null : true; + } else { + result = true; + } + return result; + } + @Override public void setServiceContext(TuttiServiceContext context) { super.setServiceContext(context);