Author: bleny Date: 2011-04-26 08:45:24 +0000 (Tue, 26 Apr 2011) New Revision: 1236 Log: add observation hours synthesis Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SynthesisId.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java trunk/wao-business/src/test/resources/log4j.properties trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties trunk/wao-ui/src/main/webapp/Synthesis.tml Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SynthesisId.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SynthesisId.java 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SynthesisId.java 2011-04-26 08:45:24 UTC (rev 1236) @@ -52,8 +52,11 @@ IND_ALLEGRO_REACTIVITY(n_("SynthesisId.IND_ALLEGRO_REACTIVITY")), /** */ - IND_DATA_RELIABILITY(n_("SynthesisId.IND_DATA_RELIABILITY")); + IND_DATA_RELIABILITY(n_("SynthesisId.IND_DATA_RELIABILITY")), + /** ObsDeb, number of observations per hour of the day */ + OBSERVATION_HOUR(n_("SynthesisId.OBSERVATION_HOUR")); + /** An i18n key to make enumeration printable in logs and UI. */ protected String i18nKey; Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-04-26 08:45:24 UTC (rev 1236) @@ -1263,30 +1263,34 @@ Map<String, Map<String, Integer>> result = new TreeMap<String, Map<String, Integer>>(); for (Contact contact : contacts) { - String year = yearFormat.format(contact.getObservationBeginDate()); - String hour = hourFormat.format(contact.getObservationBeginDate()); + Date observationDate = contact.getObservationBeginDate(); - Map<String, Integer> yearToObservationCount = result.get(hour); - if (yearToObservationCount == null) { - yearToObservationCount = new TreeMap<String, Integer>(); - result.put(hour, yearToObservationCount); + if (observationDate != null) { + String year = yearFormat.format(observationDate); + String hour = hourFormat.format(observationDate); + + Map<String, Integer> hourToObservationCount = result.get(year); + if (hourToObservationCount == null) { + hourToObservationCount = new TreeMap<String, Integer>(); + result.put(year, hourToObservationCount); + } + Integer count = hourToObservationCount.get(hour); + if (count == null) { + count = 0; + } + count += 1; + hourToObservationCount.put(hour, count); } - Integer count = yearToObservationCount.get(year); - if (count == null) { - count = 0; - } - count += 1; - yearToObservationCount.put(year, count); } if (log.isDebugEnabled()) { log.debug("observation hours synthesis returns "); for (Map.Entry<String, Map<String, Integer>> entry : result.entrySet()) { - String hour = entry.getKey(); - for (Map.Entry<String, Integer> yearToObservationCount : entry.getValue().entrySet()) { - String year = yearToObservationCount.getKey(); - Integer count = yearToObservationCount.getValue(); - log.debug(hour + " " + year + " " + count); + String year = entry.getKey(); + for (Map.Entry<String, Integer> hourToObservationCount : entry.getValue().entrySet()) { + String hour = hourToObservationCount.getKey(); + Integer count = hourToObservationCount.getValue(); + log.debug(year + " " + hour + " " + count); } } } Modified: trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-04-26 08:45:24 UTC (rev 1236) @@ -36,6 +36,7 @@ SynthesisId.IND_COMPLIANCE_BOARDING=Number of observers conformance SynthesisId.IND_CONTACT_STATE=Contacts states SynthesisId.IND_DATA_RELIABILITY=Data reliability +SynthesisId.OBSERVATION_HOUR=Hours of observation in the day UserRole.ADMIN=Administrator UserRole.COORDINATOR=Coordinator UserRole.GUEST=Guest Modified: trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-04-26 08:45:24 UTC (rev 1236) @@ -36,6 +36,7 @@ SynthesisId.IND_COMPLIANCE_BOARDING=Respect du nombre d'observateurs embarqu\u00E9s SynthesisId.IND_CONTACT_STATE=\u00C9tats des contacts SynthesisId.IND_DATA_RELIABILITY=Qualit\u00E9 de la donn\u00E9e +SynthesisId.OBSERVATION_HOUR=Heures d'observation dans la journ\u00E9e UserRole.ADMIN=Administrateur UserRole.COORDINATOR=Coordinateur UserRole.GUEST=Invit\u00E9 Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-26 08:45:24 UTC (rev 1236) @@ -426,6 +426,7 @@ SamplingFilter samplingFilter = serviceSampling.newSamplingFilter(fixtures.joshAsCoordinator()); Map<String, Map<String, Integer>> observationHours = serviceSynthesis.getObservationHours(samplingFilter); - Assert.assertEquals(2, observationHours.get("09:00").get("2010").intValue()); + // TODO 20110426 bleny consider validation company and validation program when counting + Assert.assertEquals(2, observationHours.get("2010").get("09:00").intValue()); } } Modified: trunk/wao-business/src/test/resources/log4j.properties =================================================================== --- trunk/wao-business/src/test/resources/log4j.properties 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-business/src/test/resources/log4j.properties 2011-04-26 08:45:24 UTC (rev 1236) @@ -31,6 +31,6 @@ log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d %5p [%t] (%F:%L) %M - %m%n -log4j.logger.fr.ifremer.wao=INFO +log4j.logger.fr.ifremer.wao=DEBUG log4j.logger.org.nuiton.util=INFO log4j.logger.org.nuiton.util.beans.BinderProvider=ERROR Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2011-04-26 08:45:24 UTC (rev 1236) @@ -142,8 +142,12 @@ public SynthesisId getActiveSynthesis() { if (activeSynthesis == null) { - // Initialize default synthesis by Data Sampling - activeSynthesis = SynthesisId.GRAPH_SAMPLING; + // fix the synthesis to show according to role + if (user.isObsDeb()) { + activeSynthesis = SynthesisId.OBSERVATION_HOUR; + } else { + activeSynthesis = SynthesisId.GRAPH_SAMPLING; + } } return activeSynthesis; } @@ -501,6 +505,16 @@ return getDataReliability().get(user.getCompany()); } + /********************* INDICATOR : OBSERVATION HOUR ***********************/ + + public JFreeChart getObservationHoursChart() throws WaoException { + Map result = serviceSynthesis.getObservationHours(getFilter()); + String title = messages.get(n_("wao.ui.synthesis.observationHours.title")); + String axisName = messages.get(n_("wao.ui.synthesis.observationHours.axisName")); + String categoryName = messages.get(n_("wao.ui.synthesis.observationHours.categoryName")); + return ChartUtils.createCategoryChart(title, axisName, categoryName, ChartType.BAR, result); + } + /********************* GLOBAL SYNTHESIS ***********************************/ @Property Modified: trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties =================================================================== --- trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-ui/src/main/resources/i18n/wao-ui_en_GB.properties 2011-04-26 08:45:24 UTC (rev 1236) @@ -1,3 +1,10 @@ +SynthesisId.GRAPH_BOARDING= +SynthesisId.GRAPH_SAMPLING= +SynthesisId.IND_ALLEGRO_REACTIVITY= +SynthesisId.IND_COMPLIANCE_BOARDING= +SynthesisId.IND_CONTACT_STATE= +SynthesisId.IND_DATA_RELIABILITY= +SynthesisId.OBSERVATION_HOUR= wao.ui.action.acceptContact=Validate contact wao.ui.action.add=Add wao.ui.action.addNewContactFromBoat=Create a new contact for this boat and the selected sample row (in filters) @@ -290,6 +297,10 @@ wao.ui.synthesis.log.entry.date=Modification date wao.ui.synthesis.log.entry.summary=Modifications done wao.ui.synthesis.log.title=Global synthesis parameters historic +wao.ui.synthesis.observationHours.axisName=Number of observations +wao.ui.synthesis.observationHours.categoryName=Hours of the day +wao.ui.synthesis.observationHours.description=Number of observations according to the time of the day (based on the observation begin date) +wao.ui.synthesis.observationHours.title=Observation hours wao.ui.unavailableOperation=Unavailable operation wao.ui.userList=Users list wao.ui.validLogin=Valid identifier Modified: trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties =================================================================== --- trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-ui/src/main/resources/i18n/wao-ui_fr_FR.properties 2011-04-26 08:45:24 UTC (rev 1236) @@ -1,3 +1,10 @@ +SynthesisId.GRAPH_BOARDING= +SynthesisId.GRAPH_SAMPLING= +SynthesisId.IND_ALLEGRO_REACTIVITY= +SynthesisId.IND_COMPLIANCE_BOARDING= +SynthesisId.IND_CONTACT_STATE= +SynthesisId.IND_DATA_RELIABILITY= +SynthesisId.OBSERVATION_HOUR= wao.ui.action.acceptContact=Valider le contact wao.ui.action.add=Ajouter wao.ui.action.addNewContactFromBoat=Cr\u00E9er un nouveau contact pour ce navire et la ligne s\u00E9lectionn\u00E9e dans les filtres @@ -289,6 +296,10 @@ wao.ui.synthesis.log.entry.date=Date de la modification wao.ui.synthesis.log.entry.summary=Modifications effectu\u00E9es wao.ui.synthesis.log.title=Historique des modifications des param\u00E8tres de la synth\u00E8se globale +wao.ui.synthesis.observationHours.axisName=Nombre d'observations +wao.ui.synthesis.observationHours.categoryName=Heures de la journ\u00E9e +wao.ui.synthesis.observationHours.description=Nombre d'observations effectu\u00E9e selon l'heure d'arriv\u00E9e +wao.ui.synthesis.observationHours.title=Distribution des p\u00E9riodes d'observation wao.ui.unavailableOperation=Op\u00E9ration non-disponible wao.ui.userList=Liste des utilisateurs wao.ui.validLogin=Identifiant valide Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Synthesis.tml 2011-04-22 12:35:30 UTC (rev 1235) +++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2011-04-26 08:45:24 UTC (rev 1236) @@ -43,56 +43,58 @@ <div class="clearfix"> <div class="fleft" id="so-synthesis-menu"> <ul> - <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_SAMPLING']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-graph-sampling.png" alt="Graphique des données des marées (réalisé / planifié)" - title="Graphique des données des marées (réalisé / planifié)" /> - </a> - </li> - <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_BOARDING']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-graph-boarding.png" alt="Graphique des sollicitations des navires" - title="Graphique des sollicitations des navires" /> - </a> - </li> - <t:unless test="user.professional"> - <t:if test="showObsMer()"> - <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'IND_COMPLIANCE_BOARDING']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-ind-non-compliance-boarding.png" alt="Indicateur de non respect du nombre d'observateurs embarqués" - title="Indicateur de non respect du nombre d'observateurs embarqués" /> - </a> - </li> - </t:if> + <t:if test="user.obsDeb"> <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'IND_ALLEGRO_REACTIVITY']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-ind-allegro-reactivity.png" alt="Indicateur de réactivité sur la saisie des données dans Allegro" - title="Indicateur de réactivité sur la saisie des données dans Allegro" /> + <a t:type="actionlink" t:context="[actionSynthesisId,'OBSERVATION_HOUR']" t:zone="so-synthesis-main" title="${message:SynthesisId.OBSERVATION_HOUR}"> + <img src="${asset:context:}/img/synthesis-observation-hour.png" alt="${message:SynthesisId.OBSERVATION_HOUR}" /> </a> </li> - <t:if test="showObsMer()"> + <p:else> <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'IND_DATA_RELIABILITY']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-ind-data-reliability.png" alt="Indicateur de la qualité des données" - title="Indicateur de la qualité des données" /> + <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_SAMPLING']" t:zone="so-synthesis-main" title="${message:SynthesisId.GRAPH_SAMPLING}"> + <img src="${asset:context:}/img/synthesis-graph-sampling.png" alt="${message:SynthesisId.GRAPH_SAMPLING}" /> </a> </li> - </t:if> - <t:if test="user.indicatorsViewer"> <li> - <a t:type="actionlink" t:context="[actionShowGlobalSynthesis,'']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-global-synthesis.png" alt="Synthèse globale des indicateurs" - title="Synthèse globale des indicateurs" /> + <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_BOARDING']" t:zone="so-synthesis-main" title="${message:SynthesisId.GRAPH_BOARDING}"> + <img src="${asset:context:}/img/synthesis-graph-boarding.png" alt="${message:SynthesisId.GRAPH_BOARDING}" /> </a> </li> - </t:if> - <li> - <a t:type="actionlink" t:context="[actionSynthesisId,'IND_CONTACT_STATE']" t:zone="so-synthesis-main"> - <img src="${asset:context:}/img/synthesis-ind-contact-states.png" alt="Indicateur sur les états des contacts" - title="Indicateur sur les états des contacts" /> - </a> - </li> - </t:unless> + <t:unless test="user.professional"> + <t:if test="showObsMer()"> + <li> + <a t:type="actionlink" t:context="[actionSynthesisId,'IND_COMPLIANCE_BOARDING']" t:zone="so-synthesis-main" title="${message:SynthesisId.IND_COMPLIANCE_BOARDING}"> + <img src="${asset:context:}/img/synthesis-ind-non-compliance-boarding.png" alt="${message:SynthesisId.IND_COMPLIANCE_BOARDING}" /> + </a> + </li> + </t:if> + <li> + <a t:type="actionlink" t:context="[actionSynthesisId,'IND_ALLEGRO_REACTIVITY']" t:zone="so-synthesis-main" title="${message:SynthesisId.IND_ALLEGRO_REACTIVITY}"> + <img src="${asset:context:}/img/synthesis-ind-allegro-reactivity.png" alt="${message:SynthesisId.IND_ALLEGRO_REACTIVITY}" /> + </a> + </li> + <t:if test="showObsMer()"> + <li> + <a t:type="actionlink" t:context="[actionSynthesisId,'IND_DATA_RELIABILITY']" t:zone="so-synthesis-main" title="${message:SynthesisId.IND_DATA_RELIABILITY}"> + <img src="${asset:context:}/img/synthesis-ind-data-reliability.png" alt="${message:SynthesisId.IND_DATA_RELIABILITY}" /> + </a> + </li> + </t:if> + <t:if test="user.indicatorsViewer"> + <li> + <a t:type="actionlink" t:context="[actionShowGlobalSynthesis,'']" t:zone="so-synthesis-main" title="${message:wao.ui.synthesis.globalSynthesis.title}"> + <img src="${asset:context:}/img/synthesis-global-synthesis.png" alt="${message:wao.ui.synthesis.globalSynthesis.title}" /> + </a> + </li> + </t:if> + <li> + <a t:type="actionlink" t:context="[actionSynthesisId,'IND_CONTACT_STATE']" t:zone="so-synthesis-main" title="${message:SynthesisId.IND_CONTACT_STATE}"> + <img src="${asset:context:}/img/synthesis-ind-contact-states.png" alt="${message:SynthesisId.IND_CONTACT_STATE}" /> + </a> + </li> + </t:unless> + </p:else> + </t:if> </ul> </div> <div t:type="zone" t:id="delegator" class="fleft" t:update="show" id="so-synthesis-main"> @@ -356,4 +358,16 @@ </div> </t:if> </t:block> + <!-- IND6 : OBSERVATION HOUR --> + <t:block t:id="ind6"> + <div class="ind-table acenter" id="so-datareliability"> + <h2>${message:wao.ui.synthesis.observationHours.title}</h2> + <br /> + <p> + ${message:wao.ui.synthesis.observationHours.description} + </p> + + <t:chart t:width="600" t:height="400" t:chart="observationHoursChart" /> + </div> + </t:block> </t:layout>