This is an automated email from the git hooks/post-receive script. New commit to branch feature/7618-LL-VerifEcranRencontres in repository tutti. See http://git.codelutin.com/tutti.git commit ef9d34c2f592be5178799cff0adedeb655004e8d Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 9 17:16:01 2016 +0100 Ajouter du filtre sur les espèces (see #7618). --- .../table/impl/longline/EncounterUIHandler.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java index fe2ef62..9b706b9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java @@ -28,9 +28,14 @@ import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.longline.ActivityLonglineEncouterDto; import fr.ird.observe.services.dto.longline.ActivityLonglineEncouterDtos; import fr.ird.observe.services.dto.longline.EncounterDto; +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.SpeciesListDto; import fr.ird.observe.services.dto.referential.longline.EncounterTypeDto; import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.services.service.longline.ActivityLongLineEncouterService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; @@ -39,6 +44,9 @@ import org.apache.commons.logging.LogFactory; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Set; import static org.nuiton.i18n.I18n.n; @@ -114,6 +122,39 @@ public class EncounterUIHandler extends ContentTableUIHandler<ActivityLonglineEn ActivityLonglineEncouterDtos.copyActivityLonglineEncouterDto(form.getObject(), getBean()); } + @Override + protected <D extends ReferentialDto> Collection<ReferentialReference<D>> filterReferentialReferences(Class<D> dtoType, String propertyName, LinkedList<ReferentialReference<D>> incomingReferences) { + + Collection<ReferentialReference<D>> result = super.filterReferentialReferences(dtoType, propertyName, incomingReferences); + + switch (propertyName) { + + case EncounterDto.PROPERTY_SPECIES: { + + String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListLonglineEncounterId(); + + ReferentialService referentialService = ObserveSwingApplicationContext.get().newService(ReferentialService.class); + + Form<SpeciesListDto> speciesListDtoForm = referentialService.loadForm(SpeciesListDto.class, speciesListId); + SpeciesListDto speciesListDto = speciesListDtoForm.getObject(); + + Set<String> speciesIds = speciesListDto.getSpeciesIds(); + + result = ReferentialReferences.filterContains(result, speciesIds); + + 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 ActivityLongLineEncouterService getActivityLongLineEncouterService() { return ObserveSwingApplicationContext.get().newService(ActivityLongLineEncouterService.class); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.