This is an automated email from the git hooks/post-receive script. New change to branch feature/6910-obsVente-effort in repository wao. See http://git.codelutin.com/wao.git from 7d071d9 refs #6910 modification de commentaires new cda662e Factorisation HTML new 74156fc Remaniement du calcul du nombre de sorties à la génération du plan 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 74156fc80df5a594cfbcb9b83fc6d601115f833a Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Apr 9 17:40:16 2015 +0200 Remaniement du calcul du nombre de sorties à la génération du plan commit cda662e70adbc0b93f9591ff33051add8b749367 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Apr 9 17:18:00 2015 +0200 Factorisation HTML Summary of changes: .../service/ObsVenteSamplingPlanBuilder.java | 64 +++++++--------------- .../WEB-INF/content/edit-sample-row-input.jsp | 14 +++-- 2 files changed, 29 insertions(+), 49 deletions(-) -- 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/6910-obsVente-effort in repository wao. See http://git.codelutin.com/wao.git commit cda662e70adbc0b93f9591ff33051add8b749367 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Apr 9 17:18:00 2015 +0200 Factorisation HTML --- .../main/webapp/WEB-INF/content/edit-sample-row-input.jsp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp index 38059e8..a1dcfbf 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp @@ -233,12 +233,14 @@ <div class="control-group"> - <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsVente"> - <label class="control-label"><s:text name="wao.ui.samplingPlan.effort.obsVente" /></label> - </s:if> - <s:else> - <label class="control-label"><s:text name="wao.ui.samplingPlan.effort" /></label> - </s:else> + <label class="control-label"> + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsVente"> + <s:text name="wao.ui.samplingPlan.effort.obsVente" /> + </s:if> + <s:else> + <s:text name="wao.ui.samplingPlan.effort" /> + </s:else> + </label> <div class="controls"> <table id="expectedObservationsByMonthsTable"> -- 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/6910-obsVente-effort in repository wao. See http://git.codelutin.com/wao.git commit 74156fc80df5a594cfbcb9b83fc6d601115f833a Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Apr 9 17:40:16 2015 +0200 Remaniement du calcul du nombre de sorties à la génération du plan --- .../service/ObsVenteSamplingPlanBuilder.java | 64 +++++++--------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanBuilder.java index e06caed..2663f16 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanBuilder.java @@ -24,8 +24,10 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Function; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; +import com.google.common.collect.HashMultimap; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.ListMultimap; +import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.Ordering; import fr.ifremer.wao.SampleRowsFilter; @@ -34,14 +36,13 @@ import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRows; -import org.apache.commons.collections4.map.MultiKeyMap; import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.Pair; import org.nuiton.util.PeriodDates; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -109,43 +110,29 @@ public class ObsVenteSamplingPlanBuilder { // get sector context SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); - // Pour chaque mois, on indique le nombre de navire observés - Map<Date, MutableInt> estimatedObservationsByMonths = new TreeMap<>(); - Map<Date, MutableInt> realObservationsByMonths = new TreeMap<>(); - - // un sortie correspondre à n couples début/fin d'observation - MultiKeyMap<Object, Pair<Date, Date>> nbRealObservationsByTripForMonth = new MultiKeyMap<>(); - MultiKeyMap<Object, Pair<Date, Date>> nbEstimatedObservationsByTrip = new MultiKeyMap<>(); - + // Pour chaque mois, un ensemble des sorties réalisées. + // En utilisant un Set, on est sûr de compter chaque sortie une seule fois même + // si on a observé plusieurs navires au cours d'une sortie + Multimap<Date, Pair<Date, Date>> estimatedTripsByMonths = HashMultimap.create(); + Multimap<Date, Pair<Date, Date>> realTripsByMonths = HashMultimap.create(); for (Contact doneObservation : doneObservations) { + // le mois sur lequel il faut compter cette sortie Date month = WaoUtils.truncateToMonth(doneObservation.getObservationBeginDate()); - Date obsBeginDate = doneObservation.getObservationBeginDate(); - Date obsEndDate = doneObservation.getObservationEndDate(); - - // si le contact doit être compté dans le réel - if (BooleanUtils.isTrue(doneObservation.getValidationCompany())) { - Pair<Date, Date> real = nbRealObservationsByTripForMonth.get(obsBeginDate, obsEndDate); - if (real == null) { - // on ajoute 1 observation - Pair<Date, Date> obs = Pair.of(obsBeginDate, obsEndDate); - nbRealObservationsByTripForMonth.put(obsBeginDate, obsEndDate, obs); + // la sortie pendant laquelle a été faite cette observation + Pair<Date, Date> trip = Pair.of( + doneObservation.getObservationBeginDate(), + doneObservation.getObservationEndDate()); - increaseOutput(realObservationsByMonths, month); - } + // si la sortie doit être comptée dans le réel + if (BooleanUtils.isTrue(doneObservation.getValidationCompany())) { + realTripsByMonths.put(month, trip); } - // le contact doit être ajouté dans l'estimée (car on ne parcourt pas les contacts refusés) - Pair<Date, Date> estimated = nbEstimatedObservationsByTrip.get(obsBeginDate, obsEndDate); - if (estimated == null) { - // on ajoute 1 observation dans l'estimé - Pair<Date, Date> obs = Pair.of(obsBeginDate, obsEndDate); - nbEstimatedObservationsByTrip.put(obsBeginDate, obsEndDate, obs); - - increaseOutput(estimatedObservationsByMonths, month); - } + // la sortie doit être comptée dans l'estimé + estimatedTripsByMonths.put(month, trip); } @@ -157,11 +144,11 @@ public class ObsVenteSamplingPlanBuilder { // calcul du planifié Integer expectedObservations = SampleRows.getExpectedTidesValue(sampleRow, month); - int estimatedObservations = MoreObjects.firstNonNull(estimatedObservationsByMonths.get(month), 0).intValue(); - int realObservations = MoreObjects.firstNonNull(realObservationsByMonths.get(month), 0).intValue(); + // pour avoir le nombre sortie, de compter la taille du Set et 0 si null + int estimatedObservations = MoreObjects.firstNonNull(estimatedTripsByMonths.asMap().get(month), Collections.emptySet()).size(); + int realObservations = MoreObjects.firstNonNull(estimatedTripsByMonths.asMap().get(month), Collections.emptySet()).size(); // on a le planifié, l'estimé, le réel en jour et en nombre d'observations, on fait les totaux - SamplingPlan.Effort effortForMonthInObservations = new SamplingPlan.Effort(expectedObservations, realObservations, estimatedObservations); @@ -185,15 +172,6 @@ public class ObsVenteSamplingPlanBuilder { return this; } - protected void increaseOutput(Map<Date, MutableInt> realObservationsByMonths, Date month) { - MutableInt obsForMonth = realObservationsByMonths.get(month); - if (obsForMonth == null) { - obsForMonth = new MutableInt(0); - realObservationsByMonths.put(month, obsForMonth); - } - obsForMonth.increment(); - } - public ObsVenteSamplingPlan toPlan() { // Get facade parts -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm