r1766 - in trunk: wao-services/src/main/java/fr/ifremer/wao/services/service wao-web/src/main/webapp/WEB-INF/content/obsmer
Author: tchemit Date: 2014-03-27 13:39:43 +0100 (Thu, 27 Mar 2014) New Revision: 1766 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1766 Log: refs #4483 (done for me) Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-27 12:38:49 UTC (rev 1765) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-27 12:39:43 UTC (rev 1766) @@ -47,44 +47,37 @@ protected Collection<ObsMerSamplingPlanFacadePart> facades; /** - * Statistics of total tides over the plan by month. + * Total tides over the plan by month. */ - protected Map<Date, ObsMerSamplingPlanStatistics> statisticsMap; + protected Map<Date, ObsMerSamplingPlanStatistics> totalsPerMonth; /** + * High total over the hole plan. + */ + protected ObsMerSamplingPlanStatistics highTotals; + + /** * Total of observation times in days expected. - * FIXME Voir si on doit garder un *D*ouble + * + * <strong>Note:</strong> can be null. */ protected Double observationTimesInDaysTotalExpected; /** * Total of observation times in days real. - * FIXME Voir si on doit garder un *L*ong + * + * <strong>Note:</strong> can be null. */ protected Long observationTimesInDaysTotalReal; /** * Total of observation times in days estimated. - * FIXME Voir si on doit garder un *L*ong + * + * <strong>Note:</strong> can be null. */ protected Long observationTimesInDaysTotalEstimated; /** - * ? - */ - protected int highTotalExpected; - - /** - * ? - */ - protected int highTotalReal; - - /** - * ? - */ - protected int highTotalEstimated; - - /** * List of month used by sample rows. */ protected List<Date> months; @@ -93,22 +86,18 @@ public ObsMerSamplingPlan(List<Date> months, Collection<ObsMerSamplingPlanFacadePart> facadeParts, - Map<Date, ObsMerSamplingPlanStatistics> statisticsMap, - int highTotalExpected, - int highTotalReal, - int highTotalEstimated, + Map<Date, ObsMerSamplingPlanStatistics> totalsPerMonth, + ObsMerSamplingPlanStatistics highTotals, Double observationTimesInDaysTotalExpected, Long observationTimesInDaysTotalReal, Long observationTimesInDaysTotalEstimated, SampleRowsFilterValues filterValues) { this.months = months; this.facades = facadeParts; - this.statisticsMap = statisticsMap; + this.totalsPerMonth = totalsPerMonth; + this.highTotals = highTotals; this.observationTimesInDaysTotalExpected = observationTimesInDaysTotalExpected; this.observationTimesInDaysTotalReal = observationTimesInDaysTotalReal; - this.highTotalExpected = highTotalExpected; - this.highTotalReal = highTotalReal; - this.highTotalEstimated = highTotalEstimated; this.observationTimesInDaysTotalEstimated = observationTimesInDaysTotalEstimated; this.filterValues = filterValues; } @@ -134,46 +123,40 @@ return observationTimesInDaysTotalEstimated; } - public Integer getTotalExpectedForMonth(Date month) { - Integer result = statisticsMap.get(month).getNbTidesExpected(); + public Integer getTotalExpected(Date month) { + Integer result = totalsPerMonth.get(month).getNbTidesExpected(); return result; } - public Integer getTotalRealForMonth(Date month) { - Integer result = statisticsMap.get(month).getNbTidesReal(); + public Integer getTotalReal(Date month) { + Integer result = totalsPerMonth.get(month).getNbTidesReal(); return result; } - public Integer getTotalEstimatedForMonth(Date month) { - Integer result = statisticsMap.get(month).getNbTidesEstimated(); + public Integer getTotalEstimated(Date month) { + Integer result = totalsPerMonth.get(month).getNbTidesEstimated(); return result; } - //TODO Move this in UI? - public String getRatioForMonth(Date month) { - String result = statisticsMap.get(month).getRatioForMonth(); + public String getTotalRatio(Date month) { + String result = totalsPerMonth.get(month).getRatio("-"); return result; } public Integer getHighTotalExpected() { - return highTotalExpected; + return highTotals.getNbTidesExpected(); } public Integer getHighTotalReal() { - return highTotalReal; + return highTotals.getNbTidesReal(); } public Integer getHighTotalEstimated() { - return highTotalEstimated; + return highTotals.getNbTidesEstimated(); } - //TODO Move this in UI? public String getHighTotalRatio() { - String ratio = ""; - if (highTotalExpected > 0) { - double percent = ((double) highTotalReal / highTotalExpected); - ratio = NumberFormat.getPercentInstance().format(percent); - } + String ratio = highTotals.getRatio(""); return ratio; } @@ -261,38 +244,28 @@ protected Map<Date, ObsMerSamplingPlanStatistics> nbTidesPerMonth; /** - * Total of expected tides. + * Total of tides. */ - protected int totalTidesExpected; + protected ObsMerSamplingPlanStatistics totalTides; /** - * Total of real tides. - */ - protected int totalTidesReal; - - /** - * Total of estimated tides. - */ - protected int totalTidesEstimated; - - /** * Expected Times of observation days. * <p/> - * FIXME Voir si on doit garder un *D*ouble + * <strong>Note:</strong> can be null. */ protected Double observationTimesInDaysExpected; /** * Real times of observation in days. * <p/> - * FIXME Voir si on doit garder un *L*long + * <strong>Note:</strong> can be null. */ protected Long observationTimesInDaysReal; /** * Estimated times of observation in days. * <p/> - * FIXME Voir si on doit garder un *L*long + * <strong>Note:</strong> can be null. */ protected Long observationTimesInDaysEstimated; @@ -357,6 +330,9 @@ this.nbTidesPerMonth = nbTidesPerMonth; // compute total tides + int totalTidesExpected = 0; + int totalTidesEstimated = 0; + int totalTidesReal = 0; for (ObsMerSamplingPlanStatistics obsMerSamplingPlanStatistics : nbTidesPerMonth.values()) { Integer totalExpected = obsMerSamplingPlanStatistics.getNbTidesExpected(); if (totalExpected != null) { @@ -372,6 +348,8 @@ } } + totalTides = new ObsMerSamplingPlanStatistics(totalTidesExpected, totalTidesReal, totalTidesEstimated); + fishingZones = ""; for (FishingZone zone : sampleRow.getFishingZone()) { fishingZones += zone.getDistrictCode() + ", "; @@ -415,7 +393,7 @@ } } professionDescriptionWithoutDCF5 = sampleRow.getProfessionDescriptionWithoutDCF5(); - samplingStrategy = sampleRow.getSamplingStrategy().getI18nKey(); + samplingStrategy = "";//TODO sampleRow.getSamplingStrategy().getI18nKey(); sampleRowId = sampleRow.getTopiaId(); } @@ -512,15 +490,15 @@ } public int getTotalTidesExpected() { - return totalTidesExpected; + return totalTides.getNbTidesExpected(); } public int getTotalTidesReal() { - return totalTidesReal; + return totalTides.getNbTidesReal(); } public int getTotalTidesEstimated() { - return totalTidesEstimated; + return totalTides.getNbTidesEstimated(); } public String getProfessionDescriptionWithoutDCF5() { @@ -543,13 +521,7 @@ } public String getTotalPercentage() { - String result; - if (totalTidesExpected > 0) { - double percentage = (double) totalTidesReal / (double) totalTidesExpected; - result = NumberFormat.getPercentInstance().format(percentage); - } else { - result = "- %"; - } + String result = totalTides.getRatio("-"); return result; } @@ -621,9 +593,8 @@ return nbTidesEstimated; } - //FIXME Move this in ui ? - public String getRatioForMonth() { - String ratio = "-"; + public String getRatio(String defaultValue) { + String ratio = defaultValue; if (nbTidesExpected != null && nbTidesExpected > 0 && nbTidesReal != null && nbTidesReal > 0) { double percent = ((double) nbTidesReal / nbTidesExpected); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java 2014-03-27 12:38:49 UTC (rev 1765) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java 2014-03-27 12:39:43 UTC (rev 1766) @@ -218,12 +218,12 @@ statisticsMap.put(month, planStatistics); } + ObsMerSamplingPlan.ObsMerSamplingPlanStatistics highTotals = new ObsMerSamplingPlan.ObsMerSamplingPlanStatistics(highTotalExpected, highTotalReal, highTotalEstimated); + ObsMerSamplingPlan result = new ObsMerSamplingPlan(months, sortedFacades, statisticsMap, - highTotalExpected, - highTotalReal, - highTotalEstimated, + highTotals, observationTimesInDaysTotalExpected.toDouble(), observationTimesInDaysTotalReal.toLong(), observationTimesInDaysTotalEstimated.toLong(), Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-03-27 12:38:49 UTC (rev 1765) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-03-27 12:39:43 UTC (rev 1766) @@ -284,7 +284,7 @@ <td><s:property value="nbObservants" /></td> <td> <s:if test="appliedCoverageRate"> - <s:property value="appliedCoverageRate" /> % + <s:property value="appliedCoverageRate" />% </s:if> </td> <td><s:property value="comment" /></td> @@ -367,13 +367,13 @@ <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> <td<s:if test="@fr.ifremer.wao.WaoUtils@isCurrentMonth(#month)"> class="current-month"</s:if>> - <s:property value="samplingPlan.getTotalExpectedForMonth(#month)"/> + <s:property value="samplingPlan.getTotalExpected(#month)"/> <span class="display-tides-real"> <span> - <em>(<s:property value="samplingPlan.getTotalRealForMonth(#month)"/>)</em> + <em>(<s:property value="samplingPlan.getTotalReal(#month)"/>)</em> </span> <br/> - <s:property value="samplingPlan.getRatioForMonth(#month)"/> + <s:property value="samplingPlan.getTotalRatio(#month)"/> </span> </td> </s:iterator>
participants (1)
-
tchemit@users.forge.codelutin.com