From 8dad6c44df1583a94c6bfb61ccc1e2670d4267da Mon Sep 17 00:00:00 2001 From: Andrei Isvoran Date: Mon, 4 Dec 2023 12:31:47 +0100 Subject: [PATCH] RED-7404 - Migrate to gradle --- .gitignore | 8 + .gitlab-ci.yml | 25 +- buildSrc/build.gradle.kts | 7 + ...er.red.service.java-conventions.gradle.kts | 56 ++++ config/checkstyle/checkstyle.xml | 39 +++ config/pmd/pmd.xml | 21 ++ config/pmd/test_pmd.xml | 24 ++ gradle.properties.kts | 1 + persistence-service-image-v1/pom.xml | 96 ------ .../src/main/docker/Dockerfile | 9 - .../build.gradle.kts | 12 + .../pom.xml | 29 -- .../controller/DossierTemplateController.java | 3 +- .../impl/controller/HighlightsController.java | 9 +- .../controller/ReportTemplateController.java | 1 + .../api/impl/controller/UploadController.java | 4 +- .../build.gradle.kts | 12 + .../pom.xml | 39 --- .../DossierTemplateControllerV2.java | 3 +- .../build.gradle.kts | 25 ++ .../pom.xml | 141 -------- .../build.gradle.kts | 26 ++ .../pom.xml | 147 -------- .../v2/api/external/model/lombok.config | 1 - .../build.gradle.kts | 12 + .../pom.xml | 28 -- .../build.gradle.kts | 16 + .../pom.xml | 60 ---- .../build.gradle.kts | 52 +++ .../persistence-service-processor-v1/pom.xml | 308 ----------------- .../entity/configuration/ColorsEntity.java | 4 +- .../migration/MigrationStarterService.java | 1 + .../ReduceTextFileSizeMigration10.java | 1 + .../service/DictionaryManagementService.java | 3 +- .../v1/processor/service/DownloadService.java | 1 - .../FileAttributesManagementService.java | 3 +- .../service/FileManagementStorageService.java | 1 + .../repository/CommentRepository.java | 9 +- .../DigitalSignatureRepository.java | 7 +- .../DossierAttributeConfigRepository.java | 3 +- .../DossierAttributeRepository.java | 7 +- .../repository/DossierRepository.java | 35 +- .../repository/DossierStatusRepository.java | 20 +- .../repository/DossierTemplateRepository.java | 3 +- ...DownloadRedactionFileStatusRepository.java | 14 +- .../repository/DownloadStatusRepository.java | 8 +- .../FileAttributeConfigRepository.java | 7 +- .../repository/FileAttributesRepository.java | 7 +- .../repository/FileRepository.java | 317 +++++++++++++----- .../repository/NotificationRepository.java | 19 +- .../repository/ReportTemplateRepository.java | 3 +- .../repository/RuleSetRepository.java | 5 +- .../SaasMigrationStatusRepository.java | 10 +- .../repository/TypeRepository.java | 47 ++- .../repository/ViewedPagesRepository.java | 3 +- .../ForceRedactionRepository.java | 22 +- .../LegalBasisChangeRepository.java | 22 +- .../ManualRedactionRepository.java | 26 +- .../RecategorizationRepository.java | 21 +- .../RemoveRedactionRepository.java | 18 +- .../ResizeRedactionRepository.java | 28 +- .../dictionaryentry/EntryRepository.java | 30 +- .../FalsePositiveEntryRepository.java | 7 +- .../FalseRecommendationEntryRepository.java | 7 +- .../v1/processor/utils/ResourceLoader.java | 1 + .../build.gradle.kts | 57 ++++ .../persistence-service-server-v1/pom.xml | 151 --------- .../tests/DossierTemplateTest.java | 1 + .../server/integration/tests/DossierTest.java | 1 + .../utils/KneconRedisTestContainer.java | 2 +- .../KneconSpringPostgreSQLTestContainer.java | 1 + .../integration/utils/RedisTestContainer.java | 2 +- .../utils/SpringPostgreSQLTestContainer.java | 2 +- .../server/utils/MetricsPrinterService.java | 1 + .../utils/FileSystemBackedArchiverTest.java | 1 + .../build.gradle.kts | 19 ++ .../persistence-service-shared-api-v1/pom.xml | 73 ---- .../service/v1/api/shared/model/lombok.config | 1 - persistence-service-v1/pom.xml | 146 -------- pom.xml | 20 -- publish-custom-docker-img.sh | 27 -- publish-custom-image.sh | 15 + settings.gradle.kts | 19 ++ 83 files changed, 888 insertions(+), 1585 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/com.iqser.red.service.java-conventions.gradle.kts create mode 100644 config/checkstyle/checkstyle.xml create mode 100644 config/pmd/pmd.xml create mode 100644 config/pmd/test_pmd.xml create mode 100644 gradle.properties.kts delete mode 100644 persistence-service-image-v1/pom.xml delete mode 100644 persistence-service-image-v1/src/main/docker/Dockerfile create mode 100644 persistence-service-v1/persistence-service-external-api-impl-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-external-api-impl-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-external-api-impl-v2/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-external-api-impl-v2/pom.xml create mode 100644 persistence-service-v1/persistence-service-external-api-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-external-api-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-external-api-v2/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-external-api-v2/pom.xml delete mode 100644 persistence-service-v1/persistence-service-external-api-v2/src/main/java/com/iqser/red/service/persistence/service/v2/api/external/model/lombok.config create mode 100644 persistence-service-v1/persistence-service-internal-api-impl-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-internal-api-impl-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-internal-api-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-internal-api-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-processor-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-processor-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-server-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-server-v1/pom.xml create mode 100644 persistence-service-v1/persistence-service-shared-api-v1/build.gradle.kts delete mode 100644 persistence-service-v1/persistence-service-shared-api-v1/pom.xml delete mode 100644 persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/lombok.config delete mode 100755 persistence-service-v1/pom.xml delete mode 100644 pom.xml delete mode 100755 publish-custom-docker-img.sh create mode 100755 publish-custom-image.sh create mode 100644 settings.gradle.kts diff --git a/.gitignore b/.gitignore index 6bb4badae..57b168b92 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,11 @@ **/.DS_Store **/classpath-data.json **/dependencies-and-licenses-overview.txt + +gradle.properties +gradlew +gradlew.bat +gradle/ + +**/.gradle +**/build \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da80a492c..a6c0ef0c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,27 @@ variables: - SONAR_PROJECT_KEY: 'RED_persistence-service' + SONAR_PROJECT_KEY: 'RED_redaction-report-service' include: - project: 'gitlab/gitlab' ref: 'main' - file: 'ci-templates/maven_java.yml' + file: 'ci-templates/gradle_java.yml' + +deploy: + stage: deploy + tags: + - dind + variables: + DOCKER_AUTH_CONFIG: $CI_NEXUS_DOCKER_CONFIG_JSON + DOCKER_HOST: "tcp://docker:2375" + DOCKER_TLS_CERTDIR: "" + script: + - echo "Building with gradle version ${BUILDVERSION}" + - gradle -Pversion=${BUILDVERSION} publish + - gradle bootBuildImage --cleanCache --publishImage -PbuildbootDockerHostNetwork=true -Pversion=${BUILDVERSION} + - echo "BUILDVERSION=$BUILDVERSION" >> version.env + artifacts: + reports: + dotenv: version.env + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_COMMIT_BRANCH =~ /^release/ + - if: $CI_COMMIT_TAG \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..cc02e636b --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() +} diff --git a/buildSrc/src/main/kotlin/com.iqser.red.service.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/com.iqser.red.service.java-conventions.gradle.kts new file mode 100644 index 000000000..7f4af15cc --- /dev/null +++ b/buildSrc/src/main/kotlin/com.iqser.red.service.java-conventions.gradle.kts @@ -0,0 +1,56 @@ +plugins { + `java-library` + `maven-publish` + pmd + checkstyle + jacoco +} + +repositories { + mavenLocal() + mavenCentral() + maven { + url = uri("https://nexus.knecon.com/repository/gindev/"); + credentials { + username = providers.gradleProperty("mavenUser").getOrNull(); + password = providers.gradleProperty("mavenPassword").getOrNull(); + } + } +} + +group = "com.iqser.red.service" + +java.sourceCompatibility = JavaVersion.VERSION_17 +java.targetCompatibility = JavaVersion.VERSION_17 + +tasks.pmdMain { + pmd.ruleSetFiles = files("${rootDir}/config/pmd/pmd.xml") +} + +tasks.pmdTest { + pmd.ruleSetFiles = files("${rootDir}/config/pmd/test_pmd.xml") +} + +tasks.named("test") { + useJUnitPlatform() + reports { + junitXml.outputLocation.set(layout.buildDirectory.dir("reports/junit")) + } +} + +tasks.test { + finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run +} + +tasks.jacocoTestReport { + dependsOn(tasks.test) // tests are required to run before generating the report + reports { + xml.required.set(true) + csv.required.set(false) + html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml")) + } +} + +java { + withJavadocJar() +} \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 000000000..8faaf13b4 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/pmd/pmd.xml b/config/pmd/pmd.xml new file mode 100644 index 000000000..22d6d4cd6 --- /dev/null +++ b/config/pmd/pmd.xml @@ -0,0 +1,21 @@ + + + + + Knecon ruleset checks the code for bad stuff + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/pmd/test_pmd.xml b/config/pmd/test_pmd.xml new file mode 100644 index 000000000..56d37d9e5 --- /dev/null +++ b/config/pmd/test_pmd.xml @@ -0,0 +1,24 @@ + + + + + Knecon test ruleset checks the code for bad stuff + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle.properties.kts b/gradle.properties.kts new file mode 100644 index 000000000..150928392 --- /dev/null +++ b/gradle.properties.kts @@ -0,0 +1 @@ +version = 4.0-SNAPSHOT diff --git a/persistence-service-image-v1/pom.xml b/persistence-service-image-v1/pom.xml deleted file mode 100644 index 53b4f22b3..000000000 --- a/persistence-service-image-v1/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - com.knecon.fforesight - platform-docker-dependency - 0.1.0 - - - 4.0.0 - - persistence-service-image-v1 - com.iqser.red.service - 2.0-SNAPSHOT - pom - - - persistence-service-server-v1 - ${service.server}.jar - false - ${docker.image.prefix}/${service.server} - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.codehaus.mojo - exec-maven-plugin - - - io.fabric8 - docker-maven-plugin - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - download-platform-jar - prepare-package - - copy - - - - - ${project.groupId} - ${service.server} - ${project.version} - jar - true - ${platform.jar} - - - ${docker.build.directory} - - - - - - io.fabric8 - docker-maven-plugin - - - - ${docker.image.name} - - ${docker.build.directory} - - ${platform.jar} - - - ${docker.image.version} - - - - - - - - - - diff --git a/persistence-service-image-v1/src/main/docker/Dockerfile b/persistence-service-image-v1/src/main/docker/Dockerfile deleted file mode 100644 index ca4a90669..000000000 --- a/persistence-service-image-v1/src/main/docker/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM red/base-image:2.0.2 - -ARG PLATFORM_JAR - -ENV PLATFORM_JAR ${PLATFORM_JAR} - -ENV USES_ELASTICSEARCH false - -COPY ["${PLATFORM_JAR}", "/"] diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/build.gradle.kts b/persistence-service-v1/persistence-service-external-api-impl-v1/build.gradle.kts new file mode 100644 index 000000000..48abd0167 --- /dev/null +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.spring.dependency-management") version "1.1.3" + id("org.sonarqube") version "4.4.1.3373" + id("io.freefair.lombok") version "8.4" +} + +dependencies { + api(project(":persistence-service-processor-v1")) +} + +description = "persistence-service-external-api-impl-v1" diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/pom.xml b/persistence-service-v1/persistence-service-external-api-impl-v1/pom.xml deleted file mode 100644 index 9ee0c3019..000000000 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-external-api-impl-v1 - - 1.7.30 - UTF-8 - - - - - com.iqser.red.service - persistence-service-processor-v1 - ${project.version} - - - - - diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/DossierTemplateController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/DossierTemplateController.java index 882a3935e..a90da71b6 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/DossierTemplateController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/DossierTemplateController.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -243,7 +244,7 @@ public class DossierTemplateController implements DossierTemplateResource { if (originalFileName == null || originalFileName.isEmpty()) { throw new BadRequestException("Could not upload file, no filename provided."); } - var extension = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase(); + var extension = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase(Locale.ROOT); if ("zip".equalsIgnoreCase(extension)) { if (StringUtils.isEmpty(dossierTemplateId) && updateExistingDossierTemplate) { throw new BadRequestException("Could not update with dossier template empty"); diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/HighlightsController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/HighlightsController.java index 18b5e0a7a..ebd8c704a 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/HighlightsController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/HighlightsController.java @@ -52,10 +52,11 @@ public class HighlightsController implements HighlightsResource { fileStatusService.getStatus(fileId); if (storageService.objectExists(TenantContext.getTenantId(), getStorageId(dossierId, fileId, FileType.TEXT_HIGHLIGHTS))) { - InputStream stream = fileManagementStorageService.getObject(TenantContext.getTenantId(), getStorageId(dossierId, fileId, FileType.TEXT_HIGHLIGHTS)); - Highlights highlights = objectMapper.readValue(stream, Highlights.class); - stream.close(); - return highlights; + try(InputStream stream = fileManagementStorageService.getObject(TenantContext.getTenantId(), getStorageId(dossierId, fileId, FileType.TEXT_HIGHLIGHTS))) { + Highlights highlights = objectMapper.readValue(stream, Highlights.class); + stream.close(); + return highlights; + } } return new Highlights(); diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ReportTemplateController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ReportTemplateController.java index d4713df9c..f99a6f406 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ReportTemplateController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ReportTemplateController.java @@ -59,6 +59,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @RestController @RequiredArgsConstructor +@SuppressWarnings("PMD") public class ReportTemplateController implements ReportTemplateResource { private final ReportTemplatePlaceholderClient reportTemplatePlaceholderClient; diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/UploadController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/UploadController.java index e61dac23d..b0849b3fc 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/UploadController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/UploadController.java @@ -8,6 +8,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -44,6 +45,7 @@ import lombok.extern.slf4j.Slf4j; @RestController @RequiredArgsConstructor @Slf4j +@SuppressWarnings("PMD") public class UploadController implements UploadResource { private static final int THRESHOLD_ENTRIES = 10000; @@ -119,7 +121,7 @@ public class UploadController implements UploadResource { private String getExtension(String fileName) { - return fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); + return fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.ROOT); } diff --git a/persistence-service-v1/persistence-service-external-api-impl-v2/build.gradle.kts b/persistence-service-v1/persistence-service-external-api-impl-v2/build.gradle.kts new file mode 100644 index 000000000..88086af39 --- /dev/null +++ b/persistence-service-v1/persistence-service-external-api-impl-v2/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.freefair.lombok") version "8.4" +} + +dependencies { + api(project(":persistence-service-processor-v1")) + api(project(":persistence-service-external-api-v2")) + api(project(":persistence-service-external-api-impl-v1")) +} + +description = "persistence-service-external-api-impl-v2" diff --git a/persistence-service-v1/persistence-service-external-api-impl-v2/pom.xml b/persistence-service-v1/persistence-service-external-api-impl-v2/pom.xml deleted file mode 100644 index f68c42c68..000000000 --- a/persistence-service-v1/persistence-service-external-api-impl-v2/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-external-api-impl-v2 - - 1.7.30 - UTF-8 - - - - - com.iqser.red.service - persistence-service-processor-v1 - ${project.version} - - - com.iqser.red.service - persistence-service-external-api-v2 - ${project.version} - - - com.iqser.red.service - persistence-service-external-api-impl-v1 - ${project.version} - - - - - diff --git a/persistence-service-v1/persistence-service-external-api-impl-v2/src/main/java/com/iqser/red/persistence/service/v2/external/api/impl/controller/DossierTemplateControllerV2.java b/persistence-service-v1/persistence-service-external-api-impl-v2/src/main/java/com/iqser/red/persistence/service/v2/external/api/impl/controller/DossierTemplateControllerV2.java index eaf465c56..d666b8909 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v2/src/main/java/com/iqser/red/persistence/service/v2/external/api/impl/controller/DossierTemplateControllerV2.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v2/src/main/java/com/iqser/red/persistence/service/v2/external/api/impl/controller/DossierTemplateControllerV2.java @@ -9,6 +9,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Locale; import org.springframework.core.io.InputStreamResource; import org.springframework.http.HttpHeaders; @@ -207,7 +208,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.TEXT_PLAIN); - httpHeaders.add("Content-Disposition", "attachment" + "; filename*=utf-8''" + StringEncodingUtils.urlEncode(ruleFileType.name().toLowerCase() + RULES_DOWNLOAD_FILE_NAME_SUFFIX)); + httpHeaders.add("Content-Disposition", "attachment" + "; filename*=utf-8''" + StringEncodingUtils.urlEncode(ruleFileType.name().toLowerCase(Locale.ROOT) + RULES_DOWNLOAD_FILE_NAME_SUFFIX)); InputStream is = new ByteArrayInputStream(data); diff --git a/persistence-service-v1/persistence-service-external-api-v1/build.gradle.kts b/persistence-service-v1/persistence-service-external-api-v1/build.gradle.kts new file mode 100644 index 000000000..3296df16e --- /dev/null +++ b/persistence-service-v1/persistence-service-external-api-v1/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("com.iqser.red.service.java-conventions") +} + +dependencies { + api(project(":persistence-service-internal-api-v1")) + api("com.iqser.red.service:pdftron-redaction-service-api-v1:4.38.0") + api("com.iqser.red.service:redaction-service-api-v1:4.177.0") + api("com.iqser.red.service:redaction-report-service-api-v1:4.36.0") + api("com.iqser.red.service:search-service-api-v1:2.71.0") + api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.4") + api("com.google.guava:guava:31.1-jre") + api("org.springframework.boot:spring-boot-starter-security:3.1.3") + api("org.springframework.boot:spring-boot-starter-validation:3.1.3") + api("com.iqser.red.commons:jackson-commons:2.1.0") + api(project(":persistence-service-shared-api-v1")) + testImplementation("com.iqser.red.commons:test-commons:2.1.0") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") + compileOnly("org.springdoc:springdoc-openapi-ui:1.6.13") + api("io.github.openfeign:feign-core:12.2") + compileOnly("org.springframework:spring-web:6.0.6") +} + +description = "persistence-service-external-api-v1" + diff --git a/persistence-service-v1/persistence-service-external-api-v1/pom.xml b/persistence-service-v1/persistence-service-external-api-v1/pom.xml deleted file mode 100644 index a2605d023..000000000 --- a/persistence-service-v1/persistence-service-external-api-v1/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-external-api-v1 - - - - - com.iqser.red.service - persistence-service-internal-api-v1 - ${project.version} - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-report-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - search-service-api-v1 - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.13.4 - - - - com.google.guava - guava - - - - - io.github.openfeign - feign-core - provided - - - - org.springframework - spring-web - provided - - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - com.iqser.red.commons - jackson-commons - - - - - com.iqser.red.commons - test-commons - test - - - com.iqser.red.service - persistence-service-shared-api-v1 - ${project.version} - compile - - - - diff --git a/persistence-service-v1/persistence-service-external-api-v2/build.gradle.kts b/persistence-service-v1/persistence-service-external-api-v2/build.gradle.kts new file mode 100644 index 000000000..1b4f5f56e --- /dev/null +++ b/persistence-service-v1/persistence-service-external-api-v2/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.freefair.lombok") version "8.4" +} + +dependencies { + api(project(":persistence-service-external-api-v1")) + api(project(":persistence-service-internal-api-v1")) + api("com.iqser.red.service:pdftron-redaction-service-api-v1:4.38.0") + api("com.iqser.red.service:redaction-service-api-v1:4.177.0") + api("com.iqser.red.service:redaction-report-service-api-v1:4.36.0") + api("com.iqser.red.service:search-service-api-v1:2.71.0") + api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.16.0") + api("com.google.guava:guava:31.1-jre") + api("org.springframework.boot:spring-boot-starter-security:3.1.3") + api("org.springframework.boot:spring-boot-starter-validation:3.1.3") + api("com.iqser.red.commons:jackson-commons:2.1.0") + api(project(":persistence-service-shared-api-v1")) + testImplementation("com.iqser.red.commons:test-commons:2.1.0") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") + compileOnly("org.springdoc:springdoc-openapi-ui:1.6.13") + api("io.github.openfeign:feign-core:12.2") + compileOnly("org.springframework:spring-web:6.0.6") +} + +description = "persistence-service-external-api-v2" diff --git a/persistence-service-v1/persistence-service-external-api-v2/pom.xml b/persistence-service-v1/persistence-service-external-api-v2/pom.xml deleted file mode 100644 index c18a660e6..000000000 --- a/persistence-service-v1/persistence-service-external-api-v2/pom.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-external-api-v2 - - - - - com.iqser.red.service - persistence-service-external-api-v1 - ${project.version} - - - - com.iqser.red.service - persistence-service-internal-api-v1 - ${project.version} - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-report-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - search-service-api-v1 - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.13.4 - - - - com.google.guava - guava - - - - - io.github.openfeign - feign-core - provided - - - - org.springframework - spring-web - provided - - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - com.iqser.red.commons - jackson-commons - - - - - com.iqser.red.commons - test-commons - test - - - com.iqser.red.service - persistence-service-shared-api-v1 - ${project.version} - compile - - - - diff --git a/persistence-service-v1/persistence-service-external-api-v2/src/main/java/com/iqser/red/service/persistence/service/v2/api/external/model/lombok.config b/persistence-service-v1/persistence-service-external-api-v2/src/main/java/com/iqser/red/service/persistence/service/v2/api/external/model/lombok.config deleted file mode 100644 index f902278dd..000000000 --- a/persistence-service-v1/persistence-service-external-api-v2/src/main/java/com/iqser/red/service/persistence/service/v2/api/external/model/lombok.config +++ /dev/null @@ -1 +0,0 @@ -lombok.anyConstructor.addConstructorProperties=true \ No newline at end of file diff --git a/persistence-service-v1/persistence-service-internal-api-impl-v1/build.gradle.kts b/persistence-service-v1/persistence-service-internal-api-impl-v1/build.gradle.kts new file mode 100644 index 000000000..6394db53a --- /dev/null +++ b/persistence-service-v1/persistence-service-internal-api-impl-v1/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.freefair.lombok") version "8.4" +} + +dependencies { + api(project(":persistence-service-processor-v1")) + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") +} + +description = "persistence-service-internal-api-impl-v1" + diff --git a/persistence-service-v1/persistence-service-internal-api-impl-v1/pom.xml b/persistence-service-v1/persistence-service-internal-api-impl-v1/pom.xml deleted file mode 100644 index b80f9e735..000000000 --- a/persistence-service-v1/persistence-service-internal-api-impl-v1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-internal-api-impl-v1 - - 1.7.30 - UTF-8 - - - - - com.iqser.red.service - persistence-service-processor-v1 - ${project.version} - - - - diff --git a/persistence-service-v1/persistence-service-internal-api-v1/build.gradle.kts b/persistence-service-v1/persistence-service-internal-api-v1/build.gradle.kts new file mode 100644 index 000000000..57644314d --- /dev/null +++ b/persistence-service-v1/persistence-service-internal-api-v1/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("com.iqser.red.service.java-conventions") +} + +dependencies { + api("io.github.openfeign:feign-core:12.2") + api("org.springframework.boot:spring-boot-starter-web:3.1.3") + api("org.springframework.boot:spring-boot-starter-validation:3.1.3") + api("com.iqser.red.commons:jackson-commons:2.1.0") + api(project(":persistence-service-shared-api-v1")) + compileOnly("org.springdoc:springdoc-openapi-ui:1.6.13") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") +} + +description = "persistence-service-internal-api-v1" + diff --git a/persistence-service-v1/persistence-service-internal-api-v1/pom.xml b/persistence-service-v1/persistence-service-internal-api-v1/pom.xml deleted file mode 100644 index 0afe7d956..000000000 --- a/persistence-service-v1/persistence-service-internal-api-v1/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-internal-api-v1 - - - - - - - io.github.openfeign - feign-core - true - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-web - compile - - - org.springframework.boot - spring-boot-starter-validation - compile - - - - - - com.iqser.red.commons - jackson-commons - - - com.iqser.red.service - persistence-service-shared-api-v1 - ${project.version} - compile - - - - - - diff --git a/persistence-service-v1/persistence-service-processor-v1/build.gradle.kts b/persistence-service-v1/persistence-service-processor-v1/build.gradle.kts new file mode 100644 index 000000000..5e97ba216 --- /dev/null +++ b/persistence-service-v1/persistence-service-processor-v1/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.freefair.lombok") version "8.4" +} + +val springBootStarterVersion = "3.1.3" + +dependencies { + api(project(":persistence-service-external-api-v1")) + api(project(":persistence-service-internal-api-v1")) + api("com.knecon.fforesight:jobs-commons:0.10.0") + api("com.knecon.fforesight:database-tenant-commons:0.16.0") + api("com.knecon.fforesight:keycloak-commons:0.18.0") + api("com.knecon.fforesight:swagger-commons:0.5.0") + api("com.iqser.red.service:pdftron-redaction-service-api-v1:4.38.0") + api("com.iqser.red.service:redaction-service-api-v1:4.177.0") + api("com.iqser.red.service:redaction-report-service-api-v1:4.36.0") + api("com.knecon.fforesight:layoutparser-service-internal-api:0.74.0") + api("com.iqser.red.service:search-service-api-v1:2.71.0") + api("com.giffing.bucket4j.spring.boot.starter:bucket4j-spring-boot-starter:0.4.0") + api("com.iqser.red.service:ocr-service-api-v1:3.10.0") + api("org.springframework.security:spring-security-acl:6.0.2") + api("org.springframework.boot:spring-boot-starter-mail:${springBootStarterVersion}") + api("org.springframework.boot:spring-boot-starter-data-jpa:${springBootStarterVersion}") + api("org.springframework.boot:spring-boot-starter-data-redis:${springBootStarterVersion}") + api("org.springframework.boot:spring-boot-starter-amqp:${springBootStarterVersion}") + api("com.iqser.red.commons:spring-commons:2.1.0") + api("com.iqser.red.commons:jackson-commons:2.1.0") + api("org.apache.commons:commons-compress:1.21") + api("com.iqser.red.commons:storage-commons:2.45.0") + api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2") + api("org.postgresql:postgresql:42.2.23") + api("org.apache.commons:commons-lang3:3.12.0") + api("org.springframework.boot:spring-boot-starter-web:3.1.3") + api("com.iqser.red.commons:spring-boot-starter-web-custom-commons:2.1.0") + api("com.iqser.red.commons:metric-commons:2.1.0") + api("com.opencsv:opencsv:5.4") + api("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.4") + api("commons-validator:commons-validator:1.7") + api("com.iqser.red.service:persistence-service-shared-api-v1:+") + testImplementation("org.springframework.amqp:spring-rabbit-test:3.0.2") + testImplementation("org.testcontainers:postgresql:1.17.1") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") + testImplementation("com.yannbriancon:spring-hibernate-query-utils:2.0.0") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") +} + +description = "persistence-service-processor-v1" + +java { + withJavadocJar() +} diff --git a/persistence-service-v1/persistence-service-processor-v1/pom.xml b/persistence-service-v1/persistence-service-processor-v1/pom.xml deleted file mode 100644 index e6c1ef70d..000000000 --- a/persistence-service-v1/persistence-service-processor-v1/pom.xml +++ /dev/null @@ -1,308 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-processor-v1 - - - 6.4.1 - 0.4.0 - 0.5.0 - 0.18.0 - 0.10.0 - 0.16.0 - - - - - com.knecon.fforesight - jobs-commons - ${jobs-commons.version} - - - - com.knecon.fforesight - database-tenant-commons - ${database-tenant-commons.version} - - - - com.knecon.fforesight - keycloak-commons - ${keycloak-commons.version} - - - - com.knecon.fforesight - swagger-commons - ${swagger-commons.version} - - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - com.iqser.red.service - redaction-report-service-api-v1 - - - com.iqser.red.service - persistence-service-internal-api-v1 - - - - - - com.knecon.fforesight - layoutparser-service-internal-api - 0.74.0 - - - - com.iqser.red.service - search-service-api-v1 - - - com.iqser.red.service - persistence-service-api-v1 - - - - - - - com.giffing.bucket4j.spring.boot.starter - bucket4j-spring-boot-starter - ${bucket4j.spring.version} - - - com.github.vladimir-bukhtoyarov - bucket4j-jcache - - - com.github.vladimir-bukhtoyarov - bucket4j-core - - - - - com.iqser.red.service - persistence-service-internal-api-v1 - ${project.version} - - - com.iqser.red.service - ocr-service-api-v1 - - - com.iqser.red.service - persistence-service-internal-api-v1 - - - - - com.iqser.red.service - persistence-service-external-api-v1 - ${project.version} - - - com.iqser.red.service - search-service-api-v1 - - - com.iqser.red.service - persistence-service-internal-api-v1 - - - - - com.iqser.red.service - redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-internal-api-v1 - - - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - - - com.iqser.red.service - persistence-service-internal-api-v1 - - - - - org.springframework.security - spring-security-acl - - - org.springframework.boot - spring-boot-starter-mail - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-data-redis - - - - com.iqser.red.commons - spring-commons - - - com.iqser.red.commons - jackson-commons - - - org.apache.commons - commons-compress - 1.21 - - - com.iqser.red.commons - storage-commons - ${storage.commons.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - - org.postgresql - postgresql - 42.2.23 - - - - org.apache.commons - commons-lang3 - - - - org.springframework.boot - spring-boot-starter-web - - - com.iqser.red.commons - spring-boot-starter-web-custom-commons - - - com.iqser.red.commons - metric-commons - - - com.opencsv - opencsv - 5.4 - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - org.springframework.boot - spring-boot-starter-amqp - - - - - org.springframework.amqp - spring-rabbit-test - test - - - - org.testcontainers - postgresql - 1.17.1 - test - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.yannbriancon - spring-hibernate-query-utils - 2.0.0 - test - - - commons-validator - commons-validator - 1.7 - compile - - - com.iqser.red.service - persistence-service-shared-api-v1 - ${project.version} - compile - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - lombok.launch.AnnotationProcessorHider$AnnotationProcessor - - - - - - - diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/entity/configuration/ColorsEntity.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/entity/configuration/ColorsEntity.java index 5557df0de..c5ad43f13 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/entity/configuration/ColorsEntity.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/entity/configuration/ColorsEntity.java @@ -1,5 +1,7 @@ package com.iqser.red.service.persistence.management.v1.processor.entity.configuration; +import java.util.Locale; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; @@ -78,7 +80,7 @@ public class ColorsEntity { if (color == null) { return null; } - return color.toLowerCase(); + return color.toLowerCase(Locale.ROOT); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/MigrationStarterService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/MigrationStarterService.java index 451c5fb25..91ffd7840 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/MigrationStarterService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/MigrationStarterService.java @@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @Service @RequiredArgsConstructor +@SuppressWarnings("PMD") public class MigrationStarterService { private final List migrations; diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/migrations/ReduceTextFileSizeMigration10.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/migrations/ReduceTextFileSizeMigration10.java index 693adbe85..384f17125 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/migrations/ReduceTextFileSizeMigration10.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/migration/migrations/ReduceTextFileSizeMigration10.java @@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @Setter @Service +@SuppressWarnings("PMD") public class ReduceTextFileSizeMigration10 extends Migration { private static final String NAME = "Reduce TEXT filesize migration"; diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DictionaryManagementService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DictionaryManagementService.java index 60e096b89..0f251a9cb 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DictionaryManagementService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DictionaryManagementService.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; @@ -113,7 +114,7 @@ public class DictionaryManagementService { StringBuilder strbf = new StringBuilder(); Matcher match = Pattern.compile("([a-z])([a-z]*)", Pattern.CASE_INSENSITIVE).matcher(str); while (match.find()) { - match.appendReplacement(strbf, match.group(1).toUpperCase() + match.group(2)); + match.appendReplacement(strbf, match.group(1).toUpperCase(Locale.ROOT) + match.group(2)); } return match.appendTail(strbf).toString(); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DownloadService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DownloadService.java index cfc1dddc5..7e1740261 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DownloadService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/DownloadService.java @@ -8,7 +8,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.iqser.red.service.persistence.management.v1.processor.configuration.MessagingConfiguration; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierEntity; diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileAttributesManagementService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileAttributesManagementService.java index cc7f9f3bb..5fff0c65d 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileAttributesManagementService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileAttributesManagementService.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -106,7 +107,7 @@ public class FileAttributesManagementService { } // TODO this is a primitive solution we need smart name matching - if (!fileStatusMappingColumn.toLowerCase().endsWith(".pdf")) { + if (!fileStatusMappingColumn.toLowerCase(Locale.ROOT).endsWith(".pdf")) { fileStatusMappingColumn = fileStatusMappingColumn + ".pdf"; } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileManagementStorageService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileManagementStorageService.java index 55b17bcbf..65ac81eca 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileManagementStorageService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/FileManagementStorageService.java @@ -31,6 +31,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @Service @RequiredArgsConstructor +@SuppressWarnings("PMD") public class FileManagementStorageService { private final StorageService storageService; diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/CommentRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/CommentRepository.java index 4c60bc891..5dce9c8ab 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/CommentRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/CommentRepository.java @@ -6,17 +6,18 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.CommentEntity; public interface CommentRepository extends JpaRepository { @Query("select e from CommentEntity e where e.fileId = :fileId and e.annotationId = :annotationId and (:includeDeletions = true or e.softDeletedTime is null)") - List findByFileIdAndAnnotationId(String fileId, String annotationId, boolean includeDeletions); + List findByFileIdAndAnnotationId(@Param("fileId") String fileId, @Param("annotationId") String annotationId, @Param("includeDeletions") boolean includeDeletions); @Query("select e from CommentEntity e where e.fileId = :fileId and (:includeDeletions = true or e.softDeletedTime is null)") - List findByFileId(String fileId, boolean includeDeletions); + List findByFileId(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); boolean existsByFileIdAndSoftDeletedTimeIsNull(String fileId); @@ -24,10 +25,10 @@ public interface CommentRepository extends JpaRepository { @Modifying @Query("update CommentEntity c set c.softDeletedTime = :softDeleteTime where c.id = :id") - int updateSoftDelete(long id, OffsetDateTime softDeleteTime); + int updateSoftDelete(@Param("id") long id, @Param("softDeleteTime") OffsetDateTime softDeleteTime); @Modifying @Query("update CommentEntity c set c.annotationId = :newAnnotationId where c.annotationId = :oldAnnotationId and c.fileId = :fileId") - int saasMigrationUpdateAnnotationIds(String fileId, String oldAnnotationId, String newAnnotationId); + int saasMigrationUpdateAnnotationIds(@Param("fileId") String fileId, @Param("oldAnnotationId") String oldAnnotationId, @Param("newAnnotationId") String newAnnotationId); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DigitalSignatureRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DigitalSignatureRepository.java index d9b9561b5..139ebb27c 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DigitalSignatureRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DigitalSignatureRepository.java @@ -3,6 +3,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DigitalSignatureEntity; @@ -10,6 +11,10 @@ public interface DigitalSignatureRepository extends JpaRepository findAttributeByIdOrDossierTemplateIdAndLabel(String dossierTemplateId, String dossierAttributeId, String label); + Optional findAttributeByIdOrDossierTemplateIdAndLabel(@Param("dossierTemplateId") String dossierTemplateId, @Param("dossierAttributeId") String dossierAttributeId, @Param("label") String label); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierAttributeRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierAttributeRepository.java index 6ce061ca2..b37492eb9 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierAttributeRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierAttributeRepository.java @@ -5,6 +5,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierAttributeEntity; @@ -15,16 +16,16 @@ public interface DossierAttributeRepository extends JpaRepository { @Query("select d.id from DossierEntity d where d.lastUpdated > :since") - List findDossierChangeByLastUpdatedIsAfter(OffsetDateTime since); + List findDossierChangeByLastUpdatedIsAfter(@Param("since") OffsetDateTime since); @Modifying @Query("update DossierEntity d set d.softDeletedTime = null, d.lastUpdated = :lastUpdated where d.id = :dossierId" + " and d.hardDeletedTime is null") - int undelete(String dossierId, OffsetDateTime lastUpdated); + int undelete(@Param("dossierId") String dossierId, @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying @Query("update DossierEntity d set d.softDeletedTime = :softDeletedTime, d.lastUpdated = :lastUpdated where d.id = :dossierId") - void markDossierAsDeleted(String dossierId, OffsetDateTime softDeletedTime, OffsetDateTime lastUpdated); + void markDossierAsDeleted(@Param("dossierId") String dossierId, + @Param("softDeletedTime") OffsetDateTime softDeletedTime, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying @Query("update DossierEntity d set d.hardDeletedTime = :hardDeletedTime, d.lastUpdated = :lastUpdated, " + "d.softDeletedTime = " + "case " + "when d.softDeletedTime is null then :hardDeletedTime " + "else d.softDeletedTime " + "end " + "where d.id = :dossierId") - void hardDelete(String dossierId, OffsetDateTime hardDeletedTime, OffsetDateTime lastUpdated); + void hardDelete(@Param("dossierId") String dossierId, + @Param("hardDeletedTime") OffsetDateTime hardDeletedTime, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying @Query("update DossierEntity d set d.archivedTime = :archiveTime, d.lastUpdated = :archiveTime where d.id = :dossierId ") - void archiveDossier(String dossierId, OffsetDateTime archiveTime); + void archiveDossier(@Param("dossierId") String dossierId, @Param("archiveTime") OffsetDateTime archiveTime); @Modifying @Query("update DossierEntity d set d.lastUpdated = :lastUpdated, d.archivedTime = null where d.id = :dossierId") - int unarchiveDossier(String dossierId, OffsetDateTime lastUpdated); + int unarchiveDossier(@Param("dossierId") String dossierId, @Param("lastUpdated") OffsetDateTime lastUpdated); @Query("select count(d) from DossierEntity d where d.archivedTime is not null and d.softDeletedTime is null and d.hardDeletedTime is null and d.dossierTemplateId = :dossierTemplateId") - int countArchived(String dossierTemplateId); + int countArchived(@Param("dossierTemplateId") String dossierTemplateId); @Query("select count(d) from DossierEntity d where d.hardDeletedTime is null and d.softDeletedTime is not null and d.dossierTemplateId = :dossierTemplateId") - int countSofDeleted(String dossierTemplateId); + int countSofDeleted(@Param("dossierTemplateId") String dossierTemplateId); @Query("select count(d) from DossierEntity d where d.archivedTime is null and d.softDeletedTime is null and d.hardDeletedTime is null and d.dossierTemplateId = :dossierTemplateId") - int countActive(String dossierTemplateId); + int countActive(@Param("dossierTemplateId") String dossierTemplateId); @Query("select d.dossierStatusId as dossierStatusId, count(d) as count from DossierEntity d where d.archivedTime is null and d.softDeletedTime is null and d.hardDeletedTime is null and d.dossierTemplateId = :dossierTemplateId group by d.dossierStatusId") - List countByDossierStatus(String dossierTemplateId); + List countByDossierStatus(@Param("dossierTemplateId") String dossierTemplateId); @Query("select d.id from DossierEntity d where d.dossierTemplateId = :dossierTemplateId and d.archivedTime is null and d.softDeletedTime is null and d.hardDeletedTime is null") - List findActiveDossierIdsForTemplate(String dossierTemplateId); + List findActiveDossierIdsForTemplate(@Param("dossierTemplateId") String dossierTemplateId); @Query("select d from DossierEntity d where d.dossierTemplateId = :dossierTemplateId") - List findByDossierTemplateId(String dossierTemplateId); + List findByDossierTemplateId(@Param("dossierTemplateId") String dossierTemplateId); @Modifying @Query("update DossierEntity d set d.watermarkId = null where d.watermarkId = :watermarkId") - int countDeleteWatermark(long watermarkId); + int countDeleteWatermark(@Param("watermarkId") long watermarkId); @Modifying @Query("update DossierEntity d set d.previewWatermarkId = null where d.previewWatermarkId = :previewWatermarkId") - int countDeletePreviewWatermark(long previewWatermarkId); + int countDeletePreviewWatermark(@Param("previewWatermarkId") long previewWatermarkId); @Query("select count(d) from DossierEntity d where d.watermarkId = :watermarkId or d.previewWatermarkId = :watermarkId") - int countDossiersWithWatermarkInUse(long watermarkId); + int countDossiersWithWatermarkInUse(@Param("watermarkId") long watermarkId); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierStatusRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierStatusRepository.java index 8a30378f5..ab24af392 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierStatusRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierStatusRepository.java @@ -1,5 +1,6 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository; +import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; @@ -12,25 +13,20 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp public interface DossierStatusRepository extends JpaRepository { - @Query("select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name," + "s.description, s.dossierTemplateId, s.color, s.rank, count(d)) from DossierStatusEntity s " + "left outer join s.dossiers d where s.dossierTemplateId in (:dossierTemplateIds) group by s order by s.rank ASC") - List getAllDossierStatusForDossierTemplate(List dossierTemplateIds); - - - @Query("select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name," + "s.description, s.color, s.dossierTemplateId, s.rank, count(d)) from DossierStatusEntity s left outer join s.dossiers d where s.id = :dossierStatusId group by s") - Optional findProjectionById(String dossierStatusId); + @Query("select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name, s.description, s.dossierTemplateId, s.color, s.rank, count(d)) from DossierStatusEntity s left outer join s.dossiers d where s.dossierTemplateId in (:dossierTemplateIds) group by s order by s.rank ASC") + List getAllDossierStatusForDossierTemplate(@Param("dossierTemplateIds") List dossierTemplateIds); + @Query("select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name, s.description, s.color, s.dossierTemplateId, s.rank, count(d)) from DossierStatusEntity s left outer join s.dossiers d where s.id = :dossierStatusId group by s") + Optional findProjectionById(@Param("dossierStatusId") String dossierStatusId); @Modifying @Query("update DossierStatusEntity d set d.rank = :newRank where d.id = :dossierStatusId") - void updateRank(String dossierStatusId, int newRank); - + void updateRank(@Param("dossierStatusId") String dossierStatusId, @Param("newRank") int newRank); @Modifying @Query("update DossierStatusEntity d set d.rank = d.rank + 1 where d.dossierTemplateId = :dossierTemplateId and d.rank >= :rank") - void adjustRanksForDossierTemplate(String dossierTemplateId, int rank); - + void adjustRanksForDossierTemplate(@Param("dossierTemplateId") String dossierTemplateId, @Param("rank") int rank); @Query("select count(d) from DossierStatusEntity d where d.dossierTemplateId = :dossierTemplateId and d.rank = :rankToCheck") - int getDuplicateRanks(String dossierTemplateId, int rankToCheck); - + int getDuplicateRanks(@Param("dossierTemplateId") String dossierTemplateId, @Param("rankToCheck") int rankToCheck); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierTemplateRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierTemplateRepository.java index 61fca2f2f..1e1670d85 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierTemplateRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DossierTemplateRepository.java @@ -5,6 +5,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierTemplateEntity; @@ -15,7 +16,7 @@ public interface DossierTemplateRepository extends JpaRepository findByIdAndNotDeleted(String dossierTemplateId); + Optional findByIdAndNotDeleted(@Param("dossierTemplateId") String dossierTemplateId); boolean existsByName(String name); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadRedactionFileStatusRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadRedactionFileStatusRepository.java index 9a75faec9..e49272116 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadRedactionFileStatusRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadRedactionFileStatusRepository.java @@ -1,13 +1,15 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository; -import com.iqser.red.service.persistence.management.v1.processor.entity.download.DownloadRedactionFileStatusEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import com.iqser.red.service.persistence.management.v1.processor.entity.download.DownloadRedactionFileStatusEntity; + public interface DownloadRedactionFileStatusRepository extends JpaRepository { List findAllByDownloadStorageId(String storageId); @@ -17,7 +19,7 @@ public interface DownloadRedactionFileStatusRepository extends JpaRepository findAllByUserId(String userId); - @Modifying @Query("update DownloadStatusEntity ds set ds.status = :status where ds.storageId = :storageId") - void updateStatus(String storageId, DownloadStatusValue status); - + void updateStatus(@Param("storageId") String storageId, @Param("status") DownloadStatusValue status); @Modifying @Query("update DownloadStatusEntity ds set ds.lastDownload = :lastDownload where ds.storageId = :storageId") - void updateLastDownload(String storageId, OffsetDateTime lastDownload); - + void updateLastDownload(@Param("storageId") String storageId, @Param("lastDownload") OffsetDateTime lastDownload); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributeConfigRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributeConfigRepository.java index 5603af5d4..5f62b95a8 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributeConfigRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributeConfigRepository.java @@ -6,6 +6,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileAttributeConfigEntity; @@ -16,15 +17,15 @@ public interface FileAttributeConfigRepository extends JpaRepository findByIdOrDossierTemplateIdAndLabel(String dossierTemplateId, String fileAttributeId, String label); + Optional findByIdOrDossierTemplateIdAndLabel(@Param("dossierTemplateId") String dossierTemplateId, @Param("fileAttributeId") String fileAttributeId, @Param("label") String label); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributesRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributesRepository.java index dc4ed74a6..88cb7ea70 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributesRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileAttributesRepository.java @@ -5,6 +5,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileAttributeEntity; @@ -12,15 +13,15 @@ public interface FileAttributesRepository extends JpaRepository findByFileId(String fileId); + List findByFileId(@Param("fileId") String fileId); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileRepository.java index 7916254b3..e2e91274f 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FileRepository.java @@ -7,6 +7,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.projection.FilePageCountsProjection; @@ -29,206 +30,336 @@ public interface FileRepository extends JpaRepository { @Modifying - @Query("update FileEntity e set e.hasRedactions = :hasRedactions ," + " e.hasHints = :hasHints, e.hasSuggestions = :hasSuggestions," + " e.hasImages = :hasImages, e.hasUpdates = :hasUpdates, e.hasAnnotationComments = :hasComments, " + " e.lastUpdated = :lastUpdated " + " where e.id =:fileId") - void updateFlags(String fileId, - OffsetDateTime lastUpdated, - boolean hasRedactions, - boolean hasHints, - boolean hasImages, - boolean hasSuggestions, - boolean hasComments, - boolean hasUpdates); - + @Query("update FileEntity e set e.hasRedactions = :hasRedactions ," + + " e.hasHints = :hasHints, e.hasSuggestions = :hasSuggestions," + + " e.hasImages = :hasImages, e.hasUpdates = :hasUpdates, e.hasAnnotationComments = :hasComments, " + + " e.lastUpdated = :lastUpdated " + + " where e.id =:fileId") + void updateFlags(@Param("fileId") String fileId, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("hasRedactions") boolean hasRedactions, + @Param("hasHints") boolean hasHints, + @Param("hasImages") boolean hasImages, + @Param("hasSuggestions") boolean hasSuggestions, + @Param("hasComments") boolean hasComments, + @Param("hasUpdates") boolean hasUpdates); @Modifying - @Query("update FileEntity f set f.numberOfPages = :numberOfPages, f.processingStatus = :processingStatus, " + "f.dictionaryVersion = :dictionaryVersion, f.rulesVersion = :rulesVersion, f.componentRulesVersion = :componentRulesVersion, f.legalBasisVersion = :legalBasisVersion, " + "f.analysisDuration = :analysisDuration, f.dossierDictionaryVersion = :dossierDictionaryVersion, " + "f.analysisVersion = :analysisVersion, f.numberOfAnalyses = :analysisNumber, f.lastUpdated = :lastUpdated, " + "f.lastProcessed = :lastProcessed, f.processingErrorCounter = :processingErrorCounter " + "where f.id = :fileId") - void updateProcessingStatus(String fileId, - int numberOfPages, - ProcessingStatus processingStatus, - long dictionaryVersion, - long rulesVersion, - long componentRulesVersion, - long legalBasisVersion, - long analysisDuration, - long dossierDictionaryVersion, - int analysisVersion, - OffsetDateTime lastUpdated, - OffsetDateTime lastProcessed, - int analysisNumber, - int processingErrorCounter); - + @Query("update FileEntity f set f.numberOfPages = :numberOfPages, f.processingStatus = :processingStatus, " + + "f.dictionaryVersion = :dictionaryVersion, f.rulesVersion = :rulesVersion, f.componentRulesVersion = :componentRulesVersion, f.legalBasisVersion = :legalBasisVersion, " + + "f.analysisDuration = :analysisDuration, f.dossierDictionaryVersion = :dossierDictionaryVersion, " + + "f.analysisVersion = :analysisVersion, f.numberOfAnalyses = :analysisNumber, f.lastUpdated = :lastUpdated, " + + "f.lastProcessed = :lastProcessed, f.processingErrorCounter = :processingErrorCounter " + + "where f.id = :fileId") + void updateProcessingStatus(@Param("fileId") String fileId, + @Param("numberOfPages") int numberOfPages, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("dictionaryVersion") long dictionaryVersion, + @Param("rulesVersion") long rulesVersion, + @Param("componentRulesVersion") long componentRulesVersion, + @Param("legalBasisVersion") long legalBasisVersion, + @Param("analysisDuration") long analysisDuration, + @Param("dossierDictionaryVersion") long dossierDictionaryVersion, + @Param("analysisVersion") int analysisVersion, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("lastProcessed") OffsetDateTime lastProcessed, + @Param("analysisNumber") int analysisNumber, + @Param("processingErrorCounter") int processingErrorCounter); @Modifying - @Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate," + " f.excludedFromAutomaticAnalysis = :excludedFromAutomaticAnalysis where f.id = :fileId") - void updateWorkflowStatus(String fileId, WorkflowStatus workflowStatus, OffsetDateTime lastUpdated, OffsetDateTime approvalDate, boolean excludedFromAutomaticAnalysis); - + @Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate," + + " f.excludedFromAutomaticAnalysis = :excludedFromAutomaticAnalysis where f.id = :fileId") + void updateWorkflowStatus(@Param("fileId") String fileId, + @Param("workflowStatus") WorkflowStatus workflowStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("approvalDate") OffsetDateTime approvalDate, + @Param("excludedFromAutomaticAnalysis") boolean excludedFromAutomaticAnalysis); @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate " + " where f.id = :fileId") - void updateWorkflowStatus(String fileId, WorkflowStatus workflowStatus, OffsetDateTime lastUpdated, OffsetDateTime approvalDate); - + @Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate " + + " where f.id = :fileId") + void updateWorkflowStatus(@Param("fileId") String fileId, + @Param("workflowStatus") WorkflowStatus workflowStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("approvalDate") OffsetDateTime approvalDate); @Modifying(clearAutomatically = true) @Query("update FileEntity f set f.fileSize = :fileSize where f.id = :fileId") - void updateFileSize(String fileId, long fileSize); + void updateFileSize(@Param("fileId") String fileId, @Param("fileSize") long fileSize); + @Modifying(clearAutomatically = true) - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + " f.hasHighlights = :hasHighlights, f.processingErrorCounter = :processingErrorCounter " + " where f.id = :fileId") - void updateProcessingStatus(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, boolean hasHighlights, int processingErrorCounter); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + + " f.hasHighlights = :hasHighlights, f.processingErrorCounter = :processingErrorCounter " + + " where f.id = :fileId") + void updateProcessingStatus(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("hasHighlights") boolean hasHighlights, + @Param("processingErrorCounter") int processingErrorCounter); @Modifying(clearAutomatically = true) - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, f.processingErrorCounter = :processingErrorCounter " + "where f.id = :fileId") - void updateProcessingStatus(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, int processingErrorCounter); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, f.processingErrorCounter = :processingErrorCounter " + + "where f.id = :fileId") + void updateProcessingStatus(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("processingErrorCounter") int processingErrorCounter); @Modifying - @Query("update FileEntity f set f.errorCause = :cause, f.errorQueue = :queue, f.errorService = :service, f.errorTimestamp = :timestamp where f.id = :fileId") - void updateStatusErrorInfo(String fileId, String cause, String queue, String service, OffsetDateTime timestamp); + @Query("update FileEntity f set f.errorCause = :cause, f.errorQueue = :queue, f.errorService = :service, f.errorTimestamp = :timestamp " + + "where f.id = :fileId") + void updateStatusErrorInfo(@Param("fileId") String fileId, + @Param("cause") String cause, + @Param("queue") String queue, + @Param("service") String service, + @Param("timestamp") OffsetDateTime timestamp); @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, f.lastProcessed = :lastProcessed, f.processingErrorCounter = :processingErrorCounter " + "where f.id = :fileId") - void updateProcessingStatus(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, OffsetDateTime lastProcessed, int processingErrorCounter); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, f.lastProcessed = :lastProcessed, f.processingErrorCounter = :processingErrorCounter " + + "where f.id = :fileId") + void updateProcessingStatus(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("lastProcessed") OffsetDateTime lastProcessed, + @Param("processingErrorCounter") int processingErrorCounter); @Modifying(clearAutomatically = true) - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + "f.lastIndexed = :lastIndexed, f.processingErrorCounter = :processingErrorCounter where f.id = :fileId") - void setUpdateStatusIndexingSuccessful(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, OffsetDateTime lastIndexed, int processingErrorCounter); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + + "f.lastIndexed = :lastIndexed, f.processingErrorCounter = :processingErrorCounter where f.id = :fileId") + void setUpdateStatusIndexingSuccessful(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("lastIndexed") OffsetDateTime lastIndexed, + @Param("processingErrorCounter") int processingErrorCounter); @Modifying @Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.ocrStartTime = :ocrStartTime where f.id = :fileId") - void updateOCRStartTime(String fileId, OffsetDateTime lastUpdated, OffsetDateTime ocrStartTime); + void updateOCRStartTime(@Param("fileId") String fileId, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("ocrStartTime") OffsetDateTime ocrStartTime); @Modifying @Query("update FileEntity f set f.fileManipulationDate = :fileManipulationDate where f.id = :fileId") - void updateFileModificationDate(String fileId, OffsetDateTime fileManipulationDate); + void updateFileModificationDate(@Param("fileId") String fileId, + @Param("fileManipulationDate") OffsetDateTime fileManipulationDate); @Modifying @Query("update FileEntity f set f.hasHighlights = :hasHighlights where f.id = :fileId") - void updateHasHighlights(String fileId, boolean hasHighlights); + void updateHasHighlights(@Param("fileId") String fileId, + @Param("hasHighlights") boolean hasHighlights); @Modifying @Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.hasAnnotationComments = :hasAnnotationComments where f.id = :fileId") - void updateHasComments(String fileId, OffsetDateTime lastUpdated, boolean hasAnnotationComments); + void updateHasComments(@Param("fileId") String fileId, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("hasAnnotationComments") boolean hasAnnotationComments); @Modifying - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, " + "f.deleted = :softDeletedTime where f.id = :fileId") - int setSoftDelete(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, OffsetDateTime softDeletedTime); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, " + + "f.deleted = :softDeletedTime where f.id = :fileId") + int setSoftDelete(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Modifying - @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + " f.hardDeletedTime = :hardDeletedTime, " + " f.deleted = case " + " when f.deleted is null then :deleted " + " when f.deleted is not null then f.deleted " + " end " + " where f.id = :fileId") - int setHardDelete(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated, OffsetDateTime hardDeletedTime, OffsetDateTime deleted); + @Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," + + "f.hardDeletedTime = :hardDeletedTime, " + + "f.deleted = case " + + " when f.deleted is null then :deleted " + + " when f.deleted is not null then f.deleted " + + "end " + + "where f.id = :fileId") + int setHardDelete(@Param("fileId") String fileId, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUpdated") OffsetDateTime lastUpdated, + @Param("hardDeletedTime") OffsetDateTime hardDeletedTime, + @Param("deleted") OffsetDateTime deleted); @Modifying - @Query("update FileEntity f set f.assignee = :assignee, f.lastReviewer = :lastReviewer, f.lastApprover = :lastApprover, " + "f.lastUpdated = :lastUpdated where f.id = :fileId") - int setAssignee(String fileId, String assignee, String lastReviewer, String lastApprover, OffsetDateTime lastUpdated); + @Query("update FileEntity f set f.assignee = :assignee, f.lastReviewer = :lastReviewer, f.lastApprover = :lastApprover, " + + "f.lastUpdated = :lastUpdated where f.id = :fileId") + int setAssignee(@Param("fileId") String fileId, + @Param("assignee") String assignee, + @Param("lastReviewer") String lastReviewer, + @Param("lastApprover") String lastApprover, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying(clearAutomatically = true) @Query("update FileEntity f set f.excluded = :excluded, f.lastUpdated = :lastUpdated where f.id = :fileId") - int toggleExclusion(String fileId, boolean excluded, OffsetDateTime lastUpdated); + int toggleExclusion(@Param("fileId") String fileId, + @Param("excluded") boolean excluded, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying(clearAutomatically = true) @Query("update FileEntity f set f.excludedFromAutomaticAnalysis = :excludedFromAutomaticAnalysis, f.lastUpdated = :lastUpdated where f.id = :fileId") - int toggleAutomaticAnalysis(String fileId, boolean excludedFromAutomaticAnalysis, OffsetDateTime lastUpdated); + int toggleAutomaticAnalysis(@Param("fileId") String fileId, + @Param("excludedFromAutomaticAnalysis") boolean excludedFromAutomaticAnalysis, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying(clearAutomatically = true) - @Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " + "f.workflowStatus = :workflowStatus, f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, f.fileManipulationDate = :lastUploaded, " + "f.ocrEndTime = null, f.ocrStartTime = null, f.numberOfPagesToOCR = null, f.numberOfOCRedPages = null, f.excluded = false, f.lastProcessed = null, f.lastReviewer = null, f.lastApprover = null, " + "f.assignee = null, f.approvalDate = null, f.numberOfAnalyses = 0, f.lastManualChangeDate = null, f.redactionModificationDate = null, " + "f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " + "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, " + "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, f.excludedFromAutomaticAnalysis = false, f.processingErrorCounter = 0, f.errorCause = null, f.errorQueue = null, f.errorService = null, f.errorTimestamp = null where f.id = :fileId") - int overwriteFile(String fileId, - String filename, - String uploader, - ProcessingStatus processingStatus, - WorkflowStatus workflowStatus, - OffsetDateTime lastUploaded, - OffsetDateTime lastUpdated); + @Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " + + "f.workflowStatus = :workflowStatus, f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, " + + "f.fileManipulationDate = :lastUploaded, " + + "f.ocrEndTime = null, f.ocrStartTime = null, f.numberOfPagesToOCR = null, f.numberOfOCRedPages = null, " + + "f.excluded = false, f.lastProcessed = null, f.lastReviewer = null, f.lastApprover = null, " + + "f.assignee = null, f.approvalDate = null, f.numberOfAnalyses = 0, f.lastManualChangeDate = null, " + + "f.redactionModificationDate = null, " + + "f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " + + "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, " + + "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, f.excludedFromAutomaticAnalysis = false, " + + "f.processingErrorCounter = 0, f.errorCause = null, f.errorQueue = null, f.errorService = null, " + + "f.errorTimestamp = null where f.id = :fileId") + int overwriteFile(@Param("fileId") String fileId, + @Param("filename") String filename, + @Param("uploader") String uploader, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("workflowStatus") WorkflowStatus workflowStatus, + @Param("lastUploaded") OffsetDateTime lastUploaded, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying(clearAutomatically = true) - @Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " + "f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, f.fileManipulationDate = :lastUploaded, " + "f.lastProcessed = null," + "f.approvalDate = null, f.numberOfAnalyses = 0, f.lastManualChangeDate = null, f.redactionModificationDate = null, " + "f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " + "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, " + "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, f.processingErrorCounter = 0, f.ocrStartTime = null, f.ocrEndTime = null, f.numberOfPagesToOCR = null, f.numberOfOCRedPages = null, f.errorCause = null, f.errorQueue = null, f.errorService = null, f.errorTimestamp = null where f.id = :fileId") - int overwriteFileAndKeepManualRedactions(String fileId, - String filename, - String uploader, - ProcessingStatus processingStatus, - OffsetDateTime lastUploaded, - OffsetDateTime lastUpdated); + @Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " + + "f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, f.fileManipulationDate = :lastUploaded, " + + "f.lastProcessed = null," + + "f.approvalDate = null, f.numberOfAnalyses = 0, f.lastManualChangeDate = null, f.redactionModificationDate = null, " + + "f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " + + "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, " + + "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, f.processingErrorCounter = 0, " + + "f.ocrStartTime = null, f.ocrEndTime = null, f.numberOfPagesToOCR = null, f.numberOfOCRedPages = null, " + + "f.errorCause = null, f.errorQueue = null, f.errorService = null, f.errorTimestamp = null " + + "where f.id = :fileId") + int overwriteFileAndKeepManualRedactions(@Param("fileId") String fileId, + @Param("filename") String filename, + @Param("uploader") String uploader, + @Param("processingStatus") ProcessingStatus processingStatus, + @Param("lastUploaded") OffsetDateTime lastUploaded, + @Param("lastUpdated") OffsetDateTime lastUpdated); - @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId where d.dossierTemplateId = :dossierTemplateId" + " and ((f.deleted is not null and f.hardDeletedTime is null) or " + " (d.softDeletedTime is not null and d.hardDeletedTime is null)) and d.archivedTime is null") - int countSoftDeletedFilesPerDossierTemplateId(String dossierTemplateId); + @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId " + + "where d.dossierTemplateId = :dossierTemplateId" + + " and ((f.deleted is not null and f.hardDeletedTime is null) or " + + " (d.softDeletedTime is not null and d.hardDeletedTime is null)) and d.archivedTime is null") + int countSoftDeletedFilesPerDossierTemplateId(@Param("dossierTemplateId") String dossierTemplateId); - @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId where d.id = :dossierId" + " and ((f.deleted is not null and f.hardDeletedTime is null) or " + " (d.softDeletedTime is not null and d.hardDeletedTime is null))") - int countSoftDeletedFilesPerDossierId(String dossierId); + @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId " + + "where d.id = :dossierId" + + " and ((f.deleted is not null and f.hardDeletedTime is null) or " + + " (d.softDeletedTime is not null and d.hardDeletedTime is null))") + int countSoftDeletedFilesPerDossierId(@Param("dossierId") String dossierId); @Query("select distinct f.dossierId from FileEntity f where f.lastUpdated > :since") - List findDossierChangeByLastUpdatedIsAfter(OffsetDateTime since); + List findDossierChangeByLastUpdatedIsAfter(@Param("since") OffsetDateTime since); @Modifying(clearAutomatically = true) @Query("update FileEntity f set f.redactionModificationDate = :redactionModificationDate, f.lastUpdated = :lastUpdated where f.id = :fileId") - void setLastRedactionModificationDateForFile(String fileId, OffsetDateTime redactionModificationDate, OffsetDateTime lastUpdated); + void setLastRedactionModificationDateForFile(@Param("fileId") String fileId, + @Param("redactionModificationDate") OffsetDateTime redactionModificationDate, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Modifying(clearAutomatically = true) @Query("update FileEntity f set f.lastManualChangeDate = :lastManualChangeDate, f.lastUpdated = :lastUpdated where f.id = :fileId") - void setLastManualChangeDate(String fileId, OffsetDateTime lastManualChangeDate, OffsetDateTime lastUpdated); + void setLastManualChangeDate(@Param("fileId") String fileId, + @Param("lastManualChangeDate") OffsetDateTime lastManualChangeDate, + @Param("lastUpdated") OffsetDateTime lastUpdated); - @Query("select f from FileEntity f join DossierEntity d on d.id = f.dossierId where f.excluded = false and f.workflowStatus <> 'APPROVED' and f.excludedFromAutomaticAnalysis = false " + " and ( f.processingStatus = 'PROCESSED' or f.processingStatus = 'ERROR' )" + " and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + " and f.deleted is null and f.hardDeletedTime is null and f.processingErrorCounter <= :maxRetries") - List getAllRelevantStatusesForReanalysisScheduler(int maxRetries); + @Query("select f from FileEntity f join DossierEntity d on d.id = f.dossierId " + + "where f.excluded = false and f.workflowStatus <> 'APPROVED' and f.excludedFromAutomaticAnalysis = false " + + " and ( f.processingStatus = 'PROCESSED' or f.processingStatus = 'ERROR' )" + + " and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + + " and f.deleted is null and f.hardDeletedTime is null and f.processingErrorCounter <= :maxRetries") + List getAllRelevantStatusesForReanalysisScheduler(@Param("maxRetries") int maxRetries); @Modifying @Query("update FileEntity f set f.lastFileAttributeChange = :date, f.lastUpdated = :date where f.id = :fileId") - void updateLastAttributeChangeDate(String fileId, OffsetDateTime date); + void updateLastAttributeChangeDate(@Param("fileId") String fileId, + @Param("date") OffsetDateTime date); @Query("select f from FileEntity f where f.deleted is not null and f.hardDeletedTime is null and f.dossierId in :dossierIds") - List getSoftDeletedFiles(List dossierIds); + List getSoftDeletedFiles(@Param("dossierIds") List dossierIds); - @Query("select f.processingStatus as processingStatus, count(f) as count from FileEntity f " + "inner join DossierEntity d on d.id = f.dossierId " + "where f.deleted is null and f.hardDeletedTime is null " + "and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + "and d.dossierTemplateId = :dossierTemplateId " + "group by f.processingStatus ") - List countFilesByProcessingStatus(String dossierTemplateId); + @Query("select f.processingStatus as processingStatus, count(f) as count from FileEntity f " + + "inner join DossierEntity d on d.id = f.dossierId " + + "where f.deleted is null and f.hardDeletedTime is null " + + "and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + + "and d.dossierTemplateId = :dossierTemplateId " + + "group by f.processingStatus ") + List countFilesByProcessingStatus(@Param("dossierTemplateId") String dossierTemplateId); - @Query("select f.workflowStatus as workflowStatus, count(f) as count from FileEntity f " + "inner join DossierEntity d on d.id = f.dossierId " + "where f.deleted is null and f.hardDeletedTime is null " + "and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + "and d.dossierTemplateId = :dossierTemplateId " + "group by f.workflowStatus ") - List countFilesByWorkflowStatus(String dossierTemplateId); + @Query("select f.workflowStatus as workflowStatus, count(f) as count from FileEntity f " + + "inner join DossierEntity d on d.id = f.dossierId " + + "where f.deleted is null and f.hardDeletedTime is null " + + "and d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null " + + "and d.dossierTemplateId = :dossierTemplateId " + + "group by f.workflowStatus ") + List countFilesByWorkflowStatus(@Param("dossierTemplateId") String dossierTemplateId); - @Query(value = "select COALESCE(sum(number_of_pages),0) as numberOfAnalyzedPages, COALESCE(sum(json_array_length(cast(excluded_pages AS json))),0) as numberOfExcludedPages " + " from file join dossier on file.dossier_id = dossier.id where file.deleted is null and file.hard_deleted_time is null " + " and dossier.archived_time is null and dossier.soft_deleted_time is null and dossier.hard_deleted_time is null" + " and dossier.dossier_template_id = :dossierTemplateId", nativeQuery = true) - FilePageCountsProjection countPages(String dossierTemplateId); + @Query(value = "select COALESCE(sum(number_of_pages),0) as numberOfAnalyzedPages, " + + "COALESCE(sum(json_array_length(cast(excluded_pages AS json))),0) as numberOfExcludedPages " + + "from file join dossier on file.dossier_id = dossier.id " + + "where file.deleted is null and file.hard_deleted_time is null " + + "and dossier.archived_time is null and dossier.soft_deleted_time is null and dossier.hard_deleted_time is null" + + " and dossier.dossier_template_id = :dossierTemplateId", nativeQuery = true) + FilePageCountsProjection countPages(@Param("dossierTemplateId") String dossierTemplateId); - @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId where " + "f.hardDeletedTime is null and f.deleted is null and " + "d.dossierTemplateId = :dossierTemplateId and " + "d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null") - int countActiveFiles(String dossierTemplateId); + @Query("select count(f) from FileEntity f inner join DossierEntity d on d.id = f.dossierId where " + + "f.hardDeletedTime is null and f.deleted is null and " + + "d.dossierTemplateId = :dossierTemplateId and " + + "d.softDeletedTime is null and d.hardDeletedTime is null and d.archivedTime is null") + int countActiveFiles(@Param("dossierTemplateId") String dossierTemplateId); @Transactional @Modifying(clearAutomatically = true) - @Query(value = "update FileEntity f set f.numberOfOCRedPages = :numberOfOCRedPages, f.numberOfPagesToOCR = :numberOfPagesToOCR, f.ocrEndTime = :ocrEndTime, " + " f.lastUpdated = :lastUpdated where f.id = :fileId") - void updateOCRStatus(String fileId, int numberOfPagesToOCR, int numberOfOCRedPages, OffsetDateTime ocrEndTime, OffsetDateTime lastUpdated); + @Query(value = "update FileEntity f set f.numberOfOCRedPages = :numberOfOCRedPages, " + + "f.numberOfPagesToOCR = :numberOfPagesToOCR, f.ocrEndTime = :ocrEndTime, " + + "f.lastUpdated = :lastUpdated where f.id = :fileId") + void updateOCRStatus(@Param("fileId") String fileId, + @Param("numberOfPagesToOCR") int numberOfPagesToOCR, + @Param("numberOfOCRedPages") int numberOfOCRedPages, + @Param("ocrEndTime") OffsetDateTime ocrEndTime, + @Param("lastUpdated") OffsetDateTime lastUpdated); @Transactional @Modifying(clearAutomatically = true) @Query(value = "update FileEntity f set f.lastLayoutProcessed = :offsetDateTime where f.id = :fileId") - void updateLayoutProcessedTime(String fileId, OffsetDateTime offsetDateTime); + void updateLayoutProcessedTime(@Param("fileId") String fileId, + @Param("offsetDateTime") OffsetDateTime offsetDateTime); @Query("select f.filename from FileEntity f where f.id = :fileId") - Optional getFilenameById(String fileId); + Optional getFilenameById(@Param("fileId") String fileId); + } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java index 7fea3d1e9..06e045ff7 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java @@ -6,13 +6,14 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationEntity; public interface NotificationRepository extends JpaRepository { @Query("select count(n) from NotificationEntity n where " + " (exists (select e from NotificationPreferencesEntity e where e.userId = :userId) and n.notificationType in ( select apn from NotificationPreferencesEntity p join p.inAppNotifications apn where p.userId = :userId and p.inAppNotificationsEnabled = true )) " + " and n.softDeleted is null and n.userId = :userId and n.creationDate > :since") - int hasInAppNotificationForUser(String userId, OffsetDateTime since); + int hasInAppNotificationForUser(@Param("userId") String userId, @Param("since") OffsetDateTime since); @Query(""" @@ -20,7 +21,7 @@ public interface NotificationRepository extends JpaRepository findAppNotificationsForUser(String userId); + List findAppNotificationsForUser(@Param("userId") String userId); @Query(""" @@ -28,35 +29,35 @@ public interface NotificationRepository extends JpaRepository findUnseenNotificationsForUser(String userId); + List findUnseenNotificationsForUser(@Param("userId") String userId); @Modifying @Query("update NotificationEntity n set n.seenDate = :seenDate where n.id = :notificationId and n.userId = :userId") - int setSeenDate(String userId, long notificationId, OffsetDateTime seenDate); + int setSeenDate(@Param("userId") String userId, @Param("notificationId") long notificationId, @Param("seenDate") OffsetDateTime seenDate); @Modifying @Query("update NotificationEntity n set n.readDate = :readDate where n.id = :notificationId and n.userId = :userId") - int setReadDate(String userId, long notificationId, OffsetDateTime readDate); + int setReadDate(@Param("userId") String userId ,@Param("notificationId") long notificationId, @Param("readDate") OffsetDateTime readDate); @Modifying @Query("update NotificationEntity n set n.softDeleted = :softDeleted where n.id = :notificationId and n.userId = :userId") - int softDelete(String userId, long notificationId, OffsetDateTime softDeleted); + int softDelete(@Param("userId") String userId, @Param("notificationId") long notificationId, @Param("softDeleted") OffsetDateTime softDeleted); @Modifying @Query("update NotificationEntity n set n.softDeleted = :softDeleted where n.userId = :userId") - void deleteAllByUserId(String userId, OffsetDateTime softDeleted); + void deleteAllByUserId(@Param("userId") String userId, @Param("softDeleted") OffsetDateTime softDeleted); @Modifying @Query("update NotificationEntity n set n.softDeleted = :softDeleted where n.userId = :userId and n.notificationType in :removedNotificationTypes") - void deleteAllByUserIdAndNotificationTypeIn(String userId, List removedNotificationTypes, OffsetDateTime softDeleted); + void deleteAllByUserIdAndNotificationTypeIn(@Param("userId") String userId, @Param("removedNotificationTypes") List removedNotificationTypes, @Param("softDeleted") OffsetDateTime softDeleted); @Query("select n from NotificationEntity n where " + " (exists (select e from NotificationPreferencesEntity e where e.userId = :userId) and n.notificationType in ( select apn from NotificationPreferencesEntity p join p.emailNotifications apn where p.userId = :userId and p.emailNotificationsEnabled = true )) " + " and n.userId = :userId and n.creationDate >= :from and n.creationDate <= :to order by n.creationDate desc") - List findEmailNotificationsForUserId(String userId, OffsetDateTime from, OffsetDateTime to); + List findEmailNotificationsForUserId(@Param("userId") String userId, @Param("from") OffsetDateTime from, @Param("to") OffsetDateTime to); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ReportTemplateRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ReportTemplateRepository.java index 8449e9005..9b90b9e01 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ReportTemplateRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ReportTemplateRepository.java @@ -5,6 +5,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.ReportTemplateEntity; @@ -15,6 +16,6 @@ public interface ReportTemplateRepository extends JpaRepository findByDossierTemplateIdAndRuleFileType(String dossierTemplateId, String ruleFileType); @Query("select r.version from RuleSetEntity r where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType") - Optional findVersionByDossierTemplateIdAndRuleFileType(String dossierTemplateId, String ruleFileType); + Optional findVersionByDossierTemplateIdAndRuleFileType(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/SaasMigrationStatusRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/SaasMigrationStatusRepository.java index 26f9cf5f2..482867eca 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/SaasMigrationStatusRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/SaasMigrationStatusRepository.java @@ -5,6 +5,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -14,18 +15,19 @@ public interface SaasMigrationStatusRepository extends JpaRepository { @Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplate and t.dossierId = :dossier and t.rank = :rank and t.softDeletedTime is null") - Optional findOneByDossierTemplateIdAndDossierIdAndRank(String dossierTemplate, String dossier, int rank); + Optional findOneByDossierTemplateIdAndDossierIdAndRank(@Param("dossierTemplate") String dossierTemplate, @Param("dossier") String dossier, @Param("rank") int rank); List findByDossierId(String dossierId); @Query("select t from TypeEntity t where t.id = :typeId and t.softDeletedTime is null") - Optional findByIdAndNotDeleted(String typeId); - + Optional findByIdAndNotDeleted(@Param("typeId") String typeId); @Modifying - @Query("update TypeEntity t set t.version = t.version +1 where t.id = :typeId") - void updateByIdSetIncrementVersionByOne(String typeId); + @Query("update TypeEntity t set t.version = t.version + 1 where t.id = :typeId") + void updateByIdSetIncrementVersionByOne(@Param("typeId") String typeId); @Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.type = :type and t.dossierId is not null") - List getAllDossierTypesForDossierTemplateAndType(String dossierTemplateId, String type); + List getAllDossierTypesForDossierTemplateAndType(@Param("dossierTemplateId") String dossierTemplateId, @Param("type") String type); @Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.dossierId is null") - List getAllTypesForDossierTemplate(String dossierTemplateId); - + List getAllTypesForDossierTemplate(@Param("dossierTemplateId") String dossierTemplateId); @Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId or t.dossierId = :dossierId") - List findAllTypesByDossierTemplateIdOrDossierId(String dossierTemplateId, String dossierId); + List findAllTypesByDossierTemplateIdOrDossierId(@Param("dossierTemplateId") String dossierTemplateId, @Param("dossierId") String dossierId); List findAllByDossierTemplateIdAndDossierId(String dossierTemplateId, String dossierId); - @Query("select coalesce(sum(t.version),0) from TypeEntity t where t.dossierId = :dossierId") - long getVersionForDossierId(String dossierId); - - - @Query("select coalesce(sum(t.version),0) from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.dossierId is null") - long getVersionForDossierTemplateId(String dossierTemplateId); + @Query("select coalesce(sum(t.version), 0) from TypeEntity t where t.dossierId = :dossierId") + long getVersionForDossierId(@Param("dossierId") String dossierId); + @Query("select coalesce(sum(t.version), 0) from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.dossierId is null") + long getVersionForDossierTemplateId(@Param("dossierTemplateId") String dossierTemplateId); @Query(""" - select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionarySummaryResponse(dt.id, t.id, t.type, t.label, count(e)) - from DossierTemplateEntity dt - left join TypeEntity t on t.dossierTemplateId = dt.id - left join DictionaryEntryEntity e on e.typeId = t.id - where t.softDeletedTime is null and dt.id in :dossierTemplateIds and t.dossierId is null and (e.entryId is null or e.deleted = false) - group by dt.id, t.id, t.type, t.label""") - List findDictionarySummaryList(Set dossierTemplateIds); - + select new com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionarySummaryResponse(dt.id, t.id, t.type, t.label, count(e)) + from DossierTemplateEntity dt + left join TypeEntity t on t.dossierTemplateId = dt.id + left join DictionaryEntryEntity e on e.typeId = t.id + where t.softDeletedTime is null and dt.id in :dossierTemplateIds and t.dossierId is null and (e.entryId is null or e.deleted = false) + group by dt.id, t.id, t.type, t.label""") + List findDictionarySummaryList(@Param("dossierTemplateIds") Set dossierTemplateIds); @Modifying(clearAutomatically = true, flushAutomatically = true) @Query("Update TypeEntity t set t.softDeletedTime = offset_datetime where t.id = :typeId") - void softDeleteTypeById(String typeId); - + void softDeleteTypeById(@Param("typeId") String typeId); @Modifying @Query("Update TypeEntity t set t.softDeletedTime = null where t.id = :typeId and t.softDeletedTime is not null") - int unSoftDeleteTypeById(String typeId); + int unSoftDeleteTypeById(@Param("typeId") String typeId); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ViewedPagesRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ViewedPagesRepository.java index 12283d2d2..3aa019fa0 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ViewedPagesRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/ViewedPagesRepository.java @@ -5,6 +5,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ViewedPageEntity; @@ -18,6 +19,6 @@ public interface ViewedPagesRepository extends JpaRepository viewedPagesToReset); + void deleteSeenPages(@Param("fileId") String fileId, @Param("currentReviewer") String currentReviewer, @Param("viewedPagesToReset") List viewedPagesToReset); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ForceRedactionRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ForceRedactionRepository.java index 938f029d2..14b1d3b4a 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ForceRedactionRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ForceRedactionRepository.java @@ -7,6 +7,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualForceRedactionEntity; @@ -15,29 +16,24 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations public interface ForceRedactionRepository extends JpaRepository, AnnotationEntityRepository { @Modifying(clearAutomatically = true) - @Query("update ManualForceRedactionEntity mfr set mfr.status = :annotationStatus " + "where mfr.id = :annotationEntityId") - void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus); - + @Query("update ManualForceRedactionEntity mfr set mfr.status = :annotationStatus where mfr.id = :annotationEntityId") + void updateStatus(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("annotationStatus") AnnotationStatus annotationStatus); @Modifying - @Query("update ManualForceRedactionEntity mfr set mfr.softDeletedTime = :softDeletedTime " + "where mfr.id = :annotationEntityId") - void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime); - + @Query("update ManualForceRedactionEntity mfr set mfr.softDeletedTime = :softDeletedTime where mfr.id = :annotationEntityId") + void updateSoftDelete(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Query("select mfr from ManualForceRedactionEntity mfr where mfr.id = :annotationEntityId and mfr.softDeletedTime is null") - Optional findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId); - + Optional findByIdAndNotSoftDeleted(@Param("annotationEntityId") AnnotationEntityId annotationEntityId); @Query("select mfr from ManualForceRedactionEntity mfr where mfr.id.fileId = :fileId and (:includeDeletions = true or mfr.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); - + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select mfr from ManualForceRedactionEntity mfr where mfr.id.fileId = :fileId and mfr.processedDate is null") - List findByFileIdAndUnprocessed(String fileId); - + List findByFileIdAndUnprocessed(@Param("fileId") String fileId); @Modifying @Query("update ManualForceRedactionEntity mfr set mfr.processedDate = :processedDate where mfr.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/LegalBasisChangeRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/LegalBasisChangeRepository.java index 060cafc2d..c6ed08278 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/LegalBasisChangeRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/LegalBasisChangeRepository.java @@ -7,6 +7,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualLegalBasisChangeEntity; @@ -15,29 +16,24 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations public interface LegalBasisChangeRepository extends JpaRepository, AnnotationEntityRepository { @Modifying(clearAutomatically = true) - @Query("update ManualLegalBasisChangeEntity mlbc set mlbc.status = :annotationStatus, mlbc.processedDate = :processedDate " + "where mlbc.id = :annotationEntityId") - void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate); - + @Query("update ManualLegalBasisChangeEntity mlbc set mlbc.status = :annotationStatus, mlbc.processedDate = :processedDate where mlbc.id = :annotationEntityId") + void updateStatus(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("annotationStatus") AnnotationStatus annotationStatus, @Param("processedDate") OffsetDateTime processedDate); @Modifying - @Query("update ManualLegalBasisChangeEntity mlbc set mlbc.softDeletedTime = :softDeletedTime " + "where mlbc.id = :annotationEntityId") - void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime); - + @Query("update ManualLegalBasisChangeEntity mlbc set mlbc.softDeletedTime = :softDeletedTime where mlbc.id = :annotationEntityId") + void updateSoftDelete(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id = :annotationEntityId and mlbc.softDeletedTime is null") - Optional findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId); - + Optional findByIdAndNotSoftDeleted(@Param("annotationEntityId") AnnotationEntityId annotationEntityId); @Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and (:includeDeletions = true or mlbc.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); - + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and mlbc.processedDate is null") - List findUnprocessedByFileId(String fileId); - + List findUnprocessedByFileId(@Param("fileId") String fileId); @Modifying @Query("update ManualLegalBasisChangeEntity mlbc set mlbc.processedDate = :processedDate where mlbc.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ManualRedactionRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ManualRedactionRepository.java index 895c03c57..857dd50a8 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ManualRedactionRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ManualRedactionRepository.java @@ -8,6 +8,7 @@ import java.util.Set; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity; @@ -17,38 +18,31 @@ public interface ManualRedactionRepository extends JpaRepository findAddRedaction(AnnotationEntityId id); - + Optional findAddRedaction(@Param("id") AnnotationEntityId id); @Query("select m from ManualRedactionEntryEntity m where m.id.fileId = :fileId and (:includeDeletions = true or m.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); - + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select m from ManualRedactionEntryEntity m where m.id.fileId = :fileId and m.processedDate is null") - List findByFileIdAndUnprocessed(String fileId); - + List findByFileIdAndUnprocessed(@Param("fileId") String fileId); @Modifying - @Query("update ManualRedactionEntryEntity m set m.status = :newStatus, m.processedDate = :processedDate where m.id.fileId in :fileIds and m.value = :filterValue and m.addToDictionary = true and m.status = :filterStatus ") - void updateStatus(Set fileIds, String filterValue, AnnotationStatus filterStatus, AnnotationStatus newStatus, OffsetDateTime processedDate); - + @Query("update ManualRedactionEntryEntity m set m.status = :newStatus, m.processedDate = :processedDate where m.id.fileId in :fileIds and m.value = :filterValue and m.addToDictionary = true and m.status = :filterStatus") + void updateStatus(@Param("fileIds") Set fileIds, @Param("filterValue") String filterValue, @Param("filterStatus") AnnotationStatus filterStatus, @Param("newStatus") AnnotationStatus newStatus, @Param("processedDate") OffsetDateTime processedDate); @Modifying @Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate where m.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RecategorizationRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RecategorizationRepository.java index 14b953e6b..23b0c72b7 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RecategorizationRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RecategorizationRepository.java @@ -7,6 +7,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRecategorizationEntity; @@ -15,28 +16,24 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations public interface RecategorizationRepository extends JpaRepository, AnnotationEntityRepository { @Modifying(clearAutomatically = true) - @Query("update ManualRecategorizationEntity mir set mir.status = :annotationStatus " + "where mir.id = :annotationEntityId") - void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus); - + @Query("update ManualRecategorizationEntity mir set mir.status = :annotationStatus where mir.id = :annotationEntityId") + void updateStatus(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("annotationStatus") AnnotationStatus annotationStatus); @Modifying - @Query("update ManualRecategorizationEntity mir set mir.softDeletedTime = :softDeletedTime " + "where mir.id = :annotationEntityId") - void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime); - + @Query("update ManualRecategorizationEntity mir set mir.softDeletedTime = :softDeletedTime where mir.id = :annotationEntityId") + void updateSoftDelete(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Query("select mir from ManualRecategorizationEntity mir where mir.id = :annotationEntityId and mir.softDeletedTime is null") - Optional findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId); - + Optional findByIdAndNotSoftDeleted(@Param("annotationEntityId") AnnotationEntityId annotationEntityId); @Query("select mir from ManualRecategorizationEntity mir where mir.id.fileId = :fileId and (:includeDeletions = true or mir.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select mir from ManualRecategorizationEntity mir where mir.id.fileId = :fileId and mir.processedDate is null") - List findUnprocessedByFileId(String fileId); - + List findUnprocessedByFileId(@Param("fileId") String fileId); @Modifying @Query("update ManualRecategorizationEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RemoveRedactionRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RemoveRedactionRepository.java index 6c315db31..afc950ac1 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RemoveRedactionRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/RemoveRedactionRepository.java @@ -7,36 +7,34 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.IdRemovalEntity; -import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity; import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus; public interface RemoveRedactionRepository extends JpaRepository, AnnotationEntityRepository { @Modifying @Query("update IdRemovalEntity idr set idr.softDeletedTime = :softDeletedTime where idr.id = :annotationEntityId") - void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime); - + void updateSoftDelete(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Modifying(clearAutomatically = true) @Query("update IdRemovalEntity idr set idr.status = :annotationStatus where idr.id = :annotationEntityId") - void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus); + void updateStatus(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("annotationStatus") AnnotationStatus annotationStatus); @Query("select idr from IdRemovalEntity idr where idr.id = :annotationEntityId and idr.softDeletedTime is null") - Optional findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId); - + Optional findByIdAndNotSoftDeleted(@Param("annotationEntityId") AnnotationEntityId annotationEntityId); @Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and (:includeDeletions = true or idr.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and idr.processedDate is null") - List findByFileIdAndUnprocessed(String fileId); - + List findByFileIdAndUnprocessed(@Param("fileId") String fileId); @Modifying @Query("update IdRemovalEntity idr set idr.processedDate = :processedDate where idr.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); + } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ResizeRedactionRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ResizeRedactionRepository.java index 2c9d90b35..a11ff40de 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ResizeRedactionRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/annotationentity/ResizeRedactionRepository.java @@ -7,6 +7,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualResizeRedactionEntity; @@ -15,37 +16,30 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations public interface ResizeRedactionRepository extends JpaRepository, AnnotationEntityRepository { @Modifying(clearAutomatically = true) - @Query("update ManualResizeRedactionEntity mrd set mrd.status = :annotationStatus, mrd.processedDate = :processedDate " + "where mrd.id = :annotationEntityId") - void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate); - + @Query("update ManualResizeRedactionEntity mrd set mrd.status = :annotationStatus, mrd.processedDate = :processedDate where mrd.id = :annotationEntityId") + void updateStatus(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("annotationStatus") AnnotationStatus annotationStatus, @Param("processedDate") OffsetDateTime processedDate); @Modifying - @Query("update ManualResizeRedactionEntity mrd set mrd.softDeletedTime = :softDeletedTime " + "where mrd.id = :annotationEntityId") - void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime); - + @Query("update ManualResizeRedactionEntity mrd set mrd.softDeletedTime = :softDeletedTime where mrd.id = :annotationEntityId") + void updateSoftDelete(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("softDeletedTime") OffsetDateTime softDeletedTime); @Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id = :annotationEntityId and mrd.softDeletedTime is null") - Optional findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId); - + Optional findByIdAndNotSoftDeleted(@Param("annotationEntityId") AnnotationEntityId annotationEntityId); @Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id.fileId = :fileId and (:includeDeletions = true or mrd.softDeletedTime is null)") - List findByFileIdIncludeDeletions(String fileId, boolean includeDeletions); - + List findByFileIdIncludeDeletions(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions); @Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id.fileId = :fileId and mrd.processedDate is null") - List findUnprocessedByFileId(String fileId); - + List findUnprocessedByFileId(@Param("fileId") String fileId); @Modifying @Query("update ManualResizeRedactionEntity m set m.textBefore = :textBefore, m.textAfter = :textAfter where m.id = :id") - void updateSurroundingText(AnnotationEntityId id, String textBefore, String textAfter); - - - List findByStatusAndValue(AnnotationStatus status, String value); + void updateSurroundingText(@Param("id") AnnotationEntityId id, @Param("textBefore") String textBefore, @Param("textAfter") String textAfter); + List findByStatusAndValue(@Param("status") AnnotationStatus status, @Param("value") String value); @Modifying @Query("update ManualResizeRedactionEntity mir set mir.processedDate = :processedDate where mir.id = :annotationEntityId") - void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate); + void markAsProcessed(@Param("annotationEntityId") AnnotationEntityId annotationEntityId, @Param("processedDate") OffsetDateTime processedDate); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/EntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/EntryRepository.java index 9db7f0762..9d09f76dd 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/EntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/EntryRepository.java @@ -7,36 +7,34 @@ import jakarta.transaction.Transactional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryEntryEntity; public interface EntryRepository extends EntryRepositoryCustom, JpaRepository { @Modifying - @Query("update DictionaryEntryEntity e set e.version = :version where e.typeId = :typeId and e.deleted = false") - void updateVersionWhereTypeId(long version, String typeId); - + @Query("update DictionaryEntryEntity e set e.version = :version where e.typeId = :typeId and e.deleted = false") + void updateVersionWhereTypeId(@Param("version") long version, @Param("typeId") String typeId); @Modifying - @Query("update DictionaryEntryEntity e set e.typeId = :newTypeId, e.version = e.version + 1 where e.typeId =:typeId and e.deleted = false") - void updateTypeIdAndIncrementVersionByOne(String typeId, String newTypeId); - - - List findByTypeIdAndVersionGreaterThan(String typeId, long version); - - - List findByTypeIdContainsAndValue(String typeId, String value); - + @Query("update DictionaryEntryEntity e set e.typeId = :newTypeId, e.version = e.version + 1 where e.typeId = :typeId and e.deleted = false") + void updateTypeIdAndIncrementVersionByOne(@Param("typeId") String typeId, @Param("newTypeId") String newTypeId); @Modifying(flushAutomatically = true, clearAutomatically = true) @Transactional @Query("update DictionaryEntryEntity e set e.deleted = true, e.version = :version where e.typeId = :typeId") - void deleteAllEntriesForTypeId(String typeId, long version); - + void deleteAllEntriesForTypeId(@Param("typeId") String typeId, @Param("version") long version); @Modifying(flushAutomatically = true, clearAutomatically = true) @Transactional - @Query(value = "insert into dictionary_entry (value, version, deleted, type_id) " + " select value, 1, false, :newTypeId from dictionary_entry where type_id = :originalTypeId and deleted = false", nativeQuery = true) - void cloneEntries(String originalTypeId, String newTypeId); + @Query(value = "insert into dictionary_entry (value, version, deleted, type_id) " + + " select value, 1, false, :newTypeId from dictionary_entry where type_id = :originalTypeId and deleted = false", nativeQuery = true) + void cloneEntries(@Param("originalTypeId") String originalTypeId, @Param("newTypeId") String newTypeId); + + + List findByTypeIdAndVersionGreaterThan(String typeId, long version); + + List findByTypeIdContainsAndValue(String typeId, String value); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalsePositiveEntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalsePositiveEntryRepository.java index 2058b2d92..db36d19c3 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalsePositiveEntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalsePositiveEntryRepository.java @@ -5,6 +5,7 @@ import jakarta.transaction.Transactional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -12,7 +13,7 @@ public interface FalsePositiveEntryRepository extends FalsePositiveEntryReposito @Modifying @Query("update DictionaryFalsePositiveEntryEntity e set e.version = :version where e.typeId = :typeId and e.deleted = false") - void updateVersionWhereTypeId(long version, String typeId); + void updateVersionWhereTypeId(@Param("version") long version, @Param("typeId") String typeId); List findByTypeIdAndVersionGreaterThan(String typeId, long version); @@ -21,13 +22,13 @@ public interface FalsePositiveEntryRepository extends FalsePositiveEntryReposito @Modifying @Transactional @Query("update DictionaryFalsePositiveEntryEntity e set e.deleted = true, e.version = :version where e.typeId = :typeId") - void deleteAllEntriesForTypeId(String typeId, long version); + void deleteAllEntriesForTypeId(@Param("typeId") String typeId, @Param("version") long version); @Modifying(flushAutomatically = true, clearAutomatically = true) @Transactional @Query(value = "insert into dictionary_false_positive_entry (value, version, deleted, type_id) " + " select value, 1, false, :newTypeId from dictionary_false_positive_entry where type_id = :originalTypeId and deleted = false", nativeQuery = true) - void cloneEntries(String originalTypeId, String newTypeId); + void cloneEntries(@Param("originalTypeId") String originalTypeId, @Param("newTypeId") String newTypeId); List findByTypeIdContainsAndValue(String typeId, String value); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalseRecommendationEntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalseRecommendationEntryRepository.java index 5268ee942..6121f95e2 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalseRecommendationEntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/dictionaryentry/FalseRecommendationEntryRepository.java @@ -5,6 +5,7 @@ import jakarta.transaction.Transactional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -12,7 +13,7 @@ public interface FalseRecommendationEntryRepository extends FalseRecommendationE @Modifying @Query("update DictionaryFalseRecommendationEntryEntity e set e.version = :version where e.typeId = :typeId and e.deleted = false") - void updateVersionWhereTypeId(long version, String typeId); + void updateVersionWhereTypeId(@Param("version") long version, @Param("typeId") String typeId); List findByTypeIdAndVersionGreaterThan(String typeId, long version); @@ -21,13 +22,13 @@ public interface FalseRecommendationEntryRepository extends FalseRecommendationE @Modifying @Transactional @Query("update DictionaryFalseRecommendationEntryEntity e set e.deleted = true, e.version = :version where e.typeId = :typeId") - void deleteAllEntriesForTypeId(String typeId, long version); + void deleteAllEntriesForTypeId(@Param("typeId") String typeId, @Param("version") long version); @Modifying(flushAutomatically = true, clearAutomatically = true) @Transactional @Query(value = "insert into dictionary_false_recommendation_entry (value, version, deleted, type_id) " + " select value, 1, false, :newTypeId from dictionary_false_recommendation_entry where type_id = :originalTypeId and deleted = false", nativeQuery = true) - void cloneEntries(String originalTypeId, String newTypeId); + void cloneEntries(@Param("originalTypeId") String originalTypeId, @Param("newTypeId") String newTypeId); List findByTypeIdContainsAndValue(String typeId, String value); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/utils/ResourceLoader.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/utils/ResourceLoader.java index 71d8a24c5..eff21a914 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/utils/ResourceLoader.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/utils/ResourceLoader.java @@ -11,6 +11,7 @@ import java.util.stream.Collectors; import lombok.experimental.UtilityClass; @UtilityClass +@SuppressWarnings("PMD") public class ResourceLoader { public Set load(String classpathPath) { diff --git a/persistence-service-v1/persistence-service-server-v1/build.gradle.kts b/persistence-service-v1/persistence-service-server-v1/build.gradle.kts new file mode 100644 index 000000000..1209feb96 --- /dev/null +++ b/persistence-service-v1/persistence-service-server-v1/build.gradle.kts @@ -0,0 +1,57 @@ +import org.springframework.boot.gradle.tasks.bundling.BootBuildImage + +plugins { + application + id("com.iqser.red.service.java-conventions") + id("org.springframework.boot") version "3.1.3" + id("io.spring.dependency-management") version "1.1.3" + id("org.sonarqube") version "4.4.1.3373" + id("io.freefair.lombok") version "8.4" +} + +configurations { + all { + exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging") + } +} + +dependencies { + api(project(":persistence-service-processor-v1")) + api("com.iqser.red.commons:storage-commons:2.45.0") + api("junit:junit:4.13.2") + api(project(":persistence-service-external-api-impl-v1")) + api(project(":persistence-service-external-api-impl-v2")) + api(project(":persistence-service-internal-api-impl-v1")) + testImplementation("org.springframework.amqp:spring-rabbit-test:3.0.2") + testImplementation("org.springframework.security:spring-security-test:6.0.2") + testImplementation("org.testcontainers:postgresql:1.17.1") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") + testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.19.0") + testImplementation("com.yannbriancon:spring-hibernate-query-utils:2.0.0") +} + +description = "persistence-service-server-v1" + +tasks.named("bootBuildImage") { + + environment.put("BPE_DELIM_JAVA_TOOL_OPTIONS", " ") + environment.put("BPE_APPEND_JAVA_TOOL_OPTIONS", "-Dfile.encoding=UTF-8") + + imageName.set("nexus.knecon.com:5001/red/${project.name}:${project.version}") + if (project.hasProperty("buildbootDockerHostNetwork")) { + network.set("host") + } + docker { + if (project.hasProperty("buildbootDockerHostNetwork")) { + bindHostToBuilder.set(true) + } + verboseLogging.set(true) + + publishRegistry { + username.set(providers.gradleProperty("mavenUser").getOrNull()) + password.set(providers.gradleProperty("mavenPassword").getOrNull()) + email.set(providers.gradleProperty("mavenEmail").getOrNull()) + url.set("https://nexus.knecon.com:5001/") + } + } +} diff --git a/persistence-service-v1/persistence-service-server-v1/pom.xml b/persistence-service-v1/persistence-service-server-v1/pom.xml deleted file mode 100644 index 33e8387d7..000000000 --- a/persistence-service-v1/persistence-service-server-v1/pom.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-server-v1 - - UTF-8 - - - - - com.iqser.red.service - persistence-service-processor-v1 - ${project.version} - - - com.iqser.red.commons - storage-commons - ${storage.commons.version} - - - - org.springframework.amqp - spring-rabbit-test - test - - - junit - junit - 4.13.2 - compile - - - - - org.springframework.security - spring-security-test - test - - - - org.testcontainers - postgresql - 1.17.1 - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.apache.logging.log4j - log4j-slf4j-impl - test - - - com.yannbriancon - spring-hibernate-query-utils - 2.0.0 - test - - - com.iqser.red.service - persistence-service-external-api-impl-v1 - ${project.version} - compile - - - com.iqser.red.service - persistence-service-external-api-impl-v2 - ${project.version} - compile - - - com.iqser.red.service - persistence-service-internal-api-impl-v1 - ${project.version} - compile - - - - - - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - lombok.launch.AnnotationProcessorHider$AnnotationProcessor - - - - - - - - pl.project13.maven - git-commit-id-plugin - - - - revision - - - true - - true - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - true - - - - - - - - diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateTest.java index f102991f5..3f8e82bc8 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateTest.java @@ -55,6 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +@SuppressWarnings("PMD") public class DossierTemplateTest extends AbstractPersistenceServerServiceTest { @Autowired diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTest.java index f136a7e17..0650edd3a 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTest.java @@ -90,6 +90,7 @@ public class DossierTest extends AbstractPersistenceServerServiceTest { dossierTesterAndProvider.provideTestDossier(dossierTemplate, "sameNameDossier"); } catch (Exception e) { // conflict exception is expected + log.debug("conflict exception is expected"); } }); var allDossiers = dossierClient.getDossiers(true, true); diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconRedisTestContainer.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconRedisTestContainer.java index e654f05d4..fcede2ceb 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconRedisTestContainer.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconRedisTestContainer.java @@ -3,7 +3,7 @@ package com.iqser.red.service.peristence.v1.server.integration.utils; import org.testcontainers.containers.GenericContainer; import org.testcontainers.utility.DockerImageName; -public class KneconRedisTestContainer extends GenericContainer { +public final class KneconRedisTestContainer extends GenericContainer { private static final String IMAGE_VERSION = "nexus.knecon.com:5001/bitnami/redis:7.0.5-debian-11-r7"; private static KneconRedisTestContainer container; diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconSpringPostgreSQLTestContainer.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconSpringPostgreSQLTestContainer.java index f4809b532..20035551a 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconSpringPostgreSQLTestContainer.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/KneconSpringPostgreSQLTestContainer.java @@ -10,6 +10,7 @@ import org.testcontainers.containers.JdbcDatabaseContainer; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; import org.testcontainers.utility.DockerImageName; +@SuppressWarnings("PMD") public class KneconSpringPostgreSQLTestContainer extends JdbcDatabaseContainer { private static final String IMAGE_VERSION = "nexus.knecon.com:5001/bitnami/postgresql:14.5.0-debian-11-r31"; diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/RedisTestContainer.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/RedisTestContainer.java index 90bbb8a73..a756c4f5b 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/RedisTestContainer.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/RedisTestContainer.java @@ -3,7 +3,7 @@ package com.iqser.red.service.peristence.v1.server.integration.utils; import org.testcontainers.containers.GenericContainer; import org.testcontainers.utility.DockerImageName; -public class RedisTestContainer extends GenericContainer { +public final class RedisTestContainer extends GenericContainer { private static final String IMAGE_VERSION = "redis:6.2.6"; private static RedisTestContainer container; diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/SpringPostgreSQLTestContainer.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/SpringPostgreSQLTestContainer.java index 722058a70..56adc5e8e 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/SpringPostgreSQLTestContainer.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/utils/SpringPostgreSQLTestContainer.java @@ -2,7 +2,7 @@ package com.iqser.red.service.peristence.v1.server.integration.utils; import org.testcontainers.containers.PostgreSQLContainer; -public class SpringPostgreSQLTestContainer extends PostgreSQLContainer { +public final class SpringPostgreSQLTestContainer extends PostgreSQLContainer { private static final String IMAGE_VERSION = "postgres:15.2"; private static SpringPostgreSQLTestContainer container; diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/utils/MetricsPrinterService.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/utils/MetricsPrinterService.java index b6a317110..b455bcea5 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/utils/MetricsPrinterService.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/utils/MetricsPrinterService.java @@ -14,6 +14,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @Service +@SuppressWarnings("checkstyle:all") public class MetricsPrinterService { @Value("${server.port}") diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/persistence/management/v1/processor/utils/FileSystemBackedArchiverTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/persistence/management/v1/processor/utils/FileSystemBackedArchiverTest.java index 7808accb7..660da6e90 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/persistence/management/v1/processor/utils/FileSystemBackedArchiverTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/persistence/management/v1/processor/utils/FileSystemBackedArchiverTest.java @@ -16,6 +16,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @Slf4j +@SuppressWarnings("PMD") public class FileSystemBackedArchiverTest { private final static byte[] dummyFileContent = new byte[]{1, 2}; diff --git a/persistence-service-v1/persistence-service-shared-api-v1/build.gradle.kts b/persistence-service-v1/persistence-service-shared-api-v1/build.gradle.kts new file mode 100644 index 000000000..a10ac954d --- /dev/null +++ b/persistence-service-v1/persistence-service-shared-api-v1/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("com.iqser.red.service.java-conventions") + id("io.freefair.lombok") version "8.4" +} + +dependencies { + api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.16.0") + api("com.google.guava:guava:31.1-jre") + api("org.springframework.boot:spring-boot-starter-validation:3.1.3") + api("com.iqser.red.commons:jackson-commons:2.1.0") + api("com.iqser.red.commons:dictionary-merge-commons:1.3.0") + testImplementation("com.iqser.red.commons:test-commons:2.1.0") + testImplementation("org.springframework.boot:spring-boot-starter-test:3.0.4") + compileOnly("org.springdoc:springdoc-openapi-ui:1.7.0") + compileOnly("io.github.openfeign:feign-core:12.2") + compileOnly("org.springframework:spring-web:6.0.6") +} + +description = "persistence-service-shared-api-v1" diff --git a/persistence-service-v1/persistence-service-shared-api-v1/pom.xml b/persistence-service-v1/persistence-service-shared-api-v1/pom.xml deleted file mode 100644 index 109937aff..000000000 --- a/persistence-service-v1/persistence-service-shared-api-v1/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - persistence-service-v1 - com.iqser.red.service - 2.0-SNAPSHOT - - - 4.0.0 - - persistence-service-shared-api-v1 - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.13.4 - - - - com.google.guava - guava - - - - - io.github.openfeign - feign-core - provided - - - - org.springframework - spring-web - provided - - - - org.springframework.boot - spring-boot-starter-validation - - - - - com.iqser.red.commons - jackson-commons - - - - com.iqser.red.commons - dictionary-merge-commons - 1.3.0 - - - - - com.iqser.red.commons - test-commons - test - - - - diff --git a/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/lombok.config b/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/lombok.config deleted file mode 100644 index f902278dd..000000000 --- a/persistence-service-v1/persistence-service-shared-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/shared/model/lombok.config +++ /dev/null @@ -1 +0,0 @@ -lombok.anyConstructor.addConstructorProperties=true \ No newline at end of file diff --git a/persistence-service-v1/pom.xml b/persistence-service-v1/pom.xml deleted file mode 100755 index 93c2196eb..000000000 --- a/persistence-service-v1/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - com.iqser.red - platform-dependency - 2.20.0 - - - - 4.0.0 - - com.iqser.red.service - persistence-service-v1 - 2.0-SNAPSHOT - - pom - - - persistence-service-shared-api-v1 - persistence-service-internal-api-v1 - persistence-service-external-api-v1 - persistence-service-external-api-v2 - persistence-service-processor-v1 - persistence-service-server-v1 - persistence-service-external-api-impl-v1 - persistence-service-external-api-impl-v2 - persistence-service-internal-api-impl-v1 - - - - true - true - 4.177.0 - 2.71.0 - 4.38.0 - 4.36.0 - 3.10.0 - 2.45.0 - - - - - - com.iqser.red - platform-commons-dependency - 2.9.0 - import - pom - - - org.springdoc - springdoc-openapi-ui - 1.6.13 - - - com.iqser.red.service - redaction-service-api-v1 - ${redaction-service.version} - - - com.iqser.red.service - ocr-service-api-v1 - ${ocr-service.version} - - - com.iqser.red.service - search-service-api-v1 - ${search-service.version} - - - com.iqser.red.service - redaction-report-service-api-v1 - ${redaction-report-service.version} - - - com.iqser.red.service - pdftron-redaction-service-api-v1 - ${pdftron-redaction-service.version} - - - - - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.9.0.2155 - - - org.owasp - dependency-check-maven - 6.3.1 - - ALL - - - - org.jacoco - jacoco-maven-plugin - - - prepare-agent - - prepare-agent - - - - report - - report - - - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.8 - - - prepare-agent - - prepare-agent - - - - report - - report-aggregate - - verify - - - - - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 33bee4a6a..000000000 --- a/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - 4.0.0 - - persistence-service - com.iqser.red.service - 2.0-SNAPSHOT - - - pom - - - persistence-service-v1 - persistence-service-image-v1 - - - diff --git a/publish-custom-docker-img.sh b/publish-custom-docker-img.sh deleted file mode 100755 index 4f282415d..000000000 --- a/publish-custom-docker-img.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# This script compiles the project, builds a docker image with the tag - and pushes it to our nexus. - -# Set the Nexus repository URL -NEXUS_REPO="nexus.knecon.com:5001" -# Set the image name -IMAGE_NAME="red/persistence-service-server-v1" -# path to image repo -IMAGE_REPO="persistence-service-image-v1" - -echo "Running build" -mvn clean install -Pquickbuild - -# Get the current Git branch -GIT_BRANCH=$(git symbolic-ref --short HEAD) -# Get the first 5 characters of the commit hash -GIT_COMMIT_HASH=$(git rev-parse --short=5 HEAD) -# Create the image tag by combining branch and commit hash -IMAGE_TAG="${GIT_BRANCH}-${GIT_COMMIT_HASH}" -IMAGE_NAME="$NEXUS_REPO/$IMAGE_NAME:$IMAGE_TAG" - -echo "Building docker image: {$IMAGE_NAME}" -# Build the Docker image with the specified name and tag and push to nexus -mvn -f $IMAGE_REPO docker:build docker:push -Ddocker.image.version=$IMAGE_TAG - -echo "Docker image '$IMAGE_NAME' has been built and pushed to Nexus." diff --git a/publish-custom-image.sh b/publish-custom-image.sh new file mode 100755 index 000000000..89b9f8d94 --- /dev/null +++ b/publish-custom-image.sh @@ -0,0 +1,15 @@ +#!/bin/bash +dir=${PWD##*/} +gradle assemble + +# Get the current Git branch +branch=$(git rev-parse --abbrev-ref HEAD) + +# Get the short commit hash (first 5 characters) +commit_hash=$(git rev-parse --short=5 HEAD) + +# Combine branch and commit hash +buildName="${USER}-${branch}-${commit_hash}" + +gradle bootBuildImage --cleanCache --publishImage -PbuildbootDockerHostNetwork=true -Pversion=$buildName +echo "nexus.knecon.com:5001/red/${dir}-server-v1:$buildName" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..a59dc1263 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,19 @@ +rootProject.name = "persistence-service" +include(":persistence-service-processor-v1") +include(":persistence-service-shared-api-v1") +include(":persistence-service-external-api-impl-v1") +include(":persistence-service-server-v1") +include(":persistence-service-external-api-v1") +include(":persistence-service-internal-api-impl-v1") +include(":persistence-service-external-api-v2") +include(":persistence-service-external-api-impl-v2") +include(":persistence-service-internal-api-v1") +project(":persistence-service-processor-v1").projectDir = file("persistence-service-v1/persistence-service-processor-v1") +project(":persistence-service-shared-api-v1").projectDir = file("persistence-service-v1/persistence-service-shared-api-v1") +project(":persistence-service-external-api-impl-v1").projectDir = file("persistence-service-v1/persistence-service-external-api-impl-v1") +project(":persistence-service-server-v1").projectDir = file("persistence-service-v1/persistence-service-server-v1") +project(":persistence-service-external-api-v1").projectDir = file("persistence-service-v1/persistence-service-external-api-v1") +project(":persistence-service-internal-api-impl-v1").projectDir = file("persistence-service-v1/persistence-service-internal-api-impl-v1") +project(":persistence-service-external-api-v2").projectDir = file("persistence-service-v1/persistence-service-external-api-v2") +project(":persistence-service-external-api-impl-v2").projectDir = file("persistence-service-v1/persistence-service-external-api-impl-v2") +project(":persistence-service-internal-api-v1").projectDir = file("persistence-service-v1/persistence-service-internal-api-v1")