branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant created (now b0fedab)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant in repository tutti. See http://git.codelutin.com/tutti.git at b0fedab Ajout du filtre sure les espèces de thons (see #7601). This branch includes the following new commits: new fd81f78 Ajout de trace dans les appels des services (see #7601). new b0fedab Ajout du filtre sure les espèces de thons (see #7601). The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit b0fedab03c0468973a75236a5ee40ddc58367205 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Mar 7 17:39:14 2016 +0100 Ajout du filtre sure les espèces de thons (see #7601). commit fd81f7811e9bb5334d0fb77cb3a834148d3ccb37 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Mar 7 17:37:28 2016 +0100 Ajout de trace dans les appels des services (see #7601). -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant in repository tutti. See http://git.codelutin.com/tutti.git commit fd81f7811e9bb5334d0fb77cb3a834148d3ccb37 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Mar 7 17:37:28 2016 +0100 Ajout de trace dans les appels des services (see #7601). --- .../service/seine/ObjectSchoolEstimateServiceTopia.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ObjectSchoolEstimateServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ObjectSchoolEstimateServiceTopia.java index 87dac72..35cfcd8 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ObjectSchoolEstimateServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ObjectSchoolEstimateServiceTopia.java @@ -28,14 +28,21 @@ import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.reference.request.ReferenceSetRequestDefinitions; import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.seine.FloatingObjectSchoolEstimateDto; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ public class ObjectSchoolEstimateServiceTopia extends ObserveServiceTopia implements ObjectSchoolEstimateService { + private static final Log log = LogFactory.getLog(ObjectSchoolEstimateServiceTopia.class); + @Override public Form<FloatingObjectSchoolEstimateDto> loadForm(String floatingObjectId) { + if (log.isTraceEnabled()) { + log.trace("loadForm(" + floatingObjectId + ")"); + } FloatingObject floatingObject = loadEntity(FloatingObjectSchoolEstimateDto.class, floatingObjectId); @@ -52,6 +59,9 @@ public class ObjectSchoolEstimateServiceTopia extends ObserveServiceTopia implem @Override public SaveResultDto save(FloatingObjectSchoolEstimateDto dto) { + if (log.isTraceEnabled()) { + log.trace("save(" + dto.getId() + ")"); + } FloatingObject entity = loadOrCreateEntityAndCheckLastUpdate(dto); copyDataDtoToEntity(dto, entity); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant in repository tutti. See http://git.codelutin.com/tutti.git commit b0fedab03c0468973a75236a5ee40ddc58367205 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Mar 7 17:39:14 2016 +0100 Ajout du filtre sure les espèces de thons (see #7601). --- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 40 ++++++++++++++++++++++ .../dto/referential/ReferentialReferences.java | 39 ++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java index 1604deb..874d093 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java @@ -21,14 +21,21 @@ */ package fr.ird.observe.ui.content.table.impl.seine; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; 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.SpeciesListDto; import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.seine.FloatingObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.FloatingObjectSchoolEstimateDtos; import fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto; +import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.services.service.seine.ObjectSchoolEstimateService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; @@ -37,6 +44,8 @@ import org.apache.commons.logging.LogFactory; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; +import java.util.LinkedList; +import java.util.List; import static org.nuiton.i18n.I18n.n; @@ -104,6 +113,37 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin FloatingObjectSchoolEstimateDtos.copyFloatingObjectSchoolEstimateDto(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().getSpeciesListSeineObjectSchoolEstimateId(); + + ReferentialService referentialService = ObserveSwingApplicationContext.get().newService(ReferentialService.class); + Form<SpeciesListDto> speciesListDtoForm = referentialService.loadForm(SpeciesListDto.class, speciesListId); + SpeciesListDto speciesListDto = speciesListDtoForm.getObject(); + + List<String> species = Lists.newArrayList(Iterables.transform(speciesListDto.getSpecies(), ReferentialReferences.getIdFunction())); + + result = ReferentialReferences.filterContains(result, species); + + 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 ObjectSchoolEstimateService getObjectSchoolEstimateService() { return ObserveSwingApplicationContext.get().newService(ObjectSchoolEstimateService.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..03ff70b 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 @@ -1,5 +1,6 @@ package fr.ird.observe.services.dto.referential; +import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -13,6 +14,14 @@ import java.util.List; */ public class ReferentialReferences { + protected static final Function<ReferentialReference, String> ID_FUNCTION = new Function<ReferentialReference, String>() { + + @Override + public String apply(ReferentialReference input) { + return input.getId(); + } + }; + protected static final Predicate<ReferentialReference> IS_ENABLE_PREDICATE = new Predicate<ReferentialReference>() { @Override @@ -21,10 +30,38 @@ 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; + + } + + public static <D extends ReferentialDto> List<ReferentialReference<D>> filterContains(Iterable<ReferentialReference<D>> references, List<String> containsIds) { + + List<ReferentialReference<D>> result = Lists.newArrayList(Iterables.filter(references, new ContainsPredicate(containsIds))); + return result; } + + public static Function<ReferentialReference, String> getIdFunction() { + return ID_FUNCTION; + + } + + protected static final class ContainsPredicate implements Predicate<ReferentialReference> { + + protected List<String> containsIds; + + public ContainsPredicate(List<String> containsIds) { + this.containsIds = containsIds; + } + + @Override + public boolean apply(ReferentialReference input) { + return containsIds.contains(input.getId()); + } + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm