This is an automated email from the git hooks/post-receive script. New commit to branch feature/7604-PS-VerifEcranCaptureCibleDUneCalee in repository tutti. See http://git.codelutin.com/tutti.git commit 4b85601ec28a2fab3ba03418e376a0d5f75e79d4 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Mar 8 14:21:44 2016 +0100 Ajouter du filtre sur les espèces (see #7604). --- .../table/impl/seine/TargetCatchUIHandler.java | 38 ++++++++++++++++++++-- .../dto/referential/ReferentialReferences.java | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index 06810be..2538717 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -26,14 +26,18 @@ import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.Form; +import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReference; +import fr.ird.observe.services.dto.referential.ReferentialReferences; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDtos; import fr.ird.observe.services.dto.seine.TargetCatchDto; import fr.ird.observe.services.dto.seine.TargetCatchDtos; +import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.services.service.seine.TargetCatchService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableModel; @@ -50,6 +54,7 @@ import javax.swing.table.DefaultTableCellRenderer; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -284,13 +289,42 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa @Override protected void loadEditBean(String beanId) { - String tripSeineId = getDataContext().getSelectedTripSeineId(); - Form<SetSeineTargetCatchDto> form = getTargetCatchService().loadForm(beanId, false, tripSeineId); + Form<SetSeineTargetCatchDto> form = getTargetCatchService().loadForm(beanId, false); loadReferentialReferenceSetsInModel(form); getModel().setForm(form); SetSeineTargetCatchDtos.copySetSeineTargetCatchDto(form.getObject(), getBean()); } + @Override + protected <D extends ReferentialDto> Iterable<ReferentialReference<D>> filterReferentialReferences(Class<D> dtoType, String propertyName, LinkedList<ReferentialReference<D>> incomingReferences) { + + Iterable<ReferentialReference<D>> result = super.filterReferentialReferences(dtoType, propertyName, incomingReferences); + + switch (propertyName) { + + case ObjectSchoolEstimateDto.PROPERTY_SPECIES: { + + String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListSeineTargetCatchId(); + String tripSeineId = getDataContext().getSelectedTripSeineId(); + + ReferentialService referentialService = ObserveSwingApplicationContext.get().newService(ReferentialService.class); + result = referentialService.getSpeciesByListAndTrip(speciesListId, tripSeineId); + + result = ReferentialReferences.filterEnabled(result); + + if (log.isDebugEnabled()) { + log.debug(String.format("Filter referential references (type %s - property %s), final size: %d", dtoType.getSimpleName(), propertyName, incomingReferences.size())); + } + } + + break; + + } + + return result; + + } + protected TargetCatchService getTargetCatchService() { return ObserveSwingApplicationContext.get().newService(TargetCatchService.class); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java index 0e3491f..400e8e5 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java @@ -21,7 +21,7 @@ public class ReferentialReferences { } }; - public static <D extends ReferentialDto> List<ReferentialReference<D>> filterEnabled(List<ReferentialReference<D>> references) { + public static <D extends ReferentialDto> List<ReferentialReference<D>> filterEnabled(Iterable<ReferentialReference<D>> references) { List<ReferentialReference<D>> result = Lists.newArrayList(Iterables.filter(references, IS_ENABLE_PREDICATE)); return result; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.