Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit f15894e

Browse files
Init
1 parent fd432f9 commit f15894e

15 files changed

+1304
-18
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ You should have the following things installed:
3333
* Ensure that everything is encoded in ``UTF-8``
3434
* Ensure that the JDK/Java-Version is correct
3535

36-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xdev-swing-framework-template/release.yml?branch=master)](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/release.yml)
36+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xapi-db-sqlite/release.yml?branch=master)](https://github.com/xdev-software/xapi-db-sqlite/actions/workflows/release.yml)
3737

3838
Before releasing:
39-
* Consider doing a [test-deployment](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
39+
* Consider doing a [test-deployment](https://github.com/xdev-software/xapi-db-sqlite/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
4040
* Check the [changelog](CHANGELOG.md)
4141

4242
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes.

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/xdev-swing-framework-template)](https://mvnrepository.com/artifact/com.xdev-software/xdev-swing-framework-template)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xdev-swing-framework-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3-
[![javadoc](https://javadoc.io/badge2/com.xdev-software/xdev-swing-framework-template/javadoc.svg)](https://javadoc.io/doc/com.xdev-software/xdev-swing-framework-template)
4-
# xdev-swing-framework-template
1+
[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/xapi-db-sqlite)](https://mvnrepository.com/artifact/com.xdev-software/xapi-db-sqlite)
2+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xapi-db-sqlite/checkBuild.yml?branch=develop)](https://github.com/xdev-software/xapi-db-sqlite/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3+
[![javadoc](https://javadoc.io/badge2/com.xdev-software/xapi-db-sqlite/javadoc.svg)](https://javadoc.io/doc/com.xdev-software/xapi-db-sqlite)
4+
# SqlEngine Database Adapter SQLite
55

6-
A XDEV Swing Framework Template
6+
The XDEV Application Framework provides an abstraction over database dialects as part of its SqlEngine. This module is the Database Adapter for SQLite which includes the SQLite-specific implementation for database access.
7+
8+
## Important Note
9+
This Adapter only works to read from the database. It is **not** possible to perform the following actions:
10+
- createTable
11+
- addColumn
12+
- alterColumn
13+
- dropColumn
14+
- createIndex
15+
- dropIndex
716

817
## XDEV-IDE
918
The [XDEV(-IDE)](https://xdev.software/en/products/swing-builder) is a visual Java development environment for fast and easy application development (RAD - Rapid Application Development). XDEV differs from other Java IDEs such as Eclipse or NetBeans, focusing on programming through a far-reaching RAD concept. The IDE's main components are a Swing GUI builder, the XDEV Application Framework and numerous drag-and-drop tools and wizards with which the functions of the framework can be integrated.
@@ -17,4 +26,4 @@ If you need support as soon as possible and you can't wait for any pull request,
1726
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
1827

1928
## Dependencies and Licenses
20-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/xdev-swing-framework-template/dependencies/)
29+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/xapi-db-sqlite/dependencies/)

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Reporting a Vulnerability
44

5-
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/xdev-swing-framework-template/security/advisories/new).
5+
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/xapi-db-sqlite/security/advisories/new).

pom.xml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.xdev-software</groupId>
8-
<artifactId>xdev-swing-framework-template</artifactId>
8+
<artifactId>xapi-db-sqlite</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

12-
<name>xdev-swing-framework-template</name>
13-
<description>xdev-swing-framework-template</description>
14-
<url>https://github.com/xdev-software/xdev-swing-framework-template</url>
12+
<name>SqlEngine Database Adapter SQLite</name>
13+
<description>XAPI SqlEngine Database Adapter for SQLite</description>
14+
<url>https://github.com/xdev-software/xapi-db-sqlite</url>
1515

1616
<scm>
17-
<url>https://github.com/xdev-software/xdev-swing-framework-template</url>
18-
<connection>https://github.com/xdev-software/xdev-swing-framework-template.git</connection>
19-
</scm>
17+
<url>https://github.com/xdev-software/xapi-db-sqlite</url>
18+
<connection>https://github.com/xdev-software/xapi-db-sqlite.git</connection>
19+
</scm>
2020

21-
<inceptionYear>2023</inceptionYear>
21+
<inceptionYear>2003</inceptionYear>
2222

2323
<organization>
2424
<name>XDEV Software</name>
@@ -48,6 +48,8 @@
4848

4949
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5050
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
51+
52+
<xdev.xapi.version>6.0.1</xdev.xapi.version>
5153
</properties>
5254

5355
<repositories>
@@ -87,7 +89,18 @@
8789
</distributionManagement>
8890

8991
<dependencies>
90-
92+
<dependency>
93+
<groupId>com.xdev-software</groupId>
94+
<artifactId>xapi</artifactId>
95+
<version>${xdev.xapi.version}</version>
96+
</dependency>
97+
98+
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
99+
<dependency>
100+
<groupId>org.xerial</groupId>
101+
<artifactId>sqlite-jdbc</artifactId>
102+
<version>3.7.15-M1</version>
103+
</dependency>
91104
</dependencies>
92105

93106
<build>

src/main/java/sqlite.png

867 Bytes
Loading
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* SqlEngine Database Adapter SQLite - XAPI SqlEngine Database Adapter for SQLite
3+
* Copyright © 2003 XDEV Software (https://xdev.software)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package xdev.db.sqlite.jdbc;
19+
20+
21+
22+
23+
import java.io.File;
24+
25+
import com.xdev.jadoth.sqlengine.dbms.DbmsConnectionInformation;
26+
27+
import xdev.db.ConnectionInformation;
28+
29+
public class SQLiteConnectionInformation extends ConnectionInformation<SQLiteDbms>
30+
{
31+
// /////////////////////////////////////////////////////////////////////////
32+
// constructors //
33+
// ///////////////////
34+
35+
public SQLiteConnectionInformation(final String database, final String urlExtension,
36+
final SQLiteDbms dbmsAdaptor)
37+
{
38+
super("",0,"","",database,urlExtension,dbmsAdaptor);
39+
}
40+
41+
42+
// /////////////////////////////////////////////////////////////////////////
43+
// getters //
44+
// ///////////////////
45+
/**
46+
* Gets the database.
47+
*
48+
* @return the database
49+
*/
50+
public String getDatabase()
51+
{
52+
return this.getCatalog();
53+
}
54+
55+
56+
// /////////////////////////////////////////////////////////////////////////
57+
// setters //
58+
// ///////////////////
59+
/**
60+
* Sets the database.
61+
*
62+
* @param database
63+
* the database to set
64+
*/
65+
public void setDatabase(final String database)
66+
{
67+
this.setCatalog(database);
68+
}
69+
70+
71+
// /////////////////////////////////////////////////////////////////////////
72+
// override methods //
73+
// ///////////////////
74+
/**
75+
* @see DbmsConnectionInformation#createJdbcConnectionUrl()
76+
*/
77+
@Override
78+
public String createJdbcConnectionUrl()
79+
{
80+
String db = getDatabase();
81+
File file = new File(db).getAbsoluteFile();
82+
if(!file.exists())
83+
{
84+
String projectHome = System.getProperty("project.home",null);
85+
if(projectHome != null && projectHome.length() > 0)
86+
{
87+
file = new File(new File(projectHome),db);
88+
db = file.getAbsolutePath();
89+
}
90+
}
91+
92+
String url = "jdbc:sqlite:" + db;
93+
return appendUrlExtension(url);
94+
}
95+
96+
97+
/**
98+
* @see com.xdev.jadoth.sqlengine.dbms.DbmsConnectionInformation#getJdbcDriverClassName()
99+
*/
100+
@Override
101+
public String getJdbcDriverClassName()
102+
{
103+
return "org.sqlite.JDBC";
104+
}
105+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* SqlEngine Database Adapter SQLite - XAPI SqlEngine Database Adapter for SQLite
3+
* Copyright © 2003 XDEV Software (https://xdev.software)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package xdev.db.sqlite.jdbc;
19+
20+
21+
22+
23+
import com.xdev.jadoth.sqlengine.dbms.standard.StandardDDLMapper;
24+
25+
26+
public class SQLiteDDLMapper extends StandardDDLMapper<SQLiteDbms>
27+
{
28+
protected SQLiteDDLMapper(final SQLiteDbms dbmsAdaptor)
29+
{
30+
super(dbmsAdaptor);
31+
}
32+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* SqlEngine Database Adapter SQLite - XAPI SqlEngine Database Adapter for SQLite
3+
* Copyright © 2003 XDEV Software (https://xdev.software)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package xdev.db.sqlite.jdbc;
19+
20+
21+
22+
23+
import static com.xdev.jadoth.sqlengine.internal.QueryPart.ASEXPRESSION;
24+
import static com.xdev.jadoth.sqlengine.internal.QueryPart.indent;
25+
import static com.xdev.jadoth.sqlengine.internal.QueryPart.isSingleLine;
26+
27+
import com.xdev.jadoth.sqlengine.SELECT;
28+
import com.xdev.jadoth.sqlengine.dbms.standard.StandardDMLAssembler;
29+
import com.xdev.jadoth.sqlengine.internal.SqlExpression;
30+
import com.xdev.jadoth.sqlengine.internal.SqlFunctionMOD;
31+
32+
public class SQLiteDMLAssembler extends StandardDMLAssembler<SQLiteDbms>
33+
{
34+
public SQLiteDMLAssembler(final SQLiteDbms dbms)
35+
{
36+
super(dbms);
37+
}
38+
39+
40+
// /////////////////////////////////////////////////////////////////////////
41+
// override methods //
42+
// ///////////////////
43+
/**
44+
* @see StandardDMLAssembler#assembleSELECT(SELECT, StringBuilder, int, int, String, String)
45+
*/
46+
@Override
47+
protected StringBuilder assembleSELECT(final SELECT query, final StringBuilder sb,
48+
final int indentLevel, final int flags, final String clauseSeperator,
49+
final String newLine)
50+
{
51+
indent(sb,indentLevel,isSingleLine(flags)).append(query.keyword());
52+
53+
this.assembleSelectDISTINCT(query,sb,indentLevel,flags);
54+
this.assembleSelectItems(query,sb,flags,indentLevel,newLine);
55+
this.assembleSelectSqlClauses(query,sb,indentLevel,flags | ASEXPRESSION,clauseSeperator, newLine);
56+
this.assembleAppendSELECTs(query,sb,indentLevel,flags,clauseSeperator,newLine);
57+
this.assembleSelectRowLimit(query,sb,flags,clauseSeperator,newLine,indentLevel);
58+
59+
return sb;
60+
}
61+
62+
63+
/**
64+
* @see StandardDMLAssembler#assembleSelectRowLimit(SELECT, StringBuilder, int, String, String, int)
65+
*/
66+
@Override
67+
protected StringBuilder assembleSelectRowLimit(final SELECT query, final StringBuilder sb,
68+
final int flags, final String clauseSeperator, final String newLine,
69+
final int indentLevel)
70+
{
71+
final Integer offset = query.getOffsetSkipCount();
72+
final Integer limit = query.getFetchFirstRowCount();
73+
74+
if(offset != null && limit != null)
75+
{
76+
sb.append(newLine)
77+
.append(clauseSeperator)
78+
.append("LIMIT ")
79+
.append(limit)
80+
.append(" OFFSET ")
81+
.append(offset);
82+
}
83+
else if(limit != null)
84+
{
85+
sb.append(newLine)
86+
.append(clauseSeperator)
87+
.append("LIMIT ")
88+
.append(limit);
89+
}
90+
return sb;
91+
}
92+
93+
94+
@Override
95+
public void assembleExpression(final SqlExpression expression, final StringBuilder sb,
96+
final int indentLevel, final int flags)
97+
{
98+
99+
if(expression instanceof SqlFunctionMOD)
100+
{
101+
sb.append(((SqlFunctionMOD)expression).getParameters()[0])
102+
.append(" % ")
103+
.append(((SqlFunctionMOD)expression).getParameters()[1]);
104+
}
105+
else
106+
{
107+
super.assembleExpression(expression,sb,indentLevel,flags);
108+
}
109+
}
110+
111+
}

0 commit comments

Comments
 (0)