[Suiviobsmer-commits] r735 - in trunk: 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/pages wao-ui/src/main/webapp
Author: bleny Date: 2010-11-03 18:42:33 +0000 (Wed, 03 Nov 2010) New Revision: 735 Log: update service synthesis to support modification of all global synthesis parameters Modified: 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/webapp/Administration.tml 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-11-03 16:51:31 UTC (rev 734) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-11-03 18:42:33 UTC (rev 735) @@ -895,64 +895,97 @@ } @Override - protected void executeUpdateGlobalSynthesisParameter(TopiaContext transaction, - Indicator indicator, WaoUser author, String comment) - throws Exception { - String logText = ""; + protected void executeUpdateGlobalSynthesisParameters(TopiaContext transaction, + GlobalSynthesisParameters parameters, WaoUser author, String comment) + throws Exception { + // will be true if something has changed and we need to add a log for that boolean somethingChanged = false; + String logText = ""; - // fist, find the indicator - Indicator oldIndicator = WaoDAOHelper.getIndicatorDAO(transaction) - .findByIndicatorId(indicator.getIndicatorId()); - // find what have been changed - boolean coefficientChanged = indicator.getCoefficient() - != oldIndicator.getCoefficient(); - if (coefficientChanged) { - somethingChanged = true; + List<Indicator> allIndicators = new ArrayList<Indicator>(); + allIndicators.addAll(parameters.getParameters()); + allIndicators.add(parameters.getGlobalIndicator()); + + for (Indicator indicator : allIndicators) { - // add something to log - // update database - logText += String.format( - "Modification du coefficient de l'indicateur « %s » " + - "(ancienne valeur = %s, nouvelle valeur = %s).\n\n", - indicator.getSynthesisId().getLabel(), - oldIndicator.getCoefficient(), - indicator.getCoefficient()); + boolean indicatorChanged = false; - oldIndicator.setCoefficient(indicator.getCoefficient()); - } + // fist, find the indicator + Indicator oldIndicator = WaoDAOHelper.getIndicatorDAO(transaction) + .findByIndicatorId(indicator.getIndicatorId()); - // new compare old and new level bounds - for (IndicatorLevel level : oldIndicator.getIndicatorLevel()) { - IndicatorLevel newLevel = null; + // now, find what has changed + boolean coefficientChanged = false; + if (oldIndicator.getCoefficient() != null) { + coefficientChanged = ! oldIndicator.getCoefficient(). + equals( indicator.getCoefficient()); + } - // set newLevel - for (IndicatorLevel tempLevel : indicator.getIndicatorLevel()) { - if (tempLevel.getLevel() == level.getLevel()) { - newLevel = tempLevel; - } + if (log.isDebugEnabled()) { + log.debug("old coefficient value = " + oldIndicator.getCoefficient() + + " new coefficient value = " + indicator.getCoefficient() + + " coefficientChanged = " + coefficientChanged); } + if (coefficientChanged) { + indicatorChanged = true; - boolean upperBoundChanged = level.getUpperBound() - != newLevel.getUpperBound(); - if (upperBoundChanged) { - somethingChanged = true; - + // add something to log + // update database logText += String.format( - "Modification du seuil de transition entre les niveaux " - + "%s et %s de l'indicateur « %s » (ancienne valeur = %s" - + ", nouvelle valeur = %s).\n\n", - level.getLevel(), level.getLevel() + 1, + "Modification du coefficient de l'indicateur « %s » " + + "(ancienne valeur = %s, nouvelle valeur = %s).\n\n", indicator.getSynthesisId().getLabel(), - level.getUpperBound(), newLevel.getUpperBound()); + oldIndicator.getCoefficient(), + indicator.getCoefficient()); - level.setUpperBound(newLevel.getUpperBound()); + oldIndicator.setCoefficient(indicator.getCoefficient()); + } - WaoDAOHelper.getIndicatorLevelDAO(transaction).update(level); + // new compare old and new level bounds + for (IndicatorLevel level : oldIndicator.getIndicatorLevel()) { + IndicatorLevel newLevel = null; + + // set newLevel + for (IndicatorLevel tempLevel : indicator.getIndicatorLevel()) { + if (tempLevel.getLevel() == level.getLevel()) { + newLevel = tempLevel; + } + } + + boolean upperBoundChanged = level.getUpperBound() + != newLevel.getUpperBound(); + if (upperBoundChanged) { + indicatorChanged = true; + + String changedIndicatorName; + if (indicator.getSynthesisId() == null) { + changedIndicatorName = "Bilan de la synthèse globale"; + } else { + changedIndicatorName = indicator.getSynthesisId().getLabel(); + } + + logText += String.format( + "Modification du seuil de transition entre les niveaux " + + "%s et %s de l'indicateur « %s » (ancienne valeur = %s" + + ", nouvelle valeur = %s).\n\n", + level.getLevel(), level.getLevel() + 1, + changedIndicatorName, + level.getUpperBound(), newLevel.getUpperBound()); + + level.setUpperBound(newLevel.getUpperBound()); + + WaoDAOHelper.getIndicatorLevelDAO(transaction).update(level); + } + } + if (indicatorChanged) { + // finally, update the indicator + WaoDAOHelper.getIndicatorDAO(transaction).update(oldIndicator); + somethingChanged = true; + } } if (somethingChanged) { @@ -972,15 +1005,6 @@ // add entity logText WaoDAOHelper.getIndicatorLogDAO(transaction).create(indicatorLog); - // attach the new indicator log to the concerned indicator - // Collection indicatorLogs = indicator.getIndicatorLog(); - Collection<IndicatorLog> indicatorLogs = oldIndicator.getIndicatorLog(); - indicatorLogs.add(indicatorLog); - oldIndicator.setIndicatorLog(indicatorLogs); - - // finally, update the indicator - WaoDAOHelper.getIndicatorDAO(transaction).update(oldIndicator); - transaction.commitTransaction(); } else { log.warn("no modification were found in global synthesis " + 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-11-03 16:51:31 UTC (rev 734) +++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-11-03 18:42:33 UTC (rev 735) @@ -90,7 +90,7 @@ wao.error.serviceSynthesis.getGlobalSynthesisParameters=Unable to get data about global synthesis parameters wao.error.serviceSynthesis.getGlobalSynthesisResult= wao.error.serviceSynthesis.getNonComplianceBoardingIndicator= -wao.error.serviceSynthesis.updateGlobalSynthesisParameter=Unable to update global synthesis parameters +wao.error.serviceSynthesis.updateGlobalSynthesisParameters=Unable to update global synthesis parameters wao.error.serviceUser.connect= wao.error.serviceUser.createDefaultAdmin= wao.error.serviceUser.createUpdateCompany= 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-11-03 16:51:31 UTC (rev 734) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-11-03 18:42:33 UTC (rev 735) @@ -89,7 +89,7 @@ wao.error.serviceSynthesis.getGlobalSynthesisParameters=Impossible de r\u00E9cup\u00E9rer les donn\u00E9es concernant les indicateurs pour la synth\u00E8se globale wao.error.serviceSynthesis.getGlobalSynthesisResult= wao.error.serviceSynthesis.getNonComplianceBoardingIndicator=Impossible de r\u00E9cup\u00E9rer l'indicateur de non respect du nombre d'observateurs embarqu\u00E9s -wao.error.serviceSynthesis.updateGlobalSynthesisParameter=Impossible de mettre \u00E0 jour les param\u00E8tres de la synth\u00E8se globale +wao.error.serviceSynthesis.updateGlobalSynthesisParameters=Impossible de mettre \u00E0 jour les param\u00E8tres de la synth\u00E8se globale 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 wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9 Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) 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-11-03 16:51:31 UTC (rev 734) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-11-03 18:42:33 UTC (rev 735) @@ -640,10 +640,9 @@ } void onSuccessFromSynthesisParametersForm() { - for (Indicator indicator : getGlobalSynthesisParameters().getParameters()) { - serviceSynthesis.updateGlobalSynthesisParameter - (indicator, currentUser.getUser(), comment); - } + serviceSynthesis.updateGlobalSynthesisParameters( + getGlobalSynthesisParameters(), currentUser.getUser(), comment); + getGlobalSynthesisParameters(); } /* variable used in loop */ Modified: trunk/wao-ui/src/main/webapp/Administration.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Administration.tml 2010-11-03 16:51:31 UTC (rev 734) +++ trunk/wao-ui/src/main/webapp/Administration.tml 2010-11-03 18:42:33 UTC (rev 735) @@ -182,7 +182,7 @@ <t:errors t:banner="message:errors-banner" /> <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> - <t:loop t:source="globalSynthesisParameters.parameters" t:value="indicator" volatile="true"> + <t:loop t:source="globalSynthesisParameters.parameters" t:value="indicator" t:volatile="true"> <t:indicatorLevels t:indicator="indicator" editable="true" /> </t:loop> @@ -195,7 +195,7 @@ <table class="indicatorLevels"> <tr> - <td t:type="loop" t:source="globalSynthesisParameters.globalIndicator.indicatorLevel" t:value="indicatorLevel"> + <td t:type="loop" t:source="globalSynthesisParameters.globalIndicator.indicatorLevel" t:value="indicatorLevel" t:volatile="true"> ${globalIndicatorValue.label} </td> </tr>
participants (1)
-
bleny@users.labs.libre-entreprise.org