[xwiki-users] Please, badly need help with HQL...
Hi all, Can someone help me? I need urgent two HQL queries: 1. Query for all "wanted pages" - pages that have been linked to, but are not yet written - new pages (links with the question mark next to them); 2. The version number of the document I restored/rolled back to. Thanks in advance, adoro -- View this message in context: http://n2.nabble.com/Please%2C-badly-need-help-with-HQL...-tp1493848p1493848... Sent from the XWiki- Users mailing list archive at Nabble.com.
adoro wrote:
Hi all,
Can someone help me? I need urgent two HQL queries:
1. Query for all "wanted pages" - pages that have been linked to, but are not yet written - new pages (links with the question mark next to them);
This should work: #set($query = "select link.id.link from XWikiLink link where not exists (from XWikiDocument doc where doc.fullName = link.id.link)") #foreach($item in $xwiki.search($query)) * $item #end Note that several bad entries are placed there because the link detection process does not pre-run velocity, so lots of entries actually point to velocity variables or javascript code. Definitely the backlinks need to be revised in the new rendering.
2. The version number of the document I restored/rolled back to.
That's a bit hard... Rollback is not an actual rollback, like pointing back to an older version, but the old version is loaded from the history and saved as a new version. You could parse the version comment, which looks like: "Rollback to version 2.1", and extract the version from there. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi Sergiu, thank you so much for your help, the "wanted pages" query works fine if I use it for certain spaces: #set($sql= "select link.fullName, link.link.id from XWikiLink link where link.fullName like 'MySpace.%' and not exists (select doc.fullName from XWikiDocument doc where doc.fullName = link.id.link) order by 1") #set($results= $xwiki.search($sql)) #if ($results.size() == 0) #warning('Es gibt keine gewünschte Seiten') #else {table} Space|Document|Link #foreach ($row in $results) #foreach ($col in $row) #if ($velocityCount==1) #set($docFullName=$col) #elseif ($velocityCount==2) #set($emptyLink=$col) #set($el=$emptyLink.getLink()) #set($spaceName=$xwiki.getDocument($docFullName).space) #end #end $spaceName|[$docFullName]|$el #end {table} #end Best Regards, Alla Sergiu Dumitriu-2 wrote:
This should work:
#set($query = "select link.id.link from XWikiLink link where not exists (from XWikiDocument doc where doc.fullName = link.id.link)") #foreach($item in $xwiki.search($query)) * $item #end
Note that several bad entries are placed there because the link detection process does not pre-run velocity, so lots of entries actually point to velocity variables or javascript code. Definitely the backlinks need to be revised in the new rendering.
Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://n2.nabble.com/Please%2C-badly-need-help-with-HQL...-tp1493848p1499075... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Adoro, One you have something fully working, would be nice if you could contribute this back on code.xwiki.org as a code snippet. Thanks -Vincent On Nov 14, 2008, at 4:58 PM, adoro wrote:
Hi Sergiu, thank you so much for your help, the "wanted pages" query works fine if I use it for certain spaces:
#set($sql= "select link.fullName, link.link.id from XWikiLink link where link.fullName like 'MySpace.%' and not exists (select doc.fullName from XWikiDocument doc where doc.fullName = link.id.link) order by 1")
#set($results= $xwiki.search($sql)) #if ($results.size() == 0) #warning('Es gibt keine gewünschte Seiten') #else {table} Space|Document|Link #foreach ($row in $results) #foreach ($col in $row) #if ($velocityCount==1) #set($docFullName=$col) #elseif ($velocityCount==2) #set($emptyLink=$col) #set($el=$emptyLink.getLink()) #set($spaceName=$xwiki.getDocument($docFullName).space) #end #end $spaceName|[$docFullName]|$el #end {table} #end
Best Regards, Alla
Sergiu Dumitriu-2 wrote:
This should work:
#set($query = "select link.id.link from XWikiLink link where not exists (from XWikiDocument doc where doc.fullName = link.id.link)") #foreach($item in $xwiki.search($query)) * $item #end
Note that several bad entries are placed there because the link detection process does not pre-run velocity, so lots of entries actually point to velocity variables or javascript code. Definitely the backlinks need to be revised in the new rendering.
Sergiu Dumitriu http://purl.org/net/sergiu/
participants (3)
-
adoro -
Sergiu Dumitriu -
Vincent Massol