Author: bleny Date: 2010-10-15 13:33:57 +0000 (Fri, 15 Oct 2010) New Revision: 677 Log: add second indicator position Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java trunk/wao-ui/src/main/webapp/Synthesis.tml 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-15 10:57:56 UTC (rev 676) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-15 13:33:57 UTC (rev 677) @@ -122,23 +122,39 @@ 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) { + /** in a list of indicators, find the one with given synthesisId. */ + protected Indicator findIndicator(SynthesisId id, + List<Indicator> indicators) { + for (Indicator indicator : indicators) { + if (indicator.getSynthesisId().equals(id)) { return indicator; } } - + log.warn("indicator not found : " + id); return null; } + private List<Indicator> globalSynthesisParameters; + + /** permit lazy call to serviceSynthesis to set globalSynthesisParameters field. */ + public List<Indicator> getGlobalSynthesisParameters() { + if (globalSynthesisParameters == null) { + globalSynthesisParameters = + serviceSynthesis.getGlobalSynthesisParameters(); + } + return globalSynthesisParameters; + } + + /** update activeIndicator to the indicator corresponding to activeSynthesis. + * @return the value of activeIndicator field, after modification + */ + public Indicator getActiveIndicator() { + SynthesisId activeSynthesis = getActiveSynthesis(); + List<Indicator> globalSynthesisParameters = getGlobalSynthesisParameters(); + activeIndicator = findIndicator(activeSynthesis, globalSynthesisParameters); + return activeIndicator; + } + public IndicatorLevel getActiveIndicatorLevel() { return activeIndicatorLevel; } @@ -368,7 +384,7 @@ companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding); } - /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/ + /********************* INDICATOR : NON COMPLIANCE BOARDING ****************/ private Map<String, Double> nonComplianceBoarding; @@ -383,13 +399,26 @@ * @return a Map with companies and there values for nonComplianceBoarding * @throws WaoException */ - public Map<String, Double> getNonComplianceBoarding() - throws WaoException { + public Map<String, Double> getNonComplianceBoarding() throws WaoException { if (nonComplianceBoarding == null) { Company company = !user.isAdmin() ? user.getCompany() : null; nonComplianceBoarding = serviceSynthesis.getNonComplianceBoardingIndicator(company); + + // FIXME 20101015 bleny business code, should be moved in business + double total = 0.0; + int numberOfCompanies = nonComplianceBoarding.size(); + for (Double compliance : nonComplianceBoarding.values()) { + total += compliance; + } + double indicatorValue = 100.0 - (total / numberOfCompanies); + + // XXX 20101015 bleny switching synthesisId while rendering. side-effects ? + activeSynthesis = SynthesisId.IND_COMPLIANCE_BOARDING; + activeIndicator = getActiveIndicator(); + activeIndicatorLevel = activeIndicator.getLevelForValue(indicatorValue); } + return nonComplianceBoarding; } @@ -404,7 +433,7 @@ return getNonComplianceBoarding().get(user.getCompany().getName()); } - /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/ + /********************* INDICATOR : CONTACT STATE ******************/ private Collection<ContactStateStatistics> contactStateStatistics; @@ -474,7 +503,7 @@ return (double)getNbContactStates() / (double)contactStateStats.getTotal(); } - /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/ + /********************* INDICATOR : ALLEGRO REACTIVITY ******************/ private Collection<ContactAverageReactivity> allegroReactivity; Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-15 10:57:56 UTC (rev 676) +++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-15 13:33:57 UTC (rev 677) @@ -213,6 +213,10 @@ </div> </p:else> </t:if> + + <!-- now render a table with position on global synthesis --> + <br /> + <t:indicatorLevels t:indicator="activeIndicator" highlightLevel="activeIndicatorLevel" /> </div> </t:block> <!-- IND2 : CONTACT_STATE -->