From scm@users.codelutin.com Mon Mar  7 17:39:38 2016
From: "codelutin.com scm" <scm@users.codelutin.com>
To: observe-commits@list.forge.codelutin.com
Subject: [Observe-commits] branch
 feature/7601-PS-VerifEstimationdesBancSurObjetFlottant created (now b0fedab)
Date: Mon, 07 Mar 2016 17:39:38 +0100
Message-ID: <20160307163938.27202.91409@bihar.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============2545432031209293766=="

--===============2545432031209293766==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This is an automated email from the git hooks/post-receive script.

New change to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant i=
n repository tutti.

See http://git.codelutin.com/tutti.git

        at  b0fedab   Ajout du filtre sure les esp=C3=A8ces de thons (see #76=
01).

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=C3=A8ces de thons (see #76=
01).

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=C3=A8ces 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).

--=20
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm@codelutin.com>.

--===============2545432031209293766==--


From scm@users.codelutin.com Mon Mar  7 17:39:38 2016
From: "codelutin.com scm" <scm@users.codelutin.com>
To: observe-commits@list.forge.codelutin.com
Subject: [Observe-commits] 01/02: Ajout de trace dans les appels des	services
 (see #7601).
Date: Mon, 07 Mar 2016 17:39:39 +0100
Message-ID: <20160307163938.CE4415C2523@goh.codelutin.com>
In-Reply-To: <20160307163938.27202.91409@bihar.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============4349492415527430176=="

--===============4349492415527430176==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This is an automated email from the git hooks/post-receive script.

New commit to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant i=
n 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/ser=
vice/seine/ObjectSchoolEstimateServiceTopia.java b/observe-services-topia/src=
/main/java/fr/ird/observe/services/service/seine/ObjectSchoolEstimateServiceT=
opia.java
index 87dac72..35cfcd8 100644
--- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/se=
ine/ObjectSchoolEstimateServiceTopia.java
+++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/se=
ine/ObjectSchoolEstimateServiceTopia.java
@@ -28,14 +28,21 @@ import fr.ird.observe.services.dto.Form;
 import fr.ird.observe.services.dto.reference.request.ReferenceSetRequestDefi=
nitions;
 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;
=20
 /**
  * @author Sylvain Bavencoff - bavencoff@codelutin.com
  */
 public class ObjectSchoolEstimateServiceTopia extends ObserveServiceTopia im=
plements ObjectSchoolEstimateService {
=20
+    private static final Log log =3D LogFactory.getLog(ObjectSchoolEstimateS=
erviceTopia.class);
+
     @Override
     public Form<FloatingObjectSchoolEstimateDto> loadForm(String floatingObj=
ectId) {
+        if (log.isTraceEnabled()) {
+            log.trace("loadForm(" + floatingObjectId + ")");
+        }
=20
         FloatingObject floatingObject =3D
                 loadEntity(FloatingObjectSchoolEstimateDto.class, floatingOb=
jectId);
@@ -52,6 +59,9 @@ public class ObjectSchoolEstimateServiceTopia extends Obser=
veServiceTopia implem
=20
     @Override
     public SaveResultDto save(FloatingObjectSchoolEstimateDto dto) {
+        if (log.isTraceEnabled()) {
+            log.trace("save(" + dto.getId() + ")");
+        }
=20
         FloatingObject entity =3D loadOrCreateEntityAndCheckLastUpdate(dto);
         copyDataDtoToEntity(dto, entity);

--=20
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm@codelutin.com>.

--===============4349492415527430176==--


From scm@users.codelutin.com Mon Mar  7 17:39:39 2016
From: "codelutin.com scm" <scm@users.codelutin.com>
To: observe-commits@list.forge.codelutin.com
Subject: [Observe-commits]  02/02: Ajout du filtre sure les =?utf-8?q?esp?=
 =?utf-8?q?=C3=A8ces?= de thons (see #7601).
Date: Mon, 07 Mar 2016 17:39:40 +0100
Message-ID: <20160307163939.546F95CB5D4@goh.codelutin.com>
In-Reply-To: <20160307163938.27202.91409@bihar.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1897352934525954252=="

--===============1897352934525954252==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This is an automated email from the git hooks/post-receive script.

New commit to branch feature/7601-PS-VerifEstimationdesBancSurObjetFlottant i=
n 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=C3=A8ces 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/conten=
t/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-application-s=
wing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEst=
imateUIHandler.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;
=20
+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;
=20
 import javax.swing.JTable;
 import javax.swing.table.DefaultTableCellRenderer;
+import java.util.LinkedList;
+import java.util.List;
=20
 import static org.nuiton.i18n.I18n.n;
=20
@@ -104,6 +113,37 @@ public class ObjectSchoolEstimateUIHandler extends Conte=
ntTableUIHandler<Floatin
         FloatingObjectSchoolEstimateDtos.copyFloatingObjectSchoolEstimateDto=
(form.getObject(), getBean());
     }
=20
+    @Override
+    protected <D extends ReferentialDto> Iterable<ReferentialReference<D>> f=
ilterReferentialReferences(Class<D> dtoType, String propertyName, LinkedList<=
ReferentialReference<D>> incomingReferences) {
+
+        Iterable<ReferentialReference<D>> result =3D super.filterReferential=
References(dtoType, propertyName, incomingReferences);
+
+        switch (propertyName) {
+
+            case ObjectSchoolEstimateDto.PROPERTY_SPECIES: {
+                String speciesListId =3D ObserveSwingApplicationContext.get(=
).getConfig().getSpeciesListSeineObjectSchoolEstimateId();
+
+                ReferentialService referentialService =3D ObserveSwingApplic=
ationContext.get().newService(ReferentialService.class);
+                Form<SpeciesListDto> speciesListDtoForm =3D referentialServi=
ce.loadForm(SpeciesListDto.class, speciesListId);
+                SpeciesListDto speciesListDto =3D speciesListDtoForm.getObje=
ct();
+
+                List<String> species =3D Lists.newArrayList(Iterables.transf=
orm(speciesListDto.getSpecies(), ReferentialReferences.getIdFunction()));
+
+                result =3D ReferentialReferences.filterContains(result, spec=
ies);
+
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Filter referential references (=
type %s - property %s), final size: %d", dtoType.getSimpleName(), propertyNam=
e, incomingReferences.size()));
+                }
+            }
+
+            break;
+
+        }
+
+        return result;
+
+    }
+
     protected ObjectSchoolEstimateService getObjectSchoolEstimateService() {
         return ObserveSwingApplicationContext.get().newService(ObjectSchoolE=
stimateService.class);
     }
diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto=
/referential/ReferentialReferences.java b/observe-services-model/src/main/jav=
a/fr/ird/observe/services/dto/referential/ReferentialReferences.java
index 0e3491f..03ff70b 100644
--- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/refere=
ntial/ReferentialReferences.java
+++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/refere=
ntial/ReferentialReferences.java
@@ -1,5 +1,6 @@
 package fr.ird.observe.services.dto.referential;
=20
+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 {
=20
+    protected static final Function<ReferentialReference, String> ID_FUNCTIO=
N =3D  new Function<ReferentialReference, String>() {
+
+        @Override
+        public String apply(ReferentialReference input) {
+            return input.getId();
+        }
+    };
+
     protected static final Predicate<ReferentialReference> IS_ENABLE_PREDICA=
TE =3D new Predicate<ReferentialReference>() {
=20
         @Override
@@ -21,10 +30,38 @@ public class ReferentialReferences {
         }
     };
=20
-    public static <D extends ReferentialDto> List<ReferentialReference<D>> f=
ilterEnabled(List<ReferentialReference<D>> references) {
+    public static <D extends ReferentialDto> List<ReferentialReference<D>> f=
ilterEnabled(Iterable<ReferentialReference<D>> references) {
=20
         List<ReferentialReference<D>> result =3D Lists.newArrayList(Iterable=
s.filter(references, IS_ENABLE_PREDICATE));
+
+        return result;
+
+    }
+
+    public static <D extends ReferentialDto> List<ReferentialReference<D>> f=
ilterContains(Iterable<ReferentialReference<D>> references, List<String> cont=
ainsIds) {
+
+        List<ReferentialReference<D>> result =3D Lists.newArrayList(Iterable=
s.filter(references, new ContainsPredicate(containsIds)));
+
         return result;
=20
     }
+
+    public static Function<ReferentialReference, String> getIdFunction() {
+        return ID_FUNCTION;
+
+    }
+
+    protected static final class ContainsPredicate implements Predicate<Refe=
rentialReference> {
+
+        protected List<String> containsIds;
+
+        public ContainsPredicate(List<String> containsIds) {
+            this.containsIds =3D containsIds;
+        }
+
+        @Override
+        public boolean apply(ReferentialReference input) {
+            return containsIds.contains(input.getId());
+        }
+    }
 }

--=20
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm@codelutin.com>.

--===============1897352934525954252==--


