This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 4583d5a8bc57eb348793e7c67aad137ddcdcf253 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Mar 22 20:10:31 2016 +0100 Oups encore du refactor sur le réusinage Species/Benthos --- .../fr/ifremer/tutti/service/TuttiDataContext.java | 125 ++++++++++----------- .../service/pupitri/PupitriImportService.java | 2 +- .../catches/species/BenthosBatchUISupportImpl.java | 15 ++- .../catches/species/SpeciesBatchUISupportImpl.java | 27 ++--- .../species/SpeciesOrBenthosBatchUISupport.java | 23 +++- .../create/CreateSpeciesBatchUIHandler.java | 7 +- .../species/edit/SpeciesBatchUIHandler.java | 10 +- .../edit/actions/RenameSpeciesBatchAction.java | 7 +- .../species/split/SplitSpeciesBatchUIHandler.java | 13 ++- .../species/split/SplitSpeciesBatchUIModel.java | 17 ++- 10 files changed, 144 insertions(+), 102 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java index 3c5c2cb..182c64f 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java @@ -26,7 +26,6 @@ import com.google.common.base.Preconditions; import fr.ifremer.tutti.TuttiConfiguration; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; @@ -678,63 +677,63 @@ public class TuttiDataContext extends AbstractBean implements Closeable { return maturityCaracteristics; } - /** - * Get the best possible first sample category for the given benthos. - * - * Will look inside the protocol if there is a row for the given benthos, - * if so try then to use the first selected sample category. - * - * If selected category is null, then try to use the first one from the - * given categories. - * - * @param categories list of possible categories - * @param species species to use - * @return the best first sample category to use for the given benthos - * @since 3.0 - */ - public SampleCategoryModelEntry getBestFirstBenthosSampleCategory(List<SampleCategoryModelEntry> categories, - Species species) { - - - SpeciesProtocol speciesProtocol = null; - - if (isProtocolFilled()) { - - speciesProtocol = service.getBenthosProtocol(species); - } - - return getBestFirstSampleCategory(categories, speciesProtocol); - } - - /** - * Get the best possible first sample category for the given species. - * - * Will look inside the protocol if there is a row for the given species, - * if so try then to use the first selected sample category. - * - * If selected category is null, then try to use the first one from the - * given categories. - * - * @param categories list of possible categories - * @param species species to use - * @return the best first sample category to use for the given species - * @since 3.0 - */ - public SampleCategoryModelEntry getBestFirstSpeciesSampleCategory(List<SampleCategoryModelEntry> categories, - Species species) { - - SpeciesProtocol speciesProtocol = null; - - if (isProtocolFilled()) { - - speciesProtocol = service.getSpeciesProtocol(species); - } - - return getBestFirstSampleCategory(categories, speciesProtocol); - } - - protected SampleCategoryModelEntry getBestFirstSampleCategory(List<SampleCategoryModelEntry> categories, - SpeciesProtocol speciesProtocol) { +// /** +// * Get the best possible first sample category for the given benthos. +// * +// * Will look inside the protocol if there is a row for the given benthos, +// * if so try then to use the first selected sample category. +// * +// * If selected category is null, then try to use the first one from the +// * given categories. +// * +// * @param categories list of possible categories +// * @param species species to use +// * @return the best first sample category to use for the given benthos +// * @since 3.0 +// */ +// public SampleCategoryModelEntry getBestFirstBenthosSampleCategory(List<SampleCategoryModelEntry> categories, +// Species species) { +// +// +// SpeciesProtocol speciesProtocol = null; +// +// if (isProtocolFilled()) { +// +// speciesProtocol = service.getBenthosProtocol(species); +// } +// +// return getBestFirstSampleCategory(categories, speciesProtocol); +// } +// +// /** +// * Get the best possible first sample category for the given species. +// * +// * Will look inside the protocol if there is a row for the given species, +// * if so try then to use the first selected sample category. +// * +// * If selected category is null, then try to use the first one from the +// * given categories. +// * +// * @param categories list of possible categories +// * @param species species to use +// * @return the best first sample category to use for the given species +// * @since 3.0 +// */ +// public SampleCategoryModelEntry getBestFirstSpeciesSampleCategory(List<SampleCategoryModelEntry> categories, +// Species species) { +// +// SpeciesProtocol speciesProtocol = null; +// +// if (isProtocolFilled()) { +// +// speciesProtocol = service.getSpeciesProtocol(species); +// } +// +// return getBestFirstSampleCategory(categories, speciesProtocol); +// } + + public SampleCategoryModelEntry getBestFirstSampleCategory(List<SampleCategoryModelEntry> categories, + SpeciesProtocol speciesProtocol) { SampleCategoryModelEntry selectedCategory = null; @@ -807,9 +806,9 @@ public class TuttiDataContext extends AbstractBean implements Closeable { return cpsTypeValues; } - public List<Species> getReferentSpeciesWithSurveyCode() { - return getReferentSpeciesWithSurveyCode(false); - } +// public List<Species> getReferentSpeciesWithSurveyCode() { +// return getReferentSpeciesWithSurveyCode(false); +// } public List<Species> getReferentSpeciesWithSurveyCode(boolean restrictToProtocol) { checkOpened(); @@ -846,10 +845,6 @@ public class TuttiDataContext extends AbstractBean implements Closeable { } - public List<Species> getReferentBenthosWithSurveyCode() { - return getReferentBenthosWithSurveyCode(false); - } - public List<Species> getReferentBenthosWithSurveyCode(boolean restrictToProtocol) { checkOpened(); if (referentBenthosWithSurveyCode == null) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java index 7464ef8..396af5e 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java @@ -394,7 +394,7 @@ public class PupitriImportService extends AbstractTuttiService { // get the map of species by survey code or reftax code ListMultimap<String, Species> speciesBySurveyCode = ArrayListMultimap.create(); - speciesBySurveyCode.putAll(Speciess.splitBySurveyCode(dataContext.getReferentSpeciesWithSurveyCode())); + speciesBySurveyCode.putAll(Speciess.splitBySurveyCode(dataContext.getReferentSpeciesWithSurveyCode(false))); speciesBySurveyCode.putAll(Speciess.splitByRefTaxCode(dataContext.getReferentSpecies())); CarrouselImportRequestResult result = new CarrouselImportRequestResult(speciesBySurveyCode); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java index 6507ca1..5af43d1 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java @@ -29,6 +29,7 @@ import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.TuttiUIContext; @@ -265,8 +266,18 @@ public class BenthosBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { } @Override - public List<Species> getReferentSpeciesWithSurveyCode() { - return context.getDataContext().getReferentBenthosWithSurveyCode(true); + public List<Species> getReferentSpeciesWithSurveyCode(boolean restrictToProtocol) { + return context.getDataContext().getReferentBenthosWithSurveyCode(restrictToProtocol); + } + + @Override + public List<Species> getReferentOtherSpeciesWithSurveyCode(boolean restrictToProtocol) { + return context.getDataContext().getReferentSpeciesWithSurveyCode(restrictToProtocol); + } + + @Override + public List<SpeciesProtocol> getSpeciesFromProtocol() { + return context.getDataContext().getProtocol().getBenthos(); } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java index 1144556..2dee051 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java @@ -29,6 +29,7 @@ import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.TuttiUIContext; @@ -50,29 +51,19 @@ public class SpeciesBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { public static final String PROPERTY_TOTAL_COMPUTED_WEIGHT = "totalComputedWeight"; public static final String PROPERTY_TOTAL_SORTED_WEIGHT = "totalSortedWeight"; -// public static final String PROPERTY_TOTAL_SORTED_COMPUTED_WEIGHT = "totalSortedComputedWeight"; public static final String PROPERTY_TOTAL_UNSORTED_COMPUTED_WEIGHT = "totalUnsortedComputedWeight"; public static final String PROPERTY_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT = "totalSampleSortedComputedWeight"; -// public static final String PROPERTY_TOTAL_INERT_COMPUTED_WEIGHT = "totalInertComputedWeight"; public static final String PROPERTY_TOTAL_INERT_WEIGHT = "totalInertWeight"; -// public static final String PROPERTY_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT = "totalLivingNotItemizedComputedWeight"; public static final String PROPERTY_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "totalLivingNotItemizedWeight"; -// public static final String PROPERTY_DISTINCT_SORTED_SPECIES_COUNT = "distinctSortedSpeciesCount"; -// public static final String PROPERTY_DISTINCT_UNSORTED_SPECIES_COUNT = "distinctUnsortedSpeciesCount"; protected static final Map<String, String> CATCHES_UI_MODEL_PROPERTIES_MAPPING = ImmutableMap.<String, String>builder() .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, PROPERTY_TOTAL_COMPUTED_WEIGHT) .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, PROPERTY_TOTAL_SORTED_WEIGHT) -// .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT, PROPERTY_TOTAL_SORTED_COMPUTED_WEIGHT) .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT, PROPERTY_TOTAL_UNSORTED_COMPUTED_WEIGHT) .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, PROPERTY_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT) -// .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_COMPUTED_WEIGHT, PROPERTY_TOTAL_INERT_COMPUTED_WEIGHT) .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, PROPERTY_TOTAL_INERT_WEIGHT) -// .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT, PROPERTY_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT) .put(EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, PROPERTY_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT) -// .put(EditCatchesUIModel.PROPERTY_SPECIES_DISTINCT_SORTED_SPECIES_COUNT, PROPERTY_DISTINCT_SORTED_SPECIES_COUNT) -// .put(EditCatchesUIModel.PROPERTY_SPECIES_DISTINCT_UNSORTED_SPECIES_COUNT, PROPERTY_DISTINCT_UNSORTED_SPECIES_COUNT) .build(); public SpeciesBatchUISupportImpl(TuttiUIContext context, EditCatchesUIModel catchesUIModel, WeightUnit weightUnit) { @@ -236,7 +227,7 @@ public class SpeciesBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { @Override public Map<String, Object> importMultiPost(File file, FishingOperation operation, SpeciesBatch speciesBatch, boolean importFrequencies, boolean importIndivudalObservations) { - return context.getMultiPostImportService().importSpeciesBatch(file, operation, speciesBatch,importFrequencies, importIndivudalObservations); + return context.getMultiPostImportService().importSpeciesBatch(file, operation, speciesBatch, importFrequencies, importIndivudalObservations); } @Override @@ -265,8 +256,18 @@ public class SpeciesBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { } @Override - public List<Species> getReferentSpeciesWithSurveyCode() { - return context.getDataContext().getReferentSpeciesWithSurveyCode(true); + public List<Species> getReferentSpeciesWithSurveyCode(boolean restrictToProtocol) { + return context.getDataContext().getReferentSpeciesWithSurveyCode(restrictToProtocol); + } + + @Override + public List<Species> getReferentOtherSpeciesWithSurveyCode(boolean restrictToProtocol) { + return context.getDataContext().getReferentBenthosWithSurveyCode(restrictToProtocol); + } + + @Override + public List<SpeciesProtocol> getSpeciesFromProtocol() { + return context.getDataContext().getProtocol().getSpecies(); } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java index a34a055..79e88e2 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java @@ -26,8 +26,11 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.type.WeightUnit; @@ -161,5 +164,23 @@ public abstract class SpeciesOrBenthosBatchUISupport { public abstract List<SpeciesBatchFrequency> saveBatchFrequencies(Integer speciesBatchId, List<SpeciesBatchFrequency> frequency); - public abstract List<Species> getReferentSpeciesWithSurveyCode(); + public abstract List<Species> getReferentSpeciesWithSurveyCode(boolean restrictToProtocol); + + public abstract List<Species> getReferentOtherSpeciesWithSurveyCode(boolean restrictToProtocol); + + public abstract List<SpeciesProtocol> getSpeciesFromProtocol(); + + public final List<Species> getReferentSpeciesWithSurveyCode() { + return getReferentSpeciesWithSurveyCode(false); + } + + public final SpeciesProtocol getSpeciesProtocol(Species species) { + return TuttiProtocols.getSpeciesProtocol(species, getSpeciesFromProtocol()); + } + + public final SampleCategoryModelEntry getBestFirstSampleCategory(List<SampleCategoryModelEntry> data, Species species) { + SpeciesProtocol speciesProtocol = getSpeciesProtocol(species); + return context.getDataContext().getBestFirstSampleCategory(data, speciesProtocol); + } + } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java index 2335088..dff123a 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java @@ -100,8 +100,8 @@ public class CreateSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spl @Override public void propertyChange(PropertyChangeEvent evt) { - CreateSpeciesBatchUIModel source = - (CreateSpeciesBatchUIModel) evt.getSource(); + CreateSpeciesBatchUIModel source = (CreateSpeciesBatchUIModel) evt.getSource(); + Species newValue = (Species) evt.getNewValue(); if (log.isDebugEnabled()) { @@ -148,7 +148,8 @@ public class CreateSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spl // compute the selected sample category - SampleCategoryModelEntry selectedCategory = getDataContext().getBestFirstSpeciesSampleCategory( + + SampleCategoryModelEntry selectedCategory = source.getSpeciesOrBenthosBatchUISupport().getBestFirstSampleCategory( getUI().getCategoryComboBox().getData(), newValue ); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/SpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/SpeciesBatchUIHandler.java index caa4ba5..db45cbd 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/SpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/SpeciesBatchUIHandler.java @@ -1144,15 +1144,11 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec getDataContext().getDefaultIndividualObservationCaracteristics()); for (IndividualObservationBatchRowModel obsRow : newRow.getIndividualObservation()) { - List<Attachment> attachments = - getPersistenceService().getAllAttachments(obsRow.getObjectType(), - obsRow.getObjectId()); + List<Attachment> attachments = getPersistenceService().getAllAttachments(obsRow.getObjectType(), obsRow.getObjectId()); obsRow.addAllAttachment(attachments); } - List<Attachment> attachments = - getPersistenceService().getAllAttachments(newRow.getObjectType(), - newRow.getObjectId()); + List<Attachment> attachments = getPersistenceService().getAllAttachments(newRow.getObjectType(), newRow.getObjectId()); newRow.addAllAttachment(attachments); @@ -1160,7 +1156,7 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec // the species of the parent is set to the children in loadBatchRow if (parentRow == null && getContext().isProtocolFilled()) { // get the surveycode from the species list of the model - List<Species> speciesList = getDataContext().getReferentSpeciesWithSurveyCode(); + List<Species> speciesList = speciesOrBenthosBatchUISupport.getReferentSpeciesWithSurveyCode(); int i = speciesList.indexOf(newRow.getSpecies()); if (i > -1) { newRow.setSpecies(speciesList.get(i)); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RenameSpeciesBatchAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RenameSpeciesBatchAction.java index 01999da..8da4e90 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RenameSpeciesBatchAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RenameSpeciesBatchAction.java @@ -29,6 +29,7 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.entities.referential.Speciess; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesOrBenthosBatchUISupport; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchUI; @@ -64,6 +65,8 @@ public class RenameSpeciesBatchAction extends LongActionSupport<SpeciesBatchUIMo public boolean prepareAction() throws Exception { boolean result = super.prepareAction(); + SpeciesOrBenthosBatchUISupport speciesOrBenthosBatchUISupport = getModel().getSpeciesOrBenthosBatchUISupport(); + SpeciesBatchTableModel tableModel = handler.getTableModel(); JXTable table = handler.getTable(); int selectedRowIndex = SwingUtil.getSelectedModelRow(table); @@ -79,13 +82,13 @@ public class RenameSpeciesBatchAction extends LongActionSupport<SpeciesBatchUIMo Collection<Species> speciesUsedForFirstCategory = model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue); - List<Species> speciesList = new ArrayList<>(getDataContext().getReferentSpeciesWithSurveyCode(true)); + List<Species> speciesList = new ArrayList<>(speciesOrBenthosBatchUISupport.getReferentSpeciesWithSurveyCode(true)); speciesList.removeAll(speciesUsedForFirstCategory); List<Species> allSpeciesList = new ArrayList<>(getDataContext().getSpecies()); allSpeciesList.removeAll(speciesUsedForFirstCategory); // do not show the benthos species - allSpeciesList.removeAll(getDataContext().getReferentBenthosWithSurveyCode(true)); + allSpeciesList.removeAll(speciesOrBenthosBatchUISupport.getReferentOtherSpeciesWithSurveyCode(true)); //remove the synonyms of the already used species Multimap<String, Species> speciesByReferent = Speciess.splitByReferenceTaxonId(allSpeciesList); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java index 954ccd0..410509b 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java @@ -29,6 +29,7 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.EditSpeciesBatchPanelUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesOrBenthosBatchUISupport; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; @@ -117,6 +118,8 @@ public class SplitSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spli } }; + protected SpeciesOrBenthosBatchUISupport speciesOrBenthosBatchUISupport; + public SplitSpeciesBatchUIHandler() { super(SplitSpeciesBatchRowModel.PROPERTY_SELECTED, SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE, @@ -201,7 +204,9 @@ public class SplitSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spli super.beforeInit(ui); SampleCategoryModel sampleCategoryModel = getDataContext().getSampleCategoryModel(); - SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel(getConfig().getSpeciesWeightUnit(), sampleCategoryModel); + this.speciesOrBenthosBatchUISupport = ui.getContextValue(SpeciesOrBenthosBatchUISupport.class, ui.getSpeciesOrBenthosContext()); + + SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel(speciesOrBenthosBatchUISupport, sampleCategoryModel); ui.setContextValue(model); } @@ -263,6 +268,8 @@ public class SplitSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spli // get possible the last used List<SampleCategoryModelEntry> categories = new ArrayList<>(); + SplitSpeciesBatchUIModel model = getModel(); + SampleCategoryModelEntry bestSampleCategory = null; if (batch != null) { @@ -289,11 +296,9 @@ public class SplitSpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<Spli } } - bestSampleCategory = getDataContext().getBestFirstSpeciesSampleCategory(categories, batch.getSpecies()); + bestSampleCategory = model.getSpeciesOrBenthosBatchUISupport().getBestFirstSampleCategory(categories, batch.getSpecies()); } - SplitSpeciesBatchUIModel model = getModel(); - // connect model to validator ui.getValidator().setBean(model); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java index fe980f7..5749cd0 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java @@ -24,9 +24,10 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; +import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SelectedCategoryAble; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesOrBenthosBatchUISupport; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; -import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; import java.util.List; @@ -96,14 +97,18 @@ public class SplitSpeciesBatchUIModel /** * Is ui in split mode ? + * * @since 2.6 */ protected boolean splitMode = true; - public SplitSpeciesBatchUIModel(WeightUnit weightUnit, + private final SpeciesOrBenthosBatchUISupport speciesOrBenthosBatchUISupport; + + public SplitSpeciesBatchUIModel(SpeciesOrBenthosBatchUISupport speciesOrBenthosBatchUISupport, SampleCategoryModel sampleCategoryModel) { super(SpeciesBatchRowModel.class, null, null); - this.weightUnit = weightUnit; + this.speciesOrBenthosBatchUISupport = speciesOrBenthosBatchUISupport; + this.weightUnit = speciesOrBenthosBatchUISupport.getWeightUnit(); this.sampleCategoryModel = sampleCategoryModel; } @@ -112,6 +117,10 @@ public class SplitSpeciesBatchUIModel return new SpeciesBatchRowModel(weightUnit, sampleCategoryModel); } + public SpeciesOrBenthosBatchUISupport getSpeciesOrBenthosBatchUISupport() { + return speciesOrBenthosBatchUISupport; + } + public SpeciesBatchRowModel getBatch() { return batch; } @@ -168,6 +177,6 @@ public class SplitSpeciesBatchUIModel public void setSplitMode(boolean splitMode) { Object oldValue = isSplitMode(); this.splitMode = splitMode; - firePropertyChange(PROPERTY_SPLIT_MODE, oldValue,splitMode); + firePropertyChange(PROPERTY_SPLIT_MODE, oldValue, splitMode); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.