Skip to content

Commit

Permalink
#128: The static list of property "statutProjetDemat" in class Demarc…
Browse files Browse the repository at this point in the history
…hes does not match the actual data values

(cherry picked from commit 9f94ef3)
  • Loading branch information
slauriere authored and lucaa committed Jul 2, 2018
1 parent 78ab9fc commit f7d4527
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<defaultLanguage/>
<translation>0</translation>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1527081469000</creationDate>
<creationDate>1526657567000</creationDate>
<parent>Demarches.WebHome</parent>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1530031095000</date>
<contentUpdateDate>1527081469000</contentUpdateDate>
<date>1530262416000</date>
<contentUpdateDate>1526657567000</contentUpdateDate>
<version>1.1</version>
<title>Demarches Class</title>
<comment/>
Expand Down Expand Up @@ -636,7 +636,7 @@
<unmodifiable>0</unmodifiable>
<validationMessage/>
<validationRegExp/>
<values>prevu=Prévu|encours=En cours|termine=Terminé</values>
<values>aucun=Aucun|prévu=Prévu|en cours=En cours|terminé=Terminé</values>
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
</statutProjetDemat>
<textes>
Expand Down
83 changes: 83 additions & 0 deletions wikis/wikidemat/src/main/resources/Demarches/Code/Scripts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.1" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc version="1.3" reference="Demarches.Code.Scripts" locale="">
<web>Demarches.Code</web>
<name>Scripts</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1530262804000</creationDate>
<parent>wikidemat:Demarches.Code.WebHome</parent>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1530265472000</date>
<contentUpdateDate>1530265472000</contentUpdateDate>
<version>1.1</version>
<title>Scripts</title>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}

#macro(listDemarchesByProperty $property)
== Demarches grouped by $property

#set ($xwql = "select distinct demarche.$property from Document doc, doc.object(Demarches.Code.DemarchesClass) as demarche order by demarche.$property")
#set ($results = $services.query.xwql($xwql).execute())
#foreach ($entry in $results)
|=(% width="20%" %)$property:${entry}|(((

#set ($xwql = "from doc.object(Demarches.Code.DemarchesClass) as demarche where demarche.$property='$entry'")
#set ($demarches = $services.query.xwql($xwql).execute())
#foreach ($demarche in $demarches) [[$demarche]] #end
)))
#end
#end

#listDemarchesByProperty('statutProjetDemat')

#listDemarchesByProperty('direction')

#if ($false)
== Demarches with no "statutProjetDemat"

#set ($xwql = "from doc.object(Demarches.Code.DemarchesClass) as demarche")
#set ($demarches = $services.query.xwql($xwql).execute())
#set ($counter = 0)
#foreach ($demarche in $demarches)
#set ($ddoc = $xwiki.getDocument($demarche))
#set ($value = $ddoc.statutProjetDemat)
#if ($value == '' &amp;&amp; $counter &lt; 10000)
* [[$demarche]] - $value
#set ($object = $ddoc.getObject("Demarches.Code.DemarchesClass"))
#set ($discard = $object.set('statutProjetDemat','aucun'))
#set ($discard = $ddoc.save('Mise à jour du champ "statutProjetDemat" à la valeur "Aucun"', true))
#set ($counter = $counter + 1)
#end
#end
#end

{{/velocity}}</content>
</xwikidoc>

0 comments on commit f7d4527

Please sign in to comment.