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 dbf250972037a5b899e2ba3eafd0a860db53e51e Author: dcosse <cosse@codelutin.com> Date: Thu Apr 9 15:22:11 2015 +0200 refs #6910 modification du calcul de l'effort, calculé pour le nombre sortie et non plus par le nombre de contactes --- .../service/ObsVenteSamplingPlanBuilder.java | 40 ++++++++++++++++------ .../WEB-INF/content/edit-sample-row-input.jsp | 8 ++++- .../WEB-INF/content/obsvente/sampling-plan.jsp | 2 +- 3 files changed, 38 insertions(+), 12 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 3172a75..e06caed 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 @@ -34,8 +34,10 @@ 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; @@ -111,30 +113,39 @@ public class ObsVenteSamplingPlanBuilder { 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<>(); + + for (Contact doneObservation : doneObservations) { 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())) { - // on compte 1 observation - MutableInt real = realObservationsByMonths.get(month); + Pair<Date, Date> real = nbRealObservationsByTripForMonth.get(obsBeginDate, obsEndDate); if (real == null) { - real = new MutableInt(0); - realObservationsByMonths.put(month, real); + // on ajoute 1 observation + Pair<Date, Date> obs = Pair.of(obsBeginDate, obsEndDate); + nbRealObservationsByTripForMonth.put(obsBeginDate, obsEndDate, obs); + + increaseOutput(realObservationsByMonths, month); } - real.increment(); } // le contact doit être ajouté dans l'estimée (car on ne parcourt pas les contacts refusés) - // on compte 1 observation dans l'estimé - MutableInt estimated = estimatedObservationsByMonths.get(month); + Pair<Date, Date> estimated = nbEstimatedObservationsByTrip.get(obsBeginDate, obsEndDate); if (estimated == null) { - estimated = new MutableInt(0); - estimatedObservationsByMonths.put(month, estimated); + // on ajoute 1 observation dans l'estimé + Pair<Date, Date> obs = Pair.of(obsBeginDate, obsEndDate); + nbEstimatedObservationsByTrip.put(obsBeginDate, obsEndDate, obs); + + increaseOutput(estimatedObservationsByMonths, month); } - estimated.increment(); } @@ -174,6 +185,15 @@ 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 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 c8740f1..38059e8 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,7 +233,13 @@ <div class="control-group"> - <label class="control-label"><s:text name="wao.ui.samplingPlan.effort" /></label> + <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> + <div class="controls"> <table id="expectedObservationsByMonthsTable"> <thead> diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp index ca82536..9bcd581 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp @@ -208,7 +208,7 @@ <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> <th colspan="${nbColumnsForMonths}"> - <s:text name="wao.ui.samplingPlan.effort" /> + <s:text name="wao.ui.samplingPlan.effort.obsVente" /> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> [ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.