diff --git a/src/org/kar/archidata/UserDB.java b/src/org/kar/archidata/UserDB.java index 54bd41e..c7d2e73 100755 --- a/src/org/kar/archidata/UserDB.java +++ b/src/org/kar/archidata/UserDB.java @@ -5,9 +5,9 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import org.kar.archidata.dataAccess.DataAccess; -import org.kar.archidata.dataAccess.QueryOption; import org.kar.archidata.dataAccess.QueryOptions; import org.kar.archidata.dataAccess.options.DBInterfaceOption; +import org.kar.archidata.dataAccess.options.QueryOption; import org.kar.archidata.db.DBEntry; import org.kar.archidata.model.User; diff --git a/src/org/kar/archidata/dataAccess/DataAccess.java b/src/org/kar/archidata/dataAccess/DataAccess.java index 2bfee69..9dc6cc1 100644 --- a/src/org/kar/archidata/dataAccess/DataAccess.java +++ b/src/org/kar/archidata/dataAccess/DataAccess.java @@ -31,6 +31,10 @@ import org.kar.archidata.dataAccess.options.Condition; import org.kar.archidata.dataAccess.options.DBInterfaceOption; import org.kar.archidata.dataAccess.options.DBInterfaceRoot; 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.db.DBEntry; import org.kar.archidata.exception.DataAccessException; @@ -1224,7 +1228,8 @@ public class DataAccess { 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) { final byte[] dataByte = UuidUtils.asBytes(tmp); ps.setBytes(iii.value, dataByte); diff --git a/src/org/kar/archidata/dataAccess/DataExport.java b/src/org/kar/archidata/dataAccess/DataExport.java index bb79948..bb0c150 100644 --- a/src/org/kar/archidata/dataAccess/DataExport.java +++ b/src/org/kar/archidata/dataAccess/DataExport.java @@ -20,6 +20,10 @@ import org.kar.archidata.dataAccess.exportTools.TableQuery; import org.kar.archidata.dataAccess.exportTools.TableQueryTypes; import org.kar.archidata.dataAccess.options.Condition; 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.exception.DataAccessException; import org.kar.archidata.tools.DateTools; diff --git a/src/org/kar/archidata/dataAccess/QueryAnd.java b/src/org/kar/archidata/dataAccess/QueryAnd.java index e6a720c..55f7f4a 100644 --- a/src/org/kar/archidata/dataAccess/QueryAnd.java +++ b/src/org/kar/archidata/dataAccess/QueryAnd.java @@ -8,17 +8,17 @@ import java.util.List; public class QueryAnd implements QueryItem { protected final List childs; - public QueryAnd(final List childs) { - this.childs = childs; + public QueryAnd(final List child) { + this.childs = child; } - public QueryAnd(final QueryItem... items) { + public QueryAnd(final QueryItem... child) { this.childs = new ArrayList<>(); - Collections.addAll(this.childs, items); + Collections.addAll(this.childs, child); } - public void add(final QueryItem... items) { - Collections.addAll(this.childs, items); + public void add(final QueryItem... child) { + Collections.addAll(this.childs, child); } @Override diff --git a/src/org/kar/archidata/dataAccess/QueryCondition.java b/src/org/kar/archidata/dataAccess/QueryCondition.java index 94d17c5..c399d3f 100644 --- a/src/org/kar/archidata/dataAccess/QueryCondition.java +++ b/src/org/kar/archidata/dataAccess/QueryCondition.java @@ -7,6 +7,12 @@ public class QueryCondition implements QueryItem { private final String comparator; 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) { this.key = key; this.comparator = comparator; diff --git a/src/org/kar/archidata/dataAccess/QueryOption.java b/src/org/kar/archidata/dataAccess/QueryOption.java deleted file mode 100644 index 3a986dd..0000000 --- a/src/org/kar/archidata/dataAccess/QueryOption.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.kar.archidata.dataAccess; - -public class QueryOption {} diff --git a/src/org/kar/archidata/dataAccess/QueryOptions.java b/src/org/kar/archidata/dataAccess/QueryOptions.java index ea15981..4c0b268 100644 --- a/src/org/kar/archidata/dataAccess/QueryOptions.java +++ b/src/org/kar/archidata/dataAccess/QueryOptions.java @@ -6,6 +6,7 @@ import java.util.List; import org.kar.archidata.dataAccess.options.AccessDeletedItems; import org.kar.archidata.dataAccess.options.CreateDropTable; +import org.kar.archidata.dataAccess.options.QueryOption; import org.kar.archidata.dataAccess.options.ReadAllColumn; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/org/kar/archidata/dataAccess/exportTools/README.md b/src/org/kar/archidata/dataAccess/exportTools/README.md new file mode 100644 index 0000000..cbb2b9e --- /dev/null +++ b/src/org/kar/archidata/dataAccess/exportTools/README.md @@ -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 + + + + gitea + + + + Authorization + token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + + + + + + +``` + +release: +======== + +```bash +export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH +mvn install +mvn deploy +``` + + diff --git a/src/org/kar/archidata/dataAccess/options/AccessDeletedItems.java b/src/org/kar/archidata/dataAccess/options/AccessDeletedItems.java index 278941d..1f486e1 100644 --- a/src/org/kar/archidata/dataAccess/options/AccessDeletedItems.java +++ b/src/org/kar/archidata/dataAccess/options/AccessDeletedItems.java @@ -1,7 +1,5 @@ package org.kar.archidata.dataAccess.options; -import org.kar.archidata.dataAccess.QueryOption; - /** This option permit to access on deleted items of a table */ public class AccessDeletedItems extends QueryOption { public AccessDeletedItems() {} diff --git a/src/org/kar/archidata/dataAccess/options/CheckFunction.java b/src/org/kar/archidata/dataAccess/options/CheckFunction.java index 22d83ff..ce3d5a7 100644 --- a/src/org/kar/archidata/dataAccess/options/CheckFunction.java +++ b/src/org/kar/archidata/dataAccess/options/CheckFunction.java @@ -1,7 +1,5 @@ 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. */ public class CheckFunction extends QueryOption { private final CheckFunctionInterface checker; diff --git a/src/org/kar/archidata/dataAccess/options/Condition.java b/src/org/kar/archidata/dataAccess/options/Condition.java index b4a7167..7831a80 100644 --- a/src/org/kar/archidata/dataAccess/options/Condition.java +++ b/src/org/kar/archidata/dataAccess/options/Condition.java @@ -4,7 +4,6 @@ import java.sql.PreparedStatement; import org.kar.archidata.dataAccess.CountInOut; import org.kar.archidata.dataAccess.QueryItem; -import org.kar.archidata.dataAccess.QueryOption; import org.kar.archidata.dataAccess.QueryOptions; /** By default some element are not read like createAt and UpdatedAt. This option permit to read it. */ diff --git a/src/org/kar/archidata/dataAccess/options/CreateDropTable.java b/src/org/kar/archidata/dataAccess/options/CreateDropTable.java index b4b2878..c0e6d22 100644 --- a/src/org/kar/archidata/dataAccess/options/CreateDropTable.java +++ b/src/org/kar/archidata/dataAccess/options/CreateDropTable.java @@ -1,7 +1,5 @@ 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. */ public class CreateDropTable extends QueryOption { public CreateDropTable() {} diff --git a/src/org/kar/archidata/dataAccess/options/DBInterfaceOption.java b/src/org/kar/archidata/dataAccess/options/DBInterfaceOption.java index 2f02375..1d317bf 100644 --- a/src/org/kar/archidata/dataAccess/options/DBInterfaceOption.java +++ b/src/org/kar/archidata/dataAccess/options/DBInterfaceOption.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.util.List; import org.kar.archidata.GlobalConfiguration; -import org.kar.archidata.dataAccess.QueryOption; import org.kar.archidata.dataAccess.QueryOptions; import org.kar.archidata.db.DBConfig; import org.kar.archidata.db.DBEntry; diff --git a/src/org/kar/archidata/dataAccess/options/DBInterfaceRoot.java b/src/org/kar/archidata/dataAccess/options/DBInterfaceRoot.java index 777177b..3796b5a 100644 --- a/src/org/kar/archidata/dataAccess/options/DBInterfaceRoot.java +++ b/src/org/kar/archidata/dataAccess/options/DBInterfaceRoot.java @@ -1,7 +1,5 @@ package org.kar.archidata.dataAccess.options; -import org.kar.archidata.dataAccess.QueryOption; - public class DBInterfaceRoot extends QueryOption { private final boolean root; diff --git a/src/org/kar/archidata/dataAccess/options/FilterValue.java b/src/org/kar/archidata/dataAccess/options/FilterValue.java index de20c0f..06ce818 100644 --- a/src/org/kar/archidata/dataAccess/options/FilterValue.java +++ b/src/org/kar/archidata/dataAccess/options/FilterValue.java @@ -2,8 +2,6 @@ package org.kar.archidata.dataAccess.options; 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. */ public class FilterValue extends QueryOption { public final List filterValue; diff --git a/src/org/kar/archidata/dataAccess/GroupBy.java b/src/org/kar/archidata/dataAccess/options/GroupBy.java similarity index 89% rename from src/org/kar/archidata/dataAccess/GroupBy.java rename to src/org/kar/archidata/dataAccess/options/GroupBy.java index 93bfca3..d0acf12 100644 --- a/src/org/kar/archidata/dataAccess/GroupBy.java +++ b/src/org/kar/archidata/dataAccess/options/GroupBy.java @@ -1,8 +1,10 @@ -package org.kar.archidata.dataAccess; +package org.kar.archidata.dataAccess.options; import java.sql.PreparedStatement; import java.util.List; +import org.kar.archidata.dataAccess.CountInOut; + public class GroupBy extends QueryOption { protected final List childs; diff --git a/src/org/kar/archidata/dataAccess/Limit.java b/src/org/kar/archidata/dataAccess/options/Limit.java similarity index 75% rename from src/org/kar/archidata/dataAccess/Limit.java rename to src/org/kar/archidata/dataAccess/options/Limit.java index 463655d..fbabb21 100644 --- a/src/org/kar/archidata/dataAccess/Limit.java +++ b/src/org/kar/archidata/dataAccess/options/Limit.java @@ -1,7 +1,10 @@ -package org.kar.archidata.dataAccess; +package org.kar.archidata.dataAccess.options; import java.sql.PreparedStatement; +import org.kar.archidata.dataAccess.CountInOut; +import org.kar.archidata.dataAccess.DataAccess; + public class Limit extends QueryOption { protected final long limit; diff --git a/src/org/kar/archidata/dataAccess/OrderBy.java b/src/org/kar/archidata/dataAccess/options/OrderBy.java similarity index 90% rename from src/org/kar/archidata/dataAccess/OrderBy.java rename to src/org/kar/archidata/dataAccess/options/OrderBy.java index 13ed706..be0a10e 100644 --- a/src/org/kar/archidata/dataAccess/OrderBy.java +++ b/src/org/kar/archidata/dataAccess/options/OrderBy.java @@ -1,8 +1,10 @@ -package org.kar.archidata.dataAccess; +package org.kar.archidata.dataAccess.options; import java.sql.PreparedStatement; import java.util.List; +import org.kar.archidata.dataAccess.CountInOut; + public class OrderBy extends QueryOption { protected final List childs; diff --git a/src/org/kar/archidata/dataAccess/OrderItem.java b/src/org/kar/archidata/dataAccess/options/OrderItem.java similarity index 83% rename from src/org/kar/archidata/dataAccess/OrderItem.java rename to src/org/kar/archidata/dataAccess/options/OrderItem.java index 10c4f20..49ca705 100644 --- a/src/org/kar/archidata/dataAccess/OrderItem.java +++ b/src/org/kar/archidata/dataAccess/options/OrderItem.java @@ -1,4 +1,4 @@ -package org.kar.archidata.dataAccess; +package org.kar.archidata.dataAccess.options; public class OrderItem { public enum Order { diff --git a/src/org/kar/archidata/dataAccess/options/OverrideTableName.java b/src/org/kar/archidata/dataAccess/options/OverrideTableName.java index 141489e..506eaa6 100644 --- a/src/org/kar/archidata/dataAccess/options/OverrideTableName.java +++ b/src/org/kar/archidata/dataAccess/options/OverrideTableName.java @@ -1,7 +1,5 @@ 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: * org.kar.archidata.dataAccess.addOn.model.LinkTable). */ public class OverrideTableName extends QueryOption { diff --git a/src/org/kar/archidata/dataAccess/options/QueryOption.java b/src/org/kar/archidata/dataAccess/options/QueryOption.java new file mode 100644 index 0000000..9f686f0 --- /dev/null +++ b/src/org/kar/archidata/dataAccess/options/QueryOption.java @@ -0,0 +1,3 @@ +package org.kar.archidata.dataAccess.options; + +public class QueryOption {} diff --git a/src/org/kar/archidata/dataAccess/options/ReadAllColumn.java b/src/org/kar/archidata/dataAccess/options/ReadAllColumn.java index fdd31e9..2c78825 100644 --- a/src/org/kar/archidata/dataAccess/options/ReadAllColumn.java +++ b/src/org/kar/archidata/dataAccess/options/ReadAllColumn.java @@ -1,7 +1,5 @@ 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. */ public class ReadAllColumn extends QueryOption { public ReadAllColumn() {} diff --git a/src/org/kar/archidata/dataAccess/options/TransmitKey.java b/src/org/kar/archidata/dataAccess/options/TransmitKey.java index 933600e..2048529 100644 --- a/src/org/kar/archidata/dataAccess/options/TransmitKey.java +++ b/src/org/kar/archidata/dataAccess/options/TransmitKey.java @@ -1,7 +1,5 @@ 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). */ public class TransmitKey extends QueryOption { private final Object key;