Modifications pour le document Macros de résultats Livetable

Modifié par Florent Charton le 2026/03/13 11:03

Depuis la version 5.1
modifié par Florent Charton
sur 2026/01/13 15:00
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-livetable-ui/17.10.2]
À la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:43
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-livetable-ui/15.10.11]

Résumé

Détails

Propriétés de la Page
Contenu
... ... @@ -305,7 +305,10 @@
305 305   #if(!$offset || $offset < 0)
306 306   #set($offset = 0)
307 307   #end
308 - #getAndValidateQueryLimitFromRequest('limit', 15, $limit)
308 + #set($limit = $numbertool.toNumber($request.get('limit')).intValue())
309 + #if(!$limit)
310 + #set ($limit = 15)
311 + #end
309 309   #set($query = $services.query.hql($sql))
310 310   ## Apply query filters if defined. Otherwise use default.
311 311   #foreach ($queryFilter in $stringtool.split($!request.queryFilters, ', '))
... ... @@ -503,9 +503,7 @@
503 503   #set($discard = $map.put('params', $sqlParams))
504 504   #end
505 505   #set($discard = $map.put('reqNo', $numbertool.toNumber($request.reqNo).intValue()))
506 - #if("$!request.tagcloud" == 'true')
507 - #gridresult_buildTagCloudJSON($map)
508 - #end
509 + #gridresult_buildTagCloudJSON($map)
509 509   #gridresult_buildRowsJSON($map)
510 510  #end
511 511  
... ... @@ -559,10 +559,8 @@
559 559   #elseif($propType == 'TextAreaClass' || $propType == 'UsersClass' || $propType == 'GroupsClass')
560 560   #set($tableName = 'LargeStringProperty')
561 561   #elseif($propType == 'StaticListClass' || $propType == 'DBListClass' || $propType == 'DBTreeListClass' || $propType == 'PageClass')
562 - ## The following logic is mirrored from ListClass and might need to be updated when the logic in ListClass changes.
563 563   #set($multiSelect = $propClass.get($colname).getProperty('multiSelect').getValue())
564 564   #set($relationalStorage = $propClass.get($colname).getProperty('relationalStorage').getValue())
565 - #set($largeStorage = $propClass.get($colname).getProperty('largeStorage').getValue())
566 566   #if($multiSelect == 1)
567 567   #if($relationalStorage == 1)
568 568   #set($tableName = 'DBStringListProperty')
... ... @@ -569,8 +569,6 @@
569 569   #else
570 570   #set($tableName = 'StringListProperty')
571 571   #end
572 - #elseif($largeStorage == 1)
573 - #set($tableName = 'LargeStringProperty')
574 574   #else
575 575   #set($tableName = 'StringProperty')
576 576   #end
... ... @@ -884,79 +884,34 @@
884 884   *#
885 885  #macro (livetable_filterDBStringListProperty)
886 886   ## Perform exact matching by default if no match type is specified.
887 - ## For DBStringList properties we still apply a single match type to all non-empty values, but we also allow
888 - ## combining the special "empty" match type with other match types.
884 + ## Note that for DBStringList properties we take into account only the first match type, even if multiple filter
885 + ## values are specified. Basically the first match type is used for all filter values.
889 889   #livetable_getMatchTypes($colname $filterValues.size() 'exact')
890 - #livetable_getJoinOperator($colname)
891 -
892 - ## Collect non-empty filter values (those whose match type is not 'empty').
893 - #set ($nonEmptyValues = [])
894 - #set ($hasEmpty = false)
895 - #set ($matchType = 'invalid')
896 - #foreach ($filterValue in $filterValues)
897 - #if ($matchTypes.get($foreach.index) == 'empty')
898 - #set ($hasEmpty = true)
899 - ## When we want to match empty values, we can't have other match types than exact for non-empty values as for
900 - ## other match types, we need to join with the list of values, which is not compatible with checking for
901 - ## emptiness.
902 - #set ($matchType = 'exact')
903 - #elseif ("$!filterValue" != '')
904 - #set ($discard = $nonEmptyValues.add($filterValue))
905 - ## Store the first non-empty match type.
906 - #if ($matchType == 'invalid')
907 - #set ($matchType = $matchTypes.get($foreach.index))
908 - #end
909 - #end
910 - #end
911 -
912 - ## 1) Apply the non-empty constraints.
913 - #if (!$nonEmptyValues.isEmpty())
914 - #if ($matchType == 'partial' || $matchType == 'prefix')
915 - ## We need to join with the list of values in order to be able to use the LIKE operator.
916 - #set ($matchTarget = "${safe_tableAlias}_item")
917 - #if ($whereParams.entrySet())
918 - #set ($paramPrefix = "${safe_tableAlias}_item_")
919 - #else
920 - #set ($paramPrefix = $NULL)
921 - #end
922 - #set ($joinPos = $mathtool.add($fromSql.lastIndexOf(" $safe_tableAlias"), $mathtool.add($safe_tableAlias.length(), 1)))
923 - #set ($fromSql = "$fromSql.substring(0, $joinPos) join ${safe_tableAlias}.list as $matchTarget $fromSql.substring($joinPos)")
887 + #if ($matchType == 'partial' || $matchType == 'prefix')
888 + ## We need to join with the list of values in order to be able to use the LIKE operator.
889 + #set ($matchTarget = "${safe_tableAlias}_item")
890 + #if ($whereParams.entrySet())
891 + #set ($paramPrefix = "${safe_tableAlias}_item_")
924 924   #else
925 - ## Fall-back on exact matching even if the match type is specified, when its value is not supported.
926 - #set ($matchType = 'exact')
927 - #set ($matchTarget = "${safe_tableAlias}.list")
928 - #if ($whereParams.entrySet())
929 - #set ($paramPrefix = "${safe_tableAlias}_list_")
930 - #else
931 - #set ($paramPrefix = $NULL)
932 - #end
893 + #set ($paramPrefix = $NULL)
933 933   #end
934 -
935 - #set ($filterQuery = "#livetable_getFilterQuery($matchTarget $matchType true $nonEmptyValues.size() $paramPrefix $NULL)")
936 - #if (!$hasEmpty)
937 - ## Only non-empty values are used, combine directly with the existing constraints, otherwise, they will be
938 - ## combined later together with the empty constraint.
939 - #set ($whereSql = "$whereSql and ($filterQuery.trim())")
940 - #end
941 - #foreach ($filterValue in $nonEmptyValues)
942 - #livetable_addFilterParam($filterValue $matchType $whereParams "${paramPrefix}${foreach.count}")
943 - #end
944 - #end
945 -
946 - ## 2) Optionally add a single constraint if any match type is 'empty'.
947 - #if ($hasEmpty)
948 - ## "empty" means that there is no list item stored for this property on the filtered object.
949 - ## The proper way to check for that would be "${safe_tableAlias}.list IS EMPTY", but JSQL cannot parse "IS EMPTY"
950 - ## which means that we cannot use it without programming right.
951 - #set ($emptyConstraint = "size(${safe_tableAlias}.list) = 0")
952 - #if ($nonEmptyValues.isEmpty())
953 - ## Only 'empty' is used, combine with the existing constraints.
954 - #set ($whereSql = "${whereSql} and ${emptyConstraint}")
895 + #set ($joinPos = $mathtool.add($fromSql.lastIndexOf(" $safe_tableAlias"), $mathtool.add($safe_tableAlias.length(), 1)))
896 + #set ($fromSql = "$fromSql.substring(0, $joinPos) join ${safe_tableAlias}.list as $matchTarget $fromSql.substring($joinPos)")
897 + #else
898 + ## Fall-back on exact matching even if the match type is specified, when its value is not supported.
899 + #set ($matchType = 'exact')
900 + #set ($matchTarget = "${safe_tableAlias}.list")
901 + #if ($whereParams.entrySet())
902 + #set ($paramPrefix = "${safe_tableAlias}_list_")
955 955   #else
956 - ## Combine non-empty group and empty condition using the join operator.
957 - #set ($whereSql = "${whereSql} and ($filterQuery.trim() ${joinOperator} ${emptyConstraint})")
904 + #set ($paramPrefix = $NULL)
958 958   #end
959 959   #end
907 + #set ($filterQuery = "#livetable_getFilterQuery($matchTarget $matchType true $filterValues.size() $paramPrefix $NULL)")
908 + #set ($whereSql = "$whereSql and ($filterQuery.trim())")
909 + #foreach ($filterValue in $filterValues)
910 + #livetable_addFilterParam($filterValue $matchType $whereParams "${paramPrefix}${foreach.count}")
911 + #end
960 960  #end
961 961  
962 962  
... ... @@ -1051,9 +1051,9 @@
1051 1051   #if ($matchType == 'partial' || $matchType == 'prefix')
1052 1052   #livetable_repeatParams("upper($column) like upper(?)", " $joinOperator ", $valueCount, $paramPrefix, $paramOffset)
1053 1053   #elseif($matchType == 'empty')
1054 - ## Check if the value of the column is like the empty parameter (which is often the empty string), or if the value
1006 + ## Check if the value of the column is like the empty parameter (which is often the empty string), or if the value
1055 1055   ## of the column is null (to be compliant with Oracle which stores the empty string as a NULL value).
1056 - #livetable_repeatParams("($column like ? or $column is null)", " $joinOperator ", $valueCount, $paramPrefix,
1008 + #livetable_repeatParams("($column like ? or $column is null)", " $joinOperator ", $valueCount, $paramPrefix,
1057 1057   $paramOffset)
1058 1058   #elseif ($isList)
1059 1059   #livetable_repeatParams("? in elements($column)", " $joinOperator ", $valueCount, $paramPrefix, $paramOffset)