r1281 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation
Author: tchemit Date: 2013-10-07 16:26:19 +0200 (Mon, 07 Oct 2013) New Revision: 1281 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1281 Log: fixes #3444: [DONNEES INDIVIDUELLES] pouvoir copier les mensurations depuis la page ESPECES Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-10-07 09:40:57 UTC (rev 1280) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-10-07 14:26:19 UTC (rev 1281) @@ -97,6 +97,8 @@ */ protected final WeightUnit weightUnit; + protected final WeightUnit speciesWeightUnit; + public final Integer PMFM_ID_SORTED_UNSORTED; public IndividualObservationBatchUIHandler(TuttiUI<?, ?> parentUi, IndividualObservationBatchUI ui) { @@ -111,6 +113,7 @@ IndividualObservationBatchRowModel.PROPERTY_ATTACHMENT); weightUnit = getConfig().getIndividualObservationWeightUnit(); + speciesWeightUnit = getConfig().getSpeciesWeightUnit(); PMFM_ID_SORTED_UNSORTED = persistenceService.getSortedUnsortedCaracteristic().getIdAsInt(); @@ -519,18 +522,36 @@ newRow.setSpecies(species); newRow.getCaracteristics().putAll(batchCaracteristics); - //FIXME Keep this ? - newRow.getDefaultCaracteristics().putAll(defaultCaracteristics); - //FIXME Keep this? - newRow.setWeight(model.getWeight()); - //FIXME Keep this? - newRow.setSize(model.getSize()); - //FIXME Keep this? - newRow.setLengthStepCaracteristic(model.getLengthStepCaracteristic()); +// //FIXME Keep this ? +// newRow.getDefaultCaracteristics().putAll(defaultCaracteristics); +// //FIXME Keep this? +// newRow.setWeight(model.getWeight()); +// //FIXME Keep this? +// newRow.setSize(model.getSize()); +// //FIXME Keep this? +// newRow.setLengthStepCaracteristic(model.getLengthStepCaracteristic()); rowsToCreate.add(newRow); + } + if (nbRow == 1) { + + // apply also weight found + IndividualObservationBatchRowModel lastRow = + rowsToCreate.get(rowsToCreate.size() - 1); + Float weight = TuttiEntities.getValueOrComputedValue( + leaf.getWeight(), + leaf.getFinestCategory().getCategoryWeight()); + if (weight != null) { + + // convert weight units + weight = speciesWeightUnit.toEntity(weight); + weight = weightUnit.fromEntity(weight); + } + lastRow.setWeight(weight); + } + } else { for (SpeciesFrequencyRowModel frequency : frequencies) { @@ -543,6 +564,12 @@ if (nbRow > 0) { weight /= nbRow; } + + + // convert weight units + weight = speciesWeightUnit.toEntity(weight); + weight = weightUnit.fromEntity(weight); + for (int i = 0; i < nbRow; i++) { IndividualObservationBatchRowModel newRow = tableModel.createNewRow(); newRow.setSpecies(species); @@ -551,8 +578,8 @@ newRow.setLengthStepCaracteristic(frequency.getLengthStepCaracteristic()); newRow.getCaracteristics().putAll(batchCaracteristics); - //FIXME Keep this ? - newRow.getDefaultCaracteristics().putAll(defaultCaracteristics); +// //FIXME Keep this ? +// newRow.getDefaultCaracteristics().putAll(defaultCaracteristics); rowsToCreate.add(newRow); }
participants (1)
-
tchemit@users.forge.codelutin.com