[Suiviobsmer-commits] r676 - in trunk: wao-business/src/main/java/fr/ifremer/wao/entity 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 wao-ui/src/main/webapp/css
Author: bleny Date: 2010-10-15 10:57:56 +0000 (Fri, 15 Oct 2010) New Revision: 676 Log: highlight current indicator level on graph-sampling, add missing methods in indicators to find level Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml trunk/wao-ui/src/main/webapp/Synthesis.tml trunk/wao-ui/src/main/webapp/css/common.css Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java 2010-10-14 15:20:20 UTC (rev 675) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorImpl.java 2010-10-15 10:57:56 UTC (rev 676) @@ -16,4 +16,15 @@ public void setSynthesisId(SynthesisId synthesisId) { setIndicatorId(synthesisId.ordinal()); } + + /** return the level that contains given value between it's two bound */ + @Override + public IndicatorLevel getLevelForValue(double value) { + for (IndicatorLevel level : getIndicatorLevel()) { + if (level.containsValue(value)) { + return level; + } + } + return null; + } } 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 15:20:20 UTC (rev 675) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/IndicatorLevelImpl.java 2010-10-15 10:57:56 UTC (rev 676) @@ -29,4 +29,27 @@ return getLowerBound() == getUpperBound(); } + /** if upperBound and lowerBound are equals, return true if value is equals + * if lowerBound and upperBound are different, return true if value is + * between bound. + * + * upperBound is always strict comparison, lowerBound non-strict comparison + */ + @Override + public boolean containsValue(double value) { + boolean containsValue; + if (lowerEqualsUpperBounds()) { + containsValue = value == getUpperBound(); + } else { + if (getLowerBound() < getUpperBound()) { + containsValue = value >= getLowerBound() + && value < getUpperBound(); + } else { + containsValue = value >= getUpperBound() + && value < getLowerBound(); + } + } + return containsValue; + } + } Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: 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 2010-10-14 15:20:20 UTC (rev 675) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java 2010-10-15 10:57:56 UTC (rev 676) @@ -24,10 +24,12 @@ @Inject private Logger log; - /* variable used in view */ @Parameter(required = true) private Indicator indicator; + @Parameter(required = false) + private IndicatorLevel highlightLevel; + /* variable used in view */ @Property private IndicatorLevel indicatorLevel; @@ -39,4 +41,12 @@ return indicator; } + public boolean highLightCurrentIndicatorLevel() { + if (log.isDebugEnabled()) { + log.debug("indicatorLevel = " + indicatorLevel); + log.debug("highlightLevel = " + highlightLevel); + } + return indicatorLevel.equals(highlightLevel); + } + } 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 15:20:20 UTC (rev 675) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-15 10:57:56 UTC (rev 676) @@ -35,6 +35,8 @@ import fr.ifremer.wao.bean.SamplingFilterImpl; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.Indicator; +import fr.ifremer.wao.entity.IndicatorLevel; import fr.ifremer.wao.service.ServiceSynthesis; import fr.ifremer.wao.ui.base.AbstractFilteredPage; import fr.ifremer.wao.ui.data.ChartUtils; @@ -65,6 +67,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedMap; /** @@ -76,8 +79,7 @@ */ @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; @@ -95,6 +97,12 @@ @Persist private SynthesisId activeSynthesis; + @Persist + private Indicator activeIndicator; + + @Persist + private IndicatorLevel activeIndicatorLevel; + @Inject private ComponentResources resources; @@ -106,16 +114,41 @@ initCompanyFilter(); } - public Block getActiveBlock() throws WaoException { + public SynthesisId getActiveSynthesis() { if (activeSynthesis == null) { // Initialize default synthesis by Data Sampling activeSynthesis = SynthesisId.GRAPH_SAMPLING; } - switch (activeSynthesis) { + return activeSynthesis; + } + + public Indicator getActiveIndicator() { + + SynthesisId activeSynthesis = getActiveSynthesis(); + // FIXME bleny 20101014 lazy call service and keep result ? + // what if values are updated ? + List<Indicator> globalSynthesisParameters = + serviceSynthesis.getGlobalSynthesisParameters(); + + for (Indicator indicator : globalSynthesisParameters) { + if (indicator.getSynthesisId() == activeSynthesis) { + return indicator; + } + } + + return null; + } + + public IndicatorLevel getActiveIndicatorLevel() { + return activeIndicatorLevel; + } + + public Block getActiveBlock() throws WaoException { + switch (getActiveSynthesis()) { case GRAPH_SAMPLING : initSamplingBlock(); break; case GRAPH_BOARDING : initBoardingBlock(); } - return resources.getBlock(activeSynthesis.getBlockId()); + return resources.getBlock(getActiveSynthesis().getBlockId()); } public String getActionSynthesisId() { @@ -205,6 +238,40 @@ getFilter().getEstimatedTides() ? "Estimé" : "Réalisé"; data.put(realText, res.get(1)); String title = manager.getDataSamplingTitle(getFilter()); + + + + // FIXME 20101015 bleny business code, should be moved in business + int totalNumberOfRealized = 0; + int totalNumberOfPlanned = 0; + for (Map.Entry<Date, Integer> entry : res.get(1).entrySet()) { + Date date = entry.getKey(); + int numberOfRealized = entry.getValue(); + int numberOfPlanned = res.get(0).get(date); + + totalNumberOfPlanned += numberOfPlanned; + totalNumberOfRealized += numberOfRealized; + + if (log.isDebugEnabled()) { + log.debug(String.format( + "number of planed %s (%s), number of realized %s (%s)", + numberOfPlanned, totalNumberOfPlanned, + numberOfRealized, totalNumberOfRealized)); + } + } + + double percentRealized = ((double) totalNumberOfRealized / + (double) totalNumberOfPlanned) * 100.0; + + if (log.isDebugEnabled()) { + log.debug(String.format("percent realized %f %%", percentRealized)); + } + + activeIndicatorLevel = getActiveIndicator().getLevelForValue(percentRealized); + if (log.isDebugEnabled()) { + log.debug("activeIndicatorLevel = " + activeIndicatorLevel.getLevel()); + } + return ChartUtils.createCategoryChart(title, "Nb marées", "Mois", getDataSamplingChartType(), data); } Modified: 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 2010-10-14 15:20:20 UTC (rev 675) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml 2010-10-15 10:57:56 UTC (rev 676) @@ -28,7 +28,12 @@ <tr> <th>Niveaux</th> <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel"> - <td>${indicatorLevel.level}</td> + <t:if test="highLightCurrentIndicatorLevel()"> + <td class="highlight">${indicatorLevel.level}</td> + <p:else> + <td>${indicatorLevel.level}</td> + </p:else> + </t:if> </t:loop> </tr> <tr> Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-14 15:20:20 UTC (rev 675) +++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-15 10:57:56 UTC (rev 676) @@ -143,6 +143,10 @@ <!--<t:zone t:id="dataSamplingZone" id="so-datasampling-chart" t:update="show">--> <t:chart t:width="600" t:height="400" t:chart="dataSamplingChart" /> <!--</t:zone>--> + + <!-- now render a table with position on global synthesis --> + <br /> + <t:indicatorLevels t:indicator="activeIndicator" highlightLevel="activeIndicatorLevel" /> </div> </t:block> <!-- GRAPH2 : BOARDING_BOAT --> Modified: trunk/wao-ui/src/main/webapp/css/common.css =================================================================== --- trunk/wao-ui/src/main/webapp/css/common.css 2010-10-14 15:20:20 UTC (rev 675) +++ trunk/wao-ui/src/main/webapp/css/common.css 2010-10-15 10:57:56 UTC (rev 676) @@ -393,4 +393,20 @@ table.indicator td { text-align: center; -} \ No newline at end of file +} + +table.indicator td.highlight { + border-width: 3px; +} + +table.indicator td.penalty { + background-color: #fee; +} + +table.indicator td.neutral { + background-color: #eee; +} + +table.indicator td.bonus { + background-color: #efe; +}
participants (1)
-
bleny@users.labs.libre-entreprise.org