[FEAT] reorganize pakages

This commit is contained in:
Edouard DUPIN 2024-05-05 12:33:08 +02:00
parent 9d5c3c01db
commit 70cbb1aae9
23 changed files with 175 additions and 33 deletions

View File

@ -5,9 +5,9 @@ import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.QueryOption;
import org.kar.archidata.dataAccess.QueryOptions; import org.kar.archidata.dataAccess.QueryOptions;
import org.kar.archidata.dataAccess.options.DBInterfaceOption; import org.kar.archidata.dataAccess.options.DBInterfaceOption;
import org.kar.archidata.dataAccess.options.QueryOption;
import org.kar.archidata.db.DBEntry; import org.kar.archidata.db.DBEntry;
import org.kar.archidata.model.User; import org.kar.archidata.model.User;

View File

@ -31,6 +31,10 @@ import org.kar.archidata.dataAccess.options.Condition;
import org.kar.archidata.dataAccess.options.DBInterfaceOption; import org.kar.archidata.dataAccess.options.DBInterfaceOption;
import org.kar.archidata.dataAccess.options.DBInterfaceRoot; import org.kar.archidata.dataAccess.options.DBInterfaceRoot;
import org.kar.archidata.dataAccess.options.FilterValue; import org.kar.archidata.dataAccess.options.FilterValue;
import org.kar.archidata.dataAccess.options.GroupBy;
import org.kar.archidata.dataAccess.options.Limit;
import org.kar.archidata.dataAccess.options.OrderBy;
import org.kar.archidata.dataAccess.options.QueryOption;
import org.kar.archidata.dataAccess.options.TransmitKey; import org.kar.archidata.dataAccess.options.TransmitKey;
import org.kar.archidata.db.DBEntry; import org.kar.archidata.db.DBEntry;
import org.kar.archidata.exception.DataAccessException; import org.kar.archidata.exception.DataAccessException;
@ -1224,7 +1228,8 @@ public class DataAccess {
return 0; return 0;
} }
static void addElement(final PreparedStatement ps, final Object value, final CountInOut iii) throws Exception { public static void addElement(final PreparedStatement ps, final Object value, final CountInOut iii)
throws Exception {
if (value instanceof final UUID tmp) { if (value instanceof final UUID tmp) {
final byte[] dataByte = UuidUtils.asBytes(tmp); final byte[] dataByte = UuidUtils.asBytes(tmp);
ps.setBytes(iii.value, dataByte); ps.setBytes(iii.value, dataByte);

View File

@ -20,6 +20,10 @@ import org.kar.archidata.dataAccess.exportTools.TableQuery;
import org.kar.archidata.dataAccess.exportTools.TableQueryTypes; import org.kar.archidata.dataAccess.exportTools.TableQueryTypes;
import org.kar.archidata.dataAccess.options.Condition; import org.kar.archidata.dataAccess.options.Condition;
import org.kar.archidata.dataAccess.options.DBInterfaceOption; import org.kar.archidata.dataAccess.options.DBInterfaceOption;
import org.kar.archidata.dataAccess.options.GroupBy;
import org.kar.archidata.dataAccess.options.Limit;
import org.kar.archidata.dataAccess.options.OrderBy;
import org.kar.archidata.dataAccess.options.QueryOption;
import org.kar.archidata.db.DBEntry; import org.kar.archidata.db.DBEntry;
import org.kar.archidata.exception.DataAccessException; import org.kar.archidata.exception.DataAccessException;
import org.kar.archidata.tools.DateTools; import org.kar.archidata.tools.DateTools;

View File

@ -8,17 +8,17 @@ import java.util.List;
public class QueryAnd implements QueryItem { public class QueryAnd implements QueryItem {
protected final List<QueryItem> childs; protected final List<QueryItem> childs;
public QueryAnd(final List<QueryItem> childs) { public QueryAnd(final List<QueryItem> child) {
this.childs = childs; this.childs = child;
} }
public QueryAnd(final QueryItem... items) { public QueryAnd(final QueryItem... child) {
this.childs = new ArrayList<>(); this.childs = new ArrayList<>();
Collections.addAll(this.childs, items); Collections.addAll(this.childs, child);
} }
public void add(final QueryItem... items) { public void add(final QueryItem... child) {
Collections.addAll(this.childs, items); Collections.addAll(this.childs, child);
} }
@Override @Override

View File

@ -7,6 +7,12 @@ public class QueryCondition implements QueryItem {
private final String comparator; private final String comparator;
private final Object value; private final Object value;
/**
* Simple DB comparison element. Note the injected object is injected in the statement and not in the query directly.
* @param key Field to check (the Model property name)
* @param comparator (simple comparator String)
* @param value Value that the field must be equals.
*/
public QueryCondition(final String key, final String comparator, final Object value) { public QueryCondition(final String key, final String comparator, final Object value) {
this.key = key; this.key = key;
this.comparator = comparator; this.comparator = comparator;

View File

@ -1,3 +0,0 @@
package org.kar.archidata.dataAccess;
public class QueryOption {}

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.kar.archidata.dataAccess.options.AccessDeletedItems; import org.kar.archidata.dataAccess.options.AccessDeletedItems;
import org.kar.archidata.dataAccess.options.CreateDropTable; import org.kar.archidata.dataAccess.options.CreateDropTable;
import org.kar.archidata.dataAccess.options.QueryOption;
import org.kar.archidata.dataAccess.options.ReadAllColumn; import org.kar.archidata.dataAccess.options.ReadAllColumn;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -0,0 +1,137 @@
Archi-data
==========
Archi-data is a framework that simplify:
- Creating a REST server with:
- Right control
- Swagger display interface
- Normalize error generate by the server
- Access to the DB:
- introspect Object and insert in the TD (SQLITE & MY-SQL)
- Manage migration
- JPA checker for many generic request
- simplify the request of the Test-service
Documentation:
--------------
The documentation is available [here](doc/index.md)
Develop in cmd-line:
--------------------
The first step is configuring your JAVA version (or select the JVM with the OS)
```bash
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
```
Install the dependency:
```bash
mvn install
```
Run the test
```bash
mvn test
```
Install it for external use
```bash
mvn install
```
Develop With Eclipse:
--------------------
Import the project:
- Open a (new) project on eclipse
- `File` -> `Import`
- `Maven` -> `Existing Maven project`
- Select the `pom.xml` file and click on import
Run the Test:
- Open the package `test.kar.archidata`
- Click right on it
- Select `Debug As` -> `JUnit Test`
Install in the local maven repository:
- Click right on the `pom.xml` file
- Select `Run As` -> `Maven install`
Some tools:
============
Auto-update dependency:
-----------------------
Auto-update to the last version dependency:
```bash
mvn versions:use-latest-versions
```
Format the code
---------------
Simply run the cmd-line:
```bash
mvn formatter:format
```
Reformat XML file like the pom.xml
```bash
XMLLINT_INDENT=" " xmllint --format "back/pom.xml" -o "back/pom.xml"
```
Enable the pre-commit checker
-----------------------------
```bash
./tools/configure_precommit.bash
```
> **_Note_**: You can change the code in `.git/hooks/pre-commit` by replacing `formatter:verify` with `formatter:format` to auto format the code @ every commit
Add Gitea in the dependency for the registry:
=============================================
Read instruction for tocken in ~/.m2/setting.xml
edit file: ```~/.m2/settings.xml```
```xml
<settings>
<servers>
<server>
<id>gitea</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
```
release:
========
```bash
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
mvn install
mvn deploy
```

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** This option permit to access on deleted items of a table */ /** This option permit to access on deleted items of a table */
public class AccessDeletedItems extends QueryOption { public class AccessDeletedItems extends QueryOption {
public AccessDeletedItems() {} public AccessDeletedItems() {}

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */ /** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
public class CheckFunction extends QueryOption { public class CheckFunction extends QueryOption {
private final CheckFunctionInterface checker; private final CheckFunctionInterface checker;

View File

@ -4,7 +4,6 @@ import java.sql.PreparedStatement;
import org.kar.archidata.dataAccess.CountInOut; import org.kar.archidata.dataAccess.CountInOut;
import org.kar.archidata.dataAccess.QueryItem; import org.kar.archidata.dataAccess.QueryItem;
import org.kar.archidata.dataAccess.QueryOption;
import org.kar.archidata.dataAccess.QueryOptions; import org.kar.archidata.dataAccess.QueryOptions;
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */ /** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** This option permit to create the DROP `Table` IF EXIST in the generation of structure. */ /** This option permit to create the DROP `Table` IF EXIST in the generation of structure. */
public class CreateDropTable extends QueryOption { public class CreateDropTable extends QueryOption {
public CreateDropTable() {} public CreateDropTable() {}

View File

@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import org.kar.archidata.GlobalConfiguration; import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.dataAccess.QueryOption;
import org.kar.archidata.dataAccess.QueryOptions; import org.kar.archidata.dataAccess.QueryOptions;
import org.kar.archidata.db.DBConfig; import org.kar.archidata.db.DBConfig;
import org.kar.archidata.db.DBEntry; import org.kar.archidata.db.DBEntry;

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
public class DBInterfaceRoot extends QueryOption { public class DBInterfaceRoot extends QueryOption {
private final boolean root; private final boolean root;

View File

@ -2,8 +2,6 @@ package org.kar.archidata.dataAccess.options;
import java.util.List; import java.util.List;
import org.kar.archidata.dataAccess.QueryOption;
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */ /** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
public class FilterValue extends QueryOption { public class FilterValue extends QueryOption {
public final List<String> filterValue; public final List<String> filterValue;

View File

@ -1,8 +1,10 @@
package org.kar.archidata.dataAccess; package org.kar.archidata.dataAccess.options;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.util.List; import java.util.List;
import org.kar.archidata.dataAccess.CountInOut;
public class GroupBy extends QueryOption { public class GroupBy extends QueryOption {
protected final List<String> childs; protected final List<String> childs;

View File

@ -1,7 +1,10 @@
package org.kar.archidata.dataAccess; package org.kar.archidata.dataAccess.options;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import org.kar.archidata.dataAccess.CountInOut;
import org.kar.archidata.dataAccess.DataAccess;
public class Limit extends QueryOption { public class Limit extends QueryOption {
protected final long limit; protected final long limit;

View File

@ -1,8 +1,10 @@
package org.kar.archidata.dataAccess; package org.kar.archidata.dataAccess.options;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.util.List; import java.util.List;
import org.kar.archidata.dataAccess.CountInOut;
public class OrderBy extends QueryOption { public class OrderBy extends QueryOption {
protected final List<OrderItem> childs; protected final List<OrderItem> childs;

View File

@ -1,4 +1,4 @@
package org.kar.archidata.dataAccess; package org.kar.archidata.dataAccess.options;
public class OrderItem { public class OrderItem {
public enum Order { public enum Order {

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** Option that permit to access to a table structure with an other name that is define in the structure. Note: Internal use for link tables (see: /** Option that permit to access to a table structure with an other name that is define in the structure. Note: Internal use for link tables (see:
* org.kar.archidata.dataAccess.addOn.model.LinkTable). */ * org.kar.archidata.dataAccess.addOn.model.LinkTable). */
public class OverrideTableName extends QueryOption { public class OverrideTableName extends QueryOption {

View File

@ -0,0 +1,3 @@
package org.kar.archidata.dataAccess.options;
public class QueryOption {}

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */ /** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */
public class ReadAllColumn extends QueryOption { public class ReadAllColumn extends QueryOption {
public ReadAllColumn() {} public ReadAllColumn() {}

View File

@ -1,7 +1,5 @@
package org.kar.archidata.dataAccess.options; package org.kar.archidata.dataAccess.options;
import org.kar.archidata.dataAccess.QueryOption;
/** Internal option that permit to transmit the Key when updating the ManyToMany values (first step). */ /** Internal option that permit to transmit the Key when updating the ManyToMany values (first step). */
public class TransmitKey extends QueryOption { public class TransmitKey extends QueryOption {
private final Object key; private final Object key;