[wao] branch develop updated (0785e47 -> 9b577c7)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository wao. See http://git.codelutin.com/wao.git from 0785e47 Dans l'export CSV du réalisé, le durée moyenne d'une marée en jours de mers est un entier donc on utilise le bon formatter (refs #5117) new 6cc3269 Remaniement dans le plan d'échantillonage : introduction d'une classe Effort et d'un template td-effort qu'on peut utiliser pour toutes les cellules .effort new fc64342 Extraction dans WaoUtils de l'algorithme qui détermine le nombre de jour d'une marée ObsMer et ajout d'un algo pour calculer le nombre de jour de mer pour chaque mois (refs #5661) new 92dc9de Dans ObsMerSamplingPlanService, on sépare les préoccupations entre calcul de la clé du cache, lecture du cache et calcul du plan new 91b7f09 On renomme une variable du plan pour parler d'observation et non de marée new 4f0e637 On déplace le calcul des totaux par mois et du grand total en nombre d'observations à la fin du calcul du plan plutôt que pendant new 85357f1 Suite de remaniement de la génération du plan ObsMer new 6b944fe On impacte le plan ObsVente suite au remaniement fait pour ObsMer new 4bbbec4 On montre les jours de mer dans la vue du plan d'échantillonnage obsmer new 91733c0 Dans le plan d'échantillonnage, on propose l'affichage de l'effort en jours de mer et plus seulement en nombre de marées (refs #5651)) new d42c625 Qualité du code dans WaoUtils new 9b577c7 Utilisation du pseudo-élément CSS :first-child qui est exactement fait pour ça au lieu de polluer le HTML The 11 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 9b577c76bd4a91322c46fefd35d3ad2b48ae97cd Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:19:56 2014 +0200 Utilisation du pseudo-élément CSS :first-child qui est exactement fait pour ça au lieu de polluer le HTML commit d42c625b47aba892c9b78fe423c74fc73a64ec5f Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:14:27 2014 +0200 Qualité du code dans WaoUtils commit 91733c0decd2bcbe37da654bb92c7ef8dc6b2279 Merge: 0785e47 4bbbec4 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:06:55 2014 +0200 Dans le plan d'échantillonnage, on propose l'affichage de l'effort en jours de mer et plus seulement en nombre de marées (refs #5651)) commit 4bbbec41111d10e622113213ab733ec030a12bd7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:05:27 2014 +0200 On montre les jours de mer dans la vue du plan d'échantillonnage obsmer commit 6b944fe8897469c8bbeb8b0771f8786f27d0d7d2 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 16:05:10 2014 +0200 On impacte le plan ObsVente suite au remaniement fait pour ObsMer commit 85357f14867187bb2d99a6a829eb8307e47d4830 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 15:50:09 2014 +0200 Suite de remaniement de la génération du plan ObsMer On reste isofonctionel par rapport au début de la branche. Le grand total est désormais calculé à partir des totaux pour chaque mois ; on utilise des multimaps pour stocker tous les Effort rencontrés plutôt que trois maps pour stocké le plannifié, le réel et l'estimé ; on a tous les calculs en jours de mers pour toutes les cellules du plan mais ce n'est pas affiché ; on utilise le template td-effort pour les jours de mers. commit 4f0e637a78d21f0f31b9f473fa4b6233c578ac13 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 11:57:44 2014 +0200 On déplace le calcul des totaux par mois et du grand total en nombre d'observations à la fin du calcul du plan plutôt que pendant commit 91b7f0912d2d250e259afe2f2764f059d38189b3 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 11:15:16 2014 +0200 On renomme une variable du plan pour parler d'observation et non de marée commit 92dc9de394e2e65d86acf5fc4f04e9515ba2e27b Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 18:29:52 2014 +0200 Dans ObsMerSamplingPlanService, on sépare les préoccupations entre calcul de la clé du cache, lecture du cache et calcul du plan commit fc6434219b26458dbf43ecca3bdb043e0143e9be Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 17:26:24 2014 +0200 Extraction dans WaoUtils de l'algorithme qui détermine le nombre de jour d'une marée ObsMer et ajout d'un algo pour calculer le nombre de jour de mer pour chaque mois (refs #5661) commit 6cc32698e74c024717576914ad4c560d34c316b5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 15:11:12 2014 +0200 Remaniement dans le plan d'échantillonage : introduction d'une classe Effort et d'un template td-effort qu'on peut utiliser pour toutes les cellules .effort Summary of changes: .../src/main/java/fr/ifremer/wao/BoatsFilter.java | 10 +- .../main/java/fr/ifremer/wao/ContactsFilter.java | 22 +- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 24 +- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 106 ++++---- .../java/fr/ifremer/wao/entity/ContactImpl.java | 9 +- .../src/test/java/fr/ifremer/wao/WaoUtilsTest.java | 46 ++++ .../fr/ifremer/wao/entity/ContactImplTest.java | 52 ---- .../wao/services/service/ObsMerSamplingPlan.java | 153 +++-------- .../service/ObsMerSamplingPlanBuilder.java | 282 +++++++++------------ .../service/ObsMerSamplingPlanService.java | 153 ++++------- .../wao/services/service/ObsVenteSamplingPlan.java | 8 +- .../service/ObsVenteSamplingPlanBuilder.java | 34 +-- .../ifremer/wao/services/service/SamplingPlan.java | 219 +++++++--------- .../wao/services/service/SamplingPlanCacheKey.java | 12 + .../service/csv/ObsMerSamplingPlanExportModel.java | 12 +- .../service/ObsMerSamplingPlanServiceTest.java | 12 +- .../fr/ifremer/wao/web/WaoJspActionSupport.java | 3 +- .../main/resources/i18n/wao-web_en_GB.properties | 2 + .../main/resources/i18n/wao-web_fr_FR.properties | 2 + .../WEB-INF/content/obsmer/sampling-plan.jsp | 239 ++++++----------- .../WEB-INF/content/obsvente/sampling-plan.jsp | 113 ++------- .../WEB-INF/content/templates/td-effort-obsmer.jsp | 13 + .../webapp/WEB-INF/content/templates/td-effort.jsp | 32 +++ wao-web/src/main/webapp/wao.css | 23 +- 24 files changed, 647 insertions(+), 934 deletions(-) delete mode 100644 wao-persistence/src/test/java/fr/ifremer/wao/entity/ContactImplTest.java create mode 100644 wao-web/src/main/webapp/WEB-INF/content/templates/td-effort-obsmer.jsp create mode 100644 wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 6cc32698e74c024717576914ad4c560d34c316b5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 15:11:12 2014 +0200 Remaniement dans le plan d'échantillonage : introduction d'une classe Effort et d'un template td-effort qu'on peut utiliser pour toutes les cellules .effort --- .../wao/services/service/ObsMerSamplingPlan.java | 6 +- .../service/ObsMerSamplingPlanBuilder.java | 30 ++-- .../wao/services/service/ObsVenteSamplingPlan.java | 4 +- .../service/ObsVenteSamplingPlanBuilder.java | 30 ++-- .../ifremer/wao/services/service/SamplingPlan.java | 182 ++++++++------------- .../service/csv/ObsMerSamplingPlanExportModel.java | 12 +- .../service/ObsMerSamplingPlanServiceTest.java | 12 +- .../WEB-INF/content/obsmer/sampling-plan.jsp | 105 +++--------- .../WEB-INF/content/obsvente/sampling-plan.jsp | 105 +++--------- .../webapp/WEB-INF/content/templates/td-effort.jsp | 32 ++++ 10 files changed, 183 insertions(+), 335 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java index a009b57..9ca7366 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java @@ -61,8 +61,8 @@ public class ObsMerSamplingPlan extends SamplingPlan { public ObsMerSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, - Map<Date, SamplingPlanStatistics> totalsPerMonth, - SamplingPlanStatistics highTotals, + Map<Date, Effort> totalsPerMonth, + Effort highTotals, Double observationTimesInDaysTotalExpected, Long observationTimesInDaysTotalReal, Long observationTimesInDaysTotalEstimated, @@ -144,7 +144,7 @@ public class ObsMerSamplingPlan extends SamplingPlan { protected Double appliedCoverageRate; public ObsMerSamplingPlanSampleRowPart(Locale locale, - Map<Date, SamplingPlanStatistics> nbTidesPerMonth, + Map<Date, Effort> nbTidesPerMonth, SampleRow sampleRow, Integer observationTimesInDaysExpected, Long observationTimesInDaysReal, diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java index 7adbb93..f213674 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java @@ -82,21 +82,21 @@ public class ObsMerSamplingPlanBuilder { /** * To compute the high total expected. * - * @see ObsMerSamplingPlan#highTotals + * @see ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalExpected; /** * To compute the high total real. * - * @see ObsMerSamplingPlan#highTotals + * @see ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalReal; /** * To compute the high total estimated. * - * @see ObsMerSamplingPlan#highTotals + * @see ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalEstimated; @@ -124,21 +124,21 @@ public class ObsMerSamplingPlanBuilder { /** * To compute by month the total of expected tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesExpected + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#expected */ protected Map<Date, MutableInt> totalExpectedForMonths; /** * To compute by month the total of expected tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesEstimated + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#estimated */ protected Map<Date, MutableInt> totalEstimatedForMonths; /** * To compute by month the total of real tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesReal + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#real */ protected Map<Date, MutableInt> totalRealForMonths; @@ -183,7 +183,7 @@ public class ObsMerSamplingPlanBuilder { SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); // compute nb tides per month - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); + Map<Date, SamplingPlan.Effort> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), @@ -223,20 +223,20 @@ public class ObsMerSamplingPlanBuilder { }).immutableSortedCopy(facadeParts); // Get statistics - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> statisticsMap = new TreeMap<>(); + Map<Date, SamplingPlan.Effort> statisticsMap = new TreeMap<>(); for (Date month : months) { MutableInt totalExpected = totalExpectedForMonths.get(month); MutableInt totalReal = totalRealForMonths.get(month); MutableInt totalEstimated = totalEstimatedForMonths.get(month); - ObsMerSamplingPlan.SamplingPlanStatistics planStatistics = - new ObsMerSamplingPlan.SamplingPlanStatistics(totalExpected == null ? null : totalExpected.toInteger(), + SamplingPlan.Effort planStatistics = + new SamplingPlan.Effort(totalExpected == null ? null : totalExpected.toInteger(), totalReal == null ? null : totalReal.toInteger(), totalEstimated == null ? null : totalEstimated.toInteger()); statisticsMap.put(month, planStatistics); } - ObsMerSamplingPlan.SamplingPlanStatistics highTotals = new ObsMerSamplingPlan.SamplingPlanStatistics(highTotalExpected, highTotalReal, highTotalEstimated); + SamplingPlan.Effort highTotals = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); ObsMerSamplingPlan result = new ObsMerSamplingPlan(months, sortedFacades, @@ -250,8 +250,8 @@ public class ObsMerSamplingPlanBuilder { return result; } - protected Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> computeNbTidesPerMonth(SampleRow sampleRow) { - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> result = new TreeMap<>(); + protected Map<Date, SamplingPlan.Effort> computeNbTidesPerMonth(SampleRow sampleRow) { + Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); for (Date month : months) { Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); if (expectedTidesValue != null) { @@ -281,7 +281,7 @@ public class ObsMerSamplingPlanBuilder { mutableInt.add(estimatedTidesValue); highTotalEstimated += estimatedTidesValue; } - result.put(month, new ObsMerSamplingPlan.SamplingPlanStatistics(expectedTidesValue, + result.put(month, new SamplingPlan.Effort(expectedTidesValue, realTidesValue, estimatedTidesValue)); @@ -344,7 +344,7 @@ public class ObsMerSamplingPlanBuilder { protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, SampleRow row, - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> nbTidesPerMonth, + Map<Date, SamplingPlan.Effort> nbTidesPerMonth, Integer observationTimesInDaysExpected, Long observationTimesInDaysReal, Long observationTimesInDaysEstimated, diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java index 466989b..dbe8e56 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java @@ -36,7 +36,7 @@ import java.util.Set; public class ObsVenteSamplingPlan extends SamplingPlan implements Iterable<SamplingPlan.SamplingPlanFacadePart> { - public ObsVenteSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, SamplingPlanStatistics> totalsPerMonth, SamplingPlanStatistics highTotals, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { + public ObsVenteSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, Effort> totalsPerMonth, Effort highTotals, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { super(months, facadeParts, totalsPerMonth, highTotals, filterValues, sampleRowIds); } @@ -50,7 +50,7 @@ public class ObsVenteSamplingPlan extends SamplingPlan implements Iterable<Sampl protected String samplingStrategy; - public ObsVenteSamplingPlanSampleRowPart(Locale locale, Map<Date, SamplingPlanStatistics> nbTidesPerMonth, SampleRow sampleRow, long sampleRowContactCounts) { + public ObsVenteSamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> nbTidesPerMonth, SampleRow sampleRow, long sampleRowContactCounts) { super(locale, nbTidesPerMonth, sampleRow, sampleRowContactCounts); terrestrialLocationInfos = sampleRow.getTerrestrialLocationInfos(); terrestrialLocationNamesAndDescriptions = new LinkedHashMap<>(); 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 33c3d5b..5285c75 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 @@ -74,42 +74,42 @@ public class ObsVenteSamplingPlanBuilder { /** * To compute the high total expected. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotals + * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalExpected; /** * To compute the high total real. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotals + * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalReal; /** * To compute the high total estimated. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotals + * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan#highTotalEffortInObservations */ protected int highTotalEstimated; /** * To compute by month the total of expected tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesExpected + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#expected */ protected Map<Date, MutableInt> totalExpectedForMonths; /** * To compute by month the total of expected tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesEstimated + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#estimated */ protected Map<Date, MutableInt> totalEstimatedForMonths; /** * To compute by month the total of real tides. * - * @see fr.ifremer.wao.services.service.ObsMerSamplingPlan.SamplingPlanStatistics#nbTidesReal + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#real */ protected Map<Date, MutableInt> totalRealForMonths; @@ -147,7 +147,7 @@ public class ObsVenteSamplingPlanBuilder { SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); // compute nb tides per month - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); + Map<Date, SamplingPlan.Effort> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), @@ -179,20 +179,20 @@ public class ObsVenteSamplingPlanBuilder { }).immutableSortedCopy(facadeParts); // Get statistics - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> statisticsMap = new TreeMap<>(); + Map<Date, SamplingPlan.Effort> statisticsMap = new TreeMap<>(); for (Date month : months) { MutableInt totalExpected = totalExpectedForMonths.get(month); MutableInt totalReal = totalRealForMonths.get(month); MutableInt totalEstimated = totalEstimatedForMonths.get(month); - ObsMerSamplingPlan.SamplingPlanStatistics planStatistics = - new ObsMerSamplingPlan.SamplingPlanStatistics(totalExpected == null ? null : totalExpected.toInteger(), + SamplingPlan.Effort planStatistics = + new SamplingPlan.Effort(totalExpected == null ? null : totalExpected.toInteger(), totalReal == null ? null : totalReal.toInteger(), totalEstimated == null ? null : totalEstimated.toInteger()); statisticsMap.put(month, planStatistics); } - ObsMerSamplingPlan.SamplingPlanStatistics highTotals = new ObsMerSamplingPlan.SamplingPlanStatistics(highTotalExpected, highTotalReal, highTotalEstimated); + SamplingPlan.Effort highTotals = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); ObsVenteSamplingPlan result = new ObsVenteSamplingPlan(months, sortedFacades, @@ -203,8 +203,8 @@ public class ObsVenteSamplingPlanBuilder { return result; } - protected Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> computeNbTidesPerMonth(SampleRow sampleRow) { - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> result = new TreeMap<>(); + protected Map<Date, SamplingPlan.Effort> computeNbTidesPerMonth(SampleRow sampleRow) { + Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); for (Date month : months) { Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); if (expectedTidesValue != null) { @@ -234,7 +234,7 @@ public class ObsVenteSamplingPlanBuilder { mutableInt.add(estimatedTidesValue); highTotalEstimated += estimatedTidesValue; } - result.put(month, new ObsMerSamplingPlan.SamplingPlanStatistics(expectedTidesValue, + result.put(month, new SamplingPlan.Effort(expectedTidesValue, realTidesValue, estimatedTidesValue)); @@ -297,7 +297,7 @@ public class ObsVenteSamplingPlanBuilder { protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, SampleRow row, - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> nbTidesPerMonth, + Map<Date, SamplingPlan.Effort> nbTidesPerMonth, long sampleRowContactCounts) { ObsVenteSamplingPlan.ObsVenteSamplingPlanSampleRowPart rowPart = diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java index 73c0d74..7def4aa 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java @@ -58,12 +58,12 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan /** * Total tides over the plan by month. */ - protected Map<Date, SamplingPlanStatistics> totalsPerMonth; + protected Map<Date, Effort> totalEffortInObservationsPerMonths; /** * High total over the hole plan. */ - protected SamplingPlanStatistics highTotals; + protected Effort highTotalEffortInObservations; /** * Universe of filter values. @@ -77,75 +77,83 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan public SamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, - Map<Date, SamplingPlanStatistics> totalsPerMonth, - SamplingPlanStatistics highTotals, + Map<Date, Effort> totalEffortInObservationsPerMonths, + Effort highTotalEffortInObservations, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { this.months = months; this.facades = facadeParts; - this.totalsPerMonth = totalsPerMonth; - this.highTotals = highTotals; + this.totalEffortInObservationsPerMonths = totalEffortInObservationsPerMonths; + this.highTotalEffortInObservations = highTotalEffortInObservations; this.filterValues = filterValues; this.sampleRowIds = sampleRowIds; } - public static class SamplingPlanStatistics implements Serializable { + /** + * Un effort est un triplet de valeurs dont un effort d'observation prévisionnel + * et effort d'observation estimé (qu'on devrait atteindre) et un effort réalisé + * (qu'on a atteint). + * + * Cet effort peut être exprimé en nombre d'observations (càd en nombre de marées + * pour ObsMer) mais aussi en jours d'observations. + */ + public static class Effort implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2L; + + protected static final String PERCENTAGE_UNAVAILABLE = "-"; /** - * Number of expected tides. + * L'effort prévisionnel */ - protected Integer nbTidesExpected; + protected Integer expected; /** - * Number of real tides. + * L'effort réalisé */ - protected Integer nbTidesReal; + protected Integer real; /** - * Number of estimated tides. + * L'effort estimé */ - protected Integer nbTidesEstimated; + protected Integer estimated; - public SamplingPlanStatistics(Integer nbTidesExpected, - Integer nbTidesReal, - Integer nbTidesEstimated) { - this.nbTidesExpected = nbTidesExpected; - this.nbTidesReal = nbTidesReal; - this.nbTidesEstimated = nbTidesEstimated; + public Effort(Integer expected, + Integer real, + Integer estimated) { + this.expected = expected; + this.real = real; + this.estimated = estimated; } - public Integer getNbTidesExpected() { - return nbTidesExpected; + public Integer getExpected() { + return expected; } - public Integer getNbTidesReal() { - return nbTidesReal; + public Integer getReal() { + return real; } - public Integer getNbTidesEstimated() { - return nbTidesEstimated; + public Integer getEstimated() { + return estimated; } - public String getRealRatio(String defaultValue) { - String ratio = defaultValue; - if (nbTidesExpected != null && nbTidesExpected > 0 && - nbTidesReal != null && nbTidesReal > 0) { - double percent = ((double) nbTidesReal / nbTidesExpected); - ratio = NumberFormat.getPercentInstance().format(percent); + public String getRealPercentage() { + String percentage = PERCENTAGE_UNAVAILABLE; + if (expected != null && expected > 0 && real != null && real > 0) { + double ratio = ((double) real / expected); + percentage = NumberFormat.getPercentInstance().format(ratio); } - return ratio; + return percentage; } - public String getEstimatedRatio(String defaultValue) { - String ratio = defaultValue; - if (nbTidesExpected != null && nbTidesExpected > 0 && - nbTidesEstimated != null && nbTidesEstimated > 0) { - double percent = ((double) nbTidesEstimated / nbTidesExpected); - ratio = NumberFormat.getPercentInstance().format(percent); + public String getEstimatedPercentage() { + String percentage = PERCENTAGE_UNAVAILABLE; + if (expected != null && expected > 0 && estimated != null && real > 0) { + double ratio = ((double) estimated / expected); + percentage = NumberFormat.getPercentInstance().format(ratio); } - return ratio; + return percentage; } @Override @@ -222,51 +230,12 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan } } - public Integer getTotalExpected(Date month) { - Integer result = totalsPerMonth.get(month).getNbTidesExpected(); - return result; - } - - public Integer getTotalReal(Date month) { - Integer result = totalsPerMonth.get(month).getNbTidesReal(); - return result; - } - - public Integer getTotalEstimated(Date month) { - Integer result = totalsPerMonth.get(month).getNbTidesEstimated(); - return result; - } - - public String getTotalRealRatio(Date month) { - String result = totalsPerMonth.get(month).getRealRatio("-"); - return result; - } - - public String getTotalEstimatedRatio(Date month) { - String result = totalsPerMonth.get(month).getEstimatedRatio("-"); - return result; - } - - public Integer getHighTotalExpected() { - return highTotals.getNbTidesExpected(); - } - - public Integer getHighTotalReal() { - return highTotals.getNbTidesReal(); - } - - public Integer getHighTotalEstimated() { - return highTotals.getNbTidesEstimated(); - } - - public String getHighTotalRealRatio() { - String ratio = highTotals.getRealRatio(""); - return ratio; + public Effort getTotalEffortInObservationsForMonth(Date month) { + return totalEffortInObservationsPerMonths.get(month); } - public String getHighTotalEstimatedRatio() { - String ratio = highTotals.getEstimatedRatio(""); - return ratio; + public Effort getHighTotalEffortInObservations() { + return highTotalEffortInObservations; } public Set<String> getSampleRowIds() { @@ -294,14 +263,14 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan /** * Nb tides by month. */ - protected Map<Date, SamplingPlanStatistics> nbTidesPerMonth; + protected Map<Date, Effort> nbTidesPerMonth; protected long sampleRowContactCounts; /** * Total of tides. */ - protected SamplingPlanStatistics totalTides; + protected Effort totalObservations; protected String facade; @@ -362,7 +331,7 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan protected boolean elligibleBoatsProvided; public SamplingPlanSampleRowPart(Locale locale, - Map<Date, SamplingPlanStatistics> nbTidesPerMonth, + Map<Date, Effort> nbTidesPerMonth, SampleRow sampleRow, long sampleRowContactCounts) { this.nbTidesPerMonth = nbTidesPerMonth; @@ -371,21 +340,21 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan int totalTidesExpected = 0; int totalTidesEstimated = 0; int totalTidesReal = 0; - for (SamplingPlanStatistics samplingPlanStatistics : nbTidesPerMonth.values()) { - Integer totalExpected = samplingPlanStatistics.getNbTidesExpected(); + for (Effort effort : nbTidesPerMonth.values()) { + Integer totalExpected = effort.getExpected(); if (totalExpected != null) { totalTidesExpected += totalExpected; } - Integer totalEstimated = samplingPlanStatistics.getNbTidesEstimated(); + Integer totalEstimated = effort.getEstimated(); if (totalEstimated != null) { totalTidesEstimated += totalEstimated; } - Integer totalReal = samplingPlanStatistics.getNbTidesReal(); + Integer totalReal = effort.getReal(); if (totalReal != null) { totalTidesReal += totalReal; } } - totalTides = new SamplingPlanStatistics(totalTidesExpected, totalTidesReal, totalTidesEstimated); + totalObservations = new Effort(totalTidesExpected, totalTidesReal, totalTidesEstimated); facade = sampleRow.getFacade(); sectors = sampleRow.getSectors(); fishingZones = ""; @@ -511,44 +480,25 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan return companyName; } - public int getTotalTidesExpected() { - return totalTides.getNbTidesExpected(); - } - - public int getTotalTidesReal() { - return totalTides.getNbTidesReal(); - } - - public int getTotalTidesEstimated() { - return totalTides.getNbTidesEstimated(); + public Effort getTotalObservations() { + return totalObservations; } public String getProfessionDescriptionWithoutDCF5() { return professionDescriptionWithoutDCF5; } - public Integer getNbTidesExpected(Date month) { - Integer result = nbTidesPerMonth.get(month).getNbTidesExpected(); - return result; - } - - public Integer getNbTidesReal(Date month) { - Integer result = nbTidesPerMonth.get(month).getNbTidesReal(); - return result; - } - - public Integer getNbTidesEstimated(Date month) { - Integer result = nbTidesPerMonth.get(month).getNbTidesEstimated(); - return result; + public Effort getEffortInObservationsForMonth(Date month) { + return nbTidesPerMonth.get(month); } public String getTotalRealPercentage() { - String result = totalTides.getRealRatio("-"); + String result = totalObservations.getRealPercentage(); return result; } public String getTotalEstimatedPercentage() { - String result = totalTides.getEstimatedRatio("-"); + String result = totalObservations.getEstimatedPercentage(); return result; } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerSamplingPlanExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerSamplingPlanExportModel.java index 4c7a4b6..6694e0a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerSamplingPlanExportModel.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerSamplingPlanExportModel.java @@ -69,9 +69,9 @@ public class ObsMerSamplingPlanExportModel extends AbstractExportModel<ObsMerSam modelBuilder.newColumnForExport(headerName + "_REALISE", new RealTidesValueGetter(month), Common.INTEGER); } - modelBuilder.newColumnForExport("TOTAL_EFFORT", "totalTidesExpected", Common.INTEGER); - modelBuilder.newColumnForExport("TOTAL_ESTIME", "totalTidesEstimated", Common.INTEGER); - modelBuilder.newColumnForExport("TOTAL_REALISE", "totalTidesReal", Common.INTEGER); + modelBuilder.newColumnForExport("TOTAL_EFFORT", "totalObservations.expected", Common.INTEGER); + modelBuilder.newColumnForExport("TOTAL_ESTIME", "totalObservations.estimated", Common.INTEGER); + modelBuilder.newColumnForExport("TOTAL_REALISE", "totalObservations.real", Common.INTEGER); modelBuilder.newColumnForExport("TOTAL_EFFORT_JOURS", "observationTimesInDaysExpected", Common.INTEGER); modelBuilder.newColumnForExport("TOTAL_ESTIME_JOURS", "observationTimesInDaysEstimated", Common.LONG); @@ -89,7 +89,7 @@ public class ObsMerSamplingPlanExportModel extends AbstractExportModel<ObsMerSam @Override public Integer get(ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart sampleRowPart) { - return sampleRowPart.getNbTidesExpected(month); + return sampleRowPart.getEffortInObservationsForMonth(month).getExpected(); } } @@ -103,7 +103,7 @@ public class ObsMerSamplingPlanExportModel extends AbstractExportModel<ObsMerSam @Override public Integer get(ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart sampleRowPart) { - return sampleRowPart.getNbTidesExpected(month); + return sampleRowPart.getEffortInObservationsForMonth(month).getExpected(); } } @@ -117,7 +117,7 @@ public class ObsMerSamplingPlanExportModel extends AbstractExportModel<ObsMerSam @Override public Integer get(ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart sampleRowPart) { - return sampleRowPart.getNbTidesReal(month); + return sampleRowPart.getEffortInObservationsForMonth(month).getReal(); } } } diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java index ab2653f..61c6d5b 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java @@ -169,10 +169,10 @@ public class ObsMerSamplingPlanServiceTest extends AbstractWaoServiceTest { SampleRow sampleRow = serviceContext.getPersistenceContext().getSampleRowDao().forCodeEquals("2010_M0011").findUnique(); - Map<Date, ObsMerSamplingPlan.SamplingPlanStatistics> oldStats = new HashMap<>(); + Map<Date, SamplingPlan.Effort> oldStats = new HashMap<>(); for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { - ObsMerSamplingPlan.SamplingPlanStatistics stats = new ObsMerSamplingPlan.SamplingPlanStatistics( + SamplingPlan.Effort stats = new SamplingPlan.Effort( sampleMonth.getExpectedTidesValue(), sampleMonth.getRealTidesValue(), sampleMonth.getEstimatedTidesValue() @@ -183,13 +183,13 @@ public class ObsMerSamplingPlanServiceTest extends AbstractWaoServiceTest { for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { - ObsMerSamplingPlan.SamplingPlanStatistics oldMonth = oldStats.get(sampleMonth.getPeriodDate()); + SamplingPlan.Effort oldMonth = oldStats.get(sampleMonth.getPeriodDate()); int expectedTidesValue = sampleMonth.getExpectedTidesValue(); int realTidesValue = sampleMonth.getRealTidesValue(); int estimatedTidesValue = sampleMonth.getEstimatedTidesValue(); - Assert.assertEquals(oldMonth.getNbTidesExpected(), expectedTidesValue, 0.01); - Assert.assertEquals(oldMonth.getNbTidesReal(), realTidesValue, 0.01); - Assert.assertEquals(oldMonth.getNbTidesEstimated(), estimatedTidesValue, 0.01); + Assert.assertEquals(oldMonth.getExpected(), expectedTidesValue, 0.01); + Assert.assertEquals(oldMonth.getReal(), realTidesValue, 0.01); + Assert.assertEquals(oldMonth.getEstimated(), estimatedTidesValue, 0.01); } } } diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index 1ea1696..4befaa8 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -182,9 +182,6 @@ </s:if> </div> -<s:set var="estimatedTides" value="true" /> -<s:set var="displayTidesReal" value="true" /> - <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> <s:set var="nbColumnsForProfessionInFullView" value="13" /> </s:if> @@ -368,45 +365,17 @@ </td> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="expected" value="%{getNbTidesExpected(#month)}"/> - <s:set var="estimated" value="%{getNbTidesEstimated(#month)}"/> - <s:set var="real" value="%{getNbTidesReal(#month)}"/> - <td class="effort <s:if test="isCurrentMonth(#month)"> now</s:if><s:if test="#estimated != #real"> estimated-differ-from-real</s:if>"> - <s:if test="#expected != null"> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - </s:if> - </td> + <s:set var="effort" value="%{getEffortInObservationsForMonth(#month)}"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="false"/> + <%@include file="../templates/td-effort.jsp" %> </s:iterator> - <td class="effort"> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="totalTidesEstimated < totalTidesExpected"> lower-than-expected</s:if><s:if test="totalTidesEstimated > totalTidesExpected"> higher-than-expected</s:if>"> - <s:property value="totalTidesEstimated" /> - </span> - <span class="real<s:if test="totalTidesReal < totalTidesExpected"> lower-than-expected</s:if><s:if test="totalTidesReal > totalTidesExpected"> higher-than-expected</s:if>"> - <s:property value="totalTidesReal" /> - </span> - / - </s:if> - <s:property value="totalTidesExpected" /> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="totalEstimatedPercentage" />) - </span> - <span class="real"> - (<s:property value="totalRealPercentage" />) - </span> - </s:if> - </td> + <s:set var="effort" value="#samplingPlanRow.totalObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + <td class="effort"> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> @@ -540,53 +509,17 @@ </th> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <td class="effort<s:if test="isCurrentMonth(#month)"> now</s:if>"> - <s:set var="expected" value="%{samplingPlan.getTotalExpected(#month)}"/> - <s:set var="estimated" value="%{samplingPlan.getTotalEstimated(#month)}"/> - <s:set var="real" value="%{samplingPlan.getTotalReal(#month)}"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="samplingPlan.getTotalEstimatedRatio(#month)"/>) - </span> - <span class="real"> - (<s:property value="samplingPlan.getTotalRealRatio(#month)"/>) - </span> - </s:if> - </td> + <s:set var="effort" value="samplingPlan.getTotalEffortInObservationsForMonth(#month)"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> </s:iterator> - <td class="effort"> - <s:set var="expected" value="%{samplingPlan.highTotalExpected}"/> - <s:set var="estimated" value="%{samplingPlan.highTotalEstimated}"/> - <s:set var="real" value="%{samplingPlan.highTotalReal}"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="samplingPlan.highTotalEstimatedRatio"/>) - </span> - <span class="real"> - (<s:property value="samplingPlan.highTotalRealRatio"/>) - </span> - </s:if> - </td> + + <s:set var="effort" value="samplingPlan.highTotalEffortInObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + <td class="effort"> <s:set var="expected" value="%{samplingPlan.observationTimesInDaysTotalExpected}"/> <s:set var="estimated" value="%{samplingPlan.observationTimesInDaysTotalEstimated}"/> 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 b57aec1..a1bfe56 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 @@ -186,9 +186,6 @@ </s:if> </div> -<s:set var="estimatedTides" value="true" /> -<s:set var="displayTidesReal" value="true" /> - <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> <s:set var="nbColumnsForProfessionInFullView" value="16" /> </s:if> @@ -369,45 +366,17 @@ </td> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="expected" value="%{getNbTidesExpected(#month)}"/> - <s:set var="estimated" value="%{getNbTidesEstimated(#month)}"/> - <s:set var="real" value="%{getNbTidesReal(#month)}"/> - <td class="effort <s:if test="isCurrentMonth(#month)"> now</s:if><s:if test="#estimated != #real"> estimated-differ-from-real</s:if>"> - <s:if test="#expected != null"> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - </s:if> - </td> + <s:set var="effort" value="%{getEffortInObservationsForMonth(#month)}"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="false"/> + <%@include file="../templates/td-effort.jsp" %> </s:iterator> - <td class="effort"> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="totalTidesEstimated < totalTidesExpected"> lower-than-expected</s:if><s:if test="totalTidesEstimated > totalTidesExpected"> higher-than-expected</s:if>"> - <s:property value="totalTidesEstimated" /> - </span> - <span class="real<s:if test="totalTidesReal < totalTidesExpected"> lower-than-expected</s:if><s:if test="totalTidesReal > totalTidesExpected"> higher-than-expected</s:if>"> - <s:property value="totalTidesReal" /> - </span> - / - </s:if> - <s:property value="totalTidesExpected" /> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="totalEstimatedPercentage" />) - </span> - <span class="real"> - (<s:property value="totalRealPercentage" />) - </span> - </s:if> - </td> + <s:set var="effort" value="#samplingPlanRow.totalObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + <td class="align-center"> <s:property value="averageObservationsCount"/> </td> @@ -513,53 +482,17 @@ </th> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <td class="effort<s:if test="isCurrentMonth(#month)"> now</s:if>"> - <s:set var="expected" value="%{samplingPlan.getTotalExpected(#month)}"/> - <s:set var="estimated" value="%{samplingPlan.getTotalEstimated(#month)}"/> - <s:set var="real" value="%{samplingPlan.getTotalReal(#month)}"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="samplingPlan.getTotalEstimatedRatio(#month)"/>) - </span> - <span class="real"> - (<s:property value="samplingPlan.getTotalRealRatio(#month)"/>) - </span> - </s:if> - </td> + <s:set var="effort" value="samplingPlan.getTotalEffortInObservationsForMonth(#month)"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> </s:iterator> - <td class="effort"> - <s:set var="expected" value="%{samplingPlan.highTotalExpected}"/> - <s:set var="estimated" value="%{samplingPlan.highTotalEstimated}"/> - <s:set var="real" value="%{samplingPlan.highTotalReal}"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> - </span> - / - </s:if> - <s:property value="#expected"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated"> - (<s:property value="samplingPlan.highTotalEstimatedRatio"/>) - </span> - <span class="real"> - (<s:property value="samplingPlan.highTotalRealRatio"/>) - </span> - </s:if> - </td> + + <s:set var="effort" value="samplingPlan.highTotalEffortInObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + <th colspan="${nbColumnsForOther}"></th> </tfoot> </table> diff --git a/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp new file mode 100644 index 0000000..a0c1ff9 --- /dev/null +++ b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp @@ -0,0 +1,32 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %> +<%@taglib uri="/struts-tags" prefix="s" %> + +<%-- C'est un template utilisé dans les plan d'échantillonnages pour représenter le contenu d'une cellule avec les différents efforts --%> + +<s:set var="expected" value="#effort.expected"/> +<s:set var="estimated" value="#effort.estimated"/> +<s:set var="real" value="#effort.real"/> + +<td class="effort <s:if test="#now"> now</s:if><s:if test="#estimated != #real"> estimated-differ-from-real</s:if>"> + <s:if test="#expected != null"> + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> + <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> + <s:property value="#estimated"/> + </span> + <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> + <s:property value="#real"/> + </span> + / + </s:if> + <s:property value="#expected"/> + + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal && #showPercentage"> + <span class="estimated"> + (<s:property value="#effort.estimatedPercentage" />) + </span> + <span class="real"> + (<s:property value="#effort.realPercentage" />) + </span> + </s:if> + </s:if> +</td> -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit fc6434219b26458dbf43ecca3bdb043e0143e9be Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 17:26:24 2014 +0200 Extraction dans WaoUtils de l'algorithme qui détermine le nombre de jour d'une marée ObsMer et ajout d'un algo pour calculer le nombre de jour de mer pour chaque mois (refs #5661) --- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 49 ++++++++++++++++++++ .../java/fr/ifremer/wao/entity/ContactImpl.java | 9 +--- .../src/test/java/fr/ifremer/wao/WaoUtilsTest.java | 46 +++++++++++++++++++ .../fr/ifremer/wao/entity/ContactImplTest.java | 52 ---------------------- 4 files changed, 97 insertions(+), 59 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java index e644631..be5c664 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java @@ -21,8 +21,10 @@ package fr.ifremer.wao; * #L% */ +import com.google.common.base.Verify; import fr.ifremer.wao.entity.I18nAble; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.time.DateUtils; import org.nuiton.i18n.I18n; import org.nuiton.util.DateUtil; @@ -30,11 +32,15 @@ import org.nuiton.util.DateUtil; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; public class WaoUtils { @@ -187,4 +193,47 @@ public class WaoUtils { public static boolean isAfterWaoCreation(Date date) { return WAO_CREATION_DATE.before(date); } + + /** + * Il s'agit de la façon de calculer la durée de mer d'un voyage en mer (observation + * ObsMer). Il s'agit d'une durée en jour toutefois, il ne s'agit pas de 1 jour = 24 heures + * mais du nombre de fois où minuit a été passé en mer. À partir du moment où il y a eu + * embarquement, on compte au moins un jour de mer. + * + * @param observationBeginDate date d'embarquement + * @param observationEndDate date de retour + * @return la durée du voyage en jour de mer + */ + public static int getObservationTimeInDays(Date observationBeginDate, Date observationEndDate) { + int observationTimeInDays = DateUtil.getDifferenceInDays( + DateUtils.truncate(observationBeginDate, Calendar.DAY_OF_MONTH), + DateUtils.truncate(observationEndDate, Calendar.DAY_OF_MONTH)) + 1; + Verify.verify(observationTimeInDays > 0); + return observationTimeInDays; + } + + /** + * Étant donné une date d'embarquement et une date de débarquement, pour chaque mois, le + * nombre de jour passé en mer au sens de {@link #getObservationTimeInDays(java.util.Date, java.util.Date)} + */ + public static Map<Date, Integer> getObservationDaysByMonths(Date observationBeginDate, Date observationEndDate) { + Map<Date, MutableInt> tempResult = new HashMap<>(); + Date aDay = DateUtils.truncate(observationBeginDate, Calendar.DAY_OF_MONTH); + do { + Date month = DateUtils.truncate(aDay, Calendar.MONTH); + MutableInt count = tempResult.get(month); + if (count == null) { + count = new MutableInt(); + tempResult.put(month, count); + } + count.increment(); + aDay = DateUtils.addDays(aDay, 1); + } while (aDay.before(observationEndDate)); + Map<Date, Integer> result = new TreeMap<>(); + for (Map.Entry<Date, MutableInt> entry : tempResult.entrySet()) { + result.put(entry.getKey(), entry.getValue().intValue()); + } + return result; + } + } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java index 54eb1ea..0b526e5 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java @@ -24,12 +24,10 @@ package fr.ifremer.wao.entity; +import fr.ifremer.wao.WaoUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.nuiton.util.DateUtil; -import java.util.Calendar; import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -157,10 +155,7 @@ public class ContactImpl extends ContactAbstract { public Integer getObservationTimeInDays() { Integer observationTimeInDays = null; if (getObservationBeginDate() != null && getObservationEndDate() != null) { - // +1 car demandé par le métier - observationTimeInDays = DateUtil.getDifferenceInDays( - DateUtils.truncate(getObservationBeginDate(), Calendar.DAY_OF_MONTH), - DateUtils.truncate(getObservationEndDate(), Calendar.DAY_OF_MONTH)) + 1; + observationTimeInDays = WaoUtils.getObservationTimeInDays(getObservationBeginDate(), getObservationEndDate()); } return observationTimeInDays; } diff --git a/wao-persistence/src/test/java/fr/ifremer/wao/WaoUtilsTest.java b/wao-persistence/src/test/java/fr/ifremer/wao/WaoUtilsTest.java index 3e44827..43f01f0 100644 --- a/wao-persistence/src/test/java/fr/ifremer/wao/WaoUtilsTest.java +++ b/wao-persistence/src/test/java/fr/ifremer/wao/WaoUtilsTest.java @@ -25,9 +25,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Test; +import org.nuiton.util.DateUtil; import java.text.ParseException; +import java.util.Date; import java.util.Locale; +import java.util.Map; public class WaoUtilsTest { @@ -52,4 +55,47 @@ public class WaoUtilsTest { } } + + @Test + public void testGetObservationTimeInDays() { + + Assert.assertEquals(1, WaoUtils.getObservationTimeInDays(DateUtil.createDate(0, 0, 8, 19, 5, 2014), DateUtil.createDate(0, 0, 18, 19, 5, 2014))); + Assert.assertEquals(2, WaoUtils.getObservationTimeInDays(DateUtil.createDate(0, 0, 18, 19, 5, 2014), DateUtil.createDate(0, 0, 6, 20, 5, 2014))); + Assert.assertEquals(2, WaoUtils.getObservationTimeInDays(DateUtil.createDate(0, 0, 1, 19, 5, 2014), DateUtil.createDate(0, 0, 23, 20, 5, 2014))); + Assert.assertEquals(2, WaoUtils.getObservationTimeInDays(DateUtil.createDate(0, 0, 12, 31, 1, 2014), DateUtil.createDate(0, 0, 23, 1, 2, 2014))); + + } + + @Test + public void testGetObservationDaysByMonths() { + + checkObservationTimeInDays(DateUtil.createDate(0, 0, 8, 19, 5, 2014), DateUtil.createDate(0, 0, 18, 19, 5, 2014), 1); + checkObservationTimeInDays(DateUtil.createDate(0, 0, 18, 19, 5, 2014), DateUtil.createDate(0, 0, 6, 20, 5, 2014), 1); + checkObservationTimeInDays(DateUtil.createDate(0, 0, 1, 19, 5, 2014), DateUtil.createDate(0, 0, 23, 20, 5, 2014), 1); + checkObservationTimeInDays(DateUtil.createDate(0, 0, 12, 31, 1, 2014), DateUtil.createDate(0, 0, 23, 1, 2, 2014), 2); + + } + + protected void checkObservationTimeInDays(Date observationBeginDate, Date observationEndDate, int expectedSize) { + + Map<Date, Integer> observationDaysByMonths = WaoUtils.getObservationDaysByMonths(observationBeginDate, observationEndDate); + + Assert.assertEquals( + "La répartition aurait dû se faire sur " + expectedSize + " mois et non " + observationDaysByMonths, + expectedSize, observationDaysByMonths.size()); + + int expectedObservationTimeInDays = WaoUtils.getObservationTimeInDays(observationBeginDate, observationEndDate); + int actualObservationTimeInDays = 0; + for (Integer monthValue : observationDaysByMonths.values()) { + actualObservationTimeInDays += monthValue; + } + + Assert.assertEquals( + "Il faut répartir " + expectedObservationTimeInDays + " sur les différents mois et non " + actualObservationTimeInDays + ": " + observationDaysByMonths, + expectedObservationTimeInDays, + actualObservationTimeInDays + ); + + } + } \ No newline at end of file diff --git a/wao-persistence/src/test/java/fr/ifremer/wao/entity/ContactImplTest.java b/wao-persistence/src/test/java/fr/ifremer/wao/entity/ContactImplTest.java deleted file mode 100644 index c79f945..0000000 --- a/wao-persistence/src/test/java/fr/ifremer/wao/entity/ContactImplTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package fr.ifremer.wao.entity; - -/* - * #%L - * Wao :: Persistence - * %% - * Copyright (C) 2009 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Test; -import org.nuiton.util.DateUtil; - -import java.util.Date; - -public class ContactImplTest { - - @Test - public void testGetObservationTimeInDays() { - - checkObservationTimeInDays(DateUtil.createDate(0, 0, 8, 19, 05, 2014), DateUtil.createDate(0, 0, 18, 19, 05, 2014), 1); - checkObservationTimeInDays(DateUtil.createDate(0, 0, 18, 19, 05, 2014), DateUtil.createDate(0, 0, 6, 20, 05, 2014), 2); - checkObservationTimeInDays(DateUtil.createDate(0, 0, 1, 19, 05, 2014), DateUtil.createDate(0, 0, 23, 20, 05, 2014), 2); - - } - - public void checkObservationTimeInDays(Date observationBeginDate, Date observationEndDate, int expectedObservationTimeInDays) { - - ContactImpl contact = new ContactImpl(); - contact.setObservationBeginDate(observationBeginDate); - contact.setObservationEndDate(observationEndDate); - - Integer actualObservationTimeInDays = contact.getObservationTimeInDays(); - Assert.assertEquals((Integer) expectedObservationTimeInDays, actualObservationTimeInDays); - - } - -} \ No newline at end of file -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 92dc9de394e2e65d86acf5fc4f04e9515ba2e27b Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 9 18:29:52 2014 +0200 Dans ObsMerSamplingPlanService, on sépare les préoccupations entre calcul de la clé du cache, lecture du cache et calcul du plan --- .../service/ObsMerSamplingPlanService.java | 100 ++++++++++++--------- .../wao/services/service/SamplingPlanCacheKey.java | 12 +++ 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java index ff1fd94..2bd85ab 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java @@ -63,6 +63,7 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { SampleRowsFilter sampleRowsFilter) { Locale locale = serviceContext.getLocale(); + if (log.isDebugEnabled()) { log.debug("a sampling plan with locale " + locale + " is asked"); } @@ -78,6 +79,14 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { optionalCompanyId, sampleRowsFilter); + ObsMerSamplingPlan result = getSamplingPlan(samplingPlanCacheKey); + + return result; + + } + + protected ObsMerSamplingPlan getSamplingPlan(SamplingPlanCacheKey samplingPlanCacheKey) { + Cache<SamplingPlanCacheKey, SamplingPlan> samplingPlansCache = serviceContext.getSamplingPlansCache(); @@ -85,54 +94,61 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { if (result == null) { - SampleRowTopiaDao dao = getSampleRowDao(); - ContactTopiaDao contactDao = getContactDao(); - - // recuperation des lignes du plan - List<SampleRow> sampleRows = dao.findAll(sampleRowsFilter); - - // creation du plan d'echantillonnage - ObsMerSamplingPlanBuilder builder = new ObsMerSamplingPlanBuilder( - locale, - optionalCompanyId, - sampleRowsFilter); - - // begin of month - Date periodFrom = sampleRowsFilter.getPeriodFrom(); - // end of month - Date periodTo = WaoUtils.getEndOfMonth(sampleRowsFilter.getPeriodTo()); - - for (SampleRow sampleRow : sampleRows) { - - // calcul effort plannifie - Integer observationTimesInDaysExpected = - getObservationTimesInDayExpected(periodFrom, - periodTo, - sampleRow); - - Pair<Long, Long> realAndEstimated = - getSampleRowObservationTimesInDayRealAndEstimated( - sampleRow.getTopiaId(), periodFrom, periodTo); - Long observationTimesInDaysReal = realAndEstimated.getLeft(); - Long observationTimesInDaysEstimated = realAndEstimated.getRight(); - - long sampleRowContactCounts = contactDao.forSampleRowEquals(sampleRow).count(); - - // ajout de la ligne au build de plan - builder.addSampleRow(sampleRow, - observationTimesInDaysExpected, - observationTimesInDaysReal, - observationTimesInDaysEstimated, - sampleRowContactCounts); - } - result = builder.toPlan(); + result = computeSamplingPlan(samplingPlanCacheKey); samplingPlansCache.put(samplingPlanCacheKey.clone(), result); } - return result; + } + + protected ObsMerSamplingPlan computeSamplingPlan(SamplingPlanCacheKey samplingPlanCacheKey) { + + SampleRowsFilter sampleRowsFilter = samplingPlanCacheKey.getSampleRowsFilter(); + SampleRowTopiaDao dao = getSampleRowDao(); + List<SampleRow> sampleRows = dao.findAll(sampleRowsFilter); + + // creation du plan d'echantillonnage + ObsMerSamplingPlanBuilder builder = new ObsMerSamplingPlanBuilder( + samplingPlanCacheKey.getLocale(), + samplingPlanCacheKey.getOptionalCompanyId(), + sampleRowsFilter); + + // begin of month + Date periodFrom = sampleRowsFilter.getPeriodFrom(); + // end of month + Date periodTo = WaoUtils.getEndOfMonth(sampleRowsFilter.getPeriodTo()); + + ContactTopiaDao contactDao = getContactDao(); + for (SampleRow sampleRow : sampleRows) { + + // calcul effort plannifie + Integer observationTimesInDaysExpected = + getObservationTimesInDayExpected(periodFrom, + periodTo, + sampleRow); + + Pair<Long, Long> realAndEstimated = + getSampleRowObservationTimesInDayRealAndEstimated( + sampleRow.getTopiaId(), periodFrom, periodTo); + Long observationTimesInDaysReal = realAndEstimated.getLeft(); + Long observationTimesInDaysEstimated = realAndEstimated.getRight(); + + long sampleRowContactCounts = contactDao.forSampleRowEquals(sampleRow).count(); + + // ajout de la ligne au build de plan + builder.addSampleRow(sampleRow, + observationTimesInDaysExpected, + observationTimesInDaysReal, + observationTimesInDaysEstimated, + sampleRowContactCounts); + + } + + ObsMerSamplingPlan result = builder.toPlan(); + + return result; } /** diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java index 085dd66..de55ec5 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java @@ -41,6 +41,18 @@ public class SamplingPlanCacheKey implements WaoCacheKey { this.sampleRowsFilter = sampleRowsFilter; } + public Locale getLocale() { + return locale; + } + + public Optional<String> getOptionalCompanyId() { + return optionalCompanyId; + } + + public SampleRowsFilter getSampleRowsFilter() { + return sampleRowsFilter; + } + @Override public boolean equals(Object o) { if (this == o) return true; -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 91b7f0912d2d250e259afe2f2764f059d38189b3 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 11:15:16 2014 +0200 On renomme une variable du plan pour parler d'observation et non de marée --- .../wao/services/service/ObsMerSamplingPlan.java | 4 ++-- .../services/service/ObsMerSamplingPlanBuilder.java | 14 +++++++------- .../wao/services/service/ObsVenteSamplingPlan.java | 4 ++-- .../service/ObsVenteSamplingPlanBuilder.java | 10 +++++----- .../ifremer/wao/services/service/SamplingPlan.java | 20 +++++--------------- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java index 9ca7366..ede800e 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java @@ -144,13 +144,13 @@ public class ObsMerSamplingPlan extends SamplingPlan { protected Double appliedCoverageRate; public ObsMerSamplingPlanSampleRowPart(Locale locale, - Map<Date, Effort> nbTidesPerMonth, + Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, Integer observationTimesInDaysExpected, Long observationTimesInDaysReal, Long observationTimesInDaysEstimated, long sampleRowContactCounts) { - super(locale, nbTidesPerMonth, sampleRow, sampleRowContactCounts); + super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); this.observationTimesInDaysExpected = observationTimesInDaysExpected; this.observationTimesInDaysReal = observationTimesInDaysReal; this.observationTimesInDaysEstimated = observationTimesInDaysEstimated; diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java index f213674..8a368d1 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java @@ -183,12 +183,12 @@ public class ObsMerSamplingPlanBuilder { SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); // compute nb tides per month - Map<Date, SamplingPlan.Effort> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), sampleRow, - nbTidesPerMonth, + effortInObservationsPerMonths, observationTimesInDaysExpected, observationTimesInDaysReal, observationTimesInDaysEstimated, @@ -250,7 +250,7 @@ public class ObsMerSamplingPlanBuilder { return result; } - protected Map<Date, SamplingPlan.Effort> computeNbTidesPerMonth(SampleRow sampleRow) { + protected Map<Date, SamplingPlan.Effort> getEffortInObservationsPerMonths(SampleRow sampleRow) { Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); for (Date month : months) { Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); @@ -282,8 +282,8 @@ public class ObsMerSamplingPlanBuilder { highTotalEstimated += estimatedTidesValue; } result.put(month, new SamplingPlan.Effort(expectedTidesValue, - realTidesValue, - estimatedTidesValue)); + realTidesValue, + estimatedTidesValue)); } return result; @@ -344,7 +344,7 @@ public class ObsMerSamplingPlanBuilder { protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, SampleRow row, - Map<Date, SamplingPlan.Effort> nbTidesPerMonth, + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, Integer observationTimesInDaysExpected, Long observationTimesInDaysReal, Long observationTimesInDaysEstimated, @@ -352,7 +352,7 @@ public class ObsMerSamplingPlanBuilder { ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart rowPart = new ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart(locale, - nbTidesPerMonth, + effortInObservationsPerMonths, row, observationTimesInDaysExpected, observationTimesInDaysReal, diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java index dbe8e56..eb3cd7a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java @@ -50,8 +50,8 @@ public class ObsVenteSamplingPlan extends SamplingPlan implements Iterable<Sampl protected String samplingStrategy; - public ObsVenteSamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> nbTidesPerMonth, SampleRow sampleRow, long sampleRowContactCounts) { - super(locale, nbTidesPerMonth, sampleRow, sampleRowContactCounts); + public ObsVenteSamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { + super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); terrestrialLocationInfos = sampleRow.getTerrestrialLocationInfos(); terrestrialLocationNamesAndDescriptions = new LinkedHashMap<>(); if (CollectionUtils.isNotEmpty(sampleRow.getTerrestrialLocations())) { 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 5285c75..165ea51 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 @@ -147,12 +147,12 @@ public class ObsVenteSamplingPlanBuilder { SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); // compute nb tides per month - Map<Date, SamplingPlan.Effort> nbTidesPerMonth = computeNbTidesPerMonth(sampleRow); + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), sampleRow, - nbTidesPerMonth, + effortInObservationsPerMonths, sampleRowContactCounts); sampleRowsFilterValues.addSampleRow(sampleRow); @@ -203,7 +203,7 @@ public class ObsVenteSamplingPlanBuilder { return result; } - protected Map<Date, SamplingPlan.Effort> computeNbTidesPerMonth(SampleRow sampleRow) { + protected Map<Date, SamplingPlan.Effort> getEffortInObservationsPerMonths(SampleRow sampleRow) { Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); for (Date month : months) { Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); @@ -297,13 +297,13 @@ public class ObsVenteSamplingPlanBuilder { protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, SampleRow row, - Map<Date, SamplingPlan.Effort> nbTidesPerMonth, + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, long sampleRowContactCounts) { ObsVenteSamplingPlan.ObsVenteSamplingPlanSampleRowPart rowPart = new ObsVenteSamplingPlan.ObsVenteSamplingPlanSampleRowPart( locale, - nbTidesPerMonth, + effortInObservationsPerMonths, row, sampleRowContactCounts); rows.add(rowPart); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java index 7def4aa..2f35f41 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java @@ -263,7 +263,7 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan /** * Nb tides by month. */ - protected Map<Date, Effort> nbTidesPerMonth; + protected Map<Date, Effort> effortInObservationsPerMonths; protected long sampleRowContactCounts; @@ -331,16 +331,16 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan protected boolean elligibleBoatsProvided; public SamplingPlanSampleRowPart(Locale locale, - Map<Date, Effort> nbTidesPerMonth, + Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { - this.nbTidesPerMonth = nbTidesPerMonth; + this.effortInObservationsPerMonths = effortInObservationsPerMonths; this.sampleRowContactCounts = sampleRowContactCounts; // compute total tides int totalTidesExpected = 0; int totalTidesEstimated = 0; int totalTidesReal = 0; - for (Effort effort : nbTidesPerMonth.values()) { + for (Effort effort : effortInObservationsPerMonths.values()) { Integer totalExpected = effort.getExpected(); if (totalExpected != null) { totalTidesExpected += totalExpected; @@ -489,17 +489,7 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan } public Effort getEffortInObservationsForMonth(Date month) { - return nbTidesPerMonth.get(month); - } - - public String getTotalRealPercentage() { - String result = totalObservations.getRealPercentage(); - return result; - } - - public String getTotalEstimatedPercentage() { - String result = totalObservations.getEstimatedPercentage(); - return result; + return effortInObservationsPerMonths.get(month); } public String getFishingZones() { -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 4f0e637a78d21f0f31b9f473fa4b6233c578ac13 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 11:57:44 2014 +0200 On déplace le calcul des totaux par mois et du grand total en nombre d'observations à la fin du calcul du plan plutôt que pendant --- .../wao/services/service/ObsMerSamplingPlan.java | 6 +- .../service/ObsMerSamplingPlanBuilder.java | 137 +++++++++++---------- .../wao/services/service/ObsVenteSamplingPlan.java | 4 +- 3 files changed, 78 insertions(+), 69 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java index ede800e..5af91cb 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java @@ -61,14 +61,14 @@ public class ObsMerSamplingPlan extends SamplingPlan { public ObsMerSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, - Map<Date, Effort> totalsPerMonth, - Effort highTotals, + Map<Date, Effort> totalEffortInObservationsPerMonths, + Effort highTotalEffortInObservations, Double observationTimesInDaysTotalExpected, Long observationTimesInDaysTotalReal, Long observationTimesInDaysTotalEstimated, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { - super(months, facadeParts, totalsPerMonth, highTotals, filterValues, sampleRowIds); + super(months, facadeParts, totalEffortInObservationsPerMonths, highTotalEffortInObservations, filterValues, sampleRowIds); this.observationTimesInDaysTotalExpected = observationTimesInDaysTotalExpected; this.observationTimesInDaysTotalReal = observationTimesInDaysTotalReal; this.observationTimesInDaysTotalEstimated = observationTimesInDaysTotalEstimated; diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java index 8a368d1..c467b23 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java @@ -80,27 +80,6 @@ public class ObsMerSamplingPlanBuilder { protected Map<String, FacadeContext> facadeMap; /** - * To compute the high total expected. - * - * @see ObsMerSamplingPlan#highTotalEffortInObservations - */ - protected int highTotalExpected; - - /** - * To compute the high total real. - * - * @see ObsMerSamplingPlan#highTotalEffortInObservations - */ - protected int highTotalReal; - - /** - * To compute the high total estimated. - * - * @see ObsMerSamplingPlan#highTotalEffortInObservations - */ - protected int highTotalEstimated; - - /** * To compute the total of expected observation times in days. * * @see ObsMerSamplingPlan#observationTimesInDaysTotalExpected @@ -185,6 +164,37 @@ public class ObsMerSamplingPlanBuilder { // compute nb tides per month Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); + // mise à jour des totaux mensuels + for (Map.Entry<Date, SamplingPlan.Effort> entry : effortInObservationsPerMonths.entrySet()) { + + Date month = entry.getKey(); + Integer expectedObservationsForMonth = entry.getValue().getExpected(); + Integer estimatedObservationsForMonth = entry.getValue().getEstimated(); + Integer realObservationsForMonth = entry.getValue().getReal(); + + if (expectedObservationsForMonth != null) { + MutableInt mutableInt = totalExpectedForMonths.get(month); + if (mutableInt == null) { + totalExpectedForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(expectedObservationsForMonth); + } + if (estimatedObservationsForMonth != null) { + MutableInt mutableInt = totalEstimatedForMonths.get(month); + if (mutableInt == null) { + totalEstimatedForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(estimatedObservationsForMonth); + } + if (realObservationsForMonth != null) { + MutableInt mutableInt = totalRealForMonths.get(month); + if (mutableInt == null) { + totalRealForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(realObservationsForMonth); + } + } + // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), sampleRow, @@ -222,26 +232,42 @@ public class ObsMerSamplingPlanBuilder { } }).immutableSortedCopy(facadeParts); - // Get statistics - Map<Date, SamplingPlan.Effort> statisticsMap = new TreeMap<>(); + // On a accumulé les totaux en nombre d'observation / par mois, on fait les calculs finaux + Map<Date, SamplingPlan.Effort> totalEffortInObservationsPerMonths = new TreeMap<>(); + int highTotalExpected = 0; + int highTotalReal = 0; + int highTotalEstimated = 0; + for (Date month : months) { - MutableInt totalExpected = totalExpectedForMonths.get(month); - MutableInt totalReal = totalRealForMonths.get(month); - MutableInt totalEstimated = totalEstimatedForMonths.get(month); - SamplingPlan.Effort planStatistics = - new SamplingPlan.Effort(totalExpected == null ? null : totalExpected.toInteger(), - totalReal == null ? null : totalReal.toInteger(), - totalEstimated == null ? null : totalEstimated.toInteger()); - statisticsMap.put(month, planStatistics); + MutableInt totalExpectedForMonth = totalExpectedForMonths.get(month); + MutableInt totalEstimatedForMonth = totalEstimatedForMonths.get(month); + MutableInt totalRealForMonth = totalRealForMonths.get(month); + + SamplingPlan.Effort monthEffort = + new SamplingPlan.Effort(totalExpectedForMonth == null ? null : totalExpectedForMonth.toInteger(), + totalRealForMonth == null ? null : totalRealForMonth.toInteger(), + totalEstimatedForMonth == null ? null : totalEstimatedForMonth.toInteger()); + totalEffortInObservationsPerMonths.put(month, monthEffort); + + if (totalExpectedForMonth != null) { + highTotalExpected += totalExpectedForMonth.toInteger(); + } + if (totalEstimatedForMonth != null) { + highTotalEstimated += totalEstimatedForMonth.toInteger(); + } + if (totalRealForMonth != null) { + highTotalReal += totalRealForMonth.toInteger(); + } + } - SamplingPlan.Effort highTotals = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); + SamplingPlan.Effort highTotalEffortInObservations = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); ObsMerSamplingPlan result = new ObsMerSamplingPlan(months, sortedFacades, - statisticsMap, - highTotals, + totalEffortInObservationsPerMonths, + highTotalEffortInObservations, observationTimesInDaysTotalExpected.toDouble(), observationTimesInDaysTotalReal.toLong(), observationTimesInDaysTotalEstimated.toLong(), @@ -251,42 +277,25 @@ public class ObsMerSamplingPlanBuilder { } protected Map<Date, SamplingPlan.Effort> getEffortInObservationsPerMonths(SampleRow sampleRow) { - Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); + + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = new TreeMap<>(); + for (Date month : months) { + Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); - if (expectedTidesValue != null) { - MutableInt mutableInt = totalExpectedForMonths.get(month); - if (mutableInt == null) { - totalExpectedForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(expectedTidesValue); - highTotalExpected += expectedTidesValue; - } + Integer estimatedTidesValue = SampleRows.getEstimatedTidesValue(sampleRow, month); Integer realTidesValue = SampleRows.getRealTidesValue(sampleRow, month); - if (realTidesValue != null) { - MutableInt mutableInt = totalRealForMonths.get(month); - if (mutableInt == null) { - totalRealForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(realTidesValue); - highTotalReal += realTidesValue; - } - Integer estimatedTidesValue = SampleRows.getEstimatedTidesValue(sampleRow, month); - if (estimatedTidesValue != null) { - MutableInt mutableInt = totalEstimatedForMonths.get(month); - if (mutableInt == null) { - totalEstimatedForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(estimatedTidesValue); - highTotalEstimated += estimatedTidesValue; - } - result.put(month, new SamplingPlan.Effort(expectedTidesValue, - realTidesValue, - estimatedTidesValue)); + SamplingPlan.Effort effortForMonth = + new SamplingPlan.Effort( + expectedTidesValue, + realTidesValue, + estimatedTidesValue); + effortInObservationsPerMonths.put(month, effortForMonth); } - return result; + + return effortInObservationsPerMonths; } protected static class FacadeContext { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java index eb3cd7a..6637e3e 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlan.java @@ -36,8 +36,8 @@ import java.util.Set; public class ObsVenteSamplingPlan extends SamplingPlan implements Iterable<SamplingPlan.SamplingPlanFacadePart> { - public ObsVenteSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, Effort> totalsPerMonth, Effort highTotals, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { - super(months, facadeParts, totalsPerMonth, highTotals, filterValues, sampleRowIds); + public ObsVenteSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, Effort> totalEffortInObservationsPerMonths, Effort highTotalEffortInObservations, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { + super(months, facadeParts, totalEffortInObservationsPerMonths, highTotalEffortInObservations, filterValues, sampleRowIds); } public static class ObsVenteSamplingPlanSampleRowPart extends SamplingPlanSampleRowPart { -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 85357f14867187bb2d99a6a829eb8307e47d4830 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 15:50:09 2014 +0200 Suite de remaniement de la génération du plan ObsMer On reste isofonctionel par rapport au début de la branche. Le grand total est désormais calculé à partir des totaux pour chaque mois ; on utilise des multimaps pour stocker tous les Effort rencontrés plutôt que trois maps pour stocké le plannifié, le réel et l'estimé ; on a tous les calculs en jours de mers pour toutes les cellules du plan mais ce n'est pas affiché ; on utilise le template td-effort pour les jours de mers. --- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 7 + .../wao/services/service/ObsMerSamplingPlan.java | 145 ++++-------- .../service/ObsMerSamplingPlanBuilder.java | 243 +++++++++------------ .../service/ObsMerSamplingPlanService.java | 93 +------- .../ifremer/wao/services/service/SamplingPlan.java | 33 ++- .../WEB-INF/content/obsmer/sampling-plan.jsp | 62 ++---- 6 files changed, 200 insertions(+), 383 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java index be5c664..fc25e7e 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java @@ -236,4 +236,11 @@ public class WaoUtils { return result; } + public static int sum(Collection<Integer> integers) { + int sum = 0; + for (Integer integer : integers) { + sum += integer; + } + return sum; + } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java index 5af91cb..5a1a0e3 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java @@ -34,72 +34,29 @@ public class ObsMerSamplingPlan extends SamplingPlan { private static final long serialVersionUID = 1L; - /** - * Total of observation times in days expected. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Double observationTimesInDaysTotalExpected; - - /** - * Total of observation times in days real. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Long observationTimesInDaysTotalReal; - - /** - * Total of observation times in days estimated. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Long observationTimesInDaysTotalEstimated; - - protected Double observationTimesInDaysTotalRealRatio; + protected Map<Date, Effort> totalEffortInDaysPerMonths; - protected Double observationTimesInDaysTotalEstimatedRatio; + protected Effort highTotalEffortInDays; public ObsMerSamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, Effort> totalEffortInObservationsPerMonths, + Map<Date, Effort> totalEffortInDaysPerMonths, Effort highTotalEffortInObservations, - Double observationTimesInDaysTotalExpected, - Long observationTimesInDaysTotalReal, - Long observationTimesInDaysTotalEstimated, + Effort highTotalEffortInDays, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { super(months, facadeParts, totalEffortInObservationsPerMonths, highTotalEffortInObservations, filterValues, sampleRowIds); - this.observationTimesInDaysTotalExpected = observationTimesInDaysTotalExpected; - this.observationTimesInDaysTotalReal = observationTimesInDaysTotalReal; - this.observationTimesInDaysTotalEstimated = observationTimesInDaysTotalEstimated; - if (observationTimesInDaysTotalExpected != null) { - if (observationTimesInDaysTotalReal != null) { - this.observationTimesInDaysTotalRealRatio = (double) observationTimesInDaysTotalReal / observationTimesInDaysTotalExpected; - } - if (observationTimesInDaysTotalEstimated != null) { - this.observationTimesInDaysTotalEstimatedRatio = (double) observationTimesInDaysTotalEstimated / observationTimesInDaysTotalExpected; - } - } - } - - public Double getObservationTimesInDaysTotalRealRatio() { - return observationTimesInDaysTotalRealRatio; - } - - public Double getObservationTimesInDaysTotalEstimatedRatio() { - return observationTimesInDaysTotalEstimatedRatio; - } - - public Double getObservationTimesInDaysTotalExpected() { - return observationTimesInDaysTotalExpected; + this.totalEffortInDaysPerMonths = totalEffortInDaysPerMonths; + this.highTotalEffortInDays = highTotalEffortInDays; } - public Long getObservationTimesInDaysTotalReal() { - return observationTimesInDaysTotalReal; + public Map<Date, Effort> getTotalEffortInDaysPerMonths() { + return totalEffortInDaysPerMonths; } - public Long getObservationTimesInDaysTotalEstimated() { - return observationTimesInDaysTotalEstimated; + public Effort getHighTotalEffortInDays() { + return highTotalEffortInDays; } /** @@ -112,30 +69,9 @@ public class ObsMerSamplingPlan extends SamplingPlan { private static final long serialVersionUID = 1L; - /** - * Expected Times of observation days. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Integer observationTimesInDaysExpected; + protected Map<Date, Effort> effortInDaysPerMonths; - /** - * Real times of observation in days. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Long observationTimesInDaysReal; - - /** - * Estimated times of observation in days. - * <p/> - * <strong>Note:</strong> can be null. - */ - protected Long observationTimesInDaysEstimated; - - protected Integer observationTimesInDaysEstimatedPercentage; - - protected Integer observationTimesInDaysRealPercentage; + protected Effort totalDays; protected int nbObservants; @@ -144,52 +80,45 @@ public class ObsMerSamplingPlan extends SamplingPlan { protected Double appliedCoverageRate; public ObsMerSamplingPlanSampleRowPart(Locale locale, - Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, - Integer observationTimesInDaysExpected, - Long observationTimesInDaysReal, - Long observationTimesInDaysEstimated, + Map<Date, Effort> effortInObservationsPerMonths, + Map<Date, SamplingPlan.Effort> effortInDaysPerMonths, long sampleRowContactCounts) { super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); - this.observationTimesInDaysExpected = observationTimesInDaysExpected; - this.observationTimesInDaysReal = observationTimesInDaysReal; - this.observationTimesInDaysEstimated = observationTimesInDaysEstimated; - - - if (observationTimesInDaysExpected != null && observationTimesInDaysExpected > 0) { - if (observationTimesInDaysEstimated != null) { - observationTimesInDaysEstimatedPercentage = (int) Math.round((observationTimesInDaysEstimated / observationTimesInDaysExpected) * 100); + this.effortInDaysPerMonths = effortInDaysPerMonths; + + // pour la ligne, on calcule le total en nombre de jour de mers + int totalDaysExpected = 0; + int totalDaysEstimated = 0; + int totalDaysReal = 0; + for (Effort effort : effortInDaysPerMonths.values()) { + Integer totalExpected = effort.getExpected(); + if (totalExpected != null) { + totalDaysExpected += totalExpected; } - if (observationTimesInDaysReal != null) { - observationTimesInDaysRealPercentage = (int) Math.round((observationTimesInDaysReal / observationTimesInDaysExpected) * 100); + Integer totalEstimated = effort.getEstimated(); + if (totalEstimated != null) { + totalDaysEstimated += totalEstimated; + } + Integer totalReal = effort.getReal(); + if (totalReal != null) { + totalDaysReal += totalReal; } } + totalDays = new Effort(totalDaysExpected, totalDaysReal, totalDaysEstimated); nbObservants = sampleRow.getNbObservants(); averageTideTime = sampleRow.getAverageTideTime(); - appliedCoverageRate = sampleRow.getAppliedCoverageRate(); } - public Integer getObservationTimesInDaysExpected() { - return observationTimesInDaysExpected; + public Map<Date, Effort> getEffortInDaysPerMonths() { + return effortInDaysPerMonths; } - public Long getObservationTimesInDaysReal() { - return observationTimesInDaysReal; - } - - public Long getObservationTimesInDaysEstimated() { - return observationTimesInDaysEstimated; - } - - public Integer getObservationTimesInDaysRealPercentage() { - return observationTimesInDaysRealPercentage; - } - - public Integer getObservationTimesInDaysEstimatedPercentage() { - return observationTimesInDaysEstimatedPercentage; + public Effort getTotalDays() { + return totalDays; } public Double getAppliedCoverageRate() { @@ -203,5 +132,7 @@ public class ObsMerSamplingPlan extends SamplingPlan { public int getAverageTideTime() { return averageTideTime; } + } + } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java index c467b23..261a65d 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java @@ -23,14 +23,17 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Function; import com.google.common.base.Optional; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Multimaps; import com.google.common.collect.Ordering; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.WaoUtils; +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.lang3.mutable.MutableDouble; -import org.apache.commons.lang3.mutable.MutableInt; -import org.apache.commons.lang3.mutable.MutableLong; +import org.apache.commons.lang3.BooleanUtils; import org.nuiton.util.PeriodDates; import java.util.ArrayList; @@ -67,7 +70,7 @@ public class ObsMerSamplingPlanBuilder { /** * Ids of all the sample rows included in this sampling plan. */ - protected Set<String> sampleRowIds; + protected Set<String> sampleRowIds = new HashSet<>(); /** * List of month computed from the filter. @@ -77,74 +80,23 @@ public class ObsMerSamplingPlanBuilder { /** * Dictionnary of facades indexed by their facade name. */ - protected Map<String, FacadeContext> facadeMap; + protected Map<String, FacadeContext> facadeMap = new TreeMap<>(); - /** - * To compute the total of expected observation times in days. - * - * @see ObsMerSamplingPlan#observationTimesInDaysTotalExpected - */ - protected MutableDouble observationTimesInDaysTotalExpected; - - /** - * To compute the total of estimated observation times in days. - * - * @see ObsMerSamplingPlan#observationTimesInDaysTotalEstimated - */ - protected MutableLong observationTimesInDaysTotalEstimated; - - /** - * To compute the total of actual observation times in days. - * - * @see ObsMerSamplingPlan#observationTimesInDaysTotalReal - */ - protected MutableLong observationTimesInDaysTotalReal; - - /** - * To compute by month the total of expected tides. - * - * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#expected - */ - protected Map<Date, MutableInt> totalExpectedForMonths; - - /** - * To compute by month the total of expected tides. - * - * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#estimated - */ - protected Map<Date, MutableInt> totalEstimatedForMonths; - - /** - * To compute by month the total of real tides. - * - * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#real - */ - protected Map<Date, MutableInt> totalRealForMonths; + protected ListMultimap<Date, SamplingPlan.Effort> totalObservationsForMonths = LinkedListMultimap.create(); + protected ListMultimap<Date, SamplingPlan.Effort> totalDaysForMonths = LinkedListMultimap.create(); + public ObsMerSamplingPlanBuilder(Locale locale, Optional<String> optionalCompanyId, SampleRowsFilter sampleRowsFilter) { this.sampleRowsFilter = sampleRowsFilter; this.sampleRowsFilterValues = new SampleRowsFilterValues(locale, ObsProgram.OBSMER, optionalCompanyId); - this.sampleRowIds = new HashSet<>(); - this.facadeMap = new TreeMap<>(); - this.observationTimesInDaysTotalExpected = new MutableDouble(); - this.observationTimesInDaysTotalReal = new MutableLong(); - this.observationTimesInDaysTotalEstimated = new MutableLong(); - this.totalExpectedForMonths = new TreeMap<>(); - this.totalRealForMonths = new TreeMap<>(); - this.totalEstimatedForMonths = new TreeMap<>(); - PeriodDates periodDates = new PeriodDates(sampleRowsFilter.getPeriodFrom(), sampleRowsFilter.getPeriodTo()); this.months = periodDates.getMonths(); } - public ObsMerSamplingPlanBuilder addSampleRow(SampleRow sampleRow, - Integer observationTimesInDaysExpected, - Long observationTimesInDaysReal, - Long observationTimesInDaysEstimated, - long sampleRowContactCounts) { + public void addSampleRow(SampleRow sampleRow, Collection<Contact> doneObservations, long sampleRowContactCounts) { String facade = sampleRow.getFacade(); FacadeContext facadeContext = facadeMap.get(facade); @@ -161,59 +113,82 @@ public class ObsMerSamplingPlanBuilder { // get sector context SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); - // compute nb tides per month + // calcul de l'effort en nombre d'observations puis en nombre jours Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); + Map<Date, SamplingPlan.Effort> effortInDaysPerMonths = getEffortInDaysPerMonths(sampleRow, doneObservations); - // mise à jour des totaux mensuels - for (Map.Entry<Date, SamplingPlan.Effort> entry : effortInObservationsPerMonths.entrySet()) { + // ajout dans les totaux par mois + totalObservationsForMonths.putAll(Multimaps.forMap(effortInObservationsPerMonths)); + totalDaysForMonths.putAll(Multimaps.forMap(effortInDaysPerMonths)); + + // add sample row + sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), + sampleRow, + effortInObservationsPerMonths, + effortInDaysPerMonths, + sampleRowContactCounts); - Date month = entry.getKey(); - Integer expectedObservationsForMonth = entry.getValue().getExpected(); - Integer estimatedObservationsForMonth = entry.getValue().getEstimated(); - Integer realObservationsForMonth = entry.getValue().getReal(); + sampleRowsFilterValues.addSampleRow(sampleRow); - if (expectedObservationsForMonth != null) { - MutableInt mutableInt = totalExpectedForMonths.get(month); - if (mutableInt == null) { - totalExpectedForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(expectedObservationsForMonth); + sampleRowIds.add(sampleRow.getTopiaId()); + + } + + protected Map<Date, SamplingPlan.Effort> getEffortInDaysPerMonths(SampleRow sampleRow, Collection<Contact> doneObservations) { + + // Pour chaque observation réalisée, on ajoute dans ces multimaps, une ou plusieurs + // entrées. Une observation a pu avoir lieu sur deux mois. Une entrée indique que pour + // le mois en clé, la valeur est un nombre de jour passé en mer + LinkedListMultimap<Date, Integer> estimatedObservationDaysByMonths = LinkedListMultimap.create(); + LinkedListMultimap<Date, Integer> realObservationDaysByMonths = LinkedListMultimap.create(); + + for (Contact doneObservation : doneObservations) { + + // on prend l'observation, on regarde combien de jour ça ajoute à chaque mois + Map<Date, Integer> observationDaysByMonthsForObservation = + WaoUtils.getObservationDaysByMonths( + doneObservation.getObservationBeginDate(), + doneObservation.getObservationEndDate()); + + if (BooleanUtils.isTrue(doneObservation.getValidationCompany())) { + realObservationDaysByMonths.putAll(Multimaps.forMap(observationDaysByMonthsForObservation)); } - if (estimatedObservationsForMonth != null) { - MutableInt mutableInt = totalEstimatedForMonths.get(month); - if (mutableInt == null) { - totalEstimatedForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(estimatedObservationsForMonth); + + estimatedObservationDaysByMonths.putAll(Multimaps.forMap(observationDaysByMonthsForObservation)); + + } + + Map<Date, SamplingPlan.Effort> effortInDaysPerMonths = new TreeMap<>(); + + for (Date month : months) { + + // calcul du plannifié + Integer expected = null; + Integer expectedObservations = SampleRows.getExpectedTidesValue(sampleRow, month); + if (expectedObservations != null) { + expected = expectedObservations * sampleRow.getAverageTideTime(); } - if (realObservationsForMonth != null) { - MutableInt mutableInt = totalRealForMonths.get(month); - if (mutableInt == null) { - totalRealForMonths.put(month, mutableInt = new MutableInt()); - } - mutableInt.add(realObservationsForMonth); + + // calcul de l'estimé et du réel + Collection<Integer> estimatedDoneObservationDays = estimatedObservationDaysByMonths.asMap().get(month); + Integer estimated = 0; // car estimatedDoneObservationDays peut être null si aucune observation sur le mois + if (estimatedDoneObservationDays != null) { + estimated = WaoUtils.sum(estimatedDoneObservationDays); } - } - // add sample row - sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), - sampleRow, - effortInObservationsPerMonths, - observationTimesInDaysExpected, - observationTimesInDaysReal, - observationTimesInDaysEstimated, - sampleRowContactCounts); - - // Sum total observation times in days - observationTimesInDaysTotalExpected.add(observationTimesInDaysExpected); - observationTimesInDaysTotalReal.add(observationTimesInDaysReal); - observationTimesInDaysTotalEstimated.add(observationTimesInDaysEstimated); + Collection<Integer> realDoneObservationDays = estimatedObservationDaysByMonths.asMap().get(month); + Integer real = 0; // car realDoneObservationDays peut être null si aucune observation sur le mois + if (realDoneObservationDays != null) { + real = WaoUtils.sum(realDoneObservationDays); + } - sampleRowsFilterValues.addSampleRow(sampleRow); + SamplingPlan.Effort effortForMonth = new SamplingPlan.Effort(expected, real, estimated); + effortInDaysPerMonths.put(month, effortForMonth); - sampleRowIds.add(sampleRow.getTopiaId()); + } + + return effortInDaysPerMonths; - return this; } public ObsMerSamplingPlan toPlan() { @@ -234,43 +209,30 @@ public class ObsMerSamplingPlanBuilder { // On a accumulé les totaux en nombre d'observation / par mois, on fait les calculs finaux Map<Date, SamplingPlan.Effort> totalEffortInObservationsPerMonths = new TreeMap<>(); - int highTotalExpected = 0; - int highTotalReal = 0; - int highTotalEstimated = 0; + Map<Date, SamplingPlan.Effort> totalEffortInDaysPerMonths = new TreeMap<>(); for (Date month : months) { - MutableInt totalExpectedForMonth = totalExpectedForMonths.get(month); - MutableInt totalEstimatedForMonth = totalEstimatedForMonths.get(month); - MutableInt totalRealForMonth = totalRealForMonths.get(month); - - SamplingPlan.Effort monthEffort = - new SamplingPlan.Effort(totalExpectedForMonth == null ? null : totalExpectedForMonth.toInteger(), - totalRealForMonth == null ? null : totalRealForMonth.toInteger(), - totalEstimatedForMonth == null ? null : totalEstimatedForMonth.toInteger()); - totalEffortInObservationsPerMonths.put(month, monthEffort); + Collection<SamplingPlan.Effort> totalObservationsForMonth = totalObservationsForMonths.asMap().get(month); + SamplingPlan.Effort totalEffortInObservationsForMonth = SamplingPlan.Effort.sum(totalObservationsForMonth); + totalEffortInObservationsPerMonths.put(month, totalEffortInObservationsForMonth); - if (totalExpectedForMonth != null) { - highTotalExpected += totalExpectedForMonth.toInteger(); - } - if (totalEstimatedForMonth != null) { - highTotalEstimated += totalEstimatedForMonth.toInteger(); - } - if (totalRealForMonth != null) { - highTotalReal += totalRealForMonth.toInteger(); - } + Collection<SamplingPlan.Effort> totalDaysForMonth = totalDaysForMonths.asMap().get(month); + SamplingPlan.Effort totalEffortInDaysForMonth = SamplingPlan.Effort.sum(totalDaysForMonth); + totalEffortInDaysPerMonths.put(month, totalEffortInDaysForMonth); } - SamplingPlan.Effort highTotalEffortInObservations = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); + // on calcule le grand total en faisant la somme sur tous les mois + SamplingPlan.Effort highTotalEffortInObservations = SamplingPlan.Effort.sum(totalEffortInObservationsPerMonths.values()); + SamplingPlan.Effort highTotalEffortInDays = SamplingPlan.Effort.sum(totalEffortInDaysPerMonths.values()); ObsMerSamplingPlan result = new ObsMerSamplingPlan(months, sortedFacades, totalEffortInObservationsPerMonths, + totalEffortInDaysPerMonths, highTotalEffortInObservations, - observationTimesInDaysTotalExpected.toDouble(), - observationTimesInDaysTotalReal.toLong(), - observationTimesInDaysTotalEstimated.toLong(), + highTotalEffortInDays, sampleRowsFilterValues, sampleRowIds); return result; @@ -351,25 +313,22 @@ public class ObsMerSamplingPlanBuilder { this.rows = new ArrayList<>(); } - protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, - SampleRow row, - Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, - Integer observationTimesInDaysExpected, - Long observationTimesInDaysReal, - Long observationTimesInDaysEstimated, - long sampleRowContactCounts) { + protected void addSampleRow( + Locale locale, + SampleRow row, + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, + Map<Date, SamplingPlan.Effort> effortInDaysPerMonths, + long sampleRowContactCounts) { ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart rowPart = - new ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart(locale, - effortInObservationsPerMonths, - row, - observationTimesInDaysExpected, - observationTimesInDaysReal, - observationTimesInDaysEstimated, - sampleRowContactCounts); + new ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart( + locale, + row, + effortInObservationsPerMonths, + effortInDaysPerMonths, + sampleRowContactCounts); rows.add(rowPart); - return rowPart; } protected SamplingPlan.SamplingPlanSectorPart toBean() { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java index 2bd85ab..7884a16 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java @@ -25,7 +25,6 @@ import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.cache.Cache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Range; import com.google.common.collect.Sets; import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.SampleRowsFilter; @@ -34,14 +33,11 @@ import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.ContactTopiaDao; -import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowTopiaDao; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.csv.ObsMerSamplingPlanExportModel; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Export; @@ -121,27 +117,17 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { Date periodTo = WaoUtils.getEndOfMonth(sampleRowsFilter.getPeriodTo()); ContactTopiaDao contactDao = getContactDao(); - for (SampleRow sampleRow : sampleRows) { - // calcul effort plannifie - Integer observationTimesInDaysExpected = - getObservationTimesInDayExpected(periodFrom, - periodTo, - sampleRow); + for (SampleRow sampleRow : sampleRows) { - Pair<Long, Long> realAndEstimated = - getSampleRowObservationTimesInDayRealAndEstimated( - sampleRow.getTopiaId(), periodFrom, periodTo); - Long observationTimesInDaysReal = realAndEstimated.getLeft(); - Long observationTimesInDaysEstimated = realAndEstimated.getRight(); + Collection<Contact> doneObservations = getDoneObservations(sampleRow, periodFrom, periodTo); long sampleRowContactCounts = contactDao.forSampleRowEquals(sampleRow).count(); // ajout de la ligne au build de plan - builder.addSampleRow(sampleRow, - observationTimesInDaysExpected, - observationTimesInDaysReal, - observationTimesInDaysEstimated, + builder.addSampleRow( + sampleRow, + doneObservations, sampleRowContactCounts); } @@ -149,59 +135,18 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { ObsMerSamplingPlan result = builder.toPlan(); return result; - } - - /** - * Récupérer l'effort d'observation en nombre de jours plannifié poru - * le sample row donné pendant la période donnée. - * - * @param periodFrom début de période où rechercher les contacts - * @param periodTo fin de période où rechercher les contacts - * @param sampleRow la ligne à filtrer - * @return l'effort plannifié calculé - */ - protected int getObservationTimesInDayExpected(Date periodFrom, - Date periodTo, - SampleRow sampleRow) { - - Range<Date> period = Range.closed(periodFrom, periodTo); - - int expected; - - // On prend le nombre d'observation prévue pour cette ligne du plan - // c'est à dire la somme des nombres d'observations prévues pour - // chaque mois. - int expectedObservationCount = 0; - for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { - Date periodDate = sampleMonth.getPeriodDate(); - if (period.contains(periodDate)) { - expectedObservationCount += sampleMonth.getExpectedTidesValue(); - } - } - // le prévisionnel est égal au nombre d'observations attendues × - // le nombre de jours moyen d'une observation - expected = expectedObservationCount * sampleRow.getAverageTideTime(); - return expected; } /** - * Récupérer l'effort d'observation en nombre de jours réalisé (partie gauche) et estimé (partie droite) - * pour le filtre d'échantillonnage donné. - * - * @param sampleRowId la sample row pour laquelle il faut calculer l'effor réalisé - * @param periodFrom la date à partir de laquelle on compte les contacts - * @param periodTo la date jusqu'à laquelle on compte les contacts - * @return la paire (effort réalisé - effort estimé) calculée + * Permet d'obtenir pour une période donnée toutes les observations réalisées. Cela forme + * une base de travail pour calculer le réalisé en jours de mers */ - protected Pair<Long, Long> getSampleRowObservationTimesInDayRealAndEstimated(String sampleRowId, Date periodFrom, Date periodTo) { - - // D'abord, on a besoin de récupérer toutes les observations réalisées - // pour cette ligne du plan + protected Collection<Contact> getDoneObservations(SampleRow sampleRow, Date periodFrom, Date periodTo) { ContactsFilter contactFilter = new ContactsFilter(); - contactFilter.getSampleRowFilter().setSampleRowIds(ImmutableSet.of(sampleRowId)); + contactFilter.getSampleRowFilter().setSampleRowIds(ImmutableSet.of(sampleRow.getTopiaId())); contactFilter.setFilterOnObservationBeginDate(true); contactFilter.setPeriodFrom(periodFrom); @@ -213,26 +158,10 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { // on exclue les contacts invalidés par la société contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null)); - Collection<Contact> contacts = getContactDao().forFilter(contactFilter, false).findAll(); - - long real = 0; - long estimated = 0; - - for (Contact contact : contacts) { + List<Contact> contacts = getContactDao().forFilter(contactFilter, false).findAll(); - Integer observationTimeInDays = contact.getObservationTimeInDays(); - - if (observationTimeInDays != null) { - if (BooleanUtils.isTrue(contact.getValidationCompany())) { - // real observation - real += observationTimeInDays; - } - // estimated observation - estimated += observationTimeInDays; - } - } + return contacts; - return Pair.of(real, estimated); } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java index 2f35f41..68195b0 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java @@ -126,6 +126,27 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan this.estimated = estimated; } + /** + * Créer un effort calculé à partir de la somme d'autre efforts + */ + public static Effort sum(Iterable<Effort> efforts) { + int expected = 0; + int real = 0; + int estimated = 0; + for (Effort effort : efforts) { + if (effort.getExpected() != null) { + expected += effort.getExpected(); + } + if (effort.getEstimated() != null) { + estimated += effort.getEstimated(); + } + if (effort.getReal() != null) { + real += effort.getReal(); + } + } + return new Effort(expected, real, estimated); + } + public Integer getExpected() { return expected; } @@ -230,8 +251,8 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan } } - public Effort getTotalEffortInObservationsForMonth(Date month) { - return totalEffortInObservationsPerMonths.get(month); + public Map<Date, Effort> getTotalEffortInObservationsPerMonths() { + return totalEffortInObservationsPerMonths; } public Effort getHighTotalEffortInObservations() { @@ -336,7 +357,8 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan long sampleRowContactCounts) { this.effortInObservationsPerMonths = effortInObservationsPerMonths; this.sampleRowContactCounts = sampleRowContactCounts; - // compute total tides + + // pour la ligne, on calcul le total en nombre d'observation int totalTidesExpected = 0; int totalTidesEstimated = 0; int totalTidesReal = 0; @@ -355,6 +377,7 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan } } totalObservations = new Effort(totalTidesExpected, totalTidesReal, totalTidesEstimated); + facade = sampleRow.getFacade(); sectors = sampleRow.getSectors(); fishingZones = ""; @@ -408,6 +431,10 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan elligibleBoatsProvided = sampleRow.isElligibleBoatNotEmpty(); } + public Map<Date, Effort> getEffortInObservationsPerMonths() { + return effortInObservationsPerMonths; + } + public String getSampleRowId() { return sampleRowId; } diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index 4befaa8..61e536c 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -365,7 +365,7 @@ </td> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="%{getEffortInObservationsForMonth(#month)}"/> + <s:set var="effort" value="#samplingPlanRow.effortInObservationsPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="false"/> <%@include file="../templates/td-effort.jsp" %> @@ -376,30 +376,11 @@ <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> - <td class="effort"> - - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="observationTimesInDaysEstimated < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysEstimated > observationTimesInDaysExpected"> higher-than-expected</s:if>"> - <s:property value="observationTimesInDaysEstimated" /> <s:text name="wao.ui.misc.day"/> - </span> - <span class="real<s:if test="observationTimesInDaysReal < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysReal > observationTimesInDaysExpected"> higher-than-expected</s:if>"> - <s:property value="observationTimesInDaysReal" /> <s:text name="wao.ui.misc.day"/> - </span> - / - </s:if> - - <s:property value="observationTimesInDaysExpected" /> <s:text name="wao.ui.misc.day"/> - - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="observationTimesInDaysEstimated < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysEstimated > observationTimesInDaysExpected"> higher-than-expected</s:if>"> - <s:property value="observationTimesInDaysEstimatedPercentage" /> % - </span> - <span class="real<s:if test="observationTimesInDaysReal < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysReal > observationTimesInDaysExpected"> higher-than-expected</s:if>"> - <s:property value="observationTimesInDaysRealPercentage" /> % - </span> - </s:if> + <s:set var="effort" value="#samplingPlanRow.totalDays"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> - </td> <td class="align-center"><s:property value="averageTideTime" /></td> <td class="align-center"><s:property value="nbObservants" /></td> <td class="align-center"> @@ -507,9 +488,10 @@ <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view"> <s:text name="wao.ui.misc.totals" /> </th> + <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="samplingPlan.getTotalEffortInObservationsForMonth(#month)"/> + <s:set var="effort" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> @@ -520,31 +502,13 @@ <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> - <td class="effort"> - <s:set var="expected" value="%{samplingPlan.observationTimesInDaysTotalExpected}"/> - <s:set var="estimated" value="%{samplingPlan.observationTimesInDaysTotalEstimated}"/> - <s:set var="real" value="%{samplingPlan.observationTimesInDaysTotalReal}"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="#estimated"/> <s:text name="wao.ui.misc.day"/> - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="#real"/> <s:text name="wao.ui.misc.day"/> - </span> - / - </s:if> - <s:property value="#expected"/> <s:text name="wao.ui.misc.day"/> - - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> - <s:property value="samplingPlan.observationTimesInDaysTotalEstimatedRatio * 100" /> % - </span> - <span class="real<s:if test="#real < #expected"> lower-than-expected</s:if><s:if test="#real > #expected"> higher-than-expected</s:if>"> - <s:property value="samplingPlan.observationTimesInDaysTotalRealRatio * 100" /> % - </span> - </s:if> - </td> + <s:set var="effort" value="samplingPlan.highTotalEffortInDays"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + <th colspan="${nbColumnsForOther}"></th> + </tfoot> </table> -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 6b944fe8897469c8bbeb8b0771f8786f27d0d7d2 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 16:05:10 2014 +0200 On impacte le plan ObsVente suite au remaniement fait pour ObsMer --- wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a1bfe56..84f6f6b 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 @@ -366,7 +366,7 @@ </td> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="%{getEffortInObservationsForMonth(#month)}"/> + <s:set var="effort" value="#samplingPlanRow.effortInObservationsPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="false"/> <%@include file="../templates/td-effort.jsp" %> @@ -482,7 +482,7 @@ </th> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="samplingPlan.getTotalEffortInObservationsForMonth(#month)"/> + <s:set var="effort" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 4bbbec41111d10e622113213ab733ec030a12bd7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:05:27 2014 +0200 On montre les jours de mer dans la vue du plan d'échantillonnage obsmer --- .../fr/ifremer/wao/web/WaoJspActionSupport.java | 3 +- .../main/resources/i18n/wao-web_en_GB.properties | 2 + .../main/resources/i18n/wao-web_fr_FR.properties | 2 + .../WEB-INF/content/obsmer/sampling-plan.jsp | 106 +++++++++++++-------- .../WEB-INF/content/templates/td-effort-obsmer.jsp | 13 +++ .../webapp/WEB-INF/content/templates/td-effort.jsp | 2 +- wao-web/src/main/webapp/wao.css | 2 + 7 files changed, 89 insertions(+), 41 deletions(-) diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java b/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java index daf61a0..118f6a0 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java @@ -182,7 +182,8 @@ public class WaoJspActionSupport extends WaoActionSupport { return ImmutableMap.of( "version", (Object) "4.2", "samplingPlanFullView", isSamplingPlanFullViewByDefault(), - "contactsListFullView", isContactsListFullViewByDefault() + "contactsListFullView", isContactsListFullViewByDefault(), + "samplingPlanDaysView", false ); } diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index 00a2f11..5ed97b4 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -79,7 +79,9 @@ wao.ui.action.save.success=Modifications saved wao.ui.action.showDetails=Show details wao.ui.action.showFilters=Show filters wao.ui.action.switchToCompactView=Switch to compact view +wao.ui.action.switchToDaysView=Switch to view in days wao.ui.action.switchToFullView=Switch to full view +wao.ui.action.switchToObservationsView=Swith to view in tides wao.ui.action.unvalidateContact=Unvalidate contact wao.ui.action.viewAssociatedContacts=View sample row contacts wao.ui.action.viewAssociatedContactsForBoat=View %s contacts for this boat diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 57ae1b2..5de8dc6 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -80,7 +80,9 @@ wao.ui.action.save.success=Les informations ont bien été enregistrées wao.ui.action.showDetails=Voir les détails wao.ui.action.showFilters=Afficher les filtres wao.ui.action.switchToCompactView=Réduire la vue +wao.ui.action.switchToDaysView=Basculer vers la vue en jours de mer wao.ui.action.switchToFullView=Étendre la vue +wao.ui.action.switchToObservationsView=Basculer vers la vue en nombre de marées wao.ui.action.unvalidateContact=Invalider le contact wao.ui.action.viewAssociatedContacts=Voir les contacts associés à cette ligne wao.ui.action.viewAssociatedContactsForBoat=Voir les %s contacts pour ce navire diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index 61e536c..d32e078 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -32,8 +32,7 @@ $(document).ready(function () { - // var sampleRowsFilterController = new FilterController(WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL, $('#sampling-plan-filters-form')); - // sampleRowsFilterController.init(); + // gestion des filtres var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> @@ -80,18 +79,41 @@ sampleRowsFilterController2 = new FilterController2(sampleRowsFilterMappings, filter, WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL, $('#sampling-plan-filters-form fieldset.extra-filters')); sampleRowsFilterController2.init(); + // gestion du mode estimé vs réel + $('#switch-estimated-real').click(function () { - $('#switch-estimated-real').toggleClass('show-estimated').toggleClass('show-real'); - $('table.sampling-plan').toggleClass('show-estimated').toggleClass('show-real'); + $('#switch-estimated-real, table.sampling-plan').toggleClass('show-estimated').toggleClass('show-real'); $('.estimated-differ-from-real').effect( "highlight", "slow" ) }); + // gestion du mode compact vs vue complète + var $views = $('#switch-compact-full-view, table.sampling-plan'); $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); $('#switch-compact-full-view').click(function () { WAO.getCookie().samplingPlanFullView = ! WAO.getCookie().samplingPlanFullView; $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); + }); + + // gestion du mode observations vs jours de mer + + $.fn.toggleObservationsDaysView = function (daysView) { + return this.each(function () { + if (daysView) { + $(this).addClass('days-view').removeClass('observations-view'); + } else { + $(this).addClass('observations-view').removeClass('days-view'); + } + }) + } + + var $views2 = $('#switch-observations-days-view, table.sampling-plan'); + $views2.toggleObservationsDaysView(WAO.getCookie().samplingPlanDaysView); + + $('#switch-observations-days-view').click(function () { + WAO.getCookie().samplingPlanDaysView = ! WAO.getCookie().samplingPlanDaysView; + $views2.toggleObservationsDaysView(WAO.getCookie().samplingPlanDaysView); }); }); @@ -161,6 +183,16 @@ </s:form> <div class="sticky-buttons"> + + <button type="button" id="switch-observations-days-view" class="btn"> + <span class="only-in-observations-view"> + <i class="fa fa-calendar"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToDaysView" /></span> + </span> + <span class="only-in-days-view"> + <i class="fa fa-anchor"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToObservationsView" /></span> + </span> + </button> + <button type="button" id="switch-compact-full-view" class="btn"> <span class="only-in-compact-view"> <i class="fa fa-expand"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToFullView" /></span> @@ -180,6 +212,7 @@ </span> </button> </s:if> + </div> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> @@ -190,7 +223,7 @@ </s:else> <s:set var="nbColumnsForProfessionInCompactView" value="5" /> <s:set var="nbColumnsForMonths" value="%{samplingPlan.months.size() + 1}" /> -<s:set var="nbColumnsForOther" value="6" /> +<s:set var="nbColumnsForOther" value="5" /> <s:set var="nbColumnsTotalInFullView" value="%{#nbColumnsForProfessionInFullView + #nbColumnsForMonths + #nbColumnsForOther}" /> <s:set var="nbColumnsTotalInCompactView" value="%{#nbColumnsForProfessionInCompactView + #nbColumnsForMonths + #nbColumnsForOther}" /> @@ -203,7 +236,7 @@ <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view firstline"> <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> - <th colspan="${nbColumnsForMonths}" class="firstline"> + <th colspan="${nbColumnsForMonths}" class="firstline only-in-observations-view"> <s:text name="wao.ui.samplingPlan.effort" /> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> @@ -219,6 +252,21 @@ ] </s:if> </th> + <th colspan="${nbColumnsForMonths}" class="firstline only-in-days-view"> + <s:text name="wao.ui.samplingPlan.observationTimesInDays"/> + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> + [ + <span class="estimated"> + (<s:text name="wao.ui.samplingPlan.actual" /> + <s:text name="wao.ui.samplingPlan.estimated" />) + </span> + <span class="real"> + <s:text name="wao.ui.samplingPlan.actual" /> + </span> + / + <s:text name="wao.ui.samplingPlan.expected"/> + ] + </s:if> + </th> <th colspan="${nbColumnsForOther}" class="firstline"><s:text name="wao.ui.misc.others" /></th> </tr> <tr> @@ -251,23 +299,9 @@ </th> </s:iterator> <th><s:text name="wao.ui.misc.total"/></th> + <!-- Other columns --> <th> - <s:text name="wao.ui.samplingPlan.observationTimesInDays"/> - <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> - [ - <span class="estimated"> - (<s:text name="wao.ui.samplingPlan.actual" /> + <s:text name="wao.ui.samplingPlan.estimated" />) - </span> - <span class="real"> - <s:text name="wao.ui.samplingPlan.actual" /> - </span> - / - <s:text name="wao.ui.samplingPlan.expected"/> - ] - </s:if> - </th> - <th> <s:text name="wao.ui.samplingPlan.averageTideTime"/> </th> <th> @@ -365,21 +399,18 @@ </td> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="#samplingPlanRow.effortInObservationsPerMonths.get(#month)"/> + <s:set var="effortInObservations" value="#samplingPlanRow.effortInObservationsPerMonths.get(#month)"/> + <s:set var="effortInDays" value="#samplingPlanRow.effortInDaysPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="false"/> - <%@include file="../templates/td-effort.jsp" %> + <%@include file="../templates/td-effort-obsmer.jsp" %> </s:iterator> - <s:set var="effort" value="#samplingPlanRow.totalObservations"/> - <s:set var="now" value="false"/> - <s:set var="showPercentage" value="true"/> - <%@include file="../templates/td-effort.jsp" %> - - <s:set var="effort" value="#samplingPlanRow.totalDays"/> + <s:set var="effortInObservations" value="#samplingPlanRow.totalObservations"/> + <s:set var="effortInDays" value="#samplingPlanRow.totalDays"/> <s:set var="now" value="false"/> <s:set var="showPercentage" value="true"/> - <%@include file="../templates/td-effort.jsp" %> + <%@include file="../templates/td-effort-obsmer.jsp" %> <td class="align-center"><s:property value="averageTideTime" /></td> <td class="align-center"><s:property value="nbObservants" /></td> @@ -491,21 +522,18 @@ <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> + <s:set var="effortInObservations" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> + <s:set var="effortInDays" value="samplingPlan.totalEffortInDaysPerMonths.get(#month)"/> <s:set var="now" value="%{isCurrentMonth(#month)}"/> <s:set var="showPercentage" value="true"/> - <%@include file="../templates/td-effort.jsp" %> + <%@include file="../templates/td-effort-obsmer.jsp" %> </s:iterator> - <s:set var="effort" value="samplingPlan.highTotalEffortInObservations"/> - <s:set var="now" value="false"/> - <s:set var="showPercentage" value="true"/> - <%@include file="../templates/td-effort.jsp" %> - - <s:set var="effort" value="samplingPlan.highTotalEffortInDays"/> + <s:set var="effortInObservations" value="samplingPlan.highTotalEffortInObservations"/> + <s:set var="effortInDays" value="samplingPlan.highTotalEffortInDays"/> <s:set var="now" value="false"/> <s:set var="showPercentage" value="true"/> - <%@include file="../templates/td-effort.jsp" %> + <%@include file="../templates/td-effort-obsmer.jsp" %> <th colspan="${nbColumnsForOther}"></th> diff --git a/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort-obsmer.jsp b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort-obsmer.jsp new file mode 100644 index 0000000..27c5a80 --- /dev/null +++ b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort-obsmer.jsp @@ -0,0 +1,13 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %> +<%@taglib uri="/struts-tags" prefix="s" %> + +<%-- Pour le plan d'échantillonnage ObsMer, au lieu d'avoir une cellule d'effort, +on affiche deux td.effort : une pour les jours de mer et l'autre pour le nombre d'observations --%> + +<s:set var="effort" value="#effortInObservations"/> +<s:set var="tdCssClasses">only-in-observations-view</s:set> +<%@include file="td-effort.jsp" %> + +<s:set var="effort" value="#effortInDays"/> +<s:set var="tdCssClasses">only-in-days-view</s:set> +<%@include file="td-effort.jsp" %> diff --git a/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp index a0c1ff9..3296290 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/templates/td-effort.jsp @@ -7,7 +7,7 @@ <s:set var="estimated" value="#effort.estimated"/> <s:set var="real" value="#effort.real"/> -<td class="effort <s:if test="#now"> now</s:if><s:if test="#estimated != #real"> estimated-differ-from-real</s:if>"> +<td class="effort <s:if test="#now"> now</s:if><s:if test="#estimated != #real"> estimated-differ-from-real</s:if> <s:property value="#tdCssClasses"/>"> <s:if test="#expected != null"> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> <span class="estimated<s:if test="#estimated < #expected"> lower-than-expected</s:if><s:if test="#estimated > #expected"> higher-than-expected</s:if>"> diff --git a/wao-web/src/main/webapp/wao.css b/wao-web/src/main/webapp/wao.css index 40a54ee..f4768ed 100644 --- a/wao-web/src/main/webapp/wao.css +++ b/wao-web/src/main/webapp/wao.css @@ -96,6 +96,8 @@ span[data-toggle="tooltip"] { max-width: 100px; } +.observations-view .only-in-days-view, +.days-view .only-in-observations-view, .compact-view .only-in-full-view, .full-view .only-in-compact-view, .show-estimated .real, -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 91733c0decd2bcbe37da654bb92c7ef8dc6b2279 Merge: 0785e47 4bbbec4 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:06:55 2014 +0200 Dans le plan d'échantillonnage, on propose l'affichage de l'effort en jours de mer et plus seulement en nombre de marées (refs #5651)) .../src/main/java/fr/ifremer/wao/WaoUtils.java | 56 ++++ .../java/fr/ifremer/wao/entity/ContactImpl.java | 9 +- .../src/test/java/fr/ifremer/wao/WaoUtilsTest.java | 46 ++++ .../fr/ifremer/wao/entity/ContactImplTest.java | 52 ---- .../wao/services/service/ObsMerSamplingPlan.java | 153 +++-------- .../service/ObsMerSamplingPlanBuilder.java | 282 +++++++++------------ .../service/ObsMerSamplingPlanService.java | 153 ++++------- .../wao/services/service/ObsVenteSamplingPlan.java | 8 +- .../service/ObsVenteSamplingPlanBuilder.java | 34 +-- .../ifremer/wao/services/service/SamplingPlan.java | 219 +++++++--------- .../wao/services/service/SamplingPlanCacheKey.java | 12 + .../service/csv/ObsMerSamplingPlanExportModel.java | 12 +- .../service/ObsMerSamplingPlanServiceTest.java | 12 +- .../fr/ifremer/wao/web/WaoJspActionSupport.java | 3 +- .../main/resources/i18n/wao-web_en_GB.properties | 2 + .../main/resources/i18n/wao-web_fr_FR.properties | 2 + .../WEB-INF/content/obsmer/sampling-plan.jsp | 233 ++++++----------- .../WEB-INF/content/obsvente/sampling-plan.jsp | 105 ++------ .../WEB-INF/content/templates/td-effort-obsmer.jsp | 13 + .../webapp/WEB-INF/content/templates/td-effort.jsp | 32 +++ wao-web/src/main/webapp/wao.css | 2 + 21 files changed, 609 insertions(+), 831 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 develop in repository wao. See http://git.codelutin.com/wao.git commit d42c625b47aba892c9b78fe423c74fc73a64ec5f Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:14:27 2014 +0200 Qualité du code dans WaoUtils --- .../src/main/java/fr/ifremer/wao/BoatsFilter.java | 10 ++--- .../main/java/fr/ifremer/wao/ContactsFilter.java | 22 +++++----- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 24 +++++------ .../src/main/java/fr/ifremer/wao/WaoUtils.java | 50 +--------------------- 4 files changed, 30 insertions(+), 76 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java index 45958ac..192381d 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java @@ -185,11 +185,11 @@ public class BoatsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + Objects.hashCode(boatName); hashCode = 31 * hashCode + Objects.hashCode(registrationCode); hashCode = 31 * hashCode + Objects.hashCode(boatNameOrRegistrationCode); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(boatIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(shipOwnerIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(districtIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(portOfRegistryIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fleetIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(boatIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(shipOwnerIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(districtIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(portOfRegistryIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(fleetIds); return hashCode; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java index 1c804ff..7dcb6e9 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java @@ -351,22 +351,22 @@ public class ContactsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + Objects.hashCode(boatFilter); hashCode = 31 * hashCode + Objects.hashCode(periodFrom); hashCode = 31 * hashCode + Objects.hashCode(periodFrom); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(contactIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(contactStates); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(dataReliabilities); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(actualSamplingStrategies); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(observedDataControls); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(observerIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(terrestrialLocationIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(contactStateMotiveIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(contactIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(contactStates); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(dataReliabilities); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(actualSamplingStrategies); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(observedDataControls); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(observerIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialLocationIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(contactStateMotiveIds); hashCode = 31 * hashCode + Objects.hashCode(mammalsCaptureOnly); hashCode = 31 * hashCode + Objects.hashCode(mammalsObservationOnly); hashCode = 31 * hashCode + Objects.hashCode(commentDefinedOnly); hashCode = 31 * hashCode + Objects.hashCode(commentAdminDefinedOnly); hashCode = 31 * hashCode + Objects.hashCode(commentCompanyDefinedOnly); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(companyAcceptations); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(programAcceptations); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(completeSamplings); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(companyAcceptations); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(programAcceptations); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(completeSamplings); hashCode = 31 * hashCode + Objects.hashCode(filterOnObservationBeginDate); hashCode = 31 * hashCode + Objects.hashCode(sortedByBoardingDate); return hashCode; diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java index 0bcc1b5..1bd98e0 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java @@ -237,18 +237,18 @@ public class SampleRowsFilter extends AbstractWaoFilter { if (periodTo != null) { hashCode = 31 * hashCode + periodTo.hashCode(); } - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fishingZoneFacadeNames); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fishingZoneSectorNames); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(sampleRowCodes); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(programNames); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(fishingGearDcfIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(targetSpeciesDcfIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(samplingStrategies); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(terrestrialDistrictIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(companyIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashcode(orderByArguments); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(sampleRowIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(sampleRowIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(fishingZoneFacadeNames); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(fishingZoneSectorNames); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(sampleRowCodes); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(programNames); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(fishingGearDcfIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(targetSpeciesDcfIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(samplingStrategies); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialDistrictIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(companyIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(orderByArguments); return hashCode; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java index fc25e7e..cbda03d 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java @@ -36,8 +36,6 @@ import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -47,48 +45,13 @@ public class WaoUtils { @Deprecated protected static final String MONTH_PATTERN = "MM/yyyy"; - @Deprecated - protected static final String MONTH_ONLY_PATTERN = "MM"; - - @Deprecated - protected static final String YEAR_ONLY_PATTERN = "yyyy"; - - @Deprecated - protected static final String DATE_PATTERN = "dd/MM/yyyy"; - - @Deprecated - protected static final String DATE_TIME_PATTERN = "dd/MM/yyyy HH:mm"; - - @Deprecated - protected static final String TIME_PATTERN = "HH:mm"; - protected static final String FRENCH_LANGUAGE = new Locale("fr").getLanguage(); protected static final Date WAO_CREATION_DATE = DateUtil.createDate(27, 1, 2010); @Deprecated public static String formatMonth(Date date) { - return formatDate(date, MONTH_PATTERN); - } - - @Deprecated - public static String formatDate(Date date) { - return formatDate(date, DATE_PATTERN); - } - - @Deprecated - public static String formatDateTime(Date date) { - return formatDate(date, DATE_TIME_PATTERN); - } - - @Deprecated - public static String formatTime(Date date) { - return formatDate(date, TIME_PATTERN); - } - - @Deprecated - protected static String formatDate(Date date, String pattern) { - DateFormat dateFormat = new SimpleDateFormat(pattern); + DateFormat dateFormat = new SimpleDateFormat(MONTH_PATTERN); return dateFormat.format(date); } @@ -141,15 +104,6 @@ public class WaoUtils { return I18n.l(locale, i18nAble.getI18nKey()); } - @Deprecated - public static <T extends Enum> Collection<Integer> toOrdinals(Collection<T> enums) { - List<Integer> ordinals = new LinkedList<>(); - for (Enum anEnum : enums) { - ordinals.add(anEnum.ordinal()); - } - return ordinals; - } - public static Date getEndOfMonth(Date month) { return DateUtils.addMilliseconds( DateUtils.addMonths(month, 1), -1); @@ -177,7 +131,7 @@ public class WaoUtils { return isEqualCollection; } - public static int collectionHashcode(Collection<?> a) { + public static int collectionHashCode(Collection<?> a) { return a == null ? 0 : a.size(); } -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 9b577c76bd4a91322c46fefd35d3ad2b48ae97cd Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Oct 14 17:19:56 2014 +0200 Utilisation du pseudo-élément CSS :first-child qui est exactement fait pour ça au lieu de polluer le HTML --- .../webapp/WEB-INF/content/obsmer/sampling-plan.jsp | 10 +++++----- .../WEB-INF/content/obsvente/sampling-plan.jsp | 8 ++++---- wao-web/src/main/webapp/wao.css | 21 +-------------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index d32e078..2f2df20 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -230,13 +230,13 @@ <table id="sampling-plan" class="large-table sampling-plan show-estimated"> <thead> <tr> - <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view firstline"> + <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view"> <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> - <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view firstline"> + <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view"> <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> - <th colspan="${nbColumnsForMonths}" class="firstline only-in-observations-view"> + <th colspan="${nbColumnsForMonths}" class="only-in-observations-view"> <s:text name="wao.ui.samplingPlan.effort" /> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> @@ -252,7 +252,7 @@ ] </s:if> </th> - <th colspan="${nbColumnsForMonths}" class="firstline only-in-days-view"> + <th colspan="${nbColumnsForMonths}" class="only-in-days-view"> <s:text name="wao.ui.samplingPlan.observationTimesInDays"/> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> [ @@ -267,7 +267,7 @@ ] </s:if> </th> - <th colspan="${nbColumnsForOther}" class="firstline"><s:text name="wao.ui.misc.others" /></th> + <th colspan="${nbColumnsForOther}"><s:text name="wao.ui.misc.others" /></th> </tr> <tr> <!-- Profession columns --> 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 84f6f6b..cd1417c 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 @@ -201,13 +201,13 @@ <table id="sampling-plan" class="large-table sampling-plan show-estimated"> <thead> <tr> - <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view firstline"> + <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view"> <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> - <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view firstline"> + <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view"> <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> - <th colspan="${nbColumnsForMonths}" class="firstline"> + <th colspan="${nbColumnsForMonths}"> <s:text name="wao.ui.samplingPlan.effort" /> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> @@ -223,7 +223,7 @@ ] </s:if> </th> - <th colspan="${nbColumnsForOther}" class="firstline"><s:text name="wao.ui.misc.others" /></th> + <th colspan="${nbColumnsForOther}"><s:text name="wao.ui.misc.others" /></th> </tr> <tr> <!-- Profession columns --> diff --git a/wao-web/src/main/webapp/wao.css b/wao-web/src/main/webapp/wao.css index f4768ed..52b3e19 100644 --- a/wao-web/src/main/webapp/wao.css +++ b/wao-web/src/main/webapp/wao.css @@ -347,32 +347,13 @@ h3 { text-align: center; } -.large-table thead th.firstline { +.large-table thead tr:first-child th { color: #b2f0b2; letter-spacing: 0.5px; text-transform: uppercase; background-color: #666; } -/* -.large-table th.date, -.large-table td.date { - max-width: 75px; -} - -.large-table th.date-time, -.large-table td.date-time { - max-width: 120px; -} -*/ - -/* Html à changer dans le tableau pour modifier l'affichage des dates - -<th class="effort now"> -<span class="mois">04</span><br> 2014 -</th> - -*/ .effort .month { font-size: 21px; letter-spacing: 1px; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm