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>.