[Suiviobsmer-commits] r1377 - in trunk/wao-ui/src/main: java/fr/ifremer/wao/ui/pages webapp
Author: bleny Date: 2011-07-18 14:15:21 +0000 (Mon, 18 Jul 2011) New Revision: 1377 Log: deal with having 0 instead of null values in sampling plan Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java trunk/wao-ui/src/main/webapp/SamplingPlan.tml Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2011-07-18 09:49:08 UTC (rev 1376) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2011-07-18 14:15:21 UTC (rev 1377) @@ -345,11 +345,14 @@ } public String getTotalPercentage() { - double result = 0; + String result; if (row.getTotalTidesExpected() > 0) { - result = (double)row.getTotalTidesReal() / (double)row.getTotalTidesExpected(); + double percentage = (double)row.getTotalTidesReal() / (double)row.getTotalTidesExpected(); + result = NumberFormat.getPercentInstance().format(percentage); + } else { + result = "- %"; } - return NumberFormat.getPercentInstance().format(result); + return result; } public NumberFormat getNumberFormat() { @@ -380,8 +383,7 @@ for (Date month : getMonths()) { this.month = month; - Integer totalExpected = 0, totalReal = 0; - + Integer totalExpected = null, totalReal = null; for (SampleRow row : getData()) { this.row = row; @@ -392,9 +394,15 @@ } if (expected != null) { + if (totalExpected == null) { + totalExpected = 0; + } totalExpected += expected; } if (real != null && canDisplayTidesReal()) { + if (totalReal == null) { + totalReal = 0; + } totalReal += real; } } @@ -407,8 +415,12 @@ getDateFormat().format(month), totalExpected, totalReal)); } - highTotalExpected += totalExpected; - highTotalReal += totalReal; + if (totalExpected != null) { + highTotalExpected += totalExpected; + } + if (totalReal != null) { + highTotalReal += totalReal; + } } @@ -443,8 +455,10 @@ } public String getRatioForMonth() { - String ratio = ""; - if (getTotalExpectedForMonth() > 0) { + String ratio = "-"; + if (getTotalExpectedForMonth() == null || getTotalRealForMonth() == null) { + // + } else if (getTotalExpectedForMonth() > 0 && getTotalRealForMonth() > 0) { double percent = ((double) getTotalRealForMonth() / getTotalExpectedForMonth()); ratio = NumberFormat.getPercentInstance().format(percent); } @@ -542,7 +556,9 @@ public String getRealTidesClassForTotal() { String result = "real-warning"; - if (getTotalRealForMonth() < getTotalExpectedForMonth()) { + if (getTotalRealForMonth() == null || getTotalExpectedForMonth() == null) { + // + } else if (getTotalRealForMonth() < getTotalExpectedForMonth()) { result += "-inf"; } else if (getTotalExpectedForMonth() > getTotalRealForMonth()) { result += "-sup"; Modified: trunk/wao-ui/src/main/webapp/SamplingPlan.tml =================================================================== --- trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2011-07-18 09:49:08 UTC (rev 1376) +++ trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2011-07-18 14:15:21 UTC (rev 1377) @@ -331,12 +331,10 @@ <!--/t:if--> </td> <td class="width50 acenter bright" style="border-top: solid 2px #000000;"> - <span t:type="ck/Tooltip" title="Infos" t:value="Total sur la période du mois ${dateFormat.format(month)}" t:effect="appear"> - ${highTotalExpected} - <t:unless t:test="user.guest"> - <em>(${highTotalReal})</em><br /><strong>${highTotalRatio}</strong> - </t:unless> - </span> + ${highTotalExpected} + <t:unless t:test="user.guest"> + <em>(${highTotalReal})</em><br /><strong>${highTotalRatio}</strong> + </t:unless> </td> <td colspan="${nbColumnsForOther}" style="border: solid 2px #000000;" /> </tr>
participants (1)
-
bleny@users.labs.libre-entreprise.org