Author: tchemit Date: 2014-03-25 15:26:47 +0100 (Tue, 25 Mar 2014) New Revision: 1746 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1746 Log: refs #4483 (add estimated, expected and real values) 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-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 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-25 14:18:40 UTC (rev 1745) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-25 14:26:47 UTC (rev 1746) @@ -49,18 +49,24 @@ protected Map<Date, ObsMerSamplingPlanStatistics> statisticsMap; /** - * Total of observation times in days planned. + * Total of observation times in days expected. * FIXME Voir si on doit garder un *D*ouble */ - protected Double observationTimesInDaysTotalPlanned; + protected Double observationTimesInDaysTotalExpected; /** - * Total of observation times in days actual. + * Total of observation times in days real. * FIXME Voir si on doit garder un *L*ong */ - protected Long observationTimesInDaysTotalActual; + protected Long observationTimesInDaysTotalReal; /** + * Total of observation times in days estimated. + * FIXME Voir si on doit garder un *L*ong + */ + protected Long observationTimesInDaysTotalEstimated; + + /** * ? * FIXME Voir si on doit garder un *I*integer */ @@ -73,6 +79,12 @@ protected Integer highTotalReal; /** + * ? + * FIXME Voir si on doit garder un *I*integer + */ + protected Integer highTotalEstimated; + + /** * List of month used by sample rows. */ protected List<Date> months; @@ -82,15 +94,19 @@ Map<Date, ObsMerSamplingPlanStatistics> statisticsMap, Integer highTotalExpected, Integer highTotalReal, - Double observationTimesInDaysTotalPlanned, - Long observationTimesInDaysTotalActual) { + Integer highTotalEstimated, + Double observationTimesInDaysTotalExpected, + Long observationTimesInDaysTotalReal, + Long observationTimesInDaysTotalEstimated) { this.months = months; this.facades = facadeParts; this.statisticsMap = statisticsMap; - this.observationTimesInDaysTotalPlanned = observationTimesInDaysTotalPlanned; - this.observationTimesInDaysTotalActual = observationTimesInDaysTotalActual; + this.observationTimesInDaysTotalExpected = observationTimesInDaysTotalExpected; + this.observationTimesInDaysTotalReal = observationTimesInDaysTotalReal; this.highTotalExpected = highTotalExpected; this.highTotalReal = highTotalReal; + this.highTotalEstimated = highTotalEstimated; + this.observationTimesInDaysTotalEstimated = observationTimesInDaysTotalEstimated; } //FIXME Remove this @@ -115,14 +131,18 @@ return months; } - public Double getObservationTimesInDaysTotalPlanned() { - return observationTimesInDaysTotalPlanned; + public Double getObservationTimesInDaysTotalExpected() { + return observationTimesInDaysTotalExpected; } - public Long getObservationTimesInDaysTotalActual() { - return observationTimesInDaysTotalActual; + public Long getObservationTimesInDaysTotalReal() { + return observationTimesInDaysTotalReal; } + public Long getObservationTimesInDaysTotalEstimated() { + return observationTimesInDaysTotalEstimated; + } + public Integer getTotalExpectedForMonth(Date month) { Integer result = statisticsMap.get(month).getTotalExpected(); return result; @@ -133,6 +153,12 @@ return result; } + public Integer getTotalEstimatedForMonth(Date month) { + Integer result = statisticsMap.get(month).getTotalEstimated(); + return result; + } + + //TODO Move this in UI? public String getRatioForMonth(Date month) { String result = statisticsMap.get(month).getRatioForMonth(); return result; @@ -146,6 +172,11 @@ return highTotalReal; } + public Integer getHighTotalEstimated() { + return highTotalEstimated; + } + + //TODO Move this in UI? public String getHighTotalRatio() { String ratio = ""; if (highTotalExpected > 0) { @@ -236,26 +267,35 @@ protected SampleRow sampleRow; /** - * Times of observation days planned. + * Expected Times of observation days. * <p/> * FIXME Voir si on doit garder un *D*ouble */ - protected Double observationTimesInDaysPlanned; + protected Double observationTimesInDaysExpected; /** - * Actual times of observation in days. + * Real times of observation in days. * <p/> - * FIXME Voir si on doit garder un *D*ouble + * FIXME Voir si on doit garder un *L*long */ - protected Long observationTimesInDaysActual; + protected Long observationTimesInDaysReal; + /** + * Estimated times of observation in days. + * <p/> + * FIXME Voir si on doit garder un *L*long + */ + protected Long observationTimesInDaysEstimated; + public ObsMerSamplingPlanSampleRowPart(SampleRow sampleRow, - Double observationTimesInDaysPlanned, - Long observationTimesInDaysActual) { + Double observationTimesInDaysExpected, + Long observationTimesInDaysReal, + Long observationTimesInDaysEstimated) { this.sampleRow = sampleRow; - this.observationTimesInDaysPlanned = observationTimesInDaysPlanned; - this.observationTimesInDaysActual = observationTimesInDaysActual; + this.observationTimesInDaysExpected = observationTimesInDaysExpected; + this.observationTimesInDaysReal = observationTimesInDaysReal; + this.observationTimesInDaysEstimated = observationTimesInDaysEstimated; } public SampleRow getSampleRow() { @@ -271,18 +311,24 @@ return result; } - public Integer getNbTidesReal(Date month, boolean estimatedTides) { + public Integer getNbTidesReal(Date month) { Integer result = null; SampleMonth sampleMonth = sampleRow.getSampleMonth(month); if (sampleMonth != null) { - // result = getFilter().getEstimatedTides() ? - result = estimatedTides ? - sampleMonth.getEstimatedTidesValue() : - sampleMonth.getRealTidesValue(); + result = sampleMonth.getRealTidesValue(); } return result; } + public Integer getNbTidesEstimated(Date month) { + Integer result = null; + SampleMonth sampleMonth = sampleRow.getSampleMonth(month); + if (sampleMonth != null) { + result = sampleMonth.getEstimatedTidesValue(); + } + return result; + } + //FIXME Move this in ui ? public String getTotalPercentage() { String result; @@ -295,20 +341,30 @@ return result; } - public Double getObservationTimesInDaysPlanned() { - return observationTimesInDaysPlanned; + public Double getObservationTimesInDaysExpected() { + return observationTimesInDaysExpected; } - public Long getObservationTimesInDaysActual() { - return observationTimesInDaysActual; + public Long getObservationTimesInDaysReal() { + return observationTimesInDaysReal; } - public boolean hasNbTidesReal(Date month, boolean estimatedTides) { + public Long getObservationTimesInDaysEstimated() { + return observationTimesInDaysEstimated; + } + + public boolean hasNbTidesReal(Date month) { Date current = new Date(); boolean validMonth = month.before(current) || isCurrentMonth(month); - return validMonth && getNbTidesReal(month, estimatedTides) != null; + return validMonth && getNbTidesReal(month) != null; } + public boolean hasNbTidesEstimated(Date month) { + Date current = new Date(); + boolean validMonth = month.before(current) || isCurrentMonth(month); + return validMonth && getNbTidesEstimated(month) != null; + } + public boolean isCurrentMonth(Date month) { String currentStr = dateFormat.format(new Date()); String monthStr = dateFormat.format(month); @@ -334,9 +390,19 @@ */ protected Integer totalReal; - public ObsMerSamplingPlanStatistics(Integer totalExpected, Integer totalReal) { + /** + * Total of estimated tides. + * <p/> + * FIXME Voir si on doit garder un *I*nteger + */ + protected Integer totalEstimated; + + public ObsMerSamplingPlanStatistics(Integer totalExpected, + Integer totalReal, + Integer totalEstimated) { this.totalExpected = totalExpected; this.totalReal = totalReal; + this.totalEstimated = totalEstimated; } public Integer getTotalExpected() { @@ -347,6 +413,10 @@ return totalReal; } + public Integer getTotalEstimated() { + return totalEstimated; + } + //FIXME Move this in ui ? public String getRatioForMonth() { String ratio = "-"; 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-25 14:18:40 UTC (rev 1745) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java 2014-03-25 14:26:47 UTC (rev 1746) @@ -76,18 +76,32 @@ protected MutableInt highTotalReal; /** - * To compute the total of planned observation times in days. + * To compute the high total estimated. * - * @see ObsMerSamplingPlan#observationTimesInDaysTotalPlanned + * @see ObsMerSamplingPlan#highTotalEstimated */ - protected MutableDouble observationTimesInDaysTotalPlanned; + protected MutableInt highTotalEstimated; /** + * 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#observationTimesInDaysTotalActual + * @see ObsMerSamplingPlan#observationTimesInDaysTotalReal */ - protected MutableLong observationTimesInDaysTotalActual; + protected MutableLong observationTimesInDaysTotalReal; /** * To compute by month the total of expected tides. @@ -97,6 +111,13 @@ protected Map<Date, MutableInt> totalExpectedForMonths; /** + * To compute by month the total of expected tides. + * + * @see ObsMerSamplingPlan.ObsMerSamplingPlanStatistics#totalEstimated + */ + protected Map<Date, MutableInt> totalEstimatedForMonths; + + /** * To compute by month the total of real tides. * * @see ObsMerSamplingPlan.ObsMerSamplingPlanStatistics#totalReal @@ -108,10 +129,13 @@ this.facadeMap = new LinkedHashMap<>(); this.highTotalExpected = new MutableInt(); this.highTotalReal = new MutableInt(); - this.observationTimesInDaysTotalPlanned = new MutableDouble(); - this.observationTimesInDaysTotalActual = new MutableLong(); + this.highTotalEstimated = new MutableInt(); + 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()); @@ -119,8 +143,9 @@ } public ObsMerSamplingPlanBuilder addSampleRow(SampleRow sampleRow, - Double observationTimesInDaysPlanned, - Long observationTimesInDaysActual) { + Double observationTimesInDaysExpected, + Long observationTimesInDaysReal, + Long observationTimesInDaysEstimated) { String facade = sampleRow.getFacade(); FacadeContext facadeContext = facadeMap.get(facade); @@ -140,15 +165,17 @@ // add sample row ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart sampleRowPart = sectorPart.addSampleRow(sampleRow, - observationTimesInDaysPlanned, - observationTimesInDaysActual); + observationTimesInDaysExpected, + observationTimesInDaysReal, + observationTimesInDaysEstimated); // update totals updateTotals(sampleRowPart); // Sum total observation times in days - observationTimesInDaysTotalPlanned.add(observationTimesInDaysPlanned); - observationTimesInDaysTotalActual.add(observationTimesInDaysActual); + observationTimesInDaysTotalExpected.add(observationTimesInDaysExpected); + observationTimesInDaysTotalReal.add(observationTimesInDaysReal); + observationTimesInDaysTotalEstimated.add(observationTimesInDaysEstimated); return this; } @@ -166,9 +193,11 @@ MutableInt totalExpected = totalExpectedForMonths.get(month); MutableInt totalReal = totalRealForMonths.get(month); + MutableInt totalEstimated= totalEstimatedForMonths.get(month); ObsMerSamplingPlan.ObsMerSamplingPlanStatistics planStatistics = new ObsMerSamplingPlan.ObsMerSamplingPlanStatistics(totalExpected == null ? null : totalExpected.toInteger(), - totalReal == null ? null : totalReal.toInteger()); + totalReal == null ? null : totalReal.toInteger(), + totalEstimated == null ? null : totalEstimated.toInteger()); statisticsMap.put(month, planStatistics); } @@ -177,8 +206,10 @@ statisticsMap, highTotalExpected.toInteger(), highTotalReal.toInteger(), - observationTimesInDaysTotalPlanned.toDouble(), - observationTimesInDaysTotalActual.toLong()); + highTotalEstimated.toInteger(), + observationTimesInDaysTotalExpected.toDouble(), + observationTimesInDaysTotalReal.toLong(), + observationTimesInDaysTotalEstimated.toLong()); return result; } @@ -186,27 +217,39 @@ for (Date month : months) { Integer expected = sampleRowPart.getNbTidesExpected(month); - Integer real = sampleRowPart.getNbTidesReal(month, sampleRowsFilter.isEstimatedTides()); + Integer real = sampleRowPart.getNbTidesReal(month); + Integer estimated = sampleRowPart.getNbTidesEstimated(month); if (expected != null) { - MutableInt totalExpected = totalExpectedForMonths.get(month); - if (totalExpected == null) { - totalExpected = new MutableInt(); - totalExpectedForMonths.put(month, totalExpected); + MutableInt total = totalExpectedForMonths.get(month); + if (total == null) { + total = new MutableInt(); + totalExpectedForMonths.put(month, total); } - totalExpected.add(expected); - highTotalExpected.add(totalExpected); + total.add(expected); + highTotalExpected.add(total); } + if (estimated != null) { + + MutableInt total = totalEstimatedForMonths.get(month); + if (total == null) { + total = new MutableInt(); + totalEstimatedForMonths.put(month, total); + } + total.add(expected); + highTotalEstimated.add(total); + } + if (real != null) { - MutableInt totalReal = totalRealForMonths.get(month); - if (totalReal == null) { - totalReal = new MutableInt(); - totalRealForMonths.put(month, totalReal); + MutableInt total = totalRealForMonths.get(month); + if (total == null) { + total = new MutableInt(); + totalRealForMonths.put(month, total); } - totalReal.add(real); - highTotalReal.add(totalReal); + total.add(real); + highTotalReal.add(total); } } } @@ -258,13 +301,15 @@ } protected ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart addSampleRow(SampleRow row, - Double observationTimesInDaysPlanned, - Long observationTimesInDaysActual) { + Double observationTimesInDaysExpected, + Long observationTimesInDaysReal, + Long observationTimesInDaysEstimated) { ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart rowPart = new ObsMerSamplingPlan.ObsMerSamplingPlanSampleRowPart(row, - observationTimesInDaysPlanned, - observationTimesInDaysActual); + observationTimesInDaysExpected, + observationTimesInDaysReal, + observationTimesInDaysEstimated); rows.add(rowPart); return rowPart; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-03-25 14:18:40 UTC (rev 1745) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-03-25 14:26:47 UTC (rev 1746) @@ -374,11 +374,13 @@ ObsMerSamplingPlanBuilder builder = new ObsMerSamplingPlanBuilder(sampleRowsFilter); for (SampleRow sampleRow : sampleRows) { //TODO Compute see ServiceSamplingImpl#executeGetObservationTimesInDays - Double observationTimesInDaysPlanned = 0d; - Long observationTimesInDaysActual = 0l; + Double observationTimesInDaysExpected = 0d; + Long observationTimesInDaysReal = 0l; + Long observationTimesInDaysEstimated = 0l; builder.addSampleRow(sampleRow, - observationTimesInDaysPlanned, - observationTimesInDaysActual); + observationTimesInDaysExpected, + observationTimesInDaysReal, + observationTimesInDaysEstimated); } ObsMerSamplingPlan result = builder.toPlan();