%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/
Upload File :
Create Path :
Current File : //home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/suggest.vm

##
## @Deprecated since 9.8RC1 use the ClassPropertyValues REST resource instead.
##
$response.setContentType("text/xml")
##
#set($classname = $request.get("classname"))
#set($fieldname = $request.get("fieldname"))
#set($firCol = "$!{request.get('firCol')}")
#set($secCol = "$!{request.get('secCol')}")
#set($templatename = $classname + 'Template')
#set($p = $xwiki.getDocument($classname).getxWikiClass().get($fieldname).getPropertyClass())
#set($hibquery = "$!p.getSql()")
##
## Determine what was the input. If the property accepts multiple values and has separators, then
## use only the last token as the input.
## TODO: What if the user is actually typing in the middle of the input string? The actual word for
## which the autocompletion is triggered should be sent from JS.
##
#set($input = "$!{request.get('input').toLowerCase()}")
#set($sep = "$!{p.getSeparators()}")
#if($p.isMultiSelect() && ($sep != "")) ### has separators
  #set($input_words = $stringtool.split($input, $sep))
  #foreach($i in $input_words)
    #set($input = $i.trim())
  #end
#end
#set($input = $input.replaceAll('[\[_%!]', '!$0'))
##
######################### User hibernate query
#if("$!hibquery" != "")
  #if($secCol != "-")
    ### two columns, hidden input
    #set($likeCol = $secCol)
    #set($resultsType = 1)
  #else ### one column, no hidden input
    #set($likeCol = $firCol)
    #set($resultsType = 2)
  #end
  #set($whereidx = $hibquery.toLowerCase().indexOf("where"))
  #if($whereidx < 0)
    #set($like = " where lower("+ $likeCol.replaceAll("[^a-zA-Z0-9_.]", "") + ") like :input ESCAPE '!'")
    #set($hibquery = $hibquery.concat($like))
  #else
    #set($whereidx = $whereidx + 5)
    #set($like = " lower("+ $likeCol.replaceAll("[^a-zA-Z0-9_.]", "") + ") like :input ESCAPE '!' and")
    #set($hibquery = "${hibquery.substring(0, $whereidx)}${like}${hibquery.substring($whereidx)}")
  #end
  #set($results = $services.query.hql($hibquery).setLimit(30).bindValue('input', "%${input}%").execute())
  <?xml version="1.0" encoding="UTF-8"?>
  <results type="${resultsType}">
  #foreach($res in $results)
    #set($info = '')
    #set($rs = $res)
    #foreach($r in $res)
      #if($velocityCount == 1)
        #set($info = $r)
      #elseif($velocityCount == 2)
        #set($rs = $r)
      #end
    #end
    #if(($info != '-') && ($rs != '-'))
      <rs id="" info="$!{escapetool.xml($info)}">$!{escapetool.xml($rs)}</rs>
    #end
  #end
  </results>
#else ## hibquery == ""
  ######################### DBListProperty query
  #if($p.isRelationalStorage() && $p.isMultiSelect())
    #set($query = "select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name <> :templatename and obj.className = :classname and prop.id.id = obj.id and prop.id.name = :fieldname and lower(list) like :input ESCAPE '!'")
    #set($queryResult = $services.query.hql($query).setLimit(30).bindValues({'templatename' : ${templatename}, 'classname' : ${classname}, 'fieldname' : ${fieldname}, 'input' : "%${input}%"}).execute())
    #set($results = $queryResult.toArray())
    <?xml version="1.0" encoding="UTF-8"?>
    <results type="3">
    #foreach($res in $results)
      <rs id="$velocityCount" info="">$!{escapetool.xml($res)}</rs>
    #end
    </results>
  ######################### StringListProperty query
  #elseif($p.isMultiSelect())
    #set($query = "select distinct prop.textValue from BaseObject as obj, StringListProperty as prop where obj.name <> :templatename and obj.className = :classname and prop.id.id = obj.id and prop.name = :fieldname and lower(prop.textValue) like :input ESCAPE '!'")
    #set($queryResult = $services.query.hql($query).setLimit(30).bindValues({'templatename' : ${templatename}, 'classname' : ${classname}, 'fieldname' : ${fieldname}, 'input' : "%${input}%"}).execute())
    #set($results = $queryResult.toArray())
    <?xml version="1.0" encoding="UTF-8"?>
    <results type="5">
    #foreach($res in $results)
      #set($list = $p.getListFromString($res, $sep, false))
      #set($list = $list.toArray())
      #foreach($word in $list)
          <rs id="$velocityCount" info="">$!{escapetool.xml($word)}</rs>
      #end
    #end
    </results>
  ######################### StringProperty query
  #else
    #set($query = "select distinct prop.value from BaseObject as obj, StringProperty as prop where obj.className = :classname and obj.name <> :templatename and prop.id.id = obj.id and prop.id.name = :fieldname and lower(prop.value) like :input ESCAPE '!'")
    #set($queryResult = $services.query.hql($query).setLimit(30).bindValues({'templatename' : ${templatename}, 'classname' : ${classname}, 'fieldname' : ${fieldname}, 'input' : "%${input}%"}).execute())
    #set($results = $queryResult.toArray())
    <?xml version="1.0" encoding="UTF-8"?>
    <results type="8">
    #foreach($res in $results)
      <rs id="$velocityCount" info="">$!{escapetool.xml($res)}</rs>
    #end
    </results>
  #end
#end ## if hibquery

Zerion Mini Shell 1.0