This is an automated email from the git hooks/post-receive script. New change to branch feature/6910-obsVente-effort in repository wao. See http://git.codelutin.com/wao.git from 74156fc Remaniement du calcul du nombre de sorties à la génération du plan new e3ec1bc refs #6910 refactoring The 1 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 e3ec1bc16457028060f2ca972147fa3ed3a1367c Author: dcosse <cosse@codelutin.com> Date: Fri Apr 10 11:34:49 2015 +0200 refs #6910 refactoring Summary of changes: .../wao/services/service/SynthesisService.java | 147 ++++++--------------- 1 file changed, 42 insertions(+), 105 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 feature/6910-obsVente-effort in repository wao. See http://git.codelutin.com/wao.git commit e3ec1bc16457028060f2ca972147fa3ed3a1367c Author: dcosse <cosse@codelutin.com> Date: Fri Apr 10 11:34:49 2015 +0200 refs #6910 refactoring --- .../wao/services/service/SynthesisService.java | 147 ++++++--------------- 1 file changed, 42 insertions(+), 105 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java index 4a3efc9..3460fb0 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java @@ -526,30 +526,14 @@ public class SynthesisService extends WaoServiceSupport { Range<Date> periodRange = Range.between(periodFromMonth, periodToMonth); // Calcul du programmé - SortedMap<Date, Integer> expectedEffortByPeriods = new TreeMap<>(); - for (SampleRow sampleRow : sampleRows) { - for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { - Date month = sampleMonth.getPeriodDate(); - Date period = truncateToTimePeriod(month); - Integer expected = MoreObjects.firstNonNull( - expectedEffortByPeriods.get(period), - 0); - expected += getExpected(sampleMonth); - expectedEffortByPeriods.put(period, expected); - } - } + SortedMap<Date, Integer> expectedEffortByPeriods = computePlannedContacts(); if (log.isDebugEnabled()) { log.debug("expected effort by periods is " + expectedEffortByPeriods); } // Calcul du réalisé - ListMultimap<Date, Integer> actualObservationsByPeriods = LinkedListMultimap.create(); - for (Contact contact : contacts) { - Preconditions.checkState(sampleRows.contains(contact.getSampleRow())); - Map<Date, Integer> actualPerPeriods = getActualPerPeriods(contact); - actualObservationsByPeriods.putAll(Multimaps.forMap(actualPerPeriods)); - } + ListMultimap<Date, Integer> actualObservationsByPeriods = computeEffectiveContacts(contacts); if (log.isDebugEnabled()) { log.debug("actual effort by periods is " + actualObservationsByPeriods); @@ -607,7 +591,33 @@ public class SynthesisService extends WaoServiceSupport { } - protected abstract Map<Date, Integer> getActualPerPeriods(Contact contact); + protected SortedMap<Date, Integer> computePlannedContacts() { + SortedMap<Date, Integer> expectedEffortByPeriods = new TreeMap<>(); + for (SampleRow sampleRow : sampleRows) { + for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { + Date month = sampleMonth.getPeriodDate(); + Date period = truncateToTimePeriod(month); + Integer expected = MoreObjects.firstNonNull( + expectedEffortByPeriods.get(period), + 0); + expected += getExpected(sampleMonth); + expectedEffortByPeriods.put(period, expected); + } + } + return expectedEffortByPeriods; + } + + protected ListMultimap<Date, Integer> computeEffectiveContacts(ImmutableSet<Contact> contacts) { + ListMultimap<Date, Integer> actualObservationsByPeriods = LinkedListMultimap.create(); + for (Contact contact : contacts) { + Preconditions.checkState(sampleRows.contains(contact.getSampleRow())); + Map<Date, Integer> actualPerPeriods = getContactActualPerPeriods(contact); + actualObservationsByPeriods.putAll(Multimaps.forMap(actualPerPeriods)); + } + return actualObservationsByPeriods; + } + + protected abstract Map<Date, Integer> getContactActualPerPeriods(Contact contact); protected abstract String getValueAxisLabel(); @@ -663,7 +673,7 @@ public class SynthesisService extends WaoServiceSupport { * Le réalisé est le nombre d'observation, on compte 1 observation pour 1 navire donc 1 pour chaque contact. */ @Override - protected Map<Date, Integer> getActualPerPeriods(Contact contact) { + protected Map<Date, Integer> getContactActualPerPeriods(Contact contact) { // on calcule les jours de mers pour chaque mois Map<Date, Integer> observationDaysByMonthsForObservation = WaoUtils.getObservationDaysByMonths( @@ -673,6 +683,7 @@ public class SynthesisService extends WaoServiceSupport { Date month = WaoUtils.getKeyWithHighestValue(observationDaysByMonthsForObservation); return ImmutableMap.of(month, 1); } + } /** @@ -714,7 +725,7 @@ public class SynthesisService extends WaoServiceSupport { * Le réalisé est le de jours de mers pour chaque mois. */ @Override - protected Map<Date, Integer> getActualPerPeriods(Contact contact) { + protected Map<Date, Integer> getContactActualPerPeriods(Contact contact) { Map<Date, Integer> observationDaysByMonthsForObservation = WaoUtils.getObservationDaysByMonths( contact.getObservationBeginDate(), @@ -758,37 +769,16 @@ public class SynthesisService extends WaoServiceSupport { } @Override - protected Map<Date, Integer> getActualPerPeriods(Contact contact) { + protected Map<Date, Integer> getContactActualPerPeriods(Contact contact) { return ImmutableMap.of(truncateToTimePeriod(contact.getObservationBeginDate()), 1); } + /* + * Le réalisé est le nombre de sortie, on compte 1 sortie pour un et unique couple début/fin d'observation + * + */ @Override - public JFreeChart getChart() { - // définition de la fenêtre - Date periodFromMonth = truncateToTimePeriod(periodFrom); - Date periodToMonth = truncateToTimePeriod(periodTo); - - Range<Date> periodRange = Range.between(periodFromMonth, periodToMonth); - - // Calcul du programmé - SortedMap<Date, Integer> expectedEffortByPeriods = new TreeMap<>(); - for (SampleRow sampleRow : sampleRows) { - for (SampleMonth sampleMonth : sampleRow.getSampleMonth()) { - Date month = sampleMonth.getPeriodDate(); - Date period = truncateToTimePeriod(month); - Integer expected = MoreObjects.firstNonNull( - expectedEffortByPeriods.get(period), - 0); - expected += getExpected(sampleMonth); - expectedEffortByPeriods.put(period, expected); - } - } - - if (log.isDebugEnabled()) { - log.debug("expected effort by periods is " + expectedEffortByPeriods); - } - - // Calcul du réalisé + protected ListMultimap<Date, Integer> computeEffectiveContacts(ImmutableSet<Contact> contacts) { ListMultimap<Date, Integer> actualObservationsByPeriods = LinkedListMultimap.create(); // Le réalisé est le nombre de sortie, on compte 1 sortie pour un et unique couple début/fin d'observation @@ -809,67 +799,13 @@ public class SynthesisService extends WaoServiceSupport { Pair<Date, Date> obs = Pair.of(obsBeginDate, obsEndDate); nbRealObservationsByTripForMonth.put(obsBeginDate, obsEndDate, obs); - Map<Date, Integer> actualPerPeriods = getActualPerPeriods(doneObservation); + Map<Date, Integer> actualPerPeriods = getContactActualPerPeriods(doneObservation); actualObservationsByPeriods.putAll(Multimaps.forMap(actualPerPeriods)); } } } - - if (log.isDebugEnabled()) { - log.debug("actual effort by periods is " + actualObservationsByPeriods); - } - - // Création du graphique - DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - - // pour la barre représentant le planifié - for (Map.Entry<Date, Integer> entry : expectedEffortByPeriods.entrySet()) { - Date period = entry.getKey(); - if (periodRange.contains(period)) { - Integer expected = entry.getValue(); - dataset.setValue(expected, I18n.l(locale, "wao.synthesis.planned"), formatPeriod(period)); - } - } - - // pour la barre représentant l'estimé ou le réel - String rowKey; - if (realVsEstimated) { - rowKey = I18n.l(locale, "wao.ui.samplingPlan.Actual"); - } else { - rowKey = I18n.l(locale, "wao.synthesis.estimated"); - } - for (Map.Entry<Date, Collection<Integer>> entry : actualObservationsByPeriods.asMap().entrySet()) { - Date period = entry.getKey(); - if (periodRange.contains(period)) { - Integer actual = WaoUtils.sum(entry.getValue()); - dataset.setValue(actual, rowKey, formatPeriod(period)); - } - } - - // Axises - CategoryAxis categoryAxis = new CategoryAxis(""); - - String valueAxisLabel = getValueAxisLabel(); - ValueAxis valueAxis = new NumberAxis(valueAxisLabel); - valueAxis.setUpperMargin(0.15); - - // Renderer for Category - AbstractCategoryItemRenderer renderer = new BarRenderer(); - // Show labels on each element - renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); - renderer.setBaseItemLabelsVisible(Boolean.TRUE); - - CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); - plot.setOrientation(PlotOrientation.VERTICAL); - plot.setAxisOffset(RectangleInsets.ZERO_INSETS); - - JFreeChart chart = new JFreeChart( - I18n.l(locale, SynthesisId.GRAPH_SAMPLING.getI18nKey()), - JFreeChart.DEFAULT_TITLE_FONT, plot, true); - - return chart; - + return actualObservationsByPeriods; } } @@ -911,11 +847,12 @@ public class SynthesisService extends WaoServiceSupport { * Le réalisé est le nombre d'individus échantilonnés sur le trimestre. */ @Override - protected Map<Date, Integer> getActualPerPeriods(Contact contact) { + protected Map<Date, Integer> getContactActualPerPeriods(Contact contact) { Date trimester = truncateToTimePeriod(contact.getObservationBeginDate()); Integer actual = contact.getSampleSize(); return ImmutableMap.of(trimester, actual); } + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm