[Suiviobsmer-commits] r712 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service 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-26 17:06:43 +0000 (Tue, 26 Oct 2010) New Revision: 712 Log: WIP : create form to update indicators and levels Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.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/Administration.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml trunk/wao-ui/src/main/webapp/Administration.tml trunk/wao-ui/src/main/webapp/Synthesis.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-10-26 12:52:54 UTC (rev 711) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-10-26 17:06:43 UTC (rev 712) @@ -841,6 +841,100 @@ return indicators; } + @Override + protected void executeUpdateGlobalSynthesisParameters(TopiaContext transaction, + Indicator indicator, WaoUser author, String comment) + throws Exception { + String logText = ""; + + boolean somethingChanged = false; + + // fist, find the indicator + Indicator oldIndicator = WaoDAOHelper.getIndicatorDAO(transaction) + .findAllByIndicatorId(indicator.getIndicatorId()) + .iterator().next(); + + // find what have been changed + boolean coefficientChanged = indicator.getCoefficient() + != oldIndicator.getCoefficient(); + if (coefficientChanged) { + somethingChanged = true; + + // 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()); + } + + // new compare old and new level bounds + for (IndicatorLevel level : oldIndicator.getIndicatorLevel()) { + IndicatorLevel newLevel = null; + + // set oldLevel + for (IndicatorLevel tempLevel : indicator.getIndicatorLevel()) { + log.debug(tempLevel.getLevel() + " ?= " + level.getLevel()); + if (tempLevel.getLevel() == level.getLevel()) { + newLevel = tempLevel; + } + } + + boolean upperBoundChanged = level.getUpperBound() + != newLevel.getUpperBound(); + if (upperBoundChanged) { + somethingChanged = true; + + 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, + indicator.getSynthesisId().getLabel(), + level.getUpperBound(), newLevel.getUpperBound()); + + level.setUpperBound(newLevel.getUpperBound()); + + WaoDAOHelper.getIndicatorLevelDAO(transaction).update(level); + } + + } + + if (somethingChanged) { + + // something has changed so we must store a log + + if (log.isDebugEnabled()) { + log.debug("modifications in global synthesis parameters :\n" + + logText); + } + + IndicatorLog indicatorLog = new IndicatorLogImpl(); + indicatorLog.setAuthor(author); + indicatorLog.setComment(comment); + + // add entity logText + WaoDAOHelper.getIndicatorLogDAO(transaction).create(indicatorLog); + indicatorLog.setLogText(logText.trim()); + + // 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 " + + "parameters at updating"); + } + } + protected PieChartData createContactPieChartData() { PieChartData data = new PieChartDataImpl(); for (ContactPieChartConstant constant : ContactPieChartConstant.values()) { 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-26 12:52:54 UTC (rev 711) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/IndicatorLevels.java 2010-10-26 17:06:43 UTC (rev 712) @@ -34,6 +34,9 @@ @Parameter(required = false) private Boolean withLegend; + @Parameter + private Boolean editable; + /* variable used in view */ @Property private IndicatorLevel indicatorLevel; @@ -52,6 +55,21 @@ return withLegend; } + public void setWithLegend(Boolean withLegend) { + this.withLegend = withLegend; + } + + public void setEditable(Boolean editable) { + this.editable = editable; + } + + public Boolean getEditable() { + if (editable == null) { + editable = false; + } + return editable; + } + public boolean highLightCurrentIndicatorLevel() { if (log.isDebugEnabled()) { log.debug("indicatorLevel = " + indicatorLevel); 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-26 12:52:54 UTC (rev 711) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-10-26 17:06:43 UTC (rev 712) @@ -64,6 +64,7 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.beaneditor.BeanModel; import org.apache.tapestry5.corelib.components.BeanEditForm; +import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.internal.OptionModelImpl; import org.apache.tapestry5.internal.SelectModelImpl; @@ -633,4 +634,22 @@ } return indicators; } + + + @InjectComponent + private Form synthesisParametersForm; + + @Log + void onSuccessFromSynthesisParametersForm() { + + // FIXME bleny 20101026 replace missing comment by something from a textarea + for (Indicator indicator : getIndicators()) { + serviceSynthesis.updateGlobalSynthesisParameters(indicator, + currentUser.getUser(), "missing comment"); + } + + + } + + } 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-26 12:52:54 UTC (rev 711) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/IndicatorLevels.tml 2010-10-26 17:06:43 UTC (rev 712) @@ -23,7 +23,6 @@ xmlns:p="tapestry:parameter"> <table class="indicatorLevels"> - <caption></caption> <tbody> <tr> <th /> @@ -32,7 +31,7 @@ </tr> <tr> <th>Niveaux</th> - <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel"> + <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel" volatile="true"> <t:if test="highLightCurrentIndicatorLevel()"> <td class="highlight selected">${indicatorLevel.level}</td> <p:else> @@ -46,7 +45,7 @@ </tr> <tr> <th>Bornes</th> - <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel"> + <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel" volatile="true"> <td> <t:if test="indicatorLevel.lowerEqualsUpperBounds()"> ${indicatorLevel.upperBound} @@ -62,12 +61,31 @@ </td> </t:loop> </tr> - <!-- t:if test="isWithLegend()"> --> - <caption> - En jaune, la position actuelle de la société selon cet indicateur. - </caption> - <!--/t:if--> + <t:if test="getEditable()"> + <tr> + <th>Modifications</th> + <t:loop t:source="indicator.indicatorLevel" t:value="indicatorLevel" volatile="true"> + <td> + <t:if test="indicatorLevel.lowerBoundPositiveInfinity"> + <input type="text" size="3" value="∞" disabled="disabled" /> + <p:else> + <!-- ${indicatorLevel.lowerBound}--> + <input type="text" size="3" value="${indicatorLevel.lowerBound}" disabled="disabled" /> + <!--input t:type="textfield" value="indicatorLevel.lowerBound" size="3" disabled="disabled" /--> + </p:else> + </t:if> + <input t:type="textfield" value="indicatorLevel.upperBound" size="3" /> + </td> + </t:loop> + <td> + <input t:type="textfield" value="indicator.coefficient" size="3" /> + </td> + </tr> + </t:if> </tbody> </table> + <t:if test="isWithLegend()"> + En jaune, la position actuelle de la société selon cet indicateur. + </t:if> </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-26 12:52:54 UTC (rev 711) +++ trunk/wao-ui/src/main/webapp/Administration.tml 2010-10-26 17:06:43 UTC (rev 712) @@ -172,18 +172,26 @@ <div class="mtop10" /> - <t:if t:test="currentUser.admin"> + <t:if t:test="currentUser.admin"> <!-- read only ????--> - <h2>Indicateurs qualités prestataires</h2> + <t:zone t:id="synthesisParametersFormZone" t:update="show"> + <h2>Indicateurs qualités prestataires</h2> - <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> + <form t:type="form" t:id="synthesisParametersForm" t:zone="synthesisParametersFormZone"> - <t:loop t:source="indicators" t:value="indicator"> - <t:indicatorLevels t:indicator="indicator" /> - </t:loop> + <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> + <t:loop t:source="indicators" t:value="indicator" volatile="true"> + <t:indicatorLevels t:indicator="indicator" editable="true" /> + </t:loop> - Total coefficients : ${totalCoefficient} + Total coefficients : ${totalCoefficient} + <div class="fright"> + <input t:type="submit" t:id="saveData" class="ico save" value="Save" title="Enregistrer les modifications" /> + <input t:type="submit" t:id="cancelSave" class="ico undo" value="Undo" title="Annuler les modifications" /> + </div> + </form> + </t:zone> </t:if> </t:layout> Modified: trunk/wao-ui/src/main/webapp/Synthesis.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-26 12:52:54 UTC (rev 711) +++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-10-26 17:06:43 UTC (rev 712) @@ -162,7 +162,7 @@ <!-- now render a table with position on global synthesis --> <br /> - <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" /> + <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" withLegend="true" /> </div> </t:block> <!-- GRAPH2 : BOARDING_BOAT --> @@ -182,7 +182,7 @@ <!-- now render a table with position on global synthesis --> <br /> - <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" /> + <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" withLegend="true" /> </div> </t:block> <!-- IND1 : COMPLIANCE_BOARDING --> @@ -228,7 +228,7 @@ <!-- now render a table with position on global synthesis --> <br /> - <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" /> + <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" withLegend="true" /> </div> </t:block> <!-- IND2 : CONTACT_STATE --> @@ -311,7 +311,7 @@ <!-- now render a table with position on global synthesis --> <br /> - <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" /> + <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" withLegend="true" /> </div> </t:block> <!-- IND5 : DATA_RELIABILITY --> @@ -349,7 +349,7 @@ <!-- now render a table with position on global synthesis --> <br /> - <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" /> + <t:indicatorLevels t:indicator="activeIndicator" t:highlightLevel="activeIndicatorLevel" withLegend="true" /> </div> </t:block> <!-- GLOBAL SYNTHESIS -->
participants (1)
-
bleny@users.labs.libre-entreprise.org