From 29a6e7602ce871ba62e2d3a4e4745a2164fb56d1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 28 Apr 2024 11:44:01 +0200 Subject: [PATCH] [FEAT] add capability to set condition in update --- src/org/kar/archidata/dataAccess/DataAccess.java | 5 +++-- src/org/kar/archidata/tools/RESTApi.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/kar/archidata/dataAccess/DataAccess.java b/src/org/kar/archidata/dataAccess/DataAccess.java index 1a7e684..88f77c2 100644 --- a/src/org/kar/archidata/dataAccess/DataAccess.java +++ b/src/org/kar/archidata/dataAccess/DataAccess.java @@ -1031,9 +1031,10 @@ public class DataAccess { final QueryOptions options = new QueryOptions(option); final Condition condition = options.get(Condition.class); if (condition != null) { - throw new DataAccessException("request a updateWithJson with a condition"); + options.add(new Condition(new QueryAnd(getTableIdCondition(clazz, id), condition.condition))); + } else { + options.add(new Condition(getTableIdCondition(clazz, id))); } - options.add(new Condition(getTableIdCondition(clazz, id))); options.add(new TransmitKey(id)); return updateWhereWithJson(clazz, jsonData, options.getAllArray()); } diff --git a/src/org/kar/archidata/tools/RESTApi.java b/src/org/kar/archidata/tools/RESTApi.java index 311effc..3cce870 100644 --- a/src/org/kar/archidata/tools/RESTApi.java +++ b/src/org/kar/archidata/tools/RESTApi.java @@ -121,6 +121,7 @@ public class RESTApi { final HttpRequest request = requestBuilding.method(model, BodyPublishers.ofString(body)).build(); final HttpResponse httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); if (httpResponse.statusCode() < 200 || httpResponse.statusCode() >= 300) { + LOGGER.trace("Receive Error: {}", httpResponse.body()); try { final RESTErrorResponseExeption out = this.mapper.readValue(httpResponse.body(), RESTErrorResponseExeption.class); throw out;