[Suiviobsmer-commits] r675 - in trunk: wao-business/src/main/java/fr/ifremer/wao/entity wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-ui/src/main/java/fr/ifremer/wao/ui/components wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/resources/fr/ifremer/wao/ui/components wao-ui/src/main/webapp
Author: bleny Date: 2010-10-14 15:20:20 +0000 (Thu, 14 Oct 2010) New Revision: 675 Log: creation d'un component pour les indicateurs, doc Added: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.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/main/xmi/wao.zargo trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java trunk/wao-ui/src/main/webapp/Administration.tml Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java 2010-10-14 15:20:20 UTC (rev 675) @@ -24,4 +24,9 @@ lowerBound = Double.MAX_VALUE; } + @Override + public boolean lowerEqualsUpperBounds() { + return getLowerBound() == getUpperBound(); + } + } 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 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-14 15:20:20 UTC (rev 675) @@ -639,9 +639,10 @@ IndicatorDAO indicatorDAO = WaoDAOHelper.getIndicatorDAO(transaction); List<Indicator> indicators = indicatorDAO.findAll(); - // now, setting the lowerBound for (Indicator indicator : indicators) { + + // reading the indicators to set missing lowerBound (not stored in DB) Collection<IndicatorLevel> levels = indicator.getIndicatorLevel(); double lowerBound; @@ -659,12 +660,17 @@ lowerBound = level.getUpperBound(); } + // Finally, adding a last level IndicatorLevel lastIndicatorLevel = new IndicatorLevelImpl(); int nextLevelNumber = levels.size() + 1; lastIndicatorLevel.setLevel(nextLevelNumber); lastIndicatorLevel.setLowerBound(lowerBound); lastIndicatorLevel.setUpperBound(lastUpperBound); indicator.getIndicatorLevel().add(lastIndicatorLevel); + + // we don't store nor commit anything, those modification are only + // for those entities to be used conveniently in service and UI + // but database should not be affected } return indicators; 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 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-10-14 15:20:20 UTC (rev 675) @@ -68,6 +68,7 @@ wao.error.serviceSynthesis.getContactPieChartDataByBoatDistrict= wao.error.serviceSynthesis.getContactStateStatistics= wao.error.serviceSynthesis.getDataSampling= +wao.error.serviceSynthesis.getGlobalSynthesisParameters=Unable to get data about global synthesis parameters wao.error.serviceSynthesis.getNonComplianceBoardingIndicator= wao.error.serviceUser.connect= wao.error.serviceUser.createDefaultAdmin= 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 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-10-14 15:20:20 UTC (rev 675) @@ -67,6 +67,7 @@ wao.error.serviceSynthesis.getContactPieChartDataByBoatDistrict= wao.error.serviceSynthesis.getContactStateStatistics=Impossible de r\u00E9cup\u00E9rer les statistiques sur les \u00E9tats des contacts wao.error.serviceSynthesis.getDataSampling=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es pour le graphique dynamique des efforts de mar\u00E9es +wao.error.serviceSynthesis.getGlobalSynthesisParameters=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es concernant les indicateurs pour la synth\u00E8se globale wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=Impossible de r\u00E9cup\u00E9rer l'indicateur de non respect du nombre d'observateurs embarqu\u00E9s wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion wao.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Added: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java (rev 0) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java 2010-10-14 15:20:20 UTC (rev 675) @@ -0,0 +1,42 @@ +package fr.ifremer.wao.ui.components; + +import fr.ifremer.wao.entity.Indicator; +import fr.ifremer.wao.entity.IndicatorLevel; +import fr.ifremer.wao.service.ServiceSynthesis; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.slf4j.Logger; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Render a table with levels as columns and two lines : level number and + * lower + upper bound values. The table has a header with indicator name + * and coefficient + * + * @author bleny + */ +public class IndicatorLevels { + + @Inject + private Logger log; + + /* variable used in view */ + @Parameter(required = true) + private Indicator indicator; + + /* variable used in view */ + @Property + private IndicatorLevel indicatorLevel; + + /* variable used in view */ + private List<IndicatorLevel> indicatorLevels; + + public Indicator getIndicator() { + return indicator; + } + +} Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-10-14 15:20:20 UTC (rev 675) @@ -614,35 +614,10 @@ /* variable used in view */ private List<Indicator> indicators; - /* variable used in view */ - @Property - private IndicatorLevel indicatorLevel; - - /* variable used in view */ - private List<IndicatorLevel> indicatorLevels; - - /* variable used in view */ - private boolean lowerUpperBoundAreEquals; - public List<Indicator> getIndicators() { - List<Indicator> indicators = serviceSynthesis.getGlobalSynthesisParameters(); + if (indicators == null) { + indicators = serviceSynthesis.getGlobalSynthesisParameters(); + } return indicators; } - - public List<IndicatorLevel> getIndicatorLevels() { - Collection<IndicatorLevel> indicatorLevels = indicator.getIndicatorLevel(); - List<IndicatorLevel> result = new ArrayList<IndicatorLevel>(indicatorLevels); - - if (log.isDebugEnabled()) { - log.debug(String.format("levels for indicator %s are %s", - indicator, indicatorLevels)); - } - - return result; - } - - public boolean getLowerUpperBoundAreEquals() { - return indicatorLevel.getLowerBound() == indicatorLevel.getUpperBound(); - } - } 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 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-14 15:20:20 UTC (rev 675) @@ -76,7 +76,8 @@ */ @RequiresAuthentication({UserRole.ADMIN, UserRole.COORDINATOR, UserRole.OBSERVER}) @IncludeStylesheet("context:css/synthesis.css") -public class Synthesis extends AbstractFilteredPage { +public class + Synthesis extends AbstractFilteredPage { @Inject private WaoManager manager; Added: trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml =================================================================== --- trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml (rev 0) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml 2010-10-14 15:20:20 UTC (rev 675) @@ -0,0 +1,55 @@ +<!-- + #%L + Wao :: Web Interface + %% + Copyright (C) 2009 - 2010 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" + xmlns:p="tapestry:parameter"> + + <table class="indicator"> + <caption>Indicateur : ${indicator.synthesisId} (coefficient = ${indicator.coefficient})</caption> + <tbody> + <tr> + <th>Niveaux</th> + <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel"> + <td>${indicatorLevel.level}</td> + </t:loop> + </tr> + <tr> + <th>Bornes</th> + <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel"> + <td> + <t:if test="indicatorLevel.lowerEqualsUpperBounds()"> + ${indicatorLevel.upperBound} + <p:else> + <t:if test="indicatorLevel.lowerBoundPositiveInfinity"> + ${indicatorLevel.upperBound} et plus + <p:else> + ${indicatorLevel.lowerBound} à ${indicatorLevel.upperBound} + </p:else> + </t:if> + </p:else> + </t:if> + </td> + </t:loop> + </tr> + </tbody> + </table> + +</html> \ No newline at end of file Modified: trunk/wao-ui/src/main/webapp/Administration.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Administration.tml 2010-10-14 10:51:37 UTC (rev 674) +++ trunk/wao-ui/src/main/webapp/Administration.tml 2010-10-14 15:20:20 UTC (rev 675) @@ -179,35 +179,7 @@ <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> <t:loop t:source="indicators" t:value="indicator"> - <table class="indicator"> - <caption>Indicateur : ${indicator.synthesisId} (coefficient = ${indicator.coefficient})</caption> - <tbody> - <tr> - <th>Niveaux</th> - <t:loop t:source="indicatorLevels" t:value="indicatorLevel"> - <td>${indicatorLevel.level}</td> - </t:loop> - </tr> - <tr> - <th>Bornes</th> - <t:loop t:source="indicatorLevels" t:value="indicatorLevel"> - <td> - <t:if test="lowerUpperBoundAreEquals"> - ${indicatorLevel.upperBound} - <p:else> - <t:if test="indicatorLevel.lowerBoundPositiveInfinity"> - ${indicatorLevel.upperBound} et plus - <p:else> - ${indicatorLevel.lowerBound} à ${indicatorLevel.upperBound} - </p:else> - </t:if> - </p:else> - </t:if> - </td> - </t:loop> - </tr> - </tbody> - </table> + <t:indicatorLevels t:indicator="indicator" /> </t:loop> <!-- FORM TO MODIFY INDICATOR -->
participants (1)
-
bleny@users.labs.libre-entreprise.org