Skip to content

Commit

Permalink
* Handle the list of tables for HSQLDB (need to be done for PostGreSQ…
Browse files Browse the repository at this point in the history
…L as well)

* Handle transaction commits
  • Loading branch information
gdelhumeau committed Aug 16, 2018
1 parent ba8f848 commit 1f24dae
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 232 deletions.
24 changes: 21 additions & 3 deletions sql-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform.applications</groupId>
<artifactId>xwiki-applications</artifactId>
<version>35</version>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-pom</artifactId>
<version>6.4.1</version>
</parent>
<groupId>org.xwiki.contrib</groupId>
<artifactId>xwiki-sql-tools</artifactId>
<version>1.1</version>
<packaging>xar</packaging>
<name>SQL Tools for XWiki</name>
<description></description>
<build>
<!-- Needed to add support for the XAR packaging -->
<extensions>
<extension>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-tool-xar-handlers</artifactId>
<version>${commons.version}</version>
</extension>
</extensions>
<plugins>
<!-- The XAR packaging uses the XAR plugin and thus we need to define what version to use -->
<plugin>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-tool-xar-plugin</artifactId>
<version>${commons.version}</version>
</plugin>
</plugins>
</build>
</project>
70 changes: 44 additions & 26 deletions sql-tools/src/main/resources/SQLTools/ListTables.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>SQLTools</web>
<name>ListTables</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1352109523000</creationDate>
<date>1352109523000</date>
<contentUpdateDate>1352109523000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}

<!--
* 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="SQLTools.ListTables" locale="">
<web>SQLTools</web>
<name>ListTables</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<parent>SQLTools.WebHome</parent>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1352109523000</creationDate>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1534424225000</date>
<contentUpdateDate>1534424225000</contentUpdateDate>
<version>1.1</version>
<title/>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<content>{{velocity}}
#if($hasProgramming)
#set($sqlTools = $xwiki.parseGroovyFromPage('SQLTools.SQLToolsGroovy'))
= Form =
$sqlTools.getForm($request, $doc, true, false)
#if($request.url)
#set($connection = $sqlTools.getConnectionFromRequest($request))
#set($results = $sqlTools.getTables($connection))
#set($results = $sqlTools.getTables($connection, $xwiki, $xcontext))
= Table of content =
{{toc /}}

Expand All @@ -40,4 +57,5 @@
{{error}}Sorry, you need the programming rights to use this tool{{/error}}
#end
{{/velocity}}
</content></xwikidoc>
</content>
</xwikidoc>
73 changes: 46 additions & 27 deletions sql-tools/src/main/resources/SQLTools/ListTablesOfXWiki.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>SQLTools</web>
<name>ListTablesOfXWiki</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1352113380000</creationDate>
<date>1352113380000</date>
<contentUpdateDate>1352113380000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}

<!--
* 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="SQLTools.ListTablesOfXWiki" locale="">
<web>SQLTools</web>
<name>ListTablesOfXWiki</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<parent>SQLTools.WebHome</parent>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1352113380000</creationDate>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1534423829000</date>
<contentUpdateDate>1534423829000</contentUpdateDate>
<version>1.1</version>
<title/>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<content>{{velocity}}
#if($hasProgramming)
#set($sqlTools = $xwiki.parseGroovyFromPage('SQLTools.SQLToolsGroovy'))
#set($system = $sqlTools.getXWikiDatabaseSystem($xwiki, $xcontext))
Your database is: **$system**
#if($system == "HSQL Database Engine")
{{warning}}$system is not supported for this action{{/warning}}
#end
#set($connection = $sqlTools.getXWikiConnection($xwiki, $xcontext))
#set($results = $sqlTools.getTables($connection))
#set($store = $sqlTools.getXWikiStore($xwiki, $xcontext))
#set($connection = $sqlTools.getXWikiConnection($store, $xcontext))
#set($results = $sqlTools.getTables($connection, $xwiki, $xcontext))
= Table of content =
{{toc /}}

Expand All @@ -41,4 +59,5 @@
{{error}}Sorry, you need the programming rights to use this tool{{/error}}
#end
{{/velocity}}
</content></xwikidoc>
</content>
</xwikidoc>
68 changes: 43 additions & 25 deletions sql-tools/src/main/resources/SQLTools/Query.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>SQLTools</web>
<name>Query</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1352109523000</creationDate>
<date>1352109523000</date>
<contentUpdateDate>1352109523000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}

<!--
* 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="SQLTools.Query" locale="">
<web>SQLTools</web>
<name>Query</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<parent>SQLTools.WebHome</parent>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1352109523000</creationDate>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1534414594000</date>
<contentUpdateDate>1534414594000</contentUpdateDate>
<version>1.1</version>
<title/>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<content>{{velocity}}
#if($hasProgramming)
#set($sqlTools = $xwiki.parseGroovyFromPage('SQLTools.SQLToolsGroovy'))
= Query =
Expand All @@ -37,4 +54,5 @@
{{error}}Sorry, you need the programming rights to use this tool{{/error}}
#end
{{/velocity}}
</content></xwikidoc>
</content>
</xwikidoc>
72 changes: 46 additions & 26 deletions sql-tools/src/main/resources/SQLTools/QueryOnXWiki.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xwikidoc>
<web>SQLTools</web>
<name>QueryOnXWiki</name>
<language></language>
<defaultLanguage>en</defaultLanguage>
<translation>0</translation>
<parent></parent>
<creator>XWiki.Admin</creator>
<author>XWiki.Admin</author>
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1352113376000</creationDate>
<date>1352113376000</date>
<contentUpdateDate>1352113376000</contentUpdateDate>
<version>1.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>false</hidden>
<content>{{velocity}}

<!--
* 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="SQLTools.QueryOnXWiki" locale="">
<web>SQLTools</web>
<name>QueryOnXWiki</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<parent>SQLTools.WebHome</parent>
<creator>xwiki:XWiki.Admin</creator>
<creationDate>1352113376000</creationDate>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1534423539000</date>
<contentUpdateDate>1534423539000</contentUpdateDate>
<version>1.1</version>
<title/>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<content>{{velocity}}
#if($hasProgramming)
#set($sqlTools = $xwiki.parseGroovyFromPage('SQLTools.SQLToolsGroovy'))
#set($system = $sqlTools.getXWikiDatabaseSystem($xwiki, $xcontext))
= Query =
Your database is: **$system**
$sqlTools.getForm($request, $doc, false, true)
#if($request.query)
#set($connection = $sqlTools.getXWikiConnection($xwiki, $xcontext))
#set($store = $sqlTools.getXWikiStore($xwiki, $xcontext))
#set($connection = $sqlTools.getXWikiConnection($store, $xcontext))
#set($results = $sqlTools.getResults($connection, $request.query, true))
$store.endTransaction($xcontext.context, true)
= Results =
$results
#end
#else
{{error}}Sorry, you need the programming rights to use this tool{{/error}}
#end
{{/velocity}}
</content></xwikidoc>
</content>
</xwikidoc>
Loading

0 comments on commit 1f24dae

Please sign in to comment.