[Suiviobsmer-commits] r699 - in trunk: wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/pages
Author: bleny Date: 2010-10-20 15:04:23 +0000 (Wed, 20 Oct 2010) New Revision: 699 Log: removing business code from UI Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java 2010-10-20 13:01:31 UTC (rev 698) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/GlobalSynthesisResultImpl.java 2010-10-20 15:04:23 UTC (rev 699) @@ -2,12 +2,17 @@ import fr.ifremer.wao.entity.Indicator; import fr.ifremer.wao.entity.IndicatorLevel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; import java.util.Map; public class GlobalSynthesisResultImpl extends GlobalSynthesisResult { + private static final Logger log = + LoggerFactory.getLogger(GlobalSynthesisResultImpl.class); + protected Map<SynthesisId, Double> values; protected List<Indicator> indicators; @@ -32,8 +37,15 @@ @Override public IndicatorLevel getLevelForIndicator(SynthesisId synthesisId) { + if (log.isDebugEnabled()) { + log.debug("looking for value of " + synthesisId); + for (Map.Entry<SynthesisId, Double> value : values.entrySet()) { + log.debug("in values : " + value.getKey() + " -> " + value.getValue()); + } + } + Double value = values.get(synthesisId); + Indicator indicator = findIndicator(synthesisId); - Double value = values.get(indicator); IndicatorLevel result = indicator.getLevelForValue(value); return result; } 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-20 13:01:31 UTC (rev 698) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-20 15:04:23 UTC (rev 699) @@ -735,8 +735,6 @@ (TopiaContext transaction, Company company, PeriodDates period) throws Exception { - GlobalSynthesisResultImpl result = new GlobalSynthesisResultImpl(); - Double value = 30.0; Map<SynthesisId, Double> indicatorValues = new HashMap<SynthesisId, Double>(); @@ -755,9 +753,10 @@ // add data reliability indicator here + List<Indicator> indicators = executeGetGlobalSynthesisParameters(transaction); + GlobalSynthesisResultImpl result = new GlobalSynthesisResultImpl(); result.setIndicatorValues(indicatorValues); - List<Indicator> indicators = executeGetGlobalSynthesisParameters(transaction); result.setIndicators(indicators); return result; } 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-20 13:01:31 UTC (rev 698) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-10-20 15:04:23 UTC (rev 699) @@ -24,6 +24,7 @@ package fr.ifremer.wao.ui.pages; +import fr.ifremer.wao.bean.GlobalSynthesisResult; import fr.ifremer.wao.bean.SynthesisId; import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoardingResult; @@ -143,6 +144,18 @@ return globalSynthesisParameters; } + private GlobalSynthesisResult globalSynthesisResult; + + public GlobalSynthesisResult getGlobalSynthesisResult() { + if (globalSynthesisResult == null) { + PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12); + Company company = !user.isAdmin() ? user.getCompany() : null; + globalSynthesisResult = serviceSynthesis.getGlobalSynthesisResult( + company, period); + } + return globalSynthesisResult; + } + /** update activeIndicator to the indicator corresponding to activeSynthesis. * @return the value of activeIndicator field, after modification */ @@ -154,6 +167,7 @@ } public IndicatorLevel getActiveIndicatorLevel() { + activeIndicatorLevel = getGlobalSynthesisResult().getLevelForIndicator(getActiveSynthesis()); return activeIndicatorLevel; } @@ -252,45 +266,6 @@ 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 - // computing level for indicator - int totalNumberOfRealized = 0; - int totalNumberOfPlanned = 0; - for (Map.Entry<Date, Integer> entry : res.get(1).entrySet()) { - // res.get(1) contains number of realized - // while res.get(0) contains planned - - Date date = entry.getKey(); - // both variables will contains planned and realized at the same date - 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); } @@ -362,18 +337,6 @@ if (boardingResult == null) { boardingResult = serviceSynthesis.getBoardingBoats( getCompanyForBoarding(), getFromDate()); - - // FIXME 20101015 bleny business code, should be moved in business - // computing level for indicator - int numberOfBoatWithOneBoarding = boardingResult.getData().get("1"); - int totalNumberOfBoarding = 0; - for (Integer numberOfBoarding : boardingResult.getData().values()) { - totalNumberOfBoarding += numberOfBoarding; - } - double rate = ((double) numberOfBoatWithOneBoarding / - (double) totalNumberOfBoarding) * 100.0; - activeIndicator = getActiveIndicator(); - activeIndicatorLevel = activeIndicator.getLevelForValue(rate); } return boardingResult; } @@ -419,19 +382,6 @@ Company company = !user.isAdmin() ? user.getCompany() : null; complianceBoarding = serviceSynthesis.getComplianceBoardingIndicator(company); - - // FIXME 20101015 bleny business code, should be moved in business - // computing level for indicator - double total = 0.0; - int numberOfCompanies = complianceBoarding.size(); - for (Double compliance : complianceBoarding.values()) { - total += compliance; - } - double indicatorValue = 100 * (total / numberOfCompanies); - - activeSynthesis = SynthesisId.IND_COMPLIANCE_BOARDING; - activeIndicator = getActiveIndicator(); - activeIndicatorLevel = activeIndicator.getLevelForValue(indicatorValue); } return complianceBoarding; @@ -535,19 +485,6 @@ allegroReactivity = serviceSynthesis.getContactDataInputDateReactivity(company, getPeriodForAllegroReactivity()); - - // FIXME 20101015 bleny business code, should be moved in business - // computing level for indicator - double sumAverages = 0.0; - for (ContactAverageReactivity reactivity : allegroReactivity) { - sumAverages += reactivity.getResult(); - } - - double numberOfCompanies = (double) allegroReactivity.size(); - double totalAverages = sumAverages / numberOfCompanies; - - activeIndicator = getActiveIndicator(); - activeIndicatorLevel = activeIndicator.getLevelForValue(totalAverages); } return allegroReactivity; }
participants (1)
-
bleny@users.labs.libre-entreprise.org