From 9f627f0882a7cfbfc771d12fea2d192e434e97a0 Mon Sep 17 00:00:00 2001 From: BartChris Date: Wed, 14 Feb 2024 14:52:25 +0100 Subject: [PATCH] convert Long and BigInteger to a string, fix global search for large numbers --- .../services/data/ProcessService.java | 7 +- .../services/data/ProcessServiceIT.java | 4 + Kitodo/src/test/resources/metadata/5/meta.xml | 2 + Kitodo/src/test/resources/metadata/8/meta.xml | 91 +++++++++++++++++++ 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 Kitodo/src/test/resources/metadata/8/meta.xml diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 24909281c45..68386dfbf85 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.math.BigInteger; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -647,7 +648,7 @@ public List findByAnything(String searchQuery) throws DataException ProcessTypeField.PROJECT_TITLE.getKey(), ProcessTypeField.COMMENTS.getKey(), ProcessTypeField.WIKI_FIELD.getKey(), - ProcessTypeField.TEMPLATE_TITLE.getKey()).operator(Operator.AND); + ProcessTypeField.TEMPLATE_TITLE.getKey()).operator(Operator.AND).lenient(true); if (searchQuery.matches("^\\d*$")) { multiMatchQueryForProcessFields.fields().put(ProcessTypeField.ID.getKey(), 1.0f); @@ -2105,8 +2106,10 @@ private Map iterateOverJsonObject(JSONObject xmlJSONObject) { while (keys.hasNext()) { String key = keys.next(); Object value = xmlJSONObject.get(key); - if (value instanceof String || value instanceof Integer || value instanceof Long) { + if (value instanceof String || value instanceof Integer) { json.put(prepareKey(key), value); + } else if (value instanceof Long || value instanceof BigInteger){ + json.put(prepareKey(key), value.toString()); } else if (value instanceof JSONObject) { JSONObject jsonObject = (JSONObject) value; Map map = iterateOverJsonObject(jsonObject); diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java index 3d2d0b54c85..2b654096ea7 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java @@ -233,6 +233,10 @@ public void shouldFindByMetadataContent() throws DataException { public void shouldFindByLongNumberInMetadata() throws DataException { assertEquals(processNotFound, 1, processService .findByMetadata(Collections.singletonMap("CatalogIDDigital", "999999999999999991")).size()); + assertEquals(processNotFound, 1, processService + .findByMetadata(Collections.singletonMap("CatalogIDDigital", "991022551489706476")).size()); + assertEquals(processNotFound, 1, processService + .findByMetadata(Collections.singletonMap("CatalogIDDigital", "999999999999999999999999991")).size()); } @Test diff --git a/Kitodo/src/test/resources/metadata/5/meta.xml b/Kitodo/src/test/resources/metadata/5/meta.xml index ca358459ed2..045a27689db 100644 --- a/Kitodo/src/test/resources/metadata/5/meta.xml +++ b/Kitodo/src/test/resources/metadata/5/meta.xml @@ -16,6 +16,8 @@ Second Proc 999999999999999991 + 991022551489706476 + 999999999999999999999999991 diff --git a/Kitodo/src/test/resources/metadata/8/meta.xml b/Kitodo/src/test/resources/metadata/8/meta.xml new file mode 100644 index 00000000000..46f0b9d3a98 --- /dev/null +++ b/Kitodo/src/test/resources/metadata/8/meta.xml @@ -0,0 +1,91 @@ + + + + 8 + + + + + + Lit.Graec.B.2615 + lat + [11] Bl., 825, [118] Bl. + Argentorati + 1713 + Editio Postrema curante Joh. Henrico Lederlino + 1087020662 + 11111 + Dulssecker + Monograph + gre + VD18 11358211 + + Komm. + Kühn, Joachim + Joachim + Kühn + 1231853166 + + + Hrsg. + Lederlin + gnd + Jean Henri + 077449827 + 115755470 + http://d-nb.info/gnd/115755470 + Lederlin, Jean Henri + + + Scheffer, Johannes + Komm. + gnd + Scheffer + 100331181 + Johannes + 13970907X + http://d-nb.info/gnd/100331181 + + + http://d-nb.info/gnd/124906761 + Vultejus, Justus + gnd + 367774283 + 124906761 + Übers. + Justus + Vultejus + + + http://d-nb.info/gnd/119160285 + gnd + Aelianus, Claudius + Aelianus + 119160285 + 079955614 + Claudius + + + + + + + + + + + Ki. tolianu dophistu + + + + + + + + + + + + + +