r1012 - in trunk: tutti-service/src/main/java/fr/ifremer/tutti/service/catches tutti-service/src/main/resources/i18n tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
Author: kmorin Date: 2013-05-27 18:55:44 +0200 (Mon, 27 May 2013) New Revision: 1012 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1012 Log: fixes #2487 [VALIDATION] alertes r?\195?\169p?\195?\169t?\195?\169es et pas d'identification des donn?\195?\169es / lots concern?\195?\169s Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingException.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.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/TuttiWeightComputingException.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingException.java 2013-05-27 09:46:58 UTC (rev 1011) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingException.java 2013-05-27 16:55:44 UTC (rev 1012) @@ -34,24 +34,20 @@ private static final long serialVersionUID = 1L; - public enum CatchType { - SPECIES, BENTHOS, MARINE_LITTER - } + protected String property; - protected CatchType catchType; - protected int index; public TuttiWeightComputingException(String message, - CatchType catchType, + String property, int index) { super(message); - this.catchType = catchType; + this.property = property; this.index = index; } - public CatchType getCatchType() { - return catchType; + public String getProperty() { + return property; } public int getIndex() { 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-27 09:46:58 UTC (rev 1011) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-05-27 16:55:44 UTC (rev 1012) @@ -36,10 +36,8 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.service.AbstractTuttiService; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.service.TuttiServiceContext; -import fr.ifremer.tutti.service.ValidationService; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.*; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -63,11 +61,14 @@ protected ValidationService validationService; + protected DecoratorService decoratorService; + @Override public void setServiceContext(TuttiServiceContext context) { super.setServiceContext(context); persistenceService = getService(PersistenceService.class); validationService = getService(ValidationService.class); + decoratorService = getService(DecoratorService.class); } /** @@ -359,11 +360,18 @@ int thisIndex = currentSpeciesRowIndex++; Float categoryWeight = batch.getSampleCategoryWeight(); Float rowWeight = batch.getWeight(); + String species = decoratorService.getDecoratorByType(Species.class).toString(batch.getSpecies()); + String categoryValue = decoratorService.getDecorator(batch.getSampleCategoryValue()) + .toString(batch.getSampleCategoryValue()); NuitonValidatorResult validation = validationService.validateSpeciesBatch(batch); if (!validation.isValid()) { List<String> messages = validation.getErrorMessages(SpeciesBatch.PROPERTY_WEIGHT); - throw new TuttiBusinessException(_(messages.get(0))); + throw new TuttiWeightComputingException(_(messages.get(0), + species, batch.getSampleCategoryType().getLabel(), categoryValue, + batch.getWeight(), batch.getSampleCategoryWeight()), + SpeciesBatch.PROPERTY_WEIGHT, + thisIndex); } List<SpeciesBatch> children = batch.getChildBatchs(); @@ -386,8 +394,10 @@ } else if (categoryWeight < sum) { throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.species.incoherentParentCategoryWeight"), - TuttiWeightComputingException.CatchType.SPECIES, + _("tutti.service.operations.computeWeights.error.species.incoherentParentCategoryWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + categoryWeight, sum), + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } else { @@ -423,6 +433,14 @@ if (categoryWeight == null && rowWeight != null) { // throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentRowWeightCategory")); + } else if (rowWeight != null && !rowWeight.equals(frequencyWeight)) { + throw new TuttiWeightComputingException( + _("tutti.service.operations.computeWeights.error.species.incoherentRowWeightFrequency", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + frequencyWeight, rowWeight), + SpeciesBatch.PROPERTY_WEIGHT, + thisIndex); + } else if (categoryWeight == null && frequencyWeight != null) { // if the category weight is null and the frequencies have a weight, // then this weight is the result @@ -435,18 +453,16 @@ // if the weight of the frequencies is different from the category // weight, then set the weight of the sample if (frequencyWeight > categoryWeight) { - throw new TuttiWeightComputingException(_("tutti.service.operations.computeWeights.error.species.incoherentCategoryWeight"), - TuttiWeightComputingException.CatchType.SPECIES, - thisIndex); + throw new TuttiWeightComputingException( + _("tutti.service.operations.computeWeights.error.species.incoherentCategoryWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + frequencyWeight, categoryWeight), + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, + thisIndex); } else if (rowWeight == null) { batch.setComputedWeight(frequencyWeight); - } else if (!rowWeight.equals(frequencyWeight)) { - throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.species.incoherentRowWeightFrequency"), - TuttiWeightComputingException.CatchType.SPECIES, - thisIndex); } result = categoryWeight; @@ -458,10 +474,11 @@ result = categoryWeight; } } - if (result == null && batch.getParentBatch() == null) { + if (result == null) { throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.species.noWeight"), - TuttiWeightComputingException.CatchType.SPECIES, + _("tutti.service.operations.computeWeights.error.species.noWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue), + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } @@ -495,11 +512,18 @@ int thisIndex = currentBenthosRowIndex++; Float categoryWeight = batch.getSampleCategoryWeight(); Float rowWeight = batch.getWeight(); + String species = decoratorService.getDecoratorByType(Species.class).toString(batch.getSpecies()); + String categoryValue = decoratorService.getDecorator(batch.getSampleCategoryValue()) + .toString(batch.getSampleCategoryValue()); NuitonValidatorResult validation = validationService.validateBenthosBatch(batch); if (!validation.isValid()) { - List<String> messages = validation.getErrorMessages(SpeciesBatch.PROPERTY_WEIGHT); - throw new TuttiBusinessException(_(messages.get(0))); + List<String> messages = validation.getErrorMessages(BenthosBatch.PROPERTY_WEIGHT); + throw new TuttiWeightComputingException(_(messages.get(0), + species, batch.getSampleCategoryType().getLabel(), categoryValue, + batch.getWeight(), batch.getSampleCategoryWeight()), + BenthosBatch.PROPERTY_WEIGHT, + thisIndex); } List<BenthosBatch> children = batch.getChildBatchs(); @@ -522,8 +546,10 @@ } else if (categoryWeight < sum) { throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight"), - TuttiWeightComputingException.CatchType.BENTHOS, + _("tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + categoryWeight, sum), + BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } else { @@ -560,6 +586,14 @@ if (categoryWeight == null && rowWeight != null) { // throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentRowWeightCategory")); + } else if (!rowWeight.equals(frequencyWeight)) { + throw new TuttiWeightComputingException( + _("tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightFrequency", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + rowWeight, categoryWeight), + BenthosBatch.PROPERTY_WEIGHT, + thisIndex); + } else if (categoryWeight == null && frequencyWeight != null) { // if the category weight is null and the frequencies have a weight, // then this weight is the result @@ -573,18 +607,15 @@ // weight, then set the weight of the sample if (frequencyWeight > categoryWeight) { throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight"), - TuttiWeightComputingException.CatchType.BENTHOS, + _("tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue, + frequencyWeight, categoryWeight), + BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } else if (rowWeight == null) { batch.setComputedWeight(frequencyWeight); - } else if (!rowWeight.equals(frequencyWeight)) { - throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightFrequency"), - TuttiWeightComputingException.CatchType.BENTHOS, - thisIndex); } result = categoryWeight; @@ -596,11 +627,11 @@ result = categoryWeight; } } - if (result == null - && batch.getParentBatch() == null) { + if (result == null) { throw new TuttiWeightComputingException( - _("tutti.service.operations.computeWeights.error.benthos.noWeight"), - TuttiWeightComputingException.CatchType.BENTHOS, + _("tutti.service.operations.computeWeights.error.benthos.noWeight", + species, batch.getSampleCategoryType().getLabel(), categoryValue), + BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } @@ -623,7 +654,7 @@ if (checkWeight && batch.getWeight() == null) { throw new TuttiWeightComputingException( _("tutti.validator.warning.marineLitter.weight.required"), - TuttiWeightComputingException.CatchType.MARINE_LITTER, + MarineLitterBatch.PROPERTY_WEIGHT, i); } } Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties =================================================================== --- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-05-27 09:46:58 UTC (rev 1011) +++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-05-27 16:55:44 UTC (rev 1012) @@ -95,23 +95,23 @@ tutti.service.multipost.import.caracteristics.error=Erreur lors de l'import des caractéristiques tutti.service.multipost.import.frequencies.error=Erreur lors de l'import des mensurations tutti.service.multipost.resolveArchive.error=Erreur lors de l'ouverture de l'archive -tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight=Le poids total des mensurations d'un lot du benthos est supérieur au poids de la catégorie -tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight=Le poids de la catégorie d'un lot du benthos est différent de la somme des poids de ses sous-catégories +tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight=Benthos - Le poids total des mensurations du lot de %s/%s - %s (%skg) est supérieur au poids de la catégorie (%skg) +tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight=Benthos - Le poids du lot de %s/%s - %s (%skg) est inférieur à la somme des poids de ses sous-catégories (%skg) tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightCategory=Le poids de sous-échantillon est renseigné alors que le lot n'a pas de poids. -tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightFrequency=Le poids total des mensurations d'un lot du benthos est différent du poids du sous-échantillon -tutti.service.operations.computeWeights.error.benthos.incoherentSampleWeight=Le poids de sous-échantillon est supérieur au poids du lot. +tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightFrequency=Benthos - Le poids total des mensurations du lot de %s/%s - %s (%skg) est différent du poids du sous-échantillon (%skg) +tutti.service.operations.computeWeights.error.benthos.incoherentSampleWeight=Benthos - Le poids de sous-échantillon du lot %s/%s - %s (%skg) est supérieur au poids du lot (%skg) tutti.service.operations.computeWeights.error.benthos.incoherentTotalSorted=Le poids total Vrac du benthos est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié -tutti.service.operations.computeWeights.error.benthos.noWeight=Un lot du benthos n'a pas de poids +tutti.service.operations.computeWeights.error.benthos.noWeight=Benthos - Le lot de %s/%s - %s n'a pas de poids tutti.service.operations.computeWeights.error.incoherentRowWeightCategory=Le poids de sous-échantillon est renseigné alors que le lot n'a pas de poids. tutti.service.operations.computeWeights.error.incoherentTotal=Le poids total de la capture ne correspond pas à la somme des poids totaux Vrac, Hors Vrac et non triés tutti.service.operations.computeWeights.error.marineLitter.incoherentTotal=Le poids total des macro-déchets est inférieur à la somme des poids des macro-déchets saisis -tutti.service.operations.computeWeights.error.species.incoherentCategoryWeight=Le poids total des mensurations d'un lot des espèces est supérieur au poids de la catégorie -tutti.service.operations.computeWeights.error.species.incoherentParentCategoryWeight=Le poids de la catégorie d'un lot des espèces est différent de la somme des poids de ses sous-catégories +tutti.service.operations.computeWeights.error.species.incoherentCategoryWeight=Espèces - Le poids total des mensurations du lot de %s/%s - %s (%skg) est supérieur au poids de la catégorie (%skg) +tutti.service.operations.computeWeights.error.species.incoherentParentCategoryWeight=Espèces - Le poids du lot de %s/%s - %s (%skg) est inférieur à la somme des poids de ses sous-catégories (%skg) tutti.service.operations.computeWeights.error.species.incoherentRowWeightCategory=Le poids de sous-échantillon est renseigné alors que le lot n'a pas de poids. -tutti.service.operations.computeWeights.error.species.incoherentRowWeightFrequency=Le poids total des mensurations d'un lot des espèces est différent du poids du sous-échantillon -tutti.service.operations.computeWeights.error.species.incoherentSampleWeight=Le poids de sous-échantillon est supérieur au poids du lot. +tutti.service.operations.computeWeights.error.species.incoherentRowWeightFrequency=Espèces - Le poids total des mensurations du lot de %s/%s - %s (%skg) est différent du poids du sous-échantillon (%skg) +tutti.service.operations.computeWeights.error.species.incoherentSampleWeight=Espèces - Le poids de sous-échantillon du lot %s/%s - %s (%skg) est supérieur au poids du lot (%skg) tutti.service.operations.computeWeights.error.species.incoherentTotalSorted=Le poids total Vrac des espèces est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié -tutti.service.operations.computeWeights.error.species.noWeight=Un lot des espèces n'a pas de poids +tutti.service.operations.computeWeights.error.species.noWeight=Espèces - Le lot de %s/%s/%s n'a pas de poids tutti.service.operations.exportCatchesReport.error=Erreur lors de la génération du rapport des captures tutti.service.persistence.checkArchiveDb.error=L'archive de base de données %1s ne contient pas le dossier %2s tutti.service.persistence.checkImportstructure.fileNotExist=L'archive de base de données %s n'existe pas Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java 2013-05-27 09:46:58 UTC (rev 1011) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java 2013-05-27 16:55:44 UTC (rev 1012) @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService; @@ -61,6 +62,7 @@ import java.beans.PropertyChangeEvent; import java.util.List; import java.util.Map; +import java.util.Set; import static org.nuiton.i18n.I18n._; @@ -279,7 +281,8 @@ } protected int addMessages(NuitonValidatorScope scope, List<String> messages) { - for (String message : messages) { + Set<String> messageSet = Sets.newHashSet(messages); + for (String message : messageSet) { MessageTreeNode child = new MessageTreeNode(scope, message); this.add(child); } 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-27 09:46:58 UTC (rev 1011) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-05-27 16:55:44 UTC (rev 1012) @@ -26,12 +26,7 @@ */ import com.google.common.collect.Lists; -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.MarineLitterBatch; -import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.*; import fr.ifremer.tutti.service.catches.TuttiWeightComputingException; import fr.ifremer.tutti.service.catches.TuttiWeightComputingService; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; @@ -39,9 +34,11 @@ import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import org.jdesktop.swingx.JXTable; import javax.swing.JOptionPane; import java.util.List; +import java.util.Map; import static org.nuiton.i18n.I18n._; @@ -71,7 +68,17 @@ } catch (TuttiWeightComputingException e) { getUI().getTabPane().setSelectedIndex(1); - AbstractSelectTableAction.doSelectCell(getUI().getSpeciesTabContent().getTable(), e.getIndex(), 1); + + int index = e.getIndex(); + SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getModel().getRows().get(index); + int column; + if (SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) { + column = getFinestCategoryColumn(row.getFinestCategory().getCategoryType()); + } else { + column = 6; + } + AbstractSelectTableAction.doSelectCell(getUI().getSpeciesTabContent().getTable(), index, column); + throw e; } @@ -84,7 +91,17 @@ } catch (TuttiWeightComputingException e) { getUI().getTabPane().setSelectedIndex(2); - AbstractSelectTableAction.doSelectCell(getUI().getBenthosTabContent().getTable(), e.getIndex(), 1); + + int index = e.getIndex(); + BenthosBatchRowModel row = getUI().getBenthosTabContent().getModel().getRows().get(index); + int column; + if (BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) { + column = getFinestCategoryColumn(row.getFinestCategory().getCategoryType()); + } else { + column = 6; + } + AbstractSelectTableAction.doSelectCell(getUI().getBenthosTabContent().getTable(), index, column); + throw e; } @@ -228,4 +245,18 @@ } return totalSortedWeight; } + + protected int getFinestCategoryColumn(SampleCategoryEnum categoryType) { + int column = 1; + + List<Integer> samplingOrderIds = getConfig().getServiceConfig().getSamplingOrderIds(); + Integer categoryId = categoryType.getFieldValue(); + + int index = samplingOrderIds.indexOf(categoryId); + if (index > -1) { + column += index + 1; + } + + return column; + } }
participants (1)
-
kmorin@users.forge.codelutin.com