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 27808aa5712..3bd606fa88b 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; @@ -655,7 +656,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); @@ -812,7 +813,7 @@ public List findLinkableParentProcesses(String searchInput, int proj BoolQueryBuilder processQuery = new BoolQueryBuilder() .should(createSimpleWildcardQuery(ProcessTypeField.TITLE.getKey(), searchInput)); if (searchInput.matches("\\d*")) { - processQuery.should(new MatchQueryBuilder(ProcessTypeField.ID.getKey(), searchInput)); + processQuery.should(new MatchQueryBuilder(ProcessTypeField.ID.getKey(), searchInput).lenient(true)); } BoolQueryBuilder query = new BoolQueryBuilder().must(processQuery) .must(new MatchQueryBuilder(ProcessTypeField.PROJECT_ID.getKey(), projectId)) @@ -2126,6 +2127,8 @@ private Map iterateOverJsonObject(JSONObject xmlJSONObject) { Object value = xmlJSONObject.get(key); 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 70567641158..51fb6c62c55 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 @@ -239,6 +239,19 @@ public void shouldFindByMetadataContent() throws DataException, DAOException, IO ProcessTestUtils.removeTestProcess(testProcessId); } + @Test + public void shouldFindByLongNumberInMetadata() throws DataException, DAOException, IOException { + int processId = MockDatabase.insertTestProcess("Test process", 1, 1, 1); + ProcessTestUtils.copyTestMetadataFile(processId, ProcessTestUtils.testFileForLongNumbers); + 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()); + ProcessTestUtils.removeTestProcess(processId); + } + @Test public void shouldFindProcessWithUnderscore() throws DataException, DAOException { Project project = ServiceManager.getProjectService().getById(1); diff --git a/Kitodo/src/test/java/org/kitodo/test/utils/ProcessTestUtils.java b/Kitodo/src/test/java/org/kitodo/test/utils/ProcessTestUtils.java index b92b6b8c07b..fd472582570 100644 --- a/Kitodo/src/test/java/org/kitodo/test/utils/ProcessTestUtils.java +++ b/Kitodo/src/test/java/org/kitodo/test/utils/ProcessTestUtils.java @@ -52,6 +52,7 @@ public class ProcessTestUtils { private static final int TEST_TEMPLATE_ID = 1; private static final String ID_PLACEHOLDER = "IDENTIFIER_PLACEHOLDER"; public static final String testFileForHierarchyParent = "multivalued_metadata.xml"; + public static final String testFileForLongNumbers = "testMetadataWithLongNumbers.xml"; public static final String testFileChildProcessToKeep = "testMetadataForChildProcessToKeep.xml"; private static final String testFileChildProcessToRemove = "testMetadataForKitodoScript.xml"; private static final Map hierarchyProcessTitlesAndFiles; diff --git a/Kitodo/src/test/resources/metadata/metadataFiles/testMetadataWithLongNumbers.xml b/Kitodo/src/test/resources/metadata/metadataFiles/testMetadataWithLongNumbers.xml new file mode 100644 index 00000000000..045a27689db --- /dev/null +++ b/Kitodo/src/test/resources/metadata/metadataFiles/testMetadataWithLongNumbers.xml @@ -0,0 +1,43 @@ + + + + + Kitodo - kitodo-ugh-3.0-SNAPSHOT - 18-April-2018 13:20:13 + Kitodo + + + + + + + Second process + Second + Proc + 999999999999999991 + 991022551489706476 + 999999999999999999999999991 + + + + + + + + + file:/2/images/Sec_Proc_tif + + + + + + + + + + + + + +