From 3e0bb2def3897de51ad164919790cb445fa9a4cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:31:15 +0200 Subject: [PATCH] Merge release branch '1.18.0' (#555) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * upgrade to spring boot 2.7.18 * use num aql-editor spring boot starter dependency instead of archived ehrbase * upgrade openEHR SDK to 1.20.0 * num-portal with open ehr sdk 1.22.0 * fix deprecated method * num-portal with open ehr sdk 1.24.0 * num-portal with open ehr sdk 1.29.0 * use num-aql-editor 1.0.1-rc-6 * NUM-2311 migration to openEher sdk 2.0.0 in progress * in progres upgrade to openEHR sdk 2.1.0 * fix some tests after upgrade to openEHR SDK 2.1.0 * refactoring and fix some tests * refactoring * fix tests * some tests fixes * some tests fixes * some tests fixes * other fixes * other fixes * fix test * fix cohort integration test * some cleanup * refactoring * upgrade to openEHR SDK 2.5.0 * some dependencies upgrade * upgrade to openEHR SDK 2.6.0 * NUM-2315 ehrbase admin configs for management endpoint access * update test * NUM-2160 upgrade to spring boot 3.1.8 * use latest num-aql-editor-spring-boot-starter 1.0.4 * split exception handling for custom ForbiddenException and AccesDeniedException * switch to maven repository for openEHR SDK * cleanup and refactoring deprecated method for handleBindException * NUM-2160 upgrade to spring boot 3.2.2 and some cleanup * fix sonar complaints * use latest num-aql-editor 1.0.5 * Feature/add nightly without sonar (#459) * Add first github workflow file (nightly) * update first github workflow triggert by push event * update first github workflow deactivate int tests and cirlceCi pipline * update first github workflow remove Int Test folder * update first github workflow add Int Test folder * update first github workflow add Int Test again * update first github workflow schedule job * update first github workflow schedule job I * add nightly as github workflow * disable sonar * update CI dependencies to fix: Node.js 16 actions are deprecated (#460) * Feature/nightly analyse (#461) * temp commit to analyse nightly error * temp allow int test to fail * Feature/test_PR_pipeline (#462) * add PR to develop workflow * Feature/add pull pipeline (#463) * bump trivy-action to v0.17.0 * work on trivy action * pump github/codeql-action * update PR pipeline * add dependabot.yml (#464) * Bump org.owasp:dependency-check-maven from 9.0.8 to 9.0.9 Bumps [org.owasp:dependency-check-maven](https://github.com/jeremylong/DependencyCheck) from 9.0.8 to 9.0.9. - [Release notes](https://github.com/jeremylong/DependencyCheck/releases) - [Changelog](https://github.com/jeremylong/DependencyCheck/blob/main/CHANGELOG.md) - [Commits](https://github.com/jeremylong/DependencyCheck/compare/v9.0.8...v9.0.9) --- updated-dependencies: - dependency-name: org.owasp:dependency-check-maven dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * update pipelines (#473) * run maven package into docker step (#474) * run maven package into docker step (#477) * format workflows (#478) * Feature/work on pipeline (#480) * ignore some flaky tests (#481) * include dependabot PRs into push pipeline (#482) * fix naming (#483) * Bump org.postgresql:postgresql from 42.7.1 to 42.7.2 (#472) Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.7.1 to 42.7.2. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.7.1...REL42.7.2) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * remove sonar cloud (#484) * Update README.md * Feature/work on release pipeline (#494) * start work on release pipeline * firsts step release pipelines * update release pipeline * update release pipeline * update release version step * ignore flaky test; remove CircleCI * Change project structure and pom.xml, and group.id * Change project structure and pom.xml, and group.id * Feature/remove vitagroup package structure (#501) * add numportal in package structure * Build tagging pipeline (#497) * Feature/change license (#502) * changed test data with vitagroup naming to highmed and License * highmed in License * Update CardDto.java * change to HiGHmed * update to 3.2.4 springboot parent (#503) * remove dependency checker (#505) * start pipeline on PR open (#510) * start pipeline on PR open * start pipeline on PR open * start pipeline on PR edit (#513) * start pipeline on PR edit (#516) * start pipeline on PR ready * change trigger (#519) * Add configuration properties to disable fTTP and sending of emails (#509) * Add config to disable fTTP privacy * Add config to disable sending mails * Merge release branch '1.18.0' back to develop (#523) * updated project version to 1.18.0 * updated development version to 1.19.0-SNAPSHOT --------- Co-authored-by: Github Actions Co-authored-by: Github Actions * add locel environment files (#527) * Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12 (#507) Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.11 to 0.8.12. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.11...v0.8.12) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.postgresql:postgresql from 42.7.2 to 42.7.3 (#492) Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.7.2 to 42.7.3. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.7.2...REL42.7.3) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.testcontainers:postgresql from 1.19.3 to 1.19.7 (#488) Bumps [org.testcontainers:postgresql](https://github.com/testcontainers/testcontainers-java) from 1.19.3 to 1.19.7. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.3...1.19.7) --- updated-dependencies: - dependency-name: org.testcontainers:postgresql dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump springdoc.version from 2.3.0 to 2.5.0 (#520) Bumps `springdoc.version` from 2.3.0 to 2.5.0. Updates `org.springdoc:springdoc-openapi-starter-webmvc-ui` from 2.3.0 to 2.5.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/main/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v2.3.0...v2.5.0) Updates `org.springdoc:springdoc-openapi-starter-common` from 2.3.0 to 2.5.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/main/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v2.3.0...v2.5.0) --- updated-dependencies: - dependency-name: org.springdoc:springdoc-openapi-starter-webmvc-ui dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springdoc:springdoc-openapi-starter-common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.wiremock:wiremock-standalone from 3.2.0 to 3.5.4 (#525) Bumps [org.wiremock:wiremock-standalone](https://github.com/wiremock/wiremock) from 3.2.0 to 3.5.4. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/3.2.0...3.5.4) --- updated-dependencies: - dependency-name: org.wiremock:wiremock-standalone dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.springframework.cloud:spring-cloud-dependencies (#521) Bumps [org.springframework.cloud:spring-cloud-dependencies](https://github.com/spring-cloud/spring-cloud-release) from 2023.0.0 to 2023.0.1. - [Release notes](https://github.com/spring-cloud/spring-cloud-release/releases) - [Commits](https://github.com/spring-cloud/spring-cloud-release/compare/v2023.0.0...v2023.0.1) --- updated-dependencies: - dependency-name: org.springframework.cloud:spring-cloud-dependencies dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add isvalid method (#530) * Update application-deploy.yml: add logging (#531) * maintenance and openehr-sdk update * Feature/delete status cake (#539) * add isvalid method * delete statuscake * delete status endpoint * fixed test * delete test * delete announcement path to health website * endpoint * endpoint without / * change whitelisting name for endpoint * delete classes without uses * Make the EHR ID path configurable (#542) * update spring boot parent (#540) * Feature/fix tests (#545) * fix unit Test * remove unused const * back to spring boot parent 3.2.5 (#546) * back to spring boot parent 2.5.2 * back to spring boot parent 3.2.5 * Feature/back to parent 2.5.2 (#547) * back to spring boot parent 2.5.2 * back to spring boot parent 3.2.5 * added /auth * try (#548) * override * Feature/id path branch to fix ehrproperties (#549) * override * override * Feature/id path branch to fix ehrproperties (#550) * override * override * build in the deleted PR * build in the deleted PR * Bump org.springframework.cloud:spring-cloud-dependencies (#551) Bumps [org.springframework.cloud:spring-cloud-dependencies](https://github.com/spring-cloud/spring-cloud-release) from 2023.0.1 to 2023.0.2. - [Release notes](https://github.com/spring-cloud/spring-cloud-release/releases) - [Commits](https://github.com/spring-cloud/spring-cloud-release/compare/v2023.0.1...v2023.0.2) --- updated-dependencies: - dependency-name: org.springframework.cloud:spring-cloud-dependencies dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix problems with loading resources in JARs (#541) ClassPathResource.getFile() does not work if the resource cannot be resolved as absolute file path * replace codex to rdp (#553) * replace codex to rdp * Feature/id path branch to fix ehrproperties (#550) * override * override * build in the deleted PR * build in the deleted PR * Bump org.springframework.cloud:spring-cloud-dependencies (#551) Bumps [org.springframework.cloud:spring-cloud-dependencies](https://github.com/spring-cloud/spring-cloud-release) from 2023.0.1 to 2023.0.2. - [Release notes](https://github.com/spring-cloud/spring-cloud-release/releases) - [Commits](https://github.com/spring-cloud/spring-cloud-release/compare/v2023.0.1...v2023.0.2) --- updated-dependencies: - dependency-name: org.springframework.cloud:spring-cloud-dependencies dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix problems with loading resources in JARs (#541) ClassPathResource.getFile() does not work if the resource cannot be resolved as absolute file path * changed shouldSuccessfullyExecutemanagerProject --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andreas * updated project version to 1.18.0 * updated release version to 1.18.0 --------- Signed-off-by: dependabot[bot] Co-authored-by: crisdelta <36267049+crisdelta@users.noreply.github.com> Co-authored-by: cdeac Co-authored-by: mafasva <156201303+mafasva@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ramueSVA <156297972+ramueSVA@users.noreply.github.com> Co-authored-by: romanschneidersva <156323591+romanschneidersva@users.noreply.github.com> Co-authored-by: Andreas Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Github Actions Co-authored-by: Github Actions Co-authored-by: Uwe Janßen Co-authored-by: Andreas Co-authored-by: rmueller --- .circleci/README.md | 31 - .circleci/config.yml | 238 -------- .github/dependabot.yml | 17 + .github/workflows/build-for-development.yml | 83 +++ .github/workflows/create-release-branch.yml | 85 +++ .github/workflows/nightly.yml | 57 ++ .github/workflows/release-new-tag.yml | 31 + .github/workflows/release.yml | 115 ++++ LICENSE | 2 +- NOTICE.md | 2 +- README.md | 18 +- local-env/.env-template | 16 + local-env/configDB.sql | 204 +++++++ local-env/docker-compose.yaml | 71 +++ local-env/keycloak.conf | 9 + local-env/num-portal-webapp.json | 64 ++ local-env/num-portal.json | 62 ++ pom.xml | 76 +-- sonar-project.properties | 18 - .../de/vitagroup/num/domain/dto/Language.java | 5 - .../num/domain/model/ExportType.java | 6 - .../vitagroup/num/domain/model/Operator.java | 5 - .../vitagroup/num/domain/model/SetupType.java | 55 -- .../de/vitagroup/num/domain/model/Type.java | 6 - .../num/service/SetupHealthiness.java | 163 ----- .../num/service/TemplateService.java | 99 --- .../num/service/html/HtmlContent.java | 102 ---- .../num/service/policy/EhrPolicy.java | 44 -- .../service/policy/EuropeanConsentPolicy.java | 44 -- .../vitagroup/num/service/policy/Policy.java | 201 ------ .../num/service/policy/TemplatesPolicy.java | 43 -- .../numportal}/NumPortalApplication.java | 6 +- .../attachment/AttachmentRepository.java | 6 +- .../attachment/domain/dto/AttachmentDto.java | 2 +- .../domain/dto/LightAttachmentDto.java | 2 +- .../attachment/domain/model/Attachment.java | 4 +- .../repository/AttachmentRepositoryImpl.java | 8 +- .../repository/AttachmentRepositoryJpa.java | 4 +- .../attachment/service/AttachmentService.java | 32 +- .../attachment/service/ClamAVService.java | 6 +- .../attachment/service/FileScanService.java | 8 +- .../numportal}/config/CachingConfig.java | 7 +- .../config/ClientTemplateProviderConfig.java | 6 +- .../numportal}/config/EhrBaseConfig.java | 13 +- .../numportal}/config/FttpClientConfig.java | 11 +- .../numportal}/config/MapperConfig.java | 2 +- .../config/MessageSourceConfiguration.java | 11 +- .../database/NumAttachmentFlywayConfig.java | 2 +- ...rtalAttachmentDatasourceConfiguration.java | 6 +- .../NumPortalDatasourceConfiguration.java | 6 +- .../database/NumPortalFlywayConfig.java | 2 +- .../numportal}/domain/dto/AqlCategoryDto.java | 4 +- .../highmed/numportal}/domain/dto/AqlDto.java | 15 +- .../numportal}/domain/dto/CardDto.java | 10 +- .../numportal}/domain/dto/CohortAqlDto.java | 6 +- .../numportal}/domain/dto/CohortDto.java | 9 +- .../numportal}/domain/dto/CohortGroupDto.java | 12 +- .../numportal}/domain/dto/CohortSizeDto.java | 2 +- .../numportal}/domain/dto/CommentDto.java | 8 +- .../numportal/domain/dto/Language.java | 5 + .../domain/dto/ManagerProjectDto.java | 6 +- .../numportal}/domain/dto/MetricsDto.java | 2 +- .../domain/dto/NavigationItemDto.java | 8 +- .../domain/dto/OrganizationDto.java | 6 +- .../domain/dto/ParameterOptionsDto.java | 3 +- .../numportal}/domain/dto/ProjectDto.java | 17 +- .../numportal}/domain/dto/ProjectInfoDto.java | 2 +- .../numportal}/domain/dto/ProjectViewTO.java | 6 +- .../numportal}/domain/dto/RawQueryDto.java | 7 +- .../numportal}/domain/dto/SearchCriteria.java | 4 +- .../numportal}/domain/dto/SearchFilter.java | 2 +- .../numportal}/domain/dto/SlimAqlDto.java | 7 +- .../domain/dto/TemplateInfoDto.java | 7 +- .../domain/dto/TemplateMetadataDto.java | 2 +- .../domain/dto/TemplateSizeRequestDto.java | 8 +- .../numportal}/domain/dto/UserDetailsDto.java | 5 +- .../numportal}/domain/dto/UserNameDto.java | 5 +- .../numportal}/domain/dto/ZarsInfoDto.java | 9 +- .../highmed/numportal}/domain/model/Aql.java | 16 +- .../numportal}/domain/model/AqlCategory.java | 9 +- .../numportal}/domain/model/Cohort.java | 5 +- .../numportal}/domain/model/CohortAql.java | 2 +- .../numportal}/domain/model/CohortGroup.java | 16 +- .../numportal}/domain/model/Comment.java | 11 +- .../numportal}/domain/model/Content.java | 13 +- .../numportal}/domain/model/ContentType.java | 2 +- .../numportal}/domain/model/EntityGroup.java | 2 +- .../numportal/domain/model/ExportType.java | 6 + .../numportal}/domain/model/MailDomain.java | 11 +- .../numportal/domain/model/Operator.java | 5 + .../numportal}/domain/model/Organization.java | 6 +- .../numportal}/domain/model/Project.java | 16 +- .../domain/model/ProjectCategories.java | 2 +- .../domain/model/ProjectStatus.java | 8 +- .../domain/model/ProjectTransition.java | 13 +- .../numportal}/domain/model/Roles.java | 2 +- .../numportal}/domain/model/Translation.java | 6 +- .../highmed/numportal/domain/model/Type.java | 6 + .../numportal}/domain/model/admin/Role.java | 2 +- .../numportal}/domain/model/admin/User.java | 10 +- .../domain/model/admin/UserDetails.java | 10 +- .../repository/AqlCategoryRepository.java | 4 +- .../domain/repository/AqlConverter.java | 7 +- .../domain/repository/AqlRepository.java | 4 +- .../repository/CategorySetConverter.java | 9 +- .../repository/CohortGroupRepository.java | 4 +- .../domain/repository/CohortRepository.java | 4 +- .../domain/repository/CommentRepository.java | 4 +- .../repository/ContentItemRepository.java | 6 +- .../repository/CustomProjectRepository.java | 6 +- .../repository/MailDomainRepository.java | 4 +- .../domain/repository/MapConverter.java | 4 +- .../repository/OrganizationRepository.java | 4 +- .../domain/repository/ProjectRepository.java | 6 +- .../repository/ProjectRepositoryImpl.java | 18 +- .../ProjectTransitionRepository.java | 6 +- .../domain/repository/StringSetConverter.java | 7 +- .../repository/TranslationRepository.java | 4 +- .../repository/UserDetailsRepository.java | 4 +- .../specification/AqlSpecification.java | 18 +- .../specification/BaseSpecification.java | 4 +- .../OrganizationSpecification.java | 11 +- .../specification/ProjectSpecification.java | 18 +- .../UserDetailsSpecification.java | 8 +- .../domain/templates/ExceptionsTemplate.java | 8 +- .../domain/validation/CohortValidator.java | 11 +- .../validation/TranslatedStringValidator.java | 7 +- .../domain/validation/ValidCohort.java | 6 +- .../validation/ValidTranslatedString.java | 7 +- .../events/DeactivateUserEvent.java | 2 +- .../listeners/DeactivateUserListener.java | 6 +- .../numportal}/listeners/UserCacheInit.java | 4 +- .../highmed/numportal}/mapper/AqlMapper.java | 10 +- .../numportal}/mapper/CohortMapper.java | 17 +- .../numportal}/mapper/CommentMapper.java | 10 +- .../numportal}/mapper/OrganizationMapper.java | 14 +- .../numportal}/mapper/ProjectMapper.java | 15 +- .../numportal}/mapper/ProjectViewMapper.java | 10 +- .../numportal}/mapper/TemplateMapper.java | 8 +- .../numportal}/mapper/UserDetailsMapper.java | 9 +- .../properties/ClamAVProperties.java | 2 +- .../properties/ConsentProperties.java | 2 +- .../numportal}/properties/CorsProperties.java | 7 +- .../properties/EhrBaseProperties.java | 8 +- .../numportal}/properties/FttpProperties.java | 2 +- .../numportal}/properties/NumProperties.java | 3 +- .../properties/PrivacyProperties.java | 3 +- .../PseudonymsPsnWorkflowProperties.java | 2 +- .../properties/SwaggerProperties.java | 2 +- .../numportal}/service/AqlService.java | 42 +- .../numportal}/service/CohortService.java | 88 +-- .../numportal}/service/CommentService.java | 30 +- .../numportal}/service/ContentService.java | 36 +- .../service/OrganizationService.java | 34 +- .../numportal}/service/ProjectDocCreator.java | 37 +- .../numportal}/service/ProjectService.java | 63 +- .../numportal/service/TemplateService.java | 109 ++++ .../service/UserDetailsService.java | 42 +- .../numportal}/service/UserService.java | 56 +- .../service/atna/AtnaProperties.java | 2 +- .../numportal}/service/atna/AtnaService.java | 11 +- .../service/ehrbase/CompositionFlattener.java | 22 +- .../CompositionResponseDataBuilder.java | 14 +- .../service/ehrbase/EhrBaseService.java | 153 ++--- .../service/ehrbase/ParameterService.java | 112 ++-- .../service/ehrbase/Pseudonymity.java | 13 +- .../service/ehrbase/ResponseFilter.java | 37 +- .../service/email/EmailProperties.java | 3 +- .../service/email/EmailService.java | 15 +- .../service/email/MessageSourceWrapper.java | 2 +- .../service/email/ZarsProperties.java | 2 +- .../numportal}/service/email/ZarsService.java | 25 +- .../exception/BadCredentialsException.java | 2 +- .../exception/BadRequestException.java | 2 +- .../service/exception/CustomException.java | 2 +- .../exception/CustomizedExceptionHandler.java | 64 +- .../exception/EntityNotFoundException.java | 2 +- .../service/exception}/ExceptionDto.java | 2 +- .../service/exception/ForbiddenException.java | 2 +- .../exception/IllegalArgumentException.java | 2 +- .../service/exception/PrivacyException.java | 2 +- .../service/exception/ResourceNotFound.java | 2 +- .../exception/SameEntityExistsException.java | 2 +- .../service/exception/SystemException.java | 2 +- .../exception/TokenIsNotValidException.java | 2 +- .../exception/UserUnauthorizedException.java | 4 +- ...nameNotFoundOrNoLongerActiveException.java | 2 +- .../service/exception/dto/ErrorDetails.java | 2 +- .../service/exception/dto}/ExceptionDto.java | 2 +- .../BadCredentialsException.java | 2 +- .../implementation/CustomException.java | 2 +- .../EntityNotFoundException.java | 2 +- .../SameEntityExistsException.java | 2 +- .../TokenIsNotValidException.java | 2 +- ...nameNotFoundOrNoLongerActiveException.java | 2 +- .../service/executors/AqlExecutor.java | 35 +- .../service/executors/CohortExecutor.java | 21 +- .../service/executors/CohortQueryLister.java | 19 +- .../executors/SetOperationsService.java | 8 +- .../numportal}/service/logger/AuditLog.java | 2 +- .../numportal}/service/logger/NumLogger.java | 6 +- .../notification/NotificationService.java | 13 +- .../notification/dto/NewUserNotification.java | 4 +- ...ewUserWithoutOrganizationNotification.java | 7 +- .../notification/dto/Notification.java | 9 +- .../ProjectApprovalRequestNotification.java | 7 +- .../dto/ProjectCloseNotification.java | 7 +- .../dto/ProjectStartNotification.java | 7 +- .../dto/ProjectStatusChangeNotification.java | 9 +- ...rojectStatusChangeRequestNotification.java | 6 +- .../account/AccountApprovalNotification.java | 9 +- .../AccountStatusChangedNotification.java | 6 +- .../OrganizationUpdateNotification.java | 9 +- .../dto/account/RolesUpdateNotification.java | 8 +- .../account/UserNameUpdateNotification.java | 9 +- .../numportal/service/policy/EhrPolicy.java | 59 ++ .../service/policy/EuropeanConsentPolicy.java | 48 ++ .../numportal/service/policy/Policy.java | 216 +++++++ .../service/policy/ProjectPolicyService.java | 16 +- .../service/policy/TemplatesPolicy.java | 48 ++ .../service/util/AqlQueryConstants.java | 13 + .../web/config/ApplicationSecurity.java | 28 +- .../web/config/AuthorizationConverter.java | 2 +- .../numportal}/web/config/CorsConfig.java | 4 +- .../web/config/FeignClientConfig.java | 4 +- .../highmed/numportal}/web/config/Role.java | 2 +- .../numportal}/web/config/SwaggerConfig.java | 8 +- .../web/controller/AdminController.java | 77 +-- .../web/controller/AqlController.java | 38 +- .../web/controller/CohortController.java | 36 +- .../web/controller/ContentController.java | 24 +- .../controller/NumAttachmentController.java | 27 +- .../controller/OrganizationController.java | 35 +- .../web/controller/ProfileController.java | 12 +- .../web/controller/ProjectController.java | 59 +- .../web/controller/TemplateController.java | 12 +- .../numportal}/web/feign/KeycloakFeign.java | 6 +- .../web/feign/config/ClientTokenProvider.java | 3 +- .../web/feign/config/FeignInterceptor.java | 2 +- .../web/feign/config/OAuth2Configuration.java | 7 +- .../web/feign/config/TokenProvider.java | 2 +- src/main/resources/application-deploy.yml | 19 +- src/main/resources/application-local.yml | 26 +- src/main/resources/application.yml | 26 +- .../resourcebundle/resource.properties | 20 +- .../resourcebundle/resource_de.properties | 30 +- .../resourcebundle/resource_en.properties | 30 +- .../tests/AdminControllerIT.java | 191 ------ .../tests/HealthEndpointIT.java | 66 -- .../num/service/email/EmailServiceTest.java | 52 -- .../numportal}/TestNumPortalApplication.java | 9 +- .../repository/AttachmentRepositoryTest.java | 8 +- .../service/AttachmentServiceTest.java | 40 +- .../attachment/service/ClamAVServiceTest.java | 6 +- .../service/FileScanServiceTest.java | 8 +- .../highmed/numportal}/domain/RolesTest.java | 8 +- .../domain/dto/SearchCriteriaTest.java | 5 +- .../repository/ProjectRepositoryImplTest.java | 17 +- .../specification/AqlSpecificationTest.java | 11 +- .../OrganizationSpecificationTest.java | 13 +- .../ProjectSpecificationTest.java | 15 +- .../UserDetailsSpecificationTest.java | 7 +- .../validation/CohortValidatorTest.java | 26 +- .../config/AttachmentPostgresqlContainer.java | 2 +- .../config/ClamAVContainer.java | 2 +- .../config/NumPostgresqlContainer.java | 2 +- .../security/TokenGenerator.java | 2 +- .../security/WithMockNumUser.java | 5 +- ...WithMockNumUserSecurityContextFactory.java | 2 +- .../tests/AdminControllerIT.java | 102 ++++ .../tests/AqlControllerIT.java | 19 +- .../tests/CohortControllerIT.java | 32 +- .../tests/IntegrationTest.java | 30 +- .../tests/OrganizationControllerIT.java | 26 +- .../tests/ProjectControllerIT.java | 28 +- .../tests/TemplateControllerIT.java | 6 +- .../numportal}/mapper/AqlMapperTest.java | 39 +- .../numportal}/mapper/CohortMapperTest.java | 26 +- .../numportal}/mapper/CommentMapperTest.java | 17 +- .../mapper/OrganizationMapperTest.java | 17 +- .../numportal}/mapper/ProjectMapperTest.java | 24 +- .../mapper/ProjectViewMapperTest.java | 17 +- .../numportal}/mapper/TemplateMapperTest.java | 9 +- .../mapper/UserDetailsMapperTest.java | 11 +- .../numportal}/service/AqlServiceTest.java | 38 +- .../numportal}/service/CohortServiceTest.java | 43 +- .../service/CommentServiceTest.java | 45 +- .../service/ContentServiceTest.java | 55 +- .../service/EhrBaseServiceTest.java | 89 +-- .../service/OrganizationServiceTest.java | 42 +- .../service/ProjectDocCreatorTest.java | 16 +- .../service/ProjectServiceTest.java | 220 ++++--- .../service/TemplateServiceTest.java | 39 +- .../service/UserDetailsServiceTest.java | 58 +- .../numportal}/service/UserServiceTest.java | 66 +- .../ehrbase/CompositionFlattenerTest.java | 35 +- .../CompositionResponseDataBuilderTest.java | 27 +- .../service/ehrbase/ParameterServiceTest.java | 27 +- .../ehrbase/PseudonimytyCodexPSNTest.java | 11 +- .../service/ehrbase/PseudonymityTest.java | 20 +- .../service/ehrbase/ResponseFilterTest.java | 5 +- .../service/email/EmailServiceTest.java | 70 +++ .../service/executors/AqlExecutorTest.java | 13 +- .../service/executors/CohortExecutorTest.java | 32 +- .../executors/CohortQueryListerTest.java | 11 +- .../executors/SetOperationsServiceTest.java | 20 +- .../service/logger/NumLoggerTest.java | 6 +- .../notification/NotificationServiceTest.java | 62 +- .../service/policy/EhrPolicyTest.java | 17 +- .../policy/EuropeanConsentPolicyTest.java | 14 +- .../policy/ProjectPolicyServiceTest.java | 15 +- .../service/policy/TemplatesPolicyTest.java | 22 +- .../service/zars/MemoryAppender.java | 2 +- .../service/zars/TestMessageSource.java | 5 +- .../service/zars/ZarsServiceTest.java | 24 +- src/test/resources/application-itest.yml | 14 +- src/test/resources/application.yml | 10 +- .../health-check/NUM-Codex-Status.html | 577 ------------------ .../health-check/statusCakeResponse.json | 101 --- .../statusCakeResponseWithAnnouncements.json | 101 --- src/test/resources/testdata/expected.json | 2 - 321 files changed, 3636 insertions(+), 4227 deletions(-) delete mode 100644 .circleci/README.md delete mode 100644 .circleci/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build-for-development.yml create mode 100644 .github/workflows/create-release-branch.yml create mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/release-new-tag.yml create mode 100644 .github/workflows/release.yml create mode 100644 local-env/.env-template create mode 100644 local-env/configDB.sql create mode 100644 local-env/docker-compose.yaml create mode 100644 local-env/keycloak.conf create mode 100644 local-env/num-portal-webapp.json create mode 100644 local-env/num-portal.json delete mode 100644 src/main/java/de/vitagroup/num/domain/dto/Language.java delete mode 100644 src/main/java/de/vitagroup/num/domain/model/ExportType.java delete mode 100644 src/main/java/de/vitagroup/num/domain/model/Operator.java delete mode 100644 src/main/java/de/vitagroup/num/domain/model/SetupType.java delete mode 100644 src/main/java/de/vitagroup/num/domain/model/Type.java delete mode 100644 src/main/java/de/vitagroup/num/service/SetupHealthiness.java delete mode 100644 src/main/java/de/vitagroup/num/service/TemplateService.java delete mode 100644 src/main/java/de/vitagroup/num/service/html/HtmlContent.java delete mode 100644 src/main/java/de/vitagroup/num/service/policy/EhrPolicy.java delete mode 100644 src/main/java/de/vitagroup/num/service/policy/EuropeanConsentPolicy.java delete mode 100644 src/main/java/de/vitagroup/num/service/policy/Policy.java delete mode 100644 src/main/java/de/vitagroup/num/service/policy/TemplatesPolicy.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/NumPortalApplication.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/AttachmentRepository.java (74%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/dto/AttachmentDto.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/dto/LightAttachmentDto.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/model/Attachment.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/repository/AttachmentRepositoryImpl.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/repository/AttachmentRepositoryJpa.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/AttachmentService.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/ClamAVService.java (96%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/FileScanService.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/CachingConfig.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/ClientTemplateProviderConfig.java (67%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/EhrBaseConfig.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/FttpClientConfig.java (96%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/MapperConfig.java (87%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/MessageSourceConfiguration.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/database/NumAttachmentFlywayConfig.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/database/NumPortalAttachmentDatasourceConfiguration.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/database/NumPortalDatasourceConfiguration.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/config/database/NumPortalFlywayConfig.java (94%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/AqlCategoryDto.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/AqlDto.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CardDto.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CohortAqlDto.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CohortDto.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CohortGroupDto.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CohortSizeDto.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/CommentDto.java (76%) create mode 100644 src/main/java/org/highmed/numportal/domain/dto/Language.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ManagerProjectDto.java (63%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/MetricsDto.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/NavigationItemDto.java (75%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/OrganizationDto.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ParameterOptionsDto.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ProjectDto.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ProjectInfoDto.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ProjectViewTO.java (79%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/RawQueryDto.java (71%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/SearchCriteria.java (94%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/SearchFilter.java (69%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/SlimAqlDto.java (69%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/TemplateInfoDto.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/TemplateMetadataDto.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/TemplateSizeRequestDto.java (69%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/UserDetailsDto.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/UserNameDto.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/ZarsInfoDto.java (78%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Aql.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/AqlCategory.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Cohort.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/CohortAql.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/CohortGroup.java (69%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Comment.java (73%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Content.java (58%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/ContentType.java (53%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/EntityGroup.java (58%) create mode 100644 src/main/java/org/highmed/numportal/domain/model/ExportType.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/MailDomain.java (65%) create mode 100644 src/main/java/org/highmed/numportal/domain/model/Operator.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Organization.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Project.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/ProjectCategories.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/ProjectStatus.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/ProjectTransition.java (67%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Roles.java (98%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/Translation.java (87%) create mode 100644 src/main/java/org/highmed/numportal/domain/model/Type.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/admin/Role.java (74%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/admin/User.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/model/admin/UserDetails.java (80%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/AqlCategoryRepository.java (87%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/AqlConverter.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/AqlRepository.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/CategorySetConverter.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/CohortGroupRepository.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/CohortRepository.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/CommentRepository.java (73%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/ContentItemRepository.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/CustomProjectRepository.java (57%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/MailDomainRepository.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/MapConverter.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/OrganizationRepository.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/ProjectRepository.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/ProjectRepositoryImpl.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/ProjectTransitionRepository.java (71%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/StringSetConverter.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/TranslationRepository.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/UserDetailsRepository.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/AqlSpecification.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/BaseSpecification.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/OrganizationSpecification.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/ProjectSpecification.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/UserDetailsSpecification.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/templates/ExceptionsTemplate.java (97%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/validation/CohortValidator.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/validation/TranslatedStringValidator.java (76%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/validation/ValidCohort.java (80%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/domain/validation/ValidTranslatedString.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/events/DeactivateUserEvent.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/listeners/DeactivateUserListener.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/listeners/UserCacheInit.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/AqlMapper.java (79%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/CohortMapper.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/CommentMapper.java (74%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/OrganizationMapper.java (74%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/ProjectMapper.java (80%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/ProjectViewMapper.java (70%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/TemplateMapper.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/mapper/UserDetailsMapper.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/ClamAVProperties.java (94%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/ConsentProperties.java (87%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/CorsProperties.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/EhrBaseProperties.java (65%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/FttpProperties.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/NumProperties.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/PrivacyProperties.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/PseudonymsPsnWorkflowProperties.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/properties/SwaggerProperties.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/AqlService.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/CohortService.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/CommentService.java (76%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ContentService.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/OrganizationService.java (94%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ProjectDocCreator.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ProjectService.java (96%) create mode 100644 src/main/java/org/highmed/numportal/service/TemplateService.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/UserDetailsService.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/UserService.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/atna/AtnaProperties.java (85%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/atna/AtnaService.java (97%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/CompositionFlattener.java (84%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/CompositionResponseDataBuilder.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/EhrBaseService.java (62%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/ParameterService.java (73%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/Pseudonymity.java (96%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/ResponseFilter.java (73%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/email/EmailProperties.java (78%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/email/EmailService.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/email/MessageSourceWrapper.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/email/ZarsProperties.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/email/ZarsService.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/BadCredentialsException.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/BadRequestException.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/CustomException.java (78%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/CustomizedExceptionHandler.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/EntityNotFoundException.java (81%) rename src/main/java/{de/vitagroup/num/service/exception/dto => org/highmed/numportal/service/exception}/ExceptionDto.java (78%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/ForbiddenException.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/IllegalArgumentException.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/PrivacyException.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/ResourceNotFound.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/SameEntityExistsException.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/SystemException.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/TokenIsNotValidException.java (81%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/UserUnauthorizedException.java (87%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/UsernameNotFoundOrNoLongerActiveException.java (83%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/dto/ErrorDetails.java (92%) rename src/main/java/{de/vitagroup/num/service/exception => org/highmed/numportal/service/exception/dto}/ExceptionDto.java (77%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/BadCredentialsException.java (77%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/CustomException.java (73%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/EntityNotFoundException.java (77%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/SameEntityExistsException.java (77%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/TokenIsNotValidException.java (77%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java (79%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/AqlExecutor.java (75%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/CohortExecutor.java (76%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/CohortQueryLister.java (80%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/SetOperationsService.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/logger/AuditLog.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/logger/NumLogger.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/NotificationService.java (79%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/NewUserNotification.java (95%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/NewUserWithoutOrganizationNotification.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/Notification.java (94%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/ProjectApprovalRequestNotification.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/ProjectCloseNotification.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/ProjectStartNotification.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/ProjectStatusChangeNotification.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/ProjectStatusChangeRequestNotification.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/account/AccountApprovalNotification.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/account/AccountStatusChangedNotification.java (91%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/account/OrganizationUpdateNotification.java (88%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/account/RolesUpdateNotification.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/dto/account/UserNameUpdateNotification.java (86%) create mode 100644 src/main/java/org/highmed/numportal/service/policy/EhrPolicy.java create mode 100644 src/main/java/org/highmed/numportal/service/policy/EuropeanConsentPolicy.java create mode 100644 src/main/java/org/highmed/numportal/service/policy/Policy.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/service/policy/ProjectPolicyService.java (70%) create mode 100644 src/main/java/org/highmed/numportal/service/policy/TemplatesPolicy.java create mode 100644 src/main/java/org/highmed/numportal/service/util/AqlQueryConstants.java rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/ApplicationSecurity.java (66%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/AuthorizationConverter.java (97%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/CorsConfig.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/FeignClientConfig.java (71%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/Role.java (97%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/config/SwaggerConfig.java (92%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/AdminController.java (76%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/AqlController.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/CohortController.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/ContentController.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/NumAttachmentController.java (86%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/OrganizationController.java (82%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/ProfileController.java (75%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/ProjectController.java (89%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/controller/TemplateController.java (75%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/feign/KeycloakFeign.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/feign/config/ClientTokenProvider.java (97%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/feign/config/FeignInterceptor.java (93%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/feign/config/OAuth2Configuration.java (90%) rename src/main/java/{de/vitagroup/num => org/highmed/numportal}/web/feign/config/TokenProvider.java (74%) delete mode 100644 src/test/java/de/vitagroup/num/integrationtesting/tests/AdminControllerIT.java delete mode 100644 src/test/java/de/vitagroup/num/integrationtesting/tests/HealthEndpointIT.java delete mode 100644 src/test/java/de/vitagroup/num/service/email/EmailServiceTest.java rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/TestNumPortalApplication.java (70%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/attachment/domain/repository/AttachmentRepositoryTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/AttachmentServiceTest.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/ClamAVServiceTest.java (92%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/attachment/service/FileScanServiceTest.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/RolesTest.java (93%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/dto/SearchCriteriaTest.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/repository/ProjectRepositoryImplTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/AqlSpecificationTest.java (95%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/OrganizationSpecificationTest.java (80%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/ProjectSpecificationTest.java (93%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/specification/UserDetailsSpecificationTest.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/domain/validation/CohortValidatorTest.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/config/AttachmentPostgresqlContainer.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/config/ClamAVContainer.java (92%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/config/NumPostgresqlContainer.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/security/TokenGenerator.java (90%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/security/WithMockNumUser.java (90%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/security/WithMockNumUserSecurityContextFactory.java (96%) create mode 100644 src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/AqlControllerIT.java (96%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/CohortControllerIT.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/IntegrationTest.java (71%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/OrganizationControllerIT.java (91%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/ProjectControllerIT.java (95%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/integrationtesting/tests/TemplateControllerIT.java (87%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/AqlMapperTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/CohortMapperTest.java (86%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/CommentMapperTest.java (84%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/OrganizationMapperTest.java (68%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/ProjectMapperTest.java (86%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/ProjectViewMapperTest.java (81%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/TemplateMapperTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/mapper/UserDetailsMapperTest.java (87%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/AqlServiceTest.java (96%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/CohortServiceTest.java (95%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/CommentServiceTest.java (87%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ContentServiceTest.java (90%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/EhrBaseServiceTest.java (64%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/OrganizationServiceTest.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ProjectDocCreatorTest.java (85%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ProjectServiceTest.java (90%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/TemplateServiceTest.java (78%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/UserDetailsServiceTest.java (85%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/UserServiceTest.java (96%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/CompositionFlattenerTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/CompositionResponseDataBuilderTest.java (91%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/ParameterServiceTest.java (86%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/PseudonimytyCodexPSNTest.java (88%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/PseudonymityTest.java (92%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/ehrbase/ResponseFilterTest.java (95%) create mode 100644 src/test/java/org/highmed/numportal/service/email/EmailServiceTest.java rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/AqlExecutorTest.java (82%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/CohortExecutorTest.java (90%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/CohortQueryListerTest.java (85%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/executors/SetOperationsServiceTest.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/logger/NumLoggerTest.java (94%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/notification/NotificationServiceTest.java (72%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/policy/EhrPolicyTest.java (65%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/policy/EuropeanConsentPolicyTest.java (66%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/policy/ProjectPolicyServiceTest.java (68%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/policy/TemplatesPolicyTest.java (70%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/zars/MemoryAppender.java (91%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/zars/TestMessageSource.java (89%) rename src/test/java/{de/vitagroup/num => org/highmed/numportal}/service/zars/ZarsServiceTest.java (84%) delete mode 100644 src/test/resources/health-check/NUM-Codex-Status.html delete mode 100644 src/test/resources/health-check/statusCakeResponse.json delete mode 100644 src/test/resources/health-check/statusCakeResponseWithAnnouncements.json diff --git a/.circleci/README.md b/.circleci/README.md deleted file mode 100644 index 209ab5ca6..000000000 --- a/.circleci/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Num-portal Pipelines - -## Description - -### Test Stage - -During test stage the application runs the unit tests, integrations tests and dependency-check and stores those as artifacts in CircleCI. -In Artifacts tab in CircleCi you can find the code coverage report of JaCoCo and the dependency-check.html to visualize the -results of the dependency analysis. - -The final step is the sonarscan, which simply uses the CircleCi sonarcloud orb to send the service to analysis to Sonarcloud. - - -### Version Tag Stage - -Is done for branches that follow the following regex naming conventions `^(release\/v\d+\.\d+\.\d+|hotfix\/v\d+\.\d+\.\d+)$` - -For example following branches would execute this step `release/v1.0.1` and `hotfix/v1.0.1`. With these examples -Maven package version would be updated with the given version, and a new commit with tag v1.0.1 would be created and pushed to git. - -### Build and Deploy Stage - -Is done for branches that follow the following regex naming conventions `^(release\/v\d+\.\d+\.\d+|hotfix\/v\d+\.\d+\.\d+|master|develop)$`. - -Meaning the branches executed in the previous step will also execute here, in addition develop and master branches -will execute here. - -In the case of release and hotfix branches a new Docker image is built that has a tag with the version plus suffix -rc, -for example v1.0.1-rc. In the case of master branch the version is pulled from the POM.xml, and that is used as a tag -and in the case of develop, an image with a tag `develop` is pushed. - diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6cfb562c9..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,238 +0,0 @@ -version: 2.1 - -workflows: - version: 2 - nightly: - triggers: - - schedule: - cron: "0 21 * * *" - filters: - branches: - only: - - nightly-builds - jobs: - - test: - context: - - org-global - - ms_teams - build_and_test: - jobs: - - test: - context: - - org-global - - ms_teams - - tag-version: - requires: - - test - filters: - branches: - only: - - /^(release\/v\d+\.\d+\.\d+|hotfix\/v\d+\.\d+\.\d+|master)$/ - - build_and_deploy: - requires: - - test - filters: - branches: - only: - - /^(release\/v\d+\.\d+\.\d+|hotfix\/v\d+\.\d+\.\d+|master|develop)$/ - -jobs: - test: - machine: - image: ubuntu-2204:2022.10.2 - steps: - - checkout - - cache-out-maven-dependencies - - run: - name: Run unit tests - command: ./mvnw clean test - - run: - name: Run integration tests - command: ./mvnw verify -P integration-tests - - run: - name: Run CVE scan - command: ./mvnw dependency-check:check - - run: - name: Save test results - command: | - mkdir -p ~/test-results/unit-tests/ - mkdir -p ~/test-results/integration-tests/ - find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/unit-tests/ \; - find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/test-results/integration-tests/ \; - when: always - - store_artifacts: - path: target/site/jacoco-merged-test-coverage-report - - store_artifacts: - path: target/dependency-check-report.html - - store_test_results: - path: ~/test-results/unit-tests/ - - store_test_results: - path: ~/test-results/integration-tests/ - - sonarcloud/scan - - cache-in-maven-dependencies - - jq/install - - run: - name: Get OWASP report artifact URL - command: | - ARTIFACTS_JSON=$(curl -X GET \ - "https://circleci.com/api/v2/project/github/NUM-Forschungsdatenplattform/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM/artifacts" \ - -H "Accept: application/json") - NUMBER_OF_ITEMS=$(echo $ARTIFACTS_JSON | jq '.items | length') - for (( i=0; i<$NUMBER_OF_ITEMS; i++ )) - do - ITEM=$(echo $ARTIFACTS_JSON | jq '.items['$i']') - PATH_OF_ARTIFACT=$(echo ${ITEM} | jq '.path') - if [[ "$PATH_OF_ARTIFACT" = *"dependency-check-report.html"* ]] - then - echo "export URL_OF_OWASP_REPORT=$(echo $ITEM | jq '.url' -r)" >> $BASH_ENV - break - fi - done - - run: - name: MS Teams OWASP Message - command: | - SHORT_SHA1=`echo -n $CIRCLE_SHA1 | head -c 7` - if [ `echo "$CIRCLE_REPOSITORY_URL" | grep "^git@github.com"` ]; then - COMMIT_LINK=\[$SHORT_SHA1\]\(https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/commit/$CIRCLE_SHA1\) - elif [ `echo "$CIRCLE_REPOSITORY_URL" | grep "^git@bitbucket.org"` ]; then - COMMIT_LINK=\[$SHORT_SHA1\]\(https://bitbucket.org/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/commit/$CIRCLE_SHA1\) - else - >&2 echo unknown version control system: $CIRCLE_REPOSITORY_URL - fail - fi - # Note that the "\<<" in the heredoc declaration is escaped from - # CircleCI's parameters syntax. - MS_TEAMS_MSG_TEMPLATE=$(cat \<> \n\n *CircleCI build:* ${CIRCLE_BUILD_URL} \n\n" - } - ], - "markdown": true - } - ] - } - END_HEREDOC - ) - echo "$MS_TEAMS_MSG_TEMPLATE" > /tmp/ms_teams_message - when: always - - run: - name: Report Build Success - command: | - MSG_PATH=/tmp/ms_teams_success_message - sed -e 's/__build_status__/Success/' -e 's/__theme_color__/14a603/' /tmp/ms_teams_message > $MSG_PATH - curl --fail -H "Content-Type: application/json" --data-binary @$MSG_PATH $CODEX_NOTIFICATIONS - when: on_success - - run: - name: Report Build Failure - command: | - MSG_PATH=/tmp/ms_teams_failure_message - sed -e 's/__build_status__/Failed/' -e 's/__theme_color__/e2091d/' /tmp/ms_teams_message > $MSG_PATH - curl --fail -H "Content-Type: application/json" --data-binary @$MSG_PATH $CODEX_NOTIFICATIONS - when: on_fail - tag-version: - docker: - - image: cimg/openjdk:17.0.8 - steps: - - checkout - - configure-git-for-ci-bot - - run: - name: Update Snapshot Develop Version - description: | - This automatically bumps the application version when there is a commit to release branch - It will set the version number to release branch version number, but it will do it only once. If the commit is - to the master branch, then the pipeline will create a tag and push it to the Git - command: | - VERSION_NUMBER_FROM_BRANCH="$(echo $CIRCLE_BRANCH | awk -F'/v' '{print $2;}')" - VERSION_NUMBER_FROM_POM=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) - if [ $CIRCLE_BRANCH = "master" ]; then - git tag -a $VERSION_NUMBER_FROM_POM -m "num-portal release version ${VERSION_NUMBER_FROM_POM}" - git push origin --tags - elif [ $VERSION_NUMBER_FROM_BRANCH != $VERSION_NUMBER_FROM_POM ]; then - echo "Updating the application version from the branch to ${VERSION_NUMBER_FROM_BRANCH}" - ./mvnw versions:set -DnewVersion=$VERSION_NUMBER_FROM_BRANCH versions:commit - git commit -am "updated project version to v${VERSION_NUMBER_FROM_BRANCH} [skip ci]" - git push --set-upstream origin $CIRCLE_BRANCH - fi - - exit 0 - - build_and_deploy: - docker: - - image: cimg/openjdk:17.0.8 - auth: - username: $DOCKER_USER - password: $DOCKER_HUB_PASSWORD - steps: - - checkout - - configure-git-for-ci-bot - - cache-out-maven-dependencies - - setup_remote_docker: - version: 20.10.23 - - run: - name: Build and tag image and push - command: | - if [ $CIRCLE_BRANCH = "master" ]; then - TAG=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) - git push -u origin master:nightly-builds # Make sure that the nightly build branch is up-to-date with master - elif [ $CIRCLE_BRANCH = "develop" ]; then - TAG=$CIRCLE_BRANCH - else - TAG="$(echo $CIRCLE_BRANCH | awk -F'/v' '{print $2;}')-rc$CIRCLE_BUILD_NUM" - fi - echo "Publishing Docker image with following tag: ${TAG}" - echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin - ./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=$DOCKER_USER/num-portal:$TAG -DskipTests - docker push $DOCKER_USER/num-portal:$TAG - - cache-in-maven-dependencies - -commands: - configure-git-for-ci-bot: - steps: - - add_ssh_keys: - fingerprints: - - 0c:dd:08:d5:13:cf:20:3c:25:c4:f3:59:a8:a5:c4:36 - - run: - name: Configure GIT - command: | - git config --global user.email "50235421+ehrbase-tech-user@users.noreply.github.com" - git config --global user.name "ci-bot" - git remote -v - - - cache-out-maven-dependencies: - steps: - - run: - name: Generate Cache Checksum for Maven Dependencies - command: find /home/circleci/project -name 'pom.xml' | sort | xargs cat > /tmp/num-portal_maven_cache_seed - - restore_cache: - key: v1-num-portal-deps- - - cache-in-maven-dependencies: - steps: - - save_cache: - key: v1-num-portal-deps-{{ checksum "/tmp/num-portal_maven_cache_seed" }} - paths: - - ~/.m2 - - -orbs: - sonarcloud: sonarsource/sonarcloud@2.0.0 - jq: circleci/jq@2.2.0 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..2dfcf5a80 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: maven + directory: "/" + schedule: + interval: daily + time: "04:00" + open-pull-requests-limit: 10 + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build-for-development.yml b/.github/workflows/build-for-development.yml new file mode 100644 index 000000000..84082caa8 --- /dev/null +++ b/.github/workflows/build-for-development.yml @@ -0,0 +1,83 @@ +name: Build for development + +on: + push: + branches: [ 'feature/**', 'dependabot/**' ] + pull_request_target: + branches: [ develop, main ] + types: [ ready_for_review, closed ] + +jobs: + test_and_scan: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Run unit tests + run: mvn clean test + - name: Run integration tests + run: mvn verify -P integration-tests + - name: Prepare test results + run: | + mkdir -p ~/test-results/unit-tests/ + mkdir -p ~/test-results/integration-tests/ + find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/unit-tests/ \; + find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/test-results/integration-tests/ \; + - name: Upload test coverage report + uses: actions/upload-artifact@v4 + with: + name: test-coverage-report + path: target/site/jacoco-merged-test-coverage-report + - name: Upload unit tests report + uses: actions/upload-artifact@v4 + with: + name: unit-tests-report + path: ~/test-results/unit-tests/ + - name: Upload integration tests report + uses: actions/upload-artifact@v4 + with: + name: integration-tests-report + path: ~/test-results/integration-tests/ + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + ignore-unfixed: true + format: 'sarif' + output: 'trivy-results.sarif' + severity: 'CRITICAL,HIGH' + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: 'trivy-results.sarif' + + docker: + needs: test_and_scan + if: github.event.pull_request.merged == true + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Login to docker hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push docker image + run: | + mvn spring-boot:build-image -Dspring-boot.build-image.imageName=${{ secrets.DOCKER_USERNAME }}/num-portal:develop -DskipTests + docker push ${{ secrets.DOCKER_USERNAME }}/num-portal:develop diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml new file mode 100644 index 000000000..cf095f1f9 --- /dev/null +++ b/.github/workflows/create-release-branch.yml @@ -0,0 +1,85 @@ +name: Create release branch + +on: + workflow_dispatch: + branches: [ develop ] + inputs: + release: + description: 'Type of the release.' + type: choice + options: + - major + - minor + - patch + default: minor + +jobs: + create_branch: + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/develop' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Create version + id: createVersion + run: | + CURRENT_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec) + echo "Current version: $CURRENT_VERSION" + MAJOR=`echo $CURRENT_VERSION | cut -d. -f1` + MINOR=`echo $CURRENT_VERSION | cut -d. -f2` + PATCH=`echo $CURRENT_VERSION | cut -d. -f3 | cut -d- -f1` + + if [ ${{ inputs.release }} == 'major' ]; then + MAJOR=$((MAJOR+1)) + MINOR=0 + PATCH=0 + elif [ ${{ inputs.release }} == 'minor' ]; then + MINOR=$((MINOR+1)) + PATCH=0 + else + PATCH=$((PATCH+1)) + fi + + VERSION=${MAJOR}.${MINOR}.${PATCH} + + echo + echo "Release version: $VERSION" + + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@v4 + - name: Create release branch + env: + VERSION: ${{ steps.createVersion.outputs.VERSION }} + run: | + git config --global user.email "github-actions@example.com" + git config --global user.name "Github Actions" + + git branch release/$VERSION + git checkout release/$VERSION + + mvn versions:set -DnewVersion=${VERSION}-SNAPSHOT versions:commit + git add pom.xml + git commit -m "updated project version to ${VERSION}" + + git push --set-upstream origin release/$VERSION + + wrong_branch: + if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/develop' + + runs-on: ubuntu-latest + + steps: + - name: ERROR + run: echo 'This workflow only runs on develop branch!' diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..f947fe437 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,57 @@ +name: Nightly + +on: + schedule: + - cron: '0 21 * * *' + +jobs: + verify: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Run unit tests + run: mvn clean test + - name: Run integration tests + run: mvn verify -P integration-tests + continue-on-error: true + - name: Prepare test results + run: | + mkdir -p ~/test-results/unit-tests/ + mkdir -p ~/test-results/integration-tests/ + find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/unit-tests/ \; + find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/test-results/integration-tests/ \; + - name: Upload test coverage report + uses: actions/upload-artifact@v4 + with: + name: test-coverage-report + path: target/site/jacoco-merged-test-coverage-report + - name: Upload unit tests report + uses: actions/upload-artifact@v4 + with: + name: unit-tests-report + path: ~/test-results/unit-tests/ + - name: Upload integration tests report + uses: actions/upload-artifact@v4 + with: + name: integration-tests-report + path: ~/test-results/integration-tests/ + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + ignore-unfixed: true + format: 'sarif' + output: 'trivy-results.sarif' + severity: 'CRITICAL,HIGH' + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: 'trivy-results.sarif' diff --git a/.github/workflows/release-new-tag.yml b/.github/workflows/release-new-tag.yml new file mode 100644 index 000000000..9bba506f3 --- /dev/null +++ b/.github/workflows/release-new-tag.yml @@ -0,0 +1,31 @@ +name: Release new tag + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Login to docker hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push docker image + run: | + mvn spring-boot:build-image -Dspring-boot.build-image.imageName=${{ secrets.DOCKER_USERNAME }}/num-portal:${{ github.ref_name }} -DskipTests + docker tag ${{ secrets.DOCKER_USERNAME }}/num-portal ${{ secrets.DOCKER_USERNAME }}/num-portal:${{ github.ref_name }} + docker push ${{ secrets.DOCKER_USERNAME }}/num-portal:${{ github.ref_name }} + + echo "### :rocket: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..2ed030da1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,115 @@ +name: release + +on: + workflow_dispatch: + branches: [ 'release/**' ] + +env: + RELEASE_VERSION: '' + DEV_VERSION: '' + +jobs: + + read_version: + runs-on: ubuntu-latest + + outputs: + DEV_VERSION: ${{ steps.createVersion.outputs.DEV_VERSION}} + RELEASE_VERSION: ${{ steps.createVersion.outputs.RELEASE_VERSION}} + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Create new development version + id: createVersion + run: | + CURRENT_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec) + RELEASE_VERSION=`echo $CURRENT_VERSION | cut -d- -f1` + echo "Current version: $CURRENT_VERSION" + MAJOR=`echo $CURRENT_VERSION | cut -d. -f1` + MINOR=`echo $CURRENT_VERSION | cut -d. -f2` + + DEV_VERSION=${MAJOR}.$((MINOR+1)).0-SNAPSHOT + + echo + echo "Release version: $RELEASE_VERSION" + echo "Develop version: $DEV_VERSION" + + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT" + echo "DEV_VERSION=${DEV_VERSION}" >> "$GITHUB_OUTPUT" + + echo "### :rocket: ${RELEASE_VERSION}" >> $GITHUB_STEP_SUMMARY + + update_dev: + needs: read_version + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Create branch to update develop version + env: + DEV_VERSION: ${{ needs.read_version.outputs.DEV_VERSION }} + run: | + git config --global user.email "noreply@github.com" + git config --global user.name "Github Actions" + + git branch feature/update_develop_${DEV_VERSION} + git checkout feature/update_develop_${DEV_VERSION} + + mvn versions:set -DnewVersion=${DEV_VERSION} versions:commit + git commit -am "updated development version to ${DEV_VERSION}" + + git push --set-upstream origin feature/update_develop_${DEV_VERSION} + + - name: Create PR to merge changes to Develop and update Version + env: + RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }} + GH_TOKEN: ${{ github.token }} + run: | + PR_URL=`gh pr create --draft -B develop --title "Merge release branch '${RELEASE_VERSION}' back to develop" --body "Merge release branch '${RELEASE_VERSION}' back to develop"` + echo $PR_URL + + release: + needs: read_version + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Set release version + env: + RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }} + run: | + git config --global user.email "noreply@github.com" + git config --global user.name "Github Actions" + + mvn versions:set -DremoveSnapshot versions:commit + git commit -am "updated release version to ${RELEASE_VERSION}" + git push + + - name: Create PR to merge release branch to main + env: + RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }} + GH_TOKEN: ${{ github.token }} + run: | + PR_URL=`gh pr create --draft -B main --title "Merge release branch '${RELEASE_VERSION}'" --body "Merge release branch '${RELEASE_VERSION}'"` + echo $PR_URL diff --git a/LICENSE b/LICENSE index 261eeb9e9..9398860e4 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright [2024] [HiGHmed e.V.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE.md b/NOTICE.md index 00d304f46..9a398203a 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1,6 +1,6 @@ ## Num-portal -Copyright 2021 Vitagroup AG +Copyright 2024 HiGHmed e.V. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index f2c72e7d1..293a77361 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,30 @@ # Num-portal -### Building and running locally +## Building and running locally 1. Postgres should be up and running, instructions below In the root folder of the project, open cmd and run: -1. Build app: ```mvn clean install``` -2. Run: ```mvn spring-boot:run``` +1. Build app: `mvn clean install` +2. Run: `mvn spring-boot:run` -### Database +## Database Start a local instance of PostgreSQL: -``` +``` docker run --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres ``` -### Swagger +## Swagger -http://localhost:8090/swagger-ui/ +http://localhost:8090/swagger-ui/index.html -### License +## License -Copyright 2021 vitagroup AG +Copyright 2024 HiGHmed e.V. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/local-env/.env-template b/local-env/.env-template new file mode 100644 index 000000000..298eb73b0 --- /dev/null +++ b/local-env/.env-template @@ -0,0 +1,16 @@ +# keycloak +KEYCLOAK_ADMIN=keycloak +KEYCLOAK_ADMIN_PASSWORD=admin +KC_DB_USERNAME=keycloak +KC_DB_PASSWORD=password +# postgres +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +# pgadmin +PGADMIN_DEFAULT_EMAIL=admin@domain.de +PGADMIN_DEFAULT_PASSWORD=admin +# ehrbase +DB_USER_ADMIN=ehrbase +DB_PASS_ADMIN=ehrbase +DB_USER=ehrbase_restricted +DB_PASS=ehrbase_restricted diff --git a/local-env/configDB.sql b/local-env/configDB.sql new file mode 100644 index 000000000..8cd9f8e56 --- /dev/null +++ b/local-env/configDB.sql @@ -0,0 +1,204 @@ +REVOKE CREATE ON SCHEMA public from PUBLIC; +CREATE SCHEMA IF NOT EXISTS ehr AUTHORIZATION ehrbase; +GRANT USAGE ON SCHEMA ehr to ehrbase_restricted; +alter default privileges for user ehrbase in schema ehr grant select,insert,update,delete on tables to ehrbase_restricted; +CREATE SCHEMA IF NOT EXISTS ext AUTHORIZATION ehrbase; +CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA ext; +CREATE EXTENSION IF NOT EXISTS "ltree" SCHEMA ext; + +-- setup the search_patch so the extensions can be found +ALTER DATABASE ehrbase SET search_path TO "$user",public,ext; +-- ensure INTERVAL is ISO8601 encoded +alter database ehrbase SET intervalstyle = 'iso_8601'; + +GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA ext TO ehrbase_restricted; + +-- load the temporal_tables PLPG/SQL functions to emulate the coded extension +-- original source: https://github.com/nearform/temporal_tables/blob/master/versioning_function.sql +CREATE OR REPLACE FUNCTION ext.versioning() + RETURNS TRIGGER AS $$ +DECLARE + sys_period text; + history_table text; + manipulate jsonb; + ignore_unchanged_values bool; + commonColumns text[]; + time_stamp_to_use timestamptz := current_timestamp; + range_lower timestamptz; + transaction_info txid_snapshot; + existing_range tstzrange; + holder record; + holder2 record; + pg_version integer; +BEGIN + -- version 0.4.0 + + IF TG_WHEN != 'BEFORE' OR TG_LEVEL != 'ROW' THEN + RAISE TRIGGER_PROTOCOL_VIOLATED USING + MESSAGE = 'function "versioning" must be fired BEFORE ROW'; + END IF; + + IF TG_OP != 'INSERT' AND TG_OP != 'UPDATE' AND TG_OP != 'DELETE' THEN + RAISE TRIGGER_PROTOCOL_VIOLATED USING + MESSAGE = 'function "versioning" must be fired for INSERT or UPDATE or DELETE'; + END IF; + + IF TG_NARGS not in (3,4) THEN + RAISE INVALID_PARAMETER_VALUE USING + MESSAGE = 'wrong number of parameters for function "versioning"', + HINT = 'expected 3 or 4 parameters but got ' || TG_NARGS; + END IF; + + sys_period := TG_ARGV[0]; + history_table := TG_ARGV[1]; + ignore_unchanged_values := TG_ARGV[3]; + + IF ignore_unchanged_values AND TG_OP = 'UPDATE' AND NEW IS NOT DISTINCT FROM OLD THEN + RETURN OLD; + END IF; + + -- check if sys_period exists on original table + SELECT atttypid, attndims INTO holder FROM pg_attribute WHERE attrelid = TG_RELID AND attname = sys_period AND NOT attisdropped; + IF NOT FOUND THEN + RAISE 'column "%" of relation "%" does not exist', sys_period, TG_TABLE_NAME USING + ERRCODE = 'undefined_column'; + END IF; + IF holder.atttypid != to_regtype('tstzrange') THEN + IF holder.attndims > 0 THEN + RAISE 'system period column "%" of relation "%" is not a range but an array', sys_period, TG_TABLE_NAME USING + ERRCODE = 'datatype_mismatch'; + END IF; + + SELECT rngsubtype INTO holder2 FROM pg_range WHERE rngtypid = holder.atttypid; + IF FOUND THEN + RAISE 'system period column "%" of relation "%" is not a range of timestamp with timezone but of type %', sys_period, TG_TABLE_NAME, format_type(holder2.rngsubtype, null) USING + ERRCODE = 'datatype_mismatch'; + END IF; + + RAISE 'system period column "%" of relation "%" is not a range but type %', sys_period, TG_TABLE_NAME, format_type(holder.atttypid, null) USING + ERRCODE = 'datatype_mismatch'; + END IF; + + IF TG_OP = 'UPDATE' OR TG_OP = 'DELETE' THEN + -- Ignore rows already modified in this transaction + transaction_info := txid_current_snapshot(); + IF OLD.xmin::text >= (txid_snapshot_xmin(transaction_info) % (2^32)::bigint)::text + AND OLD.xmin::text <= (txid_snapshot_xmax(transaction_info) % (2^32)::bigint)::text THEN + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + + RETURN NEW; + END IF; + + SELECT current_setting('server_version_num')::integer + INTO pg_version; + + -- to support postgres < 9.6 + IF pg_version < 90600 THEN + -- check if history table exits + IF to_regclass(history_table::cstring) IS NULL THEN + RAISE 'relation "%" does not exist', history_table; + END IF; + ELSE + IF to_regclass(history_table) IS NULL THEN + RAISE 'relation "%" does not exist', history_table; + END IF; + END IF; + + -- check if history table has sys_period + IF NOT EXISTS(SELECT * FROM pg_attribute WHERE attrelid = history_table::regclass AND attname = sys_period AND NOT attisdropped) THEN + RAISE 'history relation "%" does not contain system period column "%"', history_table, sys_period USING + HINT = 'history relation must contain system period column with the same name and data type as the versioned one'; + END IF; + + EXECUTE format('SELECT $1.%I', sys_period) USING OLD INTO existing_range; + + IF existing_range IS NULL THEN + RAISE 'system period column "%" of relation "%" must not be null', sys_period, TG_TABLE_NAME USING + ERRCODE = 'null_value_not_allowed'; + END IF; + + IF isempty(existing_range) OR NOT upper_inf(existing_range) THEN + RAISE 'system period column "%" of relation "%" contains invalid value', sys_period, TG_TABLE_NAME USING + ERRCODE = 'data_exception', + DETAIL = 'valid ranges must be non-empty and unbounded on the high side'; + END IF; + + IF TG_ARGV[2] = 'true' THEN + -- mitigate update conflicts + range_lower := lower(existing_range); + IF range_lower >= time_stamp_to_use THEN + time_stamp_to_use := range_lower + interval '1 microseconds'; + END IF; + END IF; + + WITH history AS + (SELECT attname, atttypid + FROM pg_attribute + WHERE attrelid = history_table::regclass + AND attnum > 0 + AND NOT attisdropped), + main AS + (SELECT attname, atttypid + FROM pg_attribute + WHERE attrelid = TG_RELID + AND attnum > 0 + AND NOT attisdropped) + SELECT + history.attname AS history_name, + main.attname AS main_name, + history.atttypid AS history_type, + main.atttypid AS main_type + INTO holder + FROM history + INNER JOIN main + ON history.attname = main.attname + WHERE + history.atttypid != main.atttypid; + + IF FOUND THEN + RAISE 'column "%" of relation "%" is of type % but column "%" of history relation "%" is of type %', + holder.main_name, TG_TABLE_NAME, format_type(holder.main_type, null), holder.history_name, history_table, format_type(holder.history_type, null) + USING ERRCODE = 'datatype_mismatch'; + END IF; + + WITH history AS + (SELECT attname + FROM pg_attribute + WHERE attrelid = history_table::regclass + AND attnum > 0 + AND NOT attisdropped), + main AS + (SELECT attname + FROM pg_attribute + WHERE attrelid = TG_RELID + AND attnum > 0 + AND NOT attisdropped) + SELECT array_agg(quote_ident(history.attname)) INTO commonColumns + FROM history + INNER JOIN main + ON history.attname = main.attname + AND history.attname != sys_period; + + EXECUTE ('INSERT INTO ' || + history_table || + '(' || + array_to_string(commonColumns , ',') || + ',' || + quote_ident(sys_period) || + ') VALUES ($1.' || + array_to_string(commonColumns, ',$1.') || + ',tstzrange($2, $3, ''[)''))') + USING OLD, range_lower, time_stamp_to_use; + END IF; + + IF TG_OP = 'UPDATE' OR TG_OP = 'INSERT' THEN + manipulate := jsonb_set('{}'::jsonb, ('{' || sys_period || '}')::text[], to_jsonb(tstzrange(time_stamp_to_use, null, '[)'))); + + RETURN jsonb_populate_record(NEW, manipulate); + END IF; + + RETURN OLD; +END; +$$ LANGUAGE plpgsql; diff --git a/local-env/docker-compose.yaml b/local-env/docker-compose.yaml new file mode 100644 index 000000000..c490ea75d --- /dev/null +++ b/local-env/docker-compose.yaml @@ -0,0 +1,71 @@ +services: + keycloak: + image: quay.io/keycloak/keycloak:24.0 + command: + - start-dev + environment: + KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN} + KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD} + KC_DB: postgres + KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak + KC_DB_USERNAME: ${KC_DB_USERNAME} + KC_DB_PASSWORD: ${KC_DB_PASSWORD} + KC_HOSTNAME: 'localhost:8180' + volumes: + - ./keycloak.conf:/opt/keycloak/conf/keycloak.conf + ports: + - 8180:8080 + networks: + - num-portal + depends_on: + - postgres + postgres: + image: postgres:16.2 + restart: always + ports: + - 5432:5432 + networks: + - num-portal + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + volumes: + - pgdata:/var/lib/postgresql/data + pgadmin: + image: dpage/pgadmin4:8.5 + restart: always + ports: + - 8888:80 + networks: + - num-portal + environment: + PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL} + PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD} + volumes: + - pgadmin-data:/var/lib/pgadmin + depends_on: + - postgres + ehrbase: + image: ehrbase/ehrbase:0.32.0 + ports: + - 8080:8080 + networks: + - num-portal + env_file: + - .env + - .env.ehrbase + environment: + DB_URL: jdbc:postgresql://postgres:5432/ehrbase + DB_USER_ADMIN: ${DB_USER_ADMIN} + DB_PASS_ADMIN: ${DB_PASS_ADMIN} + DB_USER: ${DB_USER} + DB_PASS: ${DB_PASS} + depends_on: + - postgres + +volumes: + pgdata: + pgadmin-data: +networks: + num-portal: + driver: bridge diff --git a/local-env/keycloak.conf b/local-env/keycloak.conf new file mode 100644 index 000000000..c25fd8f03 --- /dev/null +++ b/local-env/keycloak.conf @@ -0,0 +1,9 @@ +proxy=edge +db=postgres +db-url-host=postgres +db-user=keycloak +db-password=password +db-database=keycloak +db-schema=public +hostname-strict=false +http-enabled=true diff --git a/local-env/num-portal-webapp.json b/local-env/num-portal-webapp.json new file mode 100644 index 000000000..3c546dba0 --- /dev/null +++ b/local-env/num-portal-webapp.json @@ -0,0 +1,64 @@ +{ + "clientId": "num-portal-webapp", + "name": "num-portal-webapp", + "description": "", + "rootUrl": "", + "adminUrl": "", + "baseUrl": "", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "secret": "", + "redirectUris": [ + "*" + ], + "webOrigins": [ + "*" + ], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": true, + "serviceAccountsEnabled": false, + "publicClient": true, + "frontchannelLogout": true, + "protocol": "openid-connect", + "attributes": { + "client.secret.creation.time": "1713953831", + "oauth2.device.authorization.grant.enabled": "false", + "backchannel.logout.revoke.offline.tokens": "false", + "use.refresh.tokens": "true", + "oidc.ciba.grant.enabled": "false", + "backchannel.logout.session.required": "true", + "client_credentials.use_refresh_token": "false", + "acr.loa.map": "{}", + "require.pushed.authorization.requests": "false", + "tls.client.certificate.bound.access.tokens": "false", + "display.on.consent.screen": "false", + "token.response.type.bearer.lower-case": "false" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": true, + "nodeReRegistrationTimeout": -1, + "defaultClientScopes": [ + "web-origins", + "acr", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ], + "access": { + "view": true, + "configure": true, + "manage": true + } +} diff --git a/local-env/num-portal.json b/local-env/num-portal.json new file mode 100644 index 000000000..51fc89eb8 --- /dev/null +++ b/local-env/num-portal.json @@ -0,0 +1,62 @@ +{ + "clientId": "num-portal", + "name": "num-portal", + "description": "", + "rootUrl": "", + "adminUrl": "", + "baseUrl": "", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "secret": "", + "redirectUris": [ + "/*" + ], + "webOrigins": [ + "/*" + ], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": true, + "serviceAccountsEnabled": true, + "authorizationServicesEnabled": true, + "publicClient": false, + "frontchannelLogout": true, + "protocol": "openid-connect", + "attributes": { + "oidc.ciba.grant.enabled": "false", + "oauth2.device.authorization.grant.enabled": "false", + "client.secret.creation.time": "1713958982", + "backchannel.logout.session.required": "true", + "backchannel.logout.revoke.offline.tokens": "false", + "login_theme": "", + "display.on.consent.screen": false, + "frontchannel.logout.url": "", + "backchannel.logout.url": "" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": true, + "nodeReRegistrationTimeout": -1, + "defaultClientScopes": [ + "web-origins", + "acr", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ], + "access": { + "view": true, + "configure": true, + "manage": true + } +} diff --git a/pom.xml b/pom.xml index 199a3adaf..907455bc7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,44 +5,41 @@ 4.0.0 - de.vitagroup.num-portal + org.highmed.num-portal num-portal - 1.17.0 - + 1.18.0 + org.springframework.boot spring-boot-starter-parent - 2.7.17 + 3.3.0 4.4 - 2.15.0 - v1.18.0 + 2.16.1 + 2.11.0 - v0.5.1 + 1.0.5 7.4 3.2.0 - 1.7.0 + 2.5.0 17 - 1.10.0 - 0.8.11 - 8.4.2 - 3.2.2 - 3.2.2 + 1.11.0 + 0.8.12 + 3.2.5 + 3.2.5 3.10.8 4.9.10 false false - false - 42.6.0 + 42.7.3 6.8.3 - 3.0.0-beta-7 - 1.19.1 + 3.6.0 + 1.19.8 false - 5.8.8 - 2021.0.8 + 2023.0.2 @@ -109,20 +106,25 @@ ${postgresql.version} runtime + + org.flywaydb + flyway-database-postgresql + org.flywaydb flyway-core org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui ${springdoc.version} org.springdoc - springdoc-openapi-security + springdoc-openapi-starter-common ${springdoc.version} + commons-io commons-io @@ -151,19 +153,19 @@ spring-boot-configuration-processor - com.github.ehrbase.openEHR_SDK + org.ehrbase.openehr.sdk client ${ehr-sdk.version} - com.github.ehrbase.openEHR_SDK + org.ehrbase.openehr.sdk aql ${ehr-sdk.version} - com.github.ehrbase - aql-editor-backend-spring-boot-starter - ${aql-editor-backend-starter.version} + com.github.NUM-Forschungsdatenplattform + num-aql-editor-backend-spring-boot-starter + ${num-aql-editor-backend-starter.version} org.modelmapper @@ -237,7 +239,7 @@ test - com.github.tomakehurst + org.wiremock wiremock-standalone ${wiremock-standalone.version} test @@ -260,7 +262,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.5.0 + 3.6.1 copy-dependencies @@ -383,24 +385,6 @@ - - org.owasp - dependency-check-maven - ${dependency-check.version} - - HTML,XML - ${skip.dependency.check} - ${ossindexAnalyzerEnabled} - false - - - - - check - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/sonar-project.properties b/sonar-project.properties index 639e1bdf6..f862e276f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,21 +1,3 @@ -# -# Copyright (c) 2020 Wladislaw Wagner (Vitasystems GmbH) and Hannover Medical School. -# -# This file is part of project num-portal -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - sonar.organization=num-forschungsdatenplattform sonar.projectKey=NUM-Forschungsdatenplattform_num-portal sonar.host.url=https://sonarcloud.io diff --git a/src/main/java/de/vitagroup/num/domain/dto/Language.java b/src/main/java/de/vitagroup/num/domain/dto/Language.java deleted file mode 100644 index fd1582c2a..000000000 --- a/src/main/java/de/vitagroup/num/domain/dto/Language.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.vitagroup.num.domain.dto; - -public enum Language { - de, en -} diff --git a/src/main/java/de/vitagroup/num/domain/model/ExportType.java b/src/main/java/de/vitagroup/num/domain/model/ExportType.java deleted file mode 100644 index 4cce9613d..000000000 --- a/src/main/java/de/vitagroup/num/domain/model/ExportType.java +++ /dev/null @@ -1,6 +0,0 @@ -package de.vitagroup.num.domain.model; - -public enum ExportType { - csv, - json -} diff --git a/src/main/java/de/vitagroup/num/domain/model/Operator.java b/src/main/java/de/vitagroup/num/domain/model/Operator.java deleted file mode 100644 index 9179b6501..000000000 --- a/src/main/java/de/vitagroup/num/domain/model/Operator.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.vitagroup.num.domain.model; - -public enum Operator { - AND, OR, NOT -} diff --git a/src/main/java/de/vitagroup/num/domain/model/SetupType.java b/src/main/java/de/vitagroup/num/domain/model/SetupType.java deleted file mode 100644 index 0506f1109..000000000 --- a/src/main/java/de/vitagroup/num/domain/model/SetupType.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.vitagroup.num.domain.model; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -public enum SetupType { - PREPROD, - PROD, - DEV, - STAGING; - - @AllArgsConstructor - @Getter - public enum Preprod { - NUM("https://num-portal.crr.pre-prod.num-codex.de/admin/health"), - EHRBASE("https://ehrbase.crr.pre-prod.num-codex.de/ehrbase/management/health/readiness"), - FHIR_BRIDGE("https://fhir-bridge.crr.pre-prod.num-codex.de/fhir-bridge/actuator/health/readiness"), - FE("https://pre-prod.num-codex.de/home"), - KEYCLOAK("https://keycloak.pre-prod.num-codex.de/auth"); - private String URL; - } - - @AllArgsConstructor - @Getter - public enum Prod { - NUM("https://num-portal.crr.num-codex.de/admin/health"), - EHRBASE("https://ehrbase.crr.num-codex.de/ehrbase/management/health/readiness"), - FHIR_BRIDGE("https://fhir-bridge.crr.num-codex.de/fhir-bridge/actuator/health/readiness"), - FE("https://num-codex.de/"), - KEYCLOAK("https://keycloak.crr.num-codex.de/auth"); - private String URL; - } - - @AllArgsConstructor - @Getter - public enum Dev { - NUM("https://num-portal.crr.dev.num-codex.de/admin/health"), - EHRBASE("https://ehrbase.crr.dev.num-codex.de/ehrbase/management/health/readiness"), - FHIR_BRIDGE("https://fhir-bridge.crr.dev.num-codex.de/fhir-bridge/actuator/health/readiness"), - FE("https://dev.num-codex.de/"), - KEYCLOAK("https://keycloak.dev.num-codex.de/auth"); - private String URL; - } - - @AllArgsConstructor - @Getter - public enum Staging { - NUM("https://num-portal.crr.staging.num-codex.de/admin/health"), - EHRBASE("https://ehrbase.crr.staging.num-codex.de/ehrbase/management/health/readiness"), - FHIR_BRIDGE("https://fhir-bridge.crr.staging.num-codex.de/fhir-bridge/actuator/health/readiness"), - FE("https://staging.num-codex.de/"), - KEYCLOAK("https://keycloak.staging.num-codex.de/auth"); - private String URL; - } -} diff --git a/src/main/java/de/vitagroup/num/domain/model/Type.java b/src/main/java/de/vitagroup/num/domain/model/Type.java deleted file mode 100644 index 2f01515af..000000000 --- a/src/main/java/de/vitagroup/num/domain/model/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -package de.vitagroup.num.domain.model; - -public enum Type { - AQL, - GROUP -} diff --git a/src/main/java/de/vitagroup/num/service/SetupHealthiness.java b/src/main/java/de/vitagroup/num/service/SetupHealthiness.java deleted file mode 100644 index 0ed5ec5e4..000000000 --- a/src/main/java/de/vitagroup/num/service/SetupHealthiness.java +++ /dev/null @@ -1,163 +0,0 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.SetupType; -import de.vitagroup.num.service.html.HtmlContent; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.logging.log4j.util.Strings; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.ANNOUNCEMENT_IN_PLACE; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.EXCEPTION_HAPPENED_IN_CLASS_FOR_ENVIRONMENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.EXCEPTION_IN_PARSING_PAGE; - -@Slf4j -@Service -@RequiredArgsConstructor -public class SetupHealthiness { - - private final HtmlContent htmlContent; - - @Value("${num.systemStatusUrl}") - private String systemStatusUrl; - - @Value("${num.statusCakeUrl}") - private String statusCakeUrl; - - public Map checkHealth(SetupType setup){ - Map map = new HashMap<>(); - switch (setup) { - case PREPROD: - for (SetupType.Preprod setupType:SetupType.Preprod.values()){ - map.put(setupType.name(), - checkUrl(SetupType.Preprod.class.getSimpleName(), setupType.name(), setupType.getURL())); - } - break; - case PROD: - for (SetupType.Prod setupType:SetupType.Prod.values()){ - map.put(setupType.name(), - checkUrl(SetupType.Prod.class.getSimpleName(), setupType.name(), setupType.getURL())); - } - break; - case DEV: - for (SetupType.Dev setupType:SetupType.Dev.values()){ - map.put(setupType.name(), - checkUrl(SetupType.Dev.class.getSimpleName(), setupType.name(), setupType.getURL())); - } - break; - case STAGING: - for (SetupType.Staging setupType:SetupType.Staging.values()){ - map.put(setupType.name(), - checkUrl(SetupType.Staging.class.getSimpleName(), setupType.name(), setupType.getURL())); - } - break; - default: - throw new IllegalStateException("Unexpected value: " + setup); - } - return map; - } - - public String checkForAnnouncements() { - String message = Strings.EMPTY; - try { - String pageContent = htmlContent.pageContent(systemStatusUrl); - String publicID = getPublicID(pageContent); - if(publicID.isEmpty()){ - return message; - } - String dynamicContent = getDynamicPageContent(publicID, htmlContent); - String timeOfAnnouncement = getTimeOfAnnouncement(dynamicContent, true); - String descriptionOfAnnouncement = getTimeOfAnnouncement(dynamicContent, false); - if (timeOfAnnouncement.isEmpty() && descriptionOfAnnouncement.isEmpty()){ - return message; - } - if (!timeOfAnnouncement.isEmpty() && timeOfAnnouncement.length()<4){ - return message; - } - if (!descriptionOfAnnouncement.isEmpty() && descriptionOfAnnouncement.length()<4){ - return message; - } - if(!timeOfAnnouncement.isEmpty() && !descriptionOfAnnouncement.isEmpty()){ - return String.format(ANNOUNCEMENT_IN_PLACE, timeOfAnnouncement, descriptionOfAnnouncement); - } - if(!dynamicContent.contains( "No current announcements" )){ - message = String.format("Check the %s page for the new announcements", systemStatusUrl); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return message; - } - - private String getTimeOfAnnouncement(String dynamicContent, boolean isTimeOfAnnouncement) { - if(isTimeOfAnnouncement){ - Pattern onlyImageLink = Pattern.compile("([0-9,:,\\\\,\\/]*)\\w+"); - Matcher m = onlyImageLink.matcher( dynamicContent ); - if (m.find()) { - return m.group( 0 ).replace("",""); - } - } else { - Pattern fullMatching = Pattern.compile("([A-Z]!*)\\w+"); - Matcher m = fullMatching.matcher(dynamicContent); - if (m.find()) { - return m.group(0).replace("", ""); - } - } - return Strings.EMPTY; - } - - private String getDynamicPageContent(String publicID, HtmlContent htmlContent) throws IOException, URISyntaxException { - String newURL = statusCakeUrl + publicID; - return htmlContent.pageContent(newURL); - } - - private String getPublicID(String pageContent) { - try { - String[] arr = new String[0]; - if (pageContent.contains("var PublicID")) { - int i = pageContent.lastIndexOf("var PublicID"); - String substring = pageContent.substring(i, i + 37); - arr = substring.split("'"); - if (arr.length < 2) { - return Strings.EMPTY; - } - } - return arr[1]; - } catch (IndexOutOfBoundsException index){ - throw new IndexOutOfBoundsException(EXCEPTION_IN_PARSING_PAGE + " " + index.getMessage()); - } - } - - private String checkUrl(String preprodClass, String environment, String setupTypeURL) { - String error; - try{ - URL url = new URL(setupTypeURL); - HttpURLConnection con = (HttpURLConnection) url.openConnection(); - con.setRequestMethod("GET"); - con.setConnectTimeout(5000); - con.setReadTimeout(5000); - if(con.getResponseCode() == 200) { - return Strings.EMPTY; - } else { - return String.format(EXCEPTION_HAPPENED_IN_CLASS_FOR_ENVIRONMENT, - preprodClass, environment, setupTypeURL); - } - }catch (IOException io) { - error = String.format(EXCEPTION_HAPPENED_IN_CLASS_FOR_ENVIRONMENT, - preprodClass, environment, setupTypeURL) + " " + io.getMessage(); - log.error(error); - } - return error; - } - -} diff --git a/src/main/java/de/vitagroup/num/service/TemplateService.java b/src/main/java/de/vitagroup/num/service/TemplateService.java deleted file mode 100644 index 8e740373f..000000000 --- a/src/main/java/de/vitagroup/num/service/TemplateService.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.dto.TemplateMetadataDto; -import de.vitagroup.num.mapper.TemplateMapper; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.SystemException; -import java.util.LinkedList; -import java.util.List; -import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.util.Strings; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.EhrDto; -import org.ehrbase.aql.dto.select.SelectDto; -import org.ehrbase.aql.dto.select.SelectFieldDto; -import org.ehrbase.aql.dto.select.SelectStatementDto; -import org.ehrbase.aqleditor.dto.containment.ContainmentDto; -import org.ehrbase.aqleditor.service.AqlEditorContainmentService; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; -import org.springframework.stereotype.Service; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_FIND_TEMPLATE; - -@Service -@AllArgsConstructor -public class TemplateService { - - private final EhrBaseService ehrBaseService; - - private final TemplateMapper templateMapper; - - private final UserDetailsService userDetailsService; - - private final AqlEditorContainmentService aqlEditorContainmentService; - - private static final int COMPOSITION_CONTAINMENT_ID = 1; - private static final int EHR_CONTAINMENT_ID = 0; - private static final String EHR_CONTAINMENT_IDENTIFIER = "e"; - - /** - * Retrieves a list of all available templates metadata information - * - * @return getAllTemplatesMetadata(String userId) - */ - public List getAllTemplatesMetadata(String userId) { - userDetailsService.checkIsUserApproved(userId); - - List templateMetaDataDtos = ehrBaseService.getAllTemplatesMetadata(); - return templateMetaDataDtos.stream() - .map(templateMapper::convertToTemplateMetadataDto) - .collect(Collectors.toList()); - } - - public AqlDto createSelectCompositionQuery(String templateId) { - - try { - ContainmentDto containmentDto = aqlEditorContainmentService.buildContainment(templateId); - if (containmentDto != null && StringUtils.isNotEmpty(containmentDto.getArchetypeId())) { - return createQuery(containmentDto.getArchetypeId()); - } else { - throw new BadRequestException(TemplateService.class, CANNOT_FIND_TEMPLATE, String.format(CANNOT_FIND_TEMPLATE, templateId)); - } - } catch (SystemException e) { - throw new SystemException(TemplateService.class, CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID, - String.format(CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID, templateId)); - } - } - - private AqlDto createQuery(String archetypeId) { - org.ehrbase.aql.dto.containment.ContainmentDto contains = - new org.ehrbase.aql.dto.containment.ContainmentDto(); - contains.setArchetypeId(archetypeId); - contains.setId(COMPOSITION_CONTAINMENT_ID); - - SelectFieldDto fieldDto = new SelectFieldDto(); - fieldDto.setContainmentId(COMPOSITION_CONTAINMENT_ID); - fieldDto.setAqlPath(Strings.EMPTY); - - SelectDto select = new SelectDto(); - List fieldDtos = new LinkedList<>(); - fieldDtos.add(fieldDto); - - select.setStatement(fieldDtos); - - EhrDto ehrDto = new EhrDto(); - ehrDto.setContainmentId(EHR_CONTAINMENT_ID); - ehrDto.setIdentifier(EHR_CONTAINMENT_IDENTIFIER); - - AqlDto dto = new AqlDto(); - dto.setEhr(ehrDto); - dto.setSelect(select); - dto.setContains(contains); - - return dto; - } -} diff --git a/src/main/java/de/vitagroup/num/service/html/HtmlContent.java b/src/main/java/de/vitagroup/num/service/html/HtmlContent.java deleted file mode 100644 index 86f34322f..000000000 --- a/src/main/java/de/vitagroup/num/service/html/HtmlContent.java +++ /dev/null @@ -1,102 +0,0 @@ -package de.vitagroup.num.service.html; - -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.entity.ContentType; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContextBuilder; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -@Component -@Log4j2 -public class HtmlContent { - private CloseableHttpClient httpClient = null; - static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"; - - @PostConstruct - public void init() throws Exception { - httpClient = createTrustAllHttpClientBuilder().build(); - } - - private HttpClientBuilder createTrustAllHttpClientBuilder() throws Exception { - SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial( null, (chain, authType) -> true ); - SSLConnectionSocketFactory sslsf = new - SSLConnectionSocketFactory( builder.build(), NoopHostnameVerifier.INSTANCE ); - - int timeout = 5; - RequestConfig config = getRequestConfig( timeout ); - - return HttpClients.custom().setSSLSocketFactory( sslsf ).setUserAgent( USER_AGENT ).setDefaultRequestConfig( config ); - } - - @PreDestroy - public void destroy() throws IOException { - if (httpClient != null) { - httpClient.close(); - } - } - - private static RequestConfig getRequestConfig(int timeout) { - return RequestConfig.custom() - .setConnectTimeout( timeout * 1000 ) - .setConnectionRequestTimeout( timeout * 1000 ) - .setSocketTimeout( timeout * 1000 ).build(); - } - - public String pageContent(String urlStr) throws IOException, URISyntaxException { - - CloseableHttpResponse response = null; - try { - URI uri = new URI( urlStr ); - - HttpGet request = new HttpGet( uri ); - request.setConfig( getRequestConfig( 5*5 ) ); - - response = httpClient.execute( request ); - - if (response.getStatusLine().getStatusCode() > 200) { - throw new RuntimeException( "Invalid response for url: " + urlStr ); - } - - HttpEntity entity = response.getEntity(); - InputStream inputStream = entity.getContent(); - - ContentType contentType = ContentType.get( entity ); - Charset charSet = StandardCharsets.UTF_8; - - if (contentType != null) { - charSet = contentType.getCharset(); - - } else { - log.info( "contentType unknown" ); - } - - //file content - return IOUtils.toString( inputStream, charSet != null ? charSet : StandardCharsets.ISO_8859_1 ); - - } finally { - if (response != null) { - response.close(); - } - } - } - -} diff --git a/src/main/java/de/vitagroup/num/service/policy/EhrPolicy.java b/src/main/java/de/vitagroup/num/service/policy/EhrPolicy.java deleted file mode 100644 index 06c637991..000000000 --- a/src/main/java/de/vitagroup/num/service/policy/EhrPolicy.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.vitagroup.num.service.policy; - -import de.vitagroup.num.service.exception.SystemException; -import java.util.List; -import java.util.Set; -import lombok.Builder; -import org.apache.commons.collections.CollectionUtils; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.select.SelectFieldDto; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COHORT_SIZE_CANNOT_BE_0; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; - -/** Restricts the aql to a set of ehr ids defined by the project cohort */ -public class EhrPolicy extends Policy { - - private static final String EHR_ID_PATH = "/ehr_id/value"; - - - private Set cohortEhrIds; - - @Builder - public EhrPolicy(Set cohortEhrIds) { - this.cohortEhrIds = cohortEhrIds; - } - - @Override - public boolean apply(AqlDto aql) { - if (aql == null) { - throw new SystemException(EhrPolicy.class, INVALID_AQL); - } - - if (CollectionUtils.isEmpty(cohortEhrIds)) { - throw new SystemException(EhrPolicy.class, COHORT_SIZE_CANNOT_BE_0); - } - - SelectFieldDto select = new SelectFieldDto(); - select.setAqlPath(EHR_ID_PATH); - select.setContainmentId(aql.getEhr().getContainmentId()); - - extendWhereClause(aql, List.of(select), toSimpleValueList(cohortEhrIds)); - return true; - } -} diff --git a/src/main/java/de/vitagroup/num/service/policy/EuropeanConsentPolicy.java b/src/main/java/de/vitagroup/num/service/policy/EuropeanConsentPolicy.java deleted file mode 100644 index 84edfa25a..000000000 --- a/src/main/java/de/vitagroup/num/service/policy/EuropeanConsentPolicy.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.vitagroup.num.service.policy; - -import de.vitagroup.num.service.exception.SystemException; -import java.util.List; -import lombok.Builder; -import lombok.extern.slf4j.Slf4j; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.Value; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; - -/** - * Restricts the aql to a particular oid which defines the user consent for project data being used - * outside the European Union - */ -@Slf4j -public class EuropeanConsentPolicy extends Policy { - - private static final String FEEDER_AUDIT_PATH = - "/feeder_audit/feeder_system_audit/other_details[openEHR-EHR-ITEM_TREE.generic.v1]/items[at0001]/value/id"; - - private String oid; - - @Builder - public EuropeanConsentPolicy(String oid) { - this.oid = oid; - } - - @Override - public boolean apply(AqlDto aql) { - if (oid == null) { - throw new SystemException(EuropeanConsentPolicy.class, CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED); - } - - if (aql == null) { - throw new SystemException(EuropeanConsentPolicy.class, INVALID_AQL); - } - - List oidValues = toSimpleValueList(List.of(oid)); - restrictAqlWithCompositionAttribute(aql, FEEDER_AUDIT_PATH, oidValues); - return true; - } -} diff --git a/src/main/java/de/vitagroup/num/service/policy/Policy.java b/src/main/java/de/vitagroup/num/service/policy/Policy.java deleted file mode 100644 index 1b8663ae1..000000000 --- a/src/main/java/de/vitagroup/num/service/policy/Policy.java +++ /dev/null @@ -1,201 +0,0 @@ -package de.vitagroup.num.service.policy; - -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.ConditionDto; -import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorDto; -import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorSymbol; -import org.ehrbase.aql.dto.condition.MatchesOperatorDto; -import org.ehrbase.aql.dto.condition.SimpleValue; -import org.ehrbase.aql.dto.condition.Value; -import org.ehrbase.aql.dto.containment.ContainmentDto; -import org.ehrbase.aql.dto.containment.ContainmentExpresionDto; -import org.ehrbase.aql.dto.containment.ContainmentLogicalOperator; -import org.ehrbase.aql.dto.containment.ContainmentLogicalOperatorSymbol; -import org.ehrbase.aql.dto.select.SelectFieldDto; - -/** Defines a certain project policy to be applied to an aql query */ -public abstract class Policy { - - private static final String COMPOSITION_ARCHETYPE_ID = "COMPOSITION"; - - public abstract boolean apply(AqlDto aql); - - protected void restrictAqlWithCompositionAttribute( - AqlDto aql, String attributePath, List attributeValues) { - - List whereClauseSelectFields = new LinkedList<>(); - - ContainmentExpresionDto contains = aql.getContains(); - int nextContainmentId = findNextContainmentId(contains); - - if (contains != null) { - List compositions = findCompositions(contains); - - if (CollectionUtils.isNotEmpty(compositions)) { - compositions.forEach( - id -> { - SelectFieldDto selectFieldDto = new SelectFieldDto(); - selectFieldDto.setAqlPath(attributePath); - selectFieldDto.setContainmentId(id); - whereClauseSelectFields.add(selectFieldDto); - }); - - } else { - extendContainsClause( - aql, whereClauseSelectFields, contains, nextContainmentId, attributePath); - } - } else { - createContainsClause(aql, whereClauseSelectFields, nextContainmentId, attributePath); - } - extendWhereClause(aql, whereClauseSelectFields, attributeValues); - } - - protected void createContainsClause( - AqlDto aql, - List whereClauseSelectFields, - int nextContainmentId, - String path) { - - SelectFieldDto select = new SelectFieldDto(); - select.setAqlPath(path); - select.setContainmentId(nextContainmentId); - whereClauseSelectFields.add(select); - - ContainmentDto composition = new ContainmentDto(); - composition.setId(nextContainmentId); - composition.setArchetypeId(COMPOSITION_ARCHETYPE_ID); - aql.setContains(composition); - } - - protected void extendWhereClause(AqlDto aql, List selects, List values) { - List matchesOperatorDtos = new LinkedList<>(); - - selects.forEach( - selectFieldDto -> { - MatchesOperatorDto matches = new MatchesOperatorDto(); - matches.setStatement(selectFieldDto); - matches.setValues(values); - matchesOperatorDtos.add(matches); - }); - - ConditionLogicalOperatorDto newWhere = new ConditionLogicalOperatorDto(); - newWhere.setValues(new ArrayList<>()); - ConditionDto where = aql.getWhere(); - - if (where != null) { - newWhere.setSymbol(ConditionLogicalOperatorSymbol.AND); - newWhere.getValues().add(where); - } - - if (CollectionUtils.isNotEmpty(matchesOperatorDtos) && matchesOperatorDtos.size() > 1) { - newWhere.setSymbol(ConditionLogicalOperatorSymbol.AND); - } - - matchesOperatorDtos.forEach( - matchesOperatorDto -> newWhere.getValues().add(matchesOperatorDto)); - - aql.setWhere(newWhere); - } - - protected void extendContainsClause( - AqlDto aql, - List whereClauseSelectFields, - ContainmentExpresionDto contains, - int nextContainmentId, - String path) { - SelectFieldDto select = new SelectFieldDto(); - select.setAqlPath(path); - select.setContainmentId(nextContainmentId); - whereClauseSelectFields.add(select); - - ContainmentLogicalOperator newContains = new ContainmentLogicalOperator(); - newContains.setValues(new ArrayList<>()); - - ContainmentDto composition = new ContainmentDto(); - composition.setId(nextContainmentId); - composition.setArchetypeId(COMPOSITION_ARCHETYPE_ID); - - newContains.setSymbol(ContainmentLogicalOperatorSymbol.AND); - newContains.getValues().add(composition); - newContains.getValues().add(contains); - - aql.setContains(newContains); - } - - protected List toSimpleValueList(Collection list) { - return list.stream() - .map(SimpleValue::new) - .collect(Collectors.toList()); - } - - protected List findCompositions(ContainmentExpresionDto dto) { - if (dto == null) { - return null; - } - - List compositions = new LinkedList<>(); - - Queue queue = new ArrayDeque<>(); - queue.add(dto); - - while (!queue.isEmpty()) { - ContainmentExpresionDto current = queue.remove(); - - if (current instanceof ContainmentLogicalOperator containmentLogicalOperator) { - - queue.addAll(containmentLogicalOperator.getValues()); - - } else if (current instanceof ContainmentDto containmentDto) { - - if (containmentDto.getArchetypeId().contains(COMPOSITION_ARCHETYPE_ID)) { - compositions.add(containmentDto.getId()); - } - - if (containmentDto.getContains() != null) { - queue.add(containmentDto.getContains()); - } - } - } - return compositions; - } - - protected Integer findNextContainmentId(ContainmentExpresionDto dto) { - - if (dto == null) { - return 1; - } - - Queue queue = new ArrayDeque<>(); - queue.add(dto); - - int nextId = 0; - - while (!queue.isEmpty()) { - ContainmentExpresionDto current = queue.remove(); - - if (current instanceof ContainmentLogicalOperator containmentLogicalOperator) { - - queue.addAll(containmentLogicalOperator.getValues()); - - } else if (current instanceof ContainmentDto containmentDto) { - - if (containmentDto.getId() > nextId) { - nextId = containmentDto.getId(); - } - - if (containmentDto.getContains() != null) { - queue.add(containmentDto.getContains()); - } - } - } - return nextId + 1; - } -} diff --git a/src/main/java/de/vitagroup/num/service/policy/TemplatesPolicy.java b/src/main/java/de/vitagroup/num/service/policy/TemplatesPolicy.java deleted file mode 100644 index eebeb10b3..000000000 --- a/src/main/java/de/vitagroup/num/service/policy/TemplatesPolicy.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.vitagroup.num.service.policy; - -import de.vitagroup.num.service.exception.SystemException; -import java.util.List; -import java.util.Map; -import lombok.Builder; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.MapUtils; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.Value; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.NO_TEMPLATES_ATTACHED_TO_THE_PROJECT; - -/** Restricts the aql to a set of templates defined by the project */ -@Slf4j -public class TemplatesPolicy extends Policy { - - private static final String TEMPLATE_ID_PATH = "/archetype_details/template_id/value"; - - private Map templatesMap; - - @Builder - public TemplatesPolicy(Map templatesMap) { - this.templatesMap = templatesMap; - } - - @Override - public boolean apply(AqlDto aql) { - if (MapUtils.isEmpty(templatesMap)) { - log.error(NO_TEMPLATES_ATTACHED_TO_THE_PROJECT); - return true; - } - - if (aql == null) { - throw new SystemException(TemplatesPolicy.class, INVALID_AQL); - } - - List templateValues = toSimpleValueList(templatesMap.keySet()); - restrictAqlWithCompositionAttribute(aql, TEMPLATE_ID_PATH, templateValues); - return true; - } -} diff --git a/src/main/java/de/vitagroup/num/NumPortalApplication.java b/src/main/java/org/highmed/numportal/NumPortalApplication.java similarity index 86% rename from src/main/java/de/vitagroup/num/NumPortalApplication.java rename to src/main/java/org/highmed/numportal/NumPortalApplication.java index ae7dba6df..d2e46fd70 100644 --- a/src/main/java/de/vitagroup/num/NumPortalApplication.java +++ b/src/main/java/org/highmed/numportal/NumPortalApplication.java @@ -1,6 +1,8 @@ -package de.vitagroup.num; +package org.highmed.numportal; -import de.vitagroup.num.service.atna.AtnaProperties; + + +import org.highmed.numportal.service.atna.AtnaProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/attachment/AttachmentRepository.java b/src/main/java/org/highmed/numportal/attachment/AttachmentRepository.java similarity index 74% rename from src/main/java/de/vitagroup/num/attachment/AttachmentRepository.java rename to src/main/java/org/highmed/numportal/attachment/AttachmentRepository.java index 654cbf9ca..da7352649 100644 --- a/src/main/java/de/vitagroup/num/attachment/AttachmentRepository.java +++ b/src/main/java/org/highmed/numportal/attachment/AttachmentRepository.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.attachment; +package org.highmed.numportal.attachment; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; import java.util.List; import java.util.Optional; diff --git a/src/main/java/de/vitagroup/num/attachment/domain/dto/AttachmentDto.java b/src/main/java/org/highmed/numportal/attachment/domain/dto/AttachmentDto.java similarity index 93% rename from src/main/java/de/vitagroup/num/attachment/domain/dto/AttachmentDto.java rename to src/main/java/org/highmed/numportal/attachment/domain/dto/AttachmentDto.java index 05c987dea..19da15eab 100644 --- a/src/main/java/de/vitagroup/num/attachment/domain/dto/AttachmentDto.java +++ b/src/main/java/org/highmed/numportal/attachment/domain/dto/AttachmentDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.attachment.domain.dto; +package org.highmed.numportal.attachment.domain.dto; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/de/vitagroup/num/attachment/domain/dto/LightAttachmentDto.java b/src/main/java/org/highmed/numportal/attachment/domain/dto/LightAttachmentDto.java similarity index 89% rename from src/main/java/de/vitagroup/num/attachment/domain/dto/LightAttachmentDto.java rename to src/main/java/org/highmed/numportal/attachment/domain/dto/LightAttachmentDto.java index 524a8e805..a7fe2821b 100644 --- a/src/main/java/de/vitagroup/num/attachment/domain/dto/LightAttachmentDto.java +++ b/src/main/java/org/highmed/numportal/attachment/domain/dto/LightAttachmentDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.attachment.domain.dto; +package org.highmed.numportal.attachment.domain.dto; import java.util.List; diff --git a/src/main/java/de/vitagroup/num/attachment/domain/model/Attachment.java b/src/main/java/org/highmed/numportal/attachment/domain/model/Attachment.java similarity index 93% rename from src/main/java/de/vitagroup/num/attachment/domain/model/Attachment.java rename to src/main/java/org/highmed/numportal/attachment/domain/model/Attachment.java index 32ab415bd..3cfee68a8 100644 --- a/src/main/java/de/vitagroup/num/attachment/domain/model/Attachment.java +++ b/src/main/java/org/highmed/numportal/attachment/domain/model/Attachment.java @@ -1,11 +1,11 @@ -package de.vitagroup.num.attachment.domain.model; +package org.highmed.numportal.attachment.domain.model; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.*; import java.io.Serializable; import java.time.OffsetDateTime; diff --git a/src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryImpl.java b/src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryImpl.java similarity index 90% rename from src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryImpl.java rename to src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryImpl.java index 266a57efc..be29b808f 100644 --- a/src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryImpl.java +++ b/src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryImpl.java @@ -1,10 +1,10 @@ -package de.vitagroup.num.attachment.domain.repository; +package org.highmed.numportal.attachment.domain.repository; -import de.vitagroup.num.attachment.AttachmentRepository; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.highmed.numportal.attachment.AttachmentRepository; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryJpa.java b/src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryJpa.java similarity index 91% rename from src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryJpa.java rename to src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryJpa.java index 3903c9f5f..93aec8d79 100644 --- a/src/main/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryJpa.java +++ b/src/main/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryJpa.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.attachment.domain.repository; +package org.highmed.numportal.attachment.domain.repository; -import de.vitagroup.num.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.domain.model.Attachment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/de/vitagroup/num/attachment/service/AttachmentService.java b/src/main/java/org/highmed/numportal/attachment/service/AttachmentService.java similarity index 91% rename from src/main/java/de/vitagroup/num/attachment/service/AttachmentService.java rename to src/main/java/org/highmed/numportal/attachment/service/AttachmentService.java index 414189578..8e5ac1ccb 100644 --- a/src/main/java/de/vitagroup/num/attachment/service/AttachmentService.java +++ b/src/main/java/org/highmed/numportal/attachment/service/AttachmentService.java @@ -1,17 +1,17 @@ -package de.vitagroup.num.attachment.service; - -import de.vitagroup.num.attachment.AttachmentRepository; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.dto.LightAttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.templates.ExceptionsTemplate; -import de.vitagroup.num.service.ProjectService; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.web.controller.NumAttachmentController; +package org.highmed.numportal.attachment.service; + +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.templates.ExceptionsTemplate; +import org.highmed.numportal.attachment.AttachmentRepository; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.dto.LightAttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; +import org.highmed.numportal.service.ProjectService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.web.controller.NumAttachmentController; import lombok.extern.slf4j.Slf4j; import org.apache.logging.log4j.util.Strings; import org.modelmapper.ModelMapper; @@ -22,7 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import javax.validation.Valid; +import jakarta.validation.Valid; import java.io.IOException; import java.util.List; import java.util.Objects; @@ -30,9 +30,9 @@ import java.util.Set; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Service @Transactional(value = "attachmentTransactionManager") diff --git a/src/main/java/de/vitagroup/num/attachment/service/ClamAVService.java b/src/main/java/org/highmed/numportal/attachment/service/ClamAVService.java similarity index 96% rename from src/main/java/de/vitagroup/num/attachment/service/ClamAVService.java rename to src/main/java/org/highmed/numportal/attachment/service/ClamAVService.java index 908c5a1f3..da18004d1 100644 --- a/src/main/java/de/vitagroup/num/attachment/service/ClamAVService.java +++ b/src/main/java/org/highmed/numportal/attachment/service/ClamAVService.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.attachment.service; +package org.highmed.numportal.attachment.service; -import de.vitagroup.num.properties.ClamAVProperties; -import de.vitagroup.num.service.exception.SystemException; +import org.highmed.numportal.properties.ClamAVProperties; +import org.highmed.numportal.service.exception.SystemException; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; diff --git a/src/main/java/de/vitagroup/num/attachment/service/FileScanService.java b/src/main/java/org/highmed/numportal/attachment/service/FileScanService.java similarity index 86% rename from src/main/java/de/vitagroup/num/attachment/service/FileScanService.java rename to src/main/java/org/highmed/numportal/attachment/service/FileScanService.java index 7ca51c8e4..7d268e2ec 100644 --- a/src/main/java/de/vitagroup/num/attachment/service/FileScanService.java +++ b/src/main/java/org/highmed/numportal/attachment/service/FileScanService.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.attachment.service; +package org.highmed.numportal.attachment.service; -import de.vitagroup.num.domain.templates.ExceptionsTemplate; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.SystemException; +import org.highmed.numportal.domain.templates.ExceptionsTemplate; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.SystemException; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/de/vitagroup/num/config/CachingConfig.java b/src/main/java/org/highmed/numportal/config/CachingConfig.java similarity index 89% rename from src/main/java/de/vitagroup/num/config/CachingConfig.java rename to src/main/java/org/highmed/numportal/config/CachingConfig.java index 553554d48..7f65eb088 100644 --- a/src/main/java/de/vitagroup/num/config/CachingConfig.java +++ b/src/main/java/org/highmed/numportal/config/CachingConfig.java @@ -1,6 +1,5 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; -import java.util.Arrays; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; @@ -9,7 +8,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import static de.vitagroup.num.service.UserService.TRANSLATION_CACHE; +import java.util.Arrays; + +import static org.highmed.numportal.service.UserService.TRANSLATION_CACHE; @Configuration @EnableCaching diff --git a/src/main/java/de/vitagroup/num/config/ClientTemplateProviderConfig.java b/src/main/java/org/highmed/numportal/config/ClientTemplateProviderConfig.java similarity index 67% rename from src/main/java/de/vitagroup/num/config/ClientTemplateProviderConfig.java rename to src/main/java/org/highmed/numportal/config/ClientTemplateProviderConfig.java index 0451e0de7..24bc81d77 100644 --- a/src/main/java/de/vitagroup/num/config/ClientTemplateProviderConfig.java +++ b/src/main/java/org/highmed/numportal/config/ClientTemplateProviderConfig.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; import lombok.RequiredArgsConstructor; -import org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient; -import org.ehrbase.client.templateprovider.ClientTemplateProvider; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClient; +import org.ehrbase.openehr.sdk.client.templateprovider.ClientTemplateProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/de/vitagroup/num/config/EhrBaseConfig.java b/src/main/java/org/highmed/numportal/config/EhrBaseConfig.java similarity index 83% rename from src/main/java/de/vitagroup/num/config/EhrBaseConfig.java rename to src/main/java/org/highmed/numportal/config/EhrBaseConfig.java index 38e8dc820..76b782b7e 100644 --- a/src/main/java/de/vitagroup/num/config/EhrBaseConfig.java +++ b/src/main/java/org/highmed/numportal/config/EhrBaseConfig.java @@ -1,8 +1,6 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; -import de.vitagroup.num.properties.EhrBaseProperties; -import java.net.URI; -import java.net.URISyntaxException; +import org.highmed.numportal.properties.EhrBaseProperties; import lombok.RequiredArgsConstructor; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; @@ -10,12 +8,15 @@ import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.ehrbase.client.openehrclient.OpenEhrClientConfig; -import org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient; +import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClientConfig; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import java.net.URI; +import java.net.URISyntaxException; + @Configuration @RequiredArgsConstructor public class EhrBaseConfig { diff --git a/src/main/java/de/vitagroup/num/config/FttpClientConfig.java b/src/main/java/org/highmed/numportal/config/FttpClientConfig.java similarity index 96% rename from src/main/java/de/vitagroup/num/config/FttpClientConfig.java rename to src/main/java/org/highmed/numportal/config/FttpClientConfig.java index a23bb1525..82871e524 100644 --- a/src/main/java/de/vitagroup/num/config/FttpClientConfig.java +++ b/src/main/java/org/highmed/numportal/config/FttpClientConfig.java @@ -1,10 +1,7 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; import ca.uhn.fhir.context.FhirContext; -import de.vitagroup.num.properties.FttpProperties; -import java.security.KeyStore; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; +import org.highmed.numportal.properties.FttpProperties; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.http.auth.AuthScope; @@ -18,6 +15,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import java.security.KeyStore; + @Slf4j @Configuration @RequiredArgsConstructor diff --git a/src/main/java/de/vitagroup/num/config/MapperConfig.java b/src/main/java/org/highmed/numportal/config/MapperConfig.java similarity index 87% rename from src/main/java/de/vitagroup/num/config/MapperConfig.java rename to src/main/java/org/highmed/numportal/config/MapperConfig.java index 6de075045..95e051c56 100644 --- a/src/main/java/de/vitagroup/num/config/MapperConfig.java +++ b/src/main/java/org/highmed/numportal/config/MapperConfig.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; import org.modelmapper.ModelMapper; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/de/vitagroup/num/config/MessageSourceConfiguration.java b/src/main/java/org/highmed/numportal/config/MessageSourceConfiguration.java similarity index 92% rename from src/main/java/de/vitagroup/num/config/MessageSourceConfiguration.java rename to src/main/java/org/highmed/numportal/config/MessageSourceConfiguration.java index 557c94364..0aba9ff0a 100644 --- a/src/main/java/de/vitagroup/num/config/MessageSourceConfiguration.java +++ b/src/main/java/org/highmed/numportal/config/MessageSourceConfiguration.java @@ -1,9 +1,6 @@ -package de.vitagroup.num.config; +package org.highmed.numportal.config; -import de.vitagroup.num.properties.NumProperties; -import java.nio.charset.StandardCharsets; -import java.util.Locale; -import javax.annotation.PostConstruct; +import org.highmed.numportal.properties.NumProperties; import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.context.MessageSource; @@ -11,6 +8,10 @@ import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import java.nio.charset.StandardCharsets; +import java.util.Locale; + @Component @AllArgsConstructor public class MessageSourceConfiguration { diff --git a/src/main/java/de/vitagroup/num/config/database/NumAttachmentFlywayConfig.java b/src/main/java/org/highmed/numportal/config/database/NumAttachmentFlywayConfig.java similarity index 95% rename from src/main/java/de/vitagroup/num/config/database/NumAttachmentFlywayConfig.java rename to src/main/java/org/highmed/numportal/config/database/NumAttachmentFlywayConfig.java index 8a6292c10..47a4f869b 100644 --- a/src/main/java/de/vitagroup/num/config/database/NumAttachmentFlywayConfig.java +++ b/src/main/java/org/highmed/numportal/config/database/NumAttachmentFlywayConfig.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.config.database; +package org.highmed.numportal.config.database; import org.flywaydb.core.Flyway; import org.springframework.beans.factory.annotation.Qualifier; diff --git a/src/main/java/de/vitagroup/num/config/database/NumPortalAttachmentDatasourceConfiguration.java b/src/main/java/org/highmed/numportal/config/database/NumPortalAttachmentDatasourceConfiguration.java similarity index 95% rename from src/main/java/de/vitagroup/num/config/database/NumPortalAttachmentDatasourceConfiguration.java rename to src/main/java/org/highmed/numportal/config/database/NumPortalAttachmentDatasourceConfiguration.java index b57027263..9eb38e64d 100644 --- a/src/main/java/de/vitagroup/num/config/database/NumPortalAttachmentDatasourceConfiguration.java +++ b/src/main/java/org/highmed/numportal/config/database/NumPortalAttachmentDatasourceConfiguration.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.config.database; +package org.highmed.numportal.config.database; import com.zaxxer.hikari.HikariDataSource; import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy; @@ -24,7 +24,7 @@ @ConditionalOnProperty(prefix = "num", name = "enableAttachmentDatabase", havingValue = "true") @Configuration -@EnableJpaRepositories(basePackages = "de.vitagroup.num.attachment", +@EnableJpaRepositories(basePackages = "org.highmed.numportal.attachment", entityManagerFactoryRef = "attachmentEntityManagerFactory", transactionManagerRef = "attachmentTransactionManager") @EnableTransactionManagement @@ -50,7 +50,7 @@ public LocalContainerEntityManagerFactoryBean attachmentEntityManagerFactory(Ent @Qualifier("numAttachmentDatasource") DataSource dataSource) { LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = builder .dataSource(dataSource) - .packages("de.vitagroup.num.attachment") + .packages("org.highmed.numportal.attachment") .persistenceUnit("numAttachment") .build(); localContainerEntityManagerFactoryBean.getJpaPropertyMap().put(AvailableSettings.IMPLICIT_NAMING_STRATEGY, new SpringImplicitNamingStrategy()); diff --git a/src/main/java/de/vitagroup/num/config/database/NumPortalDatasourceConfiguration.java b/src/main/java/org/highmed/numportal/config/database/NumPortalDatasourceConfiguration.java similarity index 95% rename from src/main/java/de/vitagroup/num/config/database/NumPortalDatasourceConfiguration.java rename to src/main/java/org/highmed/numportal/config/database/NumPortalDatasourceConfiguration.java index 5ebcb3829..50bdaf433 100644 --- a/src/main/java/de/vitagroup/num/config/database/NumPortalDatasourceConfiguration.java +++ b/src/main/java/org/highmed/numportal/config/database/NumPortalDatasourceConfiguration.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.config.database; +package org.highmed.numportal.config.database; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; @@ -27,7 +27,7 @@ import java.util.Properties; @Configuration -@EnableJpaRepositories(basePackages = {"de.vitagroup.num.domain", "de.vitagroup.num.service"}, +@EnableJpaRepositories(basePackages = {"org.highmed.numportal.domain", "org.highmed.numportal.service"}, entityManagerFactoryRef = "numEntityManagerFactory", transactionManagerRef = "numTransactionManager") @EnableTransactionManagement @@ -69,7 +69,7 @@ public LocalContainerEntityManagerFactoryBean numEntityManagerFactory(Configurab @Qualifier("numPortalDatasource") DataSource dataSource) { LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); localContainerEntityManagerFactoryBean.setDataSource(dataSource); - localContainerEntityManagerFactoryBean.setPackagesToScan("de.vitagroup.num.domain", "de.vitagroup.num.service"); + localContainerEntityManagerFactoryBean.setPackagesToScan("org.highmed.numportal.domain", "org.highmed.numportal.service"); localContainerEntityManagerFactoryBean.setPersistenceUnitName("numPortal"); localContainerEntityManagerFactoryBean.getJpaPropertyMap().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory)); localContainerEntityManagerFactoryBean.getJpaPropertyMap().put(AvailableSettings.IMPLICIT_NAMING_STRATEGY, new SpringImplicitNamingStrategy()); diff --git a/src/main/java/de/vitagroup/num/config/database/NumPortalFlywayConfig.java b/src/main/java/org/highmed/numportal/config/database/NumPortalFlywayConfig.java similarity index 94% rename from src/main/java/de/vitagroup/num/config/database/NumPortalFlywayConfig.java rename to src/main/java/org/highmed/numportal/config/database/NumPortalFlywayConfig.java index 698009086..359535f9d 100644 --- a/src/main/java/de/vitagroup/num/config/database/NumPortalFlywayConfig.java +++ b/src/main/java/org/highmed/numportal/config/database/NumPortalFlywayConfig.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.config.database; +package org.highmed.numportal.config.database; import org.flywaydb.core.Flyway; import org.springframework.beans.factory.annotation.Qualifier; diff --git a/src/main/java/de/vitagroup/num/domain/dto/AqlCategoryDto.java b/src/main/java/org/highmed/numportal/domain/dto/AqlCategoryDto.java similarity index 89% rename from src/main/java/de/vitagroup/num/domain/dto/AqlCategoryDto.java rename to src/main/java/org/highmed/numportal/domain/dto/AqlCategoryDto.java index bd175b25b..20bb92ca3 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/AqlCategoryDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/AqlCategoryDto.java @@ -1,12 +1,12 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import de.vitagroup.num.domain.validation.ValidTranslatedString; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.domain.validation.ValidTranslatedString; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/domain/dto/AqlDto.java b/src/main/java/org/highmed/numportal/domain/dto/AqlDto.java similarity index 83% rename from src/main/java/de/vitagroup/num/domain/dto/AqlDto.java rename to src/main/java/org/highmed/numportal/domain/dto/AqlDto.java index 561c51beb..4c768815c 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/AqlDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/AqlDto.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; -import de.vitagroup.num.domain.model.admin.User; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.domain.model.admin.User; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.time.OffsetDateTime; @Schema @@ -18,7 +18,7 @@ @NoArgsConstructor public class AqlDto { - @Schema(description = "The unique identifier", example = "1") + @Schema(description = "The unique identifier", example = "1", accessMode = Schema.AccessMode.READ_ONLY) private Long id; @Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "The name of the aql") @@ -56,6 +56,7 @@ public class AqlDto { private String query; @Schema(description = "Flag marking aql as being public") + @Builder.Default private boolean publicAql = true; @Schema(description = "The owner of the aql", hidden = true) @@ -67,9 +68,9 @@ public class AqlDto { @Schema(description = "to for category data", hidden = true) private AqlCategoryDto category; - @Schema + @Schema(accessMode = Schema.AccessMode.READ_ONLY) private OffsetDateTime createDate; - @Schema + @Schema(accessMode = Schema.AccessMode.READ_ONLY) private OffsetDateTime modifiedDate; } diff --git a/src/main/java/de/vitagroup/num/domain/dto/CardDto.java b/src/main/java/org/highmed/numportal/domain/dto/CardDto.java similarity index 84% rename from src/main/java/de/vitagroup/num/domain/dto/CardDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CardDto.java index c8d16bb05..2fcff4f7e 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CardDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CardDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; @@ -6,9 +6,9 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import java.net.URL; @Data @@ -47,6 +47,6 @@ public static class LocalizedPart{ @NotBlank private String imageId; - @Schema(description = "The URL of the card", example = "https://www.vitagroup.ag/") + @Schema(description = "The URL of the card", example = "https://www.highmed.org/") private URL url; } diff --git a/src/main/java/de/vitagroup/num/domain/dto/CohortAqlDto.java b/src/main/java/org/highmed/numportal/domain/dto/CohortAqlDto.java similarity index 84% rename from src/main/java/de/vitagroup/num/domain/dto/CohortAqlDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CohortAqlDto.java index c51ea5f46..6496e4cf0 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CohortAqlDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CohortAqlDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; @@ -6,8 +6,8 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Schema @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/CohortDto.java b/src/main/java/org/highmed/numportal/domain/dto/CohortDto.java similarity index 82% rename from src/main/java/de/vitagroup/num/domain/dto/CohortDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CohortDto.java index 7e57f51d5..c88103cea 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CohortDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CohortDto.java @@ -1,14 +1,13 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; -import de.vitagroup.num.domain.validation.ValidCohort; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import org.highmed.numportal.domain.validation.ValidCohort; @Schema @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/CohortGroupDto.java b/src/main/java/org/highmed/numportal/domain/dto/CohortGroupDto.java similarity index 81% rename from src/main/java/de/vitagroup/num/domain/dto/CohortGroupDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CohortGroupDto.java index 39c9e0278..5b57b193f 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CohortGroupDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CohortGroupDto.java @@ -1,17 +1,17 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import com.fasterxml.jackson.annotation.JsonIgnore; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.domain.repository.AqlConverter; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Convert; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.domain.model.Operator; +import org.highmed.numportal.domain.model.Type; +import org.highmed.numportal.domain.repository.AqlConverter; -import javax.persistence.Convert; -import javax.validation.constraints.NotNull; import java.util.List; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/domain/dto/CohortSizeDto.java b/src/main/java/org/highmed/numportal/domain/dto/CohortSizeDto.java similarity index 91% rename from src/main/java/de/vitagroup/num/domain/dto/CohortSizeDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CohortSizeDto.java index 23c076a14..2766ab8e8 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CohortSizeDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CohortSizeDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; diff --git a/src/main/java/de/vitagroup/num/domain/dto/CommentDto.java b/src/main/java/org/highmed/numportal/domain/dto/CommentDto.java similarity index 76% rename from src/main/java/de/vitagroup/num/domain/dto/CommentDto.java rename to src/main/java/org/highmed/numportal/domain/dto/CommentDto.java index 0ad0b139e..361ce52fe 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/CommentDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/CommentDto.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; -import de.vitagroup.num.domain.model.admin.User; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.domain.model.admin.User; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.time.OffsetDateTime; @Schema diff --git a/src/main/java/org/highmed/numportal/domain/dto/Language.java b/src/main/java/org/highmed/numportal/domain/dto/Language.java new file mode 100644 index 000000000..c1ed62a4b --- /dev/null +++ b/src/main/java/org/highmed/numportal/domain/dto/Language.java @@ -0,0 +1,5 @@ +package org.highmed.numportal.domain.dto; + +public enum Language { + de, en +} diff --git a/src/main/java/de/vitagroup/num/domain/dto/ManagerProjectDto.java b/src/main/java/org/highmed/numportal/domain/dto/ManagerProjectDto.java similarity index 63% rename from src/main/java/de/vitagroup/num/domain/dto/ManagerProjectDto.java rename to src/main/java/org/highmed/numportal/domain/dto/ManagerProjectDto.java index e01321577..4f895724d 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ManagerProjectDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ManagerProjectDto.java @@ -1,10 +1,10 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.util.List; @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/MetricsDto.java b/src/main/java/org/highmed/numportal/domain/dto/MetricsDto.java similarity index 91% rename from src/main/java/de/vitagroup/num/domain/dto/MetricsDto.java rename to src/main/java/org/highmed/numportal/domain/dto/MetricsDto.java index 31c5fb6f3..19b4ee922 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/MetricsDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/MetricsDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; diff --git a/src/main/java/de/vitagroup/num/domain/dto/NavigationItemDto.java b/src/main/java/org/highmed/numportal/domain/dto/NavigationItemDto.java similarity index 75% rename from src/main/java/de/vitagroup/num/domain/dto/NavigationItemDto.java rename to src/main/java/org/highmed/numportal/domain/dto/NavigationItemDto.java index ae5d2866c..29532b8a7 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/NavigationItemDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/NavigationItemDto.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.net.URL; @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/OrganizationDto.java b/src/main/java/org/highmed/numportal/domain/dto/OrganizationDto.java similarity index 88% rename from src/main/java/de/vitagroup/num/domain/dto/OrganizationDto.java rename to src/main/java/org/highmed/numportal/domain/dto/OrganizationDto.java index e8be1f165..3cf6b8efd 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/OrganizationDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/OrganizationDto.java @@ -1,13 +1,13 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.util.Set; @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/ParameterOptionsDto.java b/src/main/java/org/highmed/numportal/domain/dto/ParameterOptionsDto.java similarity index 88% rename from src/main/java/de/vitagroup/num/domain/dto/ParameterOptionsDto.java rename to src/main/java/org/highmed/numportal/domain/dto/ParameterOptionsDto.java index cf327daa0..cca85cb8c 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ParameterOptionsDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ParameterOptionsDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; @@ -16,6 +16,7 @@ @AllArgsConstructor public class ParameterOptionsDto { + @Builder.Default private Map options = new LinkedHashMap<>(); private String aqlPath; private String archetypeId; diff --git a/src/main/java/de/vitagroup/num/domain/dto/ProjectDto.java b/src/main/java/org/highmed/numportal/domain/dto/ProjectDto.java similarity index 82% rename from src/main/java/de/vitagroup/num/domain/dto/ProjectDto.java rename to src/main/java/org/highmed/numportal/domain/dto/ProjectDto.java index 3508339c4..9f1ff23a8 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ProjectDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ProjectDto.java @@ -1,19 +1,19 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.domain.model.ProjectCategories; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.User; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.User; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.time.LocalDate; import java.time.OffsetDateTime; import java.util.List; @@ -27,6 +27,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class ProjectDto { + @Schema(accessMode = Schema.AccessMode.READ_ONLY) private Long id; @NotNull(message = "Project name cannot be null") diff --git a/src/main/java/de/vitagroup/num/domain/dto/ProjectInfoDto.java b/src/main/java/org/highmed/numportal/domain/dto/ProjectInfoDto.java similarity index 91% rename from src/main/java/de/vitagroup/num/domain/dto/ProjectInfoDto.java rename to src/main/java/org/highmed/numportal/domain/dto/ProjectInfoDto.java index 8a91512a0..34bdc4be8 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ProjectInfoDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ProjectInfoDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; diff --git a/src/main/java/de/vitagroup/num/domain/dto/ProjectViewTO.java b/src/main/java/org/highmed/numportal/domain/dto/ProjectViewTO.java similarity index 79% rename from src/main/java/de/vitagroup/num/domain/dto/ProjectViewTO.java rename to src/main/java/org/highmed/numportal/domain/dto/ProjectViewTO.java index cda5abd19..8ebf25144 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ProjectViewTO.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ProjectViewTO.java @@ -1,12 +1,12 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.User; import java.time.LocalDate; import java.time.OffsetDateTime; diff --git a/src/main/java/de/vitagroup/num/domain/dto/RawQueryDto.java b/src/main/java/org/highmed/numportal/domain/dto/RawQueryDto.java similarity index 71% rename from src/main/java/de/vitagroup/num/domain/dto/RawQueryDto.java rename to src/main/java/org/highmed/numportal/domain/dto/RawQueryDto.java index 4d1c1197a..86ac7a208 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/RawQueryDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/RawQueryDto.java @@ -1,14 +1,13 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - @Schema @Data @Builder diff --git a/src/main/java/de/vitagroup/num/domain/dto/SearchCriteria.java b/src/main/java/org/highmed/numportal/domain/dto/SearchCriteria.java similarity index 94% rename from src/main/java/de/vitagroup/num/domain/dto/SearchCriteria.java rename to src/main/java/org/highmed/numportal/domain/dto/SearchCriteria.java index 9d3ccb875..59c2e1edb 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/SearchCriteria.java +++ b/src/main/java/org/highmed/numportal/domain/dto/SearchCriteria.java @@ -1,12 +1,12 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; -import de.vitagroup.num.service.exception.BadRequestException; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.exception.BadRequestException; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/domain/dto/SearchFilter.java b/src/main/java/org/highmed/numportal/domain/dto/SearchFilter.java similarity index 69% rename from src/main/java/de/vitagroup/num/domain/dto/SearchFilter.java rename to src/main/java/org/highmed/numportal/domain/dto/SearchFilter.java index 9b69dafbc..78eb62637 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/SearchFilter.java +++ b/src/main/java/org/highmed/numportal/domain/dto/SearchFilter.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; public enum SearchFilter { ALL, diff --git a/src/main/java/de/vitagroup/num/domain/dto/SlimAqlDto.java b/src/main/java/org/highmed/numportal/domain/dto/SlimAqlDto.java similarity index 69% rename from src/main/java/de/vitagroup/num/domain/dto/SlimAqlDto.java rename to src/main/java/org/highmed/numportal/domain/dto/SlimAqlDto.java index e9877d61a..774beb4cb 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/SlimAqlDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/SlimAqlDto.java @@ -1,8 +1,7 @@ -package de.vitagroup.num.domain.dto; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +package org.highmed.numportal.domain.dto; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/dto/TemplateInfoDto.java b/src/main/java/org/highmed/numportal/domain/dto/TemplateInfoDto.java similarity index 84% rename from src/main/java/de/vitagroup/num/domain/dto/TemplateInfoDto.java rename to src/main/java/org/highmed/numportal/domain/dto/TemplateInfoDto.java index 466c9de27..d85606ee8 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/TemplateInfoDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/TemplateInfoDto.java @@ -1,15 +1,14 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - /** Dto for template information linked to a project */ @Data @Builder diff --git a/src/main/java/de/vitagroup/num/domain/dto/TemplateMetadataDto.java b/src/main/java/org/highmed/numportal/domain/dto/TemplateMetadataDto.java similarity index 92% rename from src/main/java/de/vitagroup/num/domain/dto/TemplateMetadataDto.java rename to src/main/java/org/highmed/numportal/domain/dto/TemplateMetadataDto.java index 6a6703a07..0a5c6755f 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/TemplateMetadataDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/TemplateMetadataDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; diff --git a/src/main/java/de/vitagroup/num/domain/dto/TemplateSizeRequestDto.java b/src/main/java/org/highmed/numportal/domain/dto/TemplateSizeRequestDto.java similarity index 69% rename from src/main/java/de/vitagroup/num/domain/dto/TemplateSizeRequestDto.java rename to src/main/java/org/highmed/numportal/domain/dto/TemplateSizeRequestDto.java index ea6af9b4e..ea560105e 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/TemplateSizeRequestDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/TemplateSizeRequestDto.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.util.List; @Data diff --git a/src/main/java/de/vitagroup/num/domain/dto/UserDetailsDto.java b/src/main/java/org/highmed/numportal/domain/dto/UserDetailsDto.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/dto/UserDetailsDto.java rename to src/main/java/org/highmed/numportal/domain/dto/UserDetailsDto.java index 201c4ab4e..dad8c9746 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/UserDetailsDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/UserDetailsDto.java @@ -1,13 +1,12 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Data @Schema @Builder diff --git a/src/main/java/de/vitagroup/num/domain/dto/UserNameDto.java b/src/main/java/org/highmed/numportal/domain/dto/UserNameDto.java similarity index 83% rename from src/main/java/de/vitagroup/num/domain/dto/UserNameDto.java rename to src/main/java/org/highmed/numportal/domain/dto/UserNameDto.java index cde41f4f7..682ec08d6 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/UserNameDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/UserNameDto.java @@ -1,13 +1,12 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Data @Schema @Builder diff --git a/src/main/java/de/vitagroup/num/domain/dto/ZarsInfoDto.java b/src/main/java/org/highmed/numportal/domain/dto/ZarsInfoDto.java similarity index 78% rename from src/main/java/de/vitagroup/num/domain/dto/ZarsInfoDto.java rename to src/main/java/org/highmed/numportal/domain/dto/ZarsInfoDto.java index 45d08af9d..e7fcec087 100644 --- a/src/main/java/de/vitagroup/num/domain/dto/ZarsInfoDto.java +++ b/src/main/java/org/highmed/numportal/domain/dto/ZarsInfoDto.java @@ -1,10 +1,11 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; + +import lombok.Data; +import org.highmed.numportal.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.ProjectCategories; -import de.vitagroup.num.domain.model.ProjectStatus; import java.time.LocalDate; import java.util.Set; -import lombok.Data; @Data public class ZarsInfoDto { diff --git a/src/main/java/de/vitagroup/num/domain/model/Aql.java b/src/main/java/org/highmed/numportal/domain/model/Aql.java similarity index 81% rename from src/main/java/de/vitagroup/num/domain/model/Aql.java rename to src/main/java/org/highmed/numportal/domain/model/Aql.java index 433cc4784..d9ea0be46 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Aql.java +++ b/src/main/java/org/highmed/numportal/domain/model/Aql.java @@ -1,21 +1,17 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; -import de.vitagroup.num.domain.model.admin.UserDetails; -import java.io.Serializable; -import java.time.OffsetDateTime; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import org.highmed.numportal.domain.model.admin.UserDetails; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; +import java.io.Serializable; +import java.time.OffsetDateTime; + @Entity @Builder @Data diff --git a/src/main/java/de/vitagroup/num/domain/model/AqlCategory.java b/src/main/java/org/highmed/numportal/domain/model/AqlCategory.java similarity index 66% rename from src/main/java/de/vitagroup/num/domain/model/AqlCategory.java rename to src/main/java/org/highmed/numportal/domain/model/AqlCategory.java index ece613d76..7f6d6dc08 100644 --- a/src/main/java/de/vitagroup/num/domain/model/AqlCategory.java +++ b/src/main/java/org/highmed/numportal/domain/model/AqlCategory.java @@ -1,13 +1,14 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; -import de.vitagroup.num.domain.repository.MapConverter; -import de.vitagroup.num.domain.validation.ValidTranslatedString; +import org.highmed.numportal.domain.repository.MapConverter; +import org.highmed.numportal.domain.validation.ValidTranslatedString; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.*; +import jakarta.persistence.*; + import java.util.Map; @Entity diff --git a/src/main/java/de/vitagroup/num/domain/model/Cohort.java b/src/main/java/org/highmed/numportal/domain/model/Cohort.java similarity index 88% rename from src/main/java/de/vitagroup/num/domain/model/Cohort.java rename to src/main/java/org/highmed/numportal/domain/model/Cohort.java index feb24365e..ba5a225c3 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Cohort.java +++ b/src/main/java/org/highmed/numportal/domain/model/Cohort.java @@ -1,12 +1,13 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import java.io.Serializable; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Data diff --git a/src/main/java/de/vitagroup/num/domain/model/CohortAql.java b/src/main/java/org/highmed/numportal/domain/model/CohortAql.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/model/CohortAql.java rename to src/main/java/org/highmed/numportal/domain/model/CohortAql.java index 800ff5c6e..eb5c067aa 100644 --- a/src/main/java/de/vitagroup/num/domain/model/CohortAql.java +++ b/src/main/java/org/highmed/numportal/domain/model/CohortAql.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/de/vitagroup/num/domain/model/CohortGroup.java b/src/main/java/org/highmed/numportal/domain/model/CohortGroup.java similarity index 69% rename from src/main/java/de/vitagroup/num/domain/model/CohortGroup.java rename to src/main/java/org/highmed/numportal/domain/model/CohortGroup.java index 96e8c4267..99fa7cc44 100644 --- a/src/main/java/de/vitagroup/num/domain/model/CohortGroup.java +++ b/src/main/java/org/highmed/numportal/domain/model/CohortGroup.java @@ -1,22 +1,14 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; -import de.vitagroup.num.domain.repository.AqlConverter; -import de.vitagroup.num.domain.repository.MapConverter; +import org.highmed.numportal.domain.repository.AqlConverter; +import org.highmed.numportal.domain.repository.MapConverter; import java.io.Serializable; import java.util.LinkedList; import java.util.List; import java.util.Map; -import javax.persistence.CascadeType; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/model/Comment.java b/src/main/java/org/highmed/numportal/domain/model/Comment.java similarity index 73% rename from src/main/java/de/vitagroup/num/domain/model/Comment.java rename to src/main/java/org/highmed/numportal/domain/model/Comment.java index f0d26905c..6593fad3b 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Comment.java +++ b/src/main/java/org/highmed/numportal/domain/model/Comment.java @@ -1,15 +1,10 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; -import de.vitagroup.num.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.model.admin.UserDetails; import java.io.Serializable; import java.time.OffsetDateTime; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/model/Content.java b/src/main/java/org/highmed/numportal/domain/model/Content.java similarity index 58% rename from src/main/java/de/vitagroup/num/domain/model/Content.java rename to src/main/java/org/highmed/numportal/domain/model/Content.java index d27ffcec0..e75a644b7 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Content.java +++ b/src/main/java/org/highmed/numportal/domain/model/Content.java @@ -1,14 +1,9 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/model/ContentType.java b/src/main/java/org/highmed/numportal/domain/model/ContentType.java similarity index 53% rename from src/main/java/de/vitagroup/num/domain/model/ContentType.java rename to src/main/java/org/highmed/numportal/domain/model/ContentType.java index 070200700..f964d1044 100644 --- a/src/main/java/de/vitagroup/num/domain/model/ContentType.java +++ b/src/main/java/org/highmed/numportal/domain/model/ContentType.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; public enum ContentType { NAVIGATION, diff --git a/src/main/java/de/vitagroup/num/domain/model/EntityGroup.java b/src/main/java/org/highmed/numportal/domain/model/EntityGroup.java similarity index 58% rename from src/main/java/de/vitagroup/num/domain/model/EntityGroup.java rename to src/main/java/org/highmed/numportal/domain/model/EntityGroup.java index 7f2cc0524..b735c1310 100644 --- a/src/main/java/de/vitagroup/num/domain/model/EntityGroup.java +++ b/src/main/java/org/highmed/numportal/domain/model/EntityGroup.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; public enum EntityGroup { PROJECT_STATUS, diff --git a/src/main/java/org/highmed/numportal/domain/model/ExportType.java b/src/main/java/org/highmed/numportal/domain/model/ExportType.java new file mode 100644 index 000000000..08c2bf88e --- /dev/null +++ b/src/main/java/org/highmed/numportal/domain/model/ExportType.java @@ -0,0 +1,6 @@ +package org.highmed.numportal.domain.model; + +public enum ExportType { + csv, + json +} diff --git a/src/main/java/de/vitagroup/num/domain/model/MailDomain.java b/src/main/java/org/highmed/numportal/domain/model/MailDomain.java similarity index 65% rename from src/main/java/de/vitagroup/num/domain/model/MailDomain.java rename to src/main/java/org/highmed/numportal/domain/model/MailDomain.java index 68cc6b4ac..04b382607 100644 --- a/src/main/java/de/vitagroup/num/domain/model/MailDomain.java +++ b/src/main/java/org/highmed/numportal/domain/model/MailDomain.java @@ -1,14 +1,9 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; + +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/org/highmed/numportal/domain/model/Operator.java b/src/main/java/org/highmed/numportal/domain/model/Operator.java new file mode 100644 index 000000000..a993f5df6 --- /dev/null +++ b/src/main/java/org/highmed/numportal/domain/model/Operator.java @@ -0,0 +1,5 @@ +package org.highmed.numportal.domain.model; + +public enum Operator { + AND, OR, NOT +} diff --git a/src/main/java/de/vitagroup/num/domain/model/Organization.java b/src/main/java/org/highmed/numportal/domain/model/Organization.java similarity index 90% rename from src/main/java/de/vitagroup/num/domain/model/Organization.java rename to src/main/java/org/highmed/numportal/domain/model/Organization.java index d30b21e37..ab327ba01 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Organization.java +++ b/src/main/java/org/highmed/numportal/domain/model/Organization.java @@ -1,10 +1,11 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonManagedReference; import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import javax.persistence.*; + +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; @@ -34,5 +35,6 @@ public class Organization implements Serializable { private Set domains = new HashSet<>(); @Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE") + @Builder.Default private Boolean active = Boolean.TRUE; } diff --git a/src/main/java/de/vitagroup/num/domain/model/Project.java b/src/main/java/org/highmed/numportal/domain/model/Project.java similarity index 88% rename from src/main/java/de/vitagroup/num/domain/model/Project.java rename to src/main/java/org/highmed/numportal/domain/model/Project.java index 764fb98e7..8997868fa 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Project.java +++ b/src/main/java/org/highmed/numportal/domain/model/Project.java @@ -1,20 +1,19 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonManagedReference; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.repository.CategorySetConverter; -import de.vitagroup.num.domain.repository.MapConverter; -import de.vitagroup.num.domain.repository.StringSetConverter; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.CategorySetConverter; +import org.highmed.numportal.domain.repository.MapConverter; +import org.highmed.numportal.domain.repository.StringSetConverter; import lombok.*; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.hibernate.annotations.JoinColumnOrFormula; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; -import javax.persistence.*; +import jakarta.persistence.*; + import java.io.Serializable; import java.time.LocalDate; import java.time.OffsetDateTime; @@ -91,7 +90,6 @@ public class Project implements Serializable { @ToString.Exclude @OneToMany(fetch = FetchType.LAZY) @JoinColumnOrFormula(column = @JoinColumn(name = "property", referencedColumnName = "status", insertable = false, updatable = false)) - @NotFound(action = NotFoundAction.IGNORE) private Set translations = new HashSet<>(); @ToString.Exclude diff --git a/src/main/java/de/vitagroup/num/domain/model/ProjectCategories.java b/src/main/java/org/highmed/numportal/domain/model/ProjectCategories.java similarity index 91% rename from src/main/java/de/vitagroup/num/domain/model/ProjectCategories.java rename to src/main/java/org/highmed/numportal/domain/model/ProjectCategories.java index 2aeb42024..5eb814e15 100644 --- a/src/main/java/de/vitagroup/num/domain/model/ProjectCategories.java +++ b/src/main/java/org/highmed/numportal/domain/model/ProjectCategories.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; public enum ProjectCategories { PEDIATRICS, diff --git a/src/main/java/de/vitagroup/num/domain/model/ProjectStatus.java b/src/main/java/org/highmed/numportal/domain/model/ProjectStatus.java similarity index 93% rename from src/main/java/de/vitagroup/num/domain/model/ProjectStatus.java rename to src/main/java/org/highmed/numportal/domain/model/ProjectStatus.java index f2b628e43..c3fc97b19 100644 --- a/src/main/java/de/vitagroup/num/domain/model/ProjectStatus.java +++ b/src/main/java/org/highmed/numportal/domain/model/ProjectStatus.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; -import static de.vitagroup.num.domain.model.Roles.STUDY_APPROVER; -import static de.vitagroup.num.domain.model.Roles.STUDY_COORDINATOR; -import static de.vitagroup.num.domain.model.Roles.SUPER_ADMIN; +import static org.highmed.numportal.domain.model.Roles.STUDY_APPROVER; +import static org.highmed.numportal.domain.model.Roles.STUDY_COORDINATOR; +import static org.highmed.numportal.domain.model.Roles.SUPER_ADMIN; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/de/vitagroup/num/domain/model/ProjectTransition.java b/src/main/java/org/highmed/numportal/domain/model/ProjectTransition.java similarity index 67% rename from src/main/java/de/vitagroup/num/domain/model/ProjectTransition.java rename to src/main/java/org/highmed/numportal/domain/model/ProjectTransition.java index 30ec59101..428a2faab 100644 --- a/src/main/java/de/vitagroup/num/domain/model/ProjectTransition.java +++ b/src/main/java/org/highmed/numportal/domain/model/ProjectTransition.java @@ -1,17 +1,10 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.fasterxml.jackson.annotation.JsonBackReference; -import de.vitagroup.num.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.model.admin.UserDetails; import java.io.Serializable; import java.time.OffsetDateTime; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/model/Roles.java b/src/main/java/org/highmed/numportal/domain/model/Roles.java similarity index 98% rename from src/main/java/de/vitagroup/num/domain/model/Roles.java rename to src/main/java/org/highmed/numportal/domain/model/Roles.java index 0f38c5b7b..9b536b435 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Roles.java +++ b/src/main/java/org/highmed/numportal/domain/model/Roles.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; import com.google.common.collect.Lists; import org.springframework.security.oauth2.jwt.Jwt; diff --git a/src/main/java/de/vitagroup/num/domain/model/Translation.java b/src/main/java/org/highmed/numportal/domain/model/Translation.java similarity index 87% rename from src/main/java/de/vitagroup/num/domain/model/Translation.java rename to src/main/java/org/highmed/numportal/domain/model/Translation.java index f6af03181..adf388940 100644 --- a/src/main/java/de/vitagroup/num/domain/model/Translation.java +++ b/src/main/java/org/highmed/numportal/domain/model/Translation.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.model; +package org.highmed.numportal.domain.model; -import de.vitagroup.num.domain.dto.Language; +import org.highmed.numportal.domain.dto.Language; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -8,7 +8,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Data diff --git a/src/main/java/org/highmed/numportal/domain/model/Type.java b/src/main/java/org/highmed/numportal/domain/model/Type.java new file mode 100644 index 000000000..6a485b25a --- /dev/null +++ b/src/main/java/org/highmed/numportal/domain/model/Type.java @@ -0,0 +1,6 @@ +package org.highmed.numportal.domain.model; + +public enum Type { + AQL, + GROUP +} diff --git a/src/main/java/de/vitagroup/num/domain/model/admin/Role.java b/src/main/java/org/highmed/numportal/domain/model/admin/Role.java similarity index 74% rename from src/main/java/de/vitagroup/num/domain/model/admin/Role.java rename to src/main/java/org/highmed/numportal/domain/model/admin/Role.java index c2a474138..e7f00ccdc 100644 --- a/src/main/java/de/vitagroup/num/domain/model/admin/Role.java +++ b/src/main/java/org/highmed/numportal/domain/model/admin/Role.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.model.admin; +package org.highmed.numportal.domain.model.admin; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/domain/model/admin/User.java b/src/main/java/org/highmed/numportal/domain/model/admin/User.java similarity index 89% rename from src/main/java/de/vitagroup/num/domain/model/admin/User.java rename to src/main/java/org/highmed/numportal/domain/model/admin/User.java index 0fd9646d8..cf702fc57 100644 --- a/src/main/java/de/vitagroup/num/domain/model/admin/User.java +++ b/src/main/java/org/highmed/numportal/domain/model/admin/User.java @@ -1,16 +1,17 @@ -package de.vitagroup.num.domain.model.admin; +package org.highmed.numportal.domain.model.admin; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; -import de.vitagroup.num.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.OrganizationDto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + import java.util.Map; import java.util.Set; @@ -49,7 +50,6 @@ public class User { private String email; @NotNull - @NotEmpty @Schema(description = "The timestamp of user registration") private Long createdTimestamp; diff --git a/src/main/java/de/vitagroup/num/domain/model/admin/UserDetails.java b/src/main/java/org/highmed/numportal/domain/model/admin/UserDetails.java similarity index 80% rename from src/main/java/de/vitagroup/num/domain/model/admin/UserDetails.java rename to src/main/java/org/highmed/numportal/domain/model/admin/UserDetails.java index 3b32aa104..8efad292e 100644 --- a/src/main/java/de/vitagroup/num/domain/model/admin/UserDetails.java +++ b/src/main/java/org/highmed/numportal/domain/model/admin/UserDetails.java @@ -1,11 +1,11 @@ -package de.vitagroup.num.domain.model.admin; +package org.highmed.numportal.domain.model.admin; import com.fasterxml.jackson.annotation.JsonBackReference; -import de.vitagroup.num.domain.model.Organization; +import org.highmed.numportal.domain.model.Organization; import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.*; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -18,13 +18,15 @@ @NoArgsConstructor public class UserDetails implements Serializable { - @Id private String userId; + @Id + private String userId; @ManyToOne @JsonBackReference @JoinColumn(name = "organization_id") private Organization organization; + @Builder.Default private boolean approved = false; private LocalDateTime createdDate; diff --git a/src/main/java/de/vitagroup/num/domain/repository/AqlCategoryRepository.java b/src/main/java/org/highmed/numportal/domain/repository/AqlCategoryRepository.java similarity index 87% rename from src/main/java/de/vitagroup/num/domain/repository/AqlCategoryRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/AqlCategoryRepository.java index 6a363bf98..ae8bc25b0 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/AqlCategoryRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/AqlCategoryRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.AqlCategory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/AqlConverter.java b/src/main/java/org/highmed/numportal/domain/repository/AqlConverter.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/repository/AqlConverter.java rename to src/main/java/org/highmed/numportal/domain/repository/AqlConverter.java index 4f9d98c55..c8bfe8bf1 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/AqlConverter.java +++ b/src/main/java/org/highmed/numportal/domain/repository/AqlConverter.java @@ -1,9 +1,10 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.CohortAql; -import javax.persistence.AttributeConverter; +import org.highmed.numportal.domain.model.CohortAql; + +import jakarta.persistence.AttributeConverter; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; diff --git a/src/main/java/de/vitagroup/num/domain/repository/AqlRepository.java b/src/main/java/org/highmed/numportal/domain/repository/AqlRepository.java similarity index 89% rename from src/main/java/de/vitagroup/num/domain/repository/AqlRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/AqlRepository.java index c748e2753..9f72f6822 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/AqlRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/AqlRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Aql; +import org.highmed.numportal.domain.model.Aql; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/de/vitagroup/num/domain/repository/CategorySetConverter.java b/src/main/java/org/highmed/numportal/domain/repository/CategorySetConverter.java similarity index 84% rename from src/main/java/de/vitagroup/num/domain/repository/CategorySetConverter.java rename to src/main/java/org/highmed/numportal/domain/repository/CategorySetConverter.java index 5b3282013..9cb02c6ad 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/CategorySetConverter.java +++ b/src/main/java/org/highmed/numportal/domain/repository/CategorySetConverter.java @@ -1,12 +1,13 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.ProjectCategories; import java.io.IOException; import java.util.Set; -import javax.persistence.AttributeConverter; -import javax.validation.constraints.NotNull; + +import jakarta.persistence.AttributeConverter; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; diff --git a/src/main/java/de/vitagroup/num/domain/repository/CohortGroupRepository.java b/src/main/java/org/highmed/numportal/domain/repository/CohortGroupRepository.java similarity index 66% rename from src/main/java/de/vitagroup/num/domain/repository/CohortGroupRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/CohortGroupRepository.java index 79eabf00e..26511092c 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/CohortGroupRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/CohortGroupRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.CohortGroup; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/CohortRepository.java b/src/main/java/org/highmed/numportal/domain/repository/CohortRepository.java similarity index 66% rename from src/main/java/de/vitagroup/num/domain/repository/CohortRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/CohortRepository.java index 3903e2214..ca521f62e 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/CohortRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/CohortRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Cohort; +import org.highmed.numportal.domain.model.Cohort; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/CommentRepository.java b/src/main/java/org/highmed/numportal/domain/repository/CommentRepository.java similarity index 73% rename from src/main/java/de/vitagroup/num/domain/repository/CommentRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/CommentRepository.java index 32ad0522f..2bd375ab4 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/CommentRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/CommentRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Comment; +import org.highmed.numportal.domain.model.Comment; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/ContentItemRepository.java b/src/main/java/org/highmed/numportal/domain/repository/ContentItemRepository.java similarity index 66% rename from src/main/java/de/vitagroup/num/domain/repository/ContentItemRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/ContentItemRepository.java index eefdd91dd..a43ebfa55 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/ContentItemRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/ContentItemRepository.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Content; -import de.vitagroup.num.domain.model.ContentType; +import org.highmed.numportal.domain.model.Content; +import org.highmed.numportal.domain.model.ContentType; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/CustomProjectRepository.java b/src/main/java/org/highmed/numportal/domain/repository/CustomProjectRepository.java similarity index 57% rename from src/main/java/de/vitagroup/num/domain/repository/CustomProjectRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/CustomProjectRepository.java index ecdb2896d..b13903b98 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/CustomProjectRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/CustomProjectRepository.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.specification.ProjectSpecification; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.specification.ProjectSpecification; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/de/vitagroup/num/domain/repository/MailDomainRepository.java b/src/main/java/org/highmed/numportal/domain/repository/MailDomainRepository.java similarity index 83% rename from src/main/java/de/vitagroup/num/domain/repository/MailDomainRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/MailDomainRepository.java index 256257982..826a650f1 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/MailDomainRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/MailDomainRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.MailDomain; +import org.highmed.numportal.domain.model.MailDomain; import java.util.List; import java.util.Optional; diff --git a/src/main/java/de/vitagroup/num/domain/repository/MapConverter.java b/src/main/java/org/highmed/numportal/domain/repository/MapConverter.java similarity index 92% rename from src/main/java/de/vitagroup/num/domain/repository/MapConverter.java rename to src/main/java/org/highmed/numportal/domain/repository/MapConverter.java index 484a81feb..41c3e400c 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/MapConverter.java +++ b/src/main/java/org/highmed/numportal/domain/repository/MapConverter.java @@ -1,12 +1,12 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.persistence.AttributeConverter; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import javax.persistence.AttributeConverter; import java.io.IOException; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/domain/repository/OrganizationRepository.java b/src/main/java/org/highmed/numportal/domain/repository/OrganizationRepository.java similarity index 83% rename from src/main/java/de/vitagroup/num/domain/repository/OrganizationRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/OrganizationRepository.java index 437f9aedb..1f23af1d1 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/OrganizationRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/OrganizationRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Organization; +import org.highmed.numportal.domain.model.Organization; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/ProjectRepository.java b/src/main/java/org/highmed/numportal/domain/repository/ProjectRepository.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/repository/ProjectRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/ProjectRepository.java index 58195ab34..d17a03386 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/ProjectRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/ProjectRepository.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/de/vitagroup/num/domain/repository/ProjectRepositoryImpl.java b/src/main/java/org/highmed/numportal/domain/repository/ProjectRepositoryImpl.java similarity index 89% rename from src/main/java/de/vitagroup/num/domain/repository/ProjectRepositoryImpl.java rename to src/main/java/org/highmed/numportal/domain/repository/ProjectRepositoryImpl.java index a8e080aab..ab95b008e 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/ProjectRepositoryImpl.java +++ b/src/main/java/org/highmed/numportal/domain/repository/ProjectRepositoryImpl.java @@ -1,19 +1,19 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.EntityGroup; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.specification.ProjectSpecification; +import org.highmed.numportal.domain.model.EntityGroup; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.specification.ProjectSpecification; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.persistence.criteria.*; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.criteria.*; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/src/main/java/de/vitagroup/num/domain/repository/ProjectTransitionRepository.java b/src/main/java/org/highmed/numportal/domain/repository/ProjectTransitionRepository.java similarity index 71% rename from src/main/java/de/vitagroup/num/domain/repository/ProjectTransitionRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/ProjectTransitionRepository.java index c306dab77..9e477088a 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/ProjectTransitionRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/ProjectTransitionRepository.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.ProjectTransition; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.ProjectTransition; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/de/vitagroup/num/domain/repository/StringSetConverter.java b/src/main/java/org/highmed/numportal/domain/repository/StringSetConverter.java similarity index 88% rename from src/main/java/de/vitagroup/num/domain/repository/StringSetConverter.java rename to src/main/java/org/highmed/numportal/domain/repository/StringSetConverter.java index b3d001c4a..02ebbcb66 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/StringSetConverter.java +++ b/src/main/java/org/highmed/numportal/domain/repository/StringSetConverter.java @@ -1,11 +1,12 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.Set; -import javax.persistence.AttributeConverter; -import javax.validation.constraints.NotNull; + +import jakarta.persistence.AttributeConverter; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; diff --git a/src/main/java/de/vitagroup/num/domain/repository/TranslationRepository.java b/src/main/java/org/highmed/numportal/domain/repository/TranslationRepository.java similarity index 66% rename from src/main/java/de/vitagroup/num/domain/repository/TranslationRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/TranslationRepository.java index 6f983eca1..614da5764 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/TranslationRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/TranslationRepository.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import de.vitagroup.num.domain.model.Translation; +import org.highmed.numportal.domain.model.Translation; @Repository public interface TranslationRepository extends JpaRepository { diff --git a/src/main/java/de/vitagroup/num/domain/repository/UserDetailsRepository.java b/src/main/java/org/highmed/numportal/domain/repository/UserDetailsRepository.java similarity index 91% rename from src/main/java/de/vitagroup/num/domain/repository/UserDetailsRepository.java rename to src/main/java/org/highmed/numportal/domain/repository/UserDetailsRepository.java index 693bb1df6..13aa7d007 100644 --- a/src/main/java/de/vitagroup/num/domain/repository/UserDetailsRepository.java +++ b/src/main/java/org/highmed/numportal/domain/repository/UserDetailsRepository.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.model.admin.UserDetails; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/de/vitagroup/num/domain/specification/AqlSpecification.java b/src/main/java/org/highmed/numportal/domain/specification/AqlSpecification.java similarity index 89% rename from src/main/java/de/vitagroup/num/domain/specification/AqlSpecification.java rename to src/main/java/org/highmed/numportal/domain/specification/AqlSpecification.java index 012ed7186..1863ada9a 100644 --- a/src/main/java/de/vitagroup/num/domain/specification/AqlSpecification.java +++ b/src/main/java/org/highmed/numportal/domain/specification/AqlSpecification.java @@ -1,19 +1,19 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.model.AqlCategory; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.SearchFilter; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.SearchFilter; import lombok.Getter; import lombok.experimental.SuperBuilder; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.data.jpa.domain.Specification; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/src/main/java/de/vitagroup/num/domain/specification/BaseSpecification.java b/src/main/java/org/highmed/numportal/domain/specification/BaseSpecification.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/specification/BaseSpecification.java rename to src/main/java/org/highmed/numportal/domain/specification/BaseSpecification.java index d21da11ba..629d1c36b 100644 --- a/src/main/java/de/vitagroup/num/domain/specification/BaseSpecification.java +++ b/src/main/java/org/highmed/numportal/domain/specification/BaseSpecification.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.dto.Language; +import org.highmed.numportal.domain.dto.Language; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/de/vitagroup/num/domain/specification/OrganizationSpecification.java b/src/main/java/org/highmed/numportal/domain/specification/OrganizationSpecification.java similarity index 84% rename from src/main/java/de/vitagroup/num/domain/specification/OrganizationSpecification.java rename to src/main/java/org/highmed/numportal/domain/specification/OrganizationSpecification.java index 438311a70..badef16a5 100644 --- a/src/main/java/de/vitagroup/num/domain/specification/OrganizationSpecification.java +++ b/src/main/java/org/highmed/numportal/domain/specification/OrganizationSpecification.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.dto.SearchCriteria; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -9,10 +9,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.data.jpa.domain.Specification; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/domain/specification/ProjectSpecification.java b/src/main/java/org/highmed/numportal/domain/specification/ProjectSpecification.java similarity index 92% rename from src/main/java/de/vitagroup/num/domain/specification/ProjectSpecification.java rename to src/main/java/org/highmed/numportal/domain/specification/ProjectSpecification.java index 912313f5e..efb5980dd 100644 --- a/src/main/java/de/vitagroup/num/domain/specification/ProjectSpecification.java +++ b/src/main/java/org/highmed/numportal/domain/specification/ProjectSpecification.java @@ -1,18 +1,18 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.SearchFilter; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.SearchFilter; +import jakarta.persistence.criteria.*; import lombok.Getter; import lombok.experimental.SuperBuilder; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import javax.persistence.criteria.*; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/de/vitagroup/num/domain/specification/UserDetailsSpecification.java b/src/main/java/org/highmed/numportal/domain/specification/UserDetailsSpecification.java similarity index 86% rename from src/main/java/de/vitagroup/num/domain/specification/UserDetailsSpecification.java rename to src/main/java/org/highmed/numportal/domain/specification/UserDetailsSpecification.java index a9387fc7d..95e387e83 100644 --- a/src/main/java/de/vitagroup/num/domain/specification/UserDetailsSpecification.java +++ b/src/main/java/org/highmed/numportal/domain/specification/UserDetailsSpecification.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.admin.UserDetails; +import jakarta.persistence.criteria.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import org.apache.commons.collections.CollectionUtils; import org.springframework.data.jpa.domain.Specification; -import javax.persistence.criteria.*; import java.util.ArrayList; import java.util.List; import java.util.Set; diff --git a/src/main/java/de/vitagroup/num/domain/templates/ExceptionsTemplate.java b/src/main/java/org/highmed/numportal/domain/templates/ExceptionsTemplate.java similarity index 97% rename from src/main/java/de/vitagroup/num/domain/templates/ExceptionsTemplate.java rename to src/main/java/org/highmed/numportal/domain/templates/ExceptionsTemplate.java index e95f23893..f07c9f9b8 100644 --- a/src/main/java/de/vitagroup/num/domain/templates/ExceptionsTemplate.java +++ b/src/main/java/org/highmed/numportal/domain/templates/ExceptionsTemplate.java @@ -1,10 +1,10 @@ -package de.vitagroup.num.domain.templates; +package org.highmed.numportal.domain.templates; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import de.vitagroup.num.service.exception.dto.ExceptionDto; +import org.highmed.numportal.service.exception.dto.ExceptionDto; public class ExceptionsTemplate { public final static String TOKEN_IS_NOT_VALID_MSG = "Token is not valid"; @@ -156,8 +156,6 @@ public class ExceptionsTemplate { public final static String CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED = "Cannot check consent for data usage outside the European Union, oid not configured"; public final static String CACHE_IS_NOT_REACHABLE = "Cache is not reachable"; public final static String EXCEPTION_HAPPENED_IN_CLASS_FOR_ENVIRONMENT = "Exception happened in %s class for %s environment. Link %s is not accessible";//3 parameters - public final static String EXCEPTION_IN_PARSING_PAGE = "health.num-codex.de page was modified and regex expressions needs to be checked."; - public final static String ANNOUNCEMENT_IN_PLACE = "Please visit health.num-codex.de page for announcement. Date/Time - [%s] Description - [%s]"; //document public final static String DOCUMENT_TYPE_MISMATCH = "Document type mismatch. Only PDF type is allowed to be uploaded."; @@ -323,8 +321,6 @@ public class ExceptionsTemplate { errorMap.put(NOT_ALLOWED_TO_UPDATE_OWN_ORGANIZATION_STATUS, new ExceptionDto(99, new ArrayList<>())); errorMap.put(CANNOT_ASSIGN_USER_TO_DEACTIVATED_ORGANIZATION, new ExceptionDto(100, new ArrayList<>()));//1 parameter errorMap.put(EXCEPTION_HAPPENED_IN_CLASS_FOR_ENVIRONMENT, new ExceptionDto(101, new ArrayList<>()));//3 parameter - errorMap.put(EXCEPTION_IN_PARSING_PAGE, new ExceptionDto(102, new ArrayList<>())); - errorMap.put(ANNOUNCEMENT_IN_PLACE, new ExceptionDto(103, new ArrayList<>()));//2 parameters errorMap.put(ATTACHMENT_NOT_FOUND, new ExceptionDto( 104, new ArrayList<>() ) );//1 parameter //Document diff --git a/src/main/java/de/vitagroup/num/domain/validation/CohortValidator.java b/src/main/java/org/highmed/numportal/domain/validation/CohortValidator.java similarity index 85% rename from src/main/java/de/vitagroup/num/domain/validation/CohortValidator.java rename to src/main/java/org/highmed/numportal/domain/validation/CohortValidator.java index cb028b8d3..77ca66dea 100644 --- a/src/main/java/de/vitagroup/num/domain/validation/CohortValidator.java +++ b/src/main/java/org/highmed/numportal/domain/validation/CohortValidator.java @@ -1,11 +1,12 @@ -package de.vitagroup.num.domain.validation; +package org.highmed.numportal.domain.validation; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.domain.model.Type; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import org.apache.commons.collections4.CollectionUtils; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.model.Operator; +import org.highmed.numportal.domain.model.Type; -import javax.validation.*; import java.util.ArrayDeque; import java.util.Queue; diff --git a/src/main/java/de/vitagroup/num/domain/validation/TranslatedStringValidator.java b/src/main/java/org/highmed/numportal/domain/validation/TranslatedStringValidator.java similarity index 76% rename from src/main/java/de/vitagroup/num/domain/validation/TranslatedStringValidator.java rename to src/main/java/org/highmed/numportal/domain/validation/TranslatedStringValidator.java index b20cee50a..1b975e5be 100644 --- a/src/main/java/de/vitagroup/num/domain/validation/TranslatedStringValidator.java +++ b/src/main/java/org/highmed/numportal/domain/validation/TranslatedStringValidator.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.domain.validation; +package org.highmed.numportal.domain.validation; import java.util.Map; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import org.apache.logging.log4j.util.Strings; public class TranslatedStringValidator diff --git a/src/main/java/de/vitagroup/num/domain/validation/ValidCohort.java b/src/main/java/org/highmed/numportal/domain/validation/ValidCohort.java similarity index 80% rename from src/main/java/de/vitagroup/num/domain/validation/ValidCohort.java rename to src/main/java/org/highmed/numportal/domain/validation/ValidCohort.java index 52d572451..c72a0f8ad 100644 --- a/src/main/java/de/vitagroup/num/domain/validation/ValidCohort.java +++ b/src/main/java/org/highmed/numportal/domain/validation/ValidCohort.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.domain.validation; +package org.highmed.numportal.domain.validation; -import javax.validation.Constraint; -import javax.validation.Payload; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; diff --git a/src/main/java/de/vitagroup/num/domain/validation/ValidTranslatedString.java b/src/main/java/org/highmed/numportal/domain/validation/ValidTranslatedString.java similarity index 81% rename from src/main/java/de/vitagroup/num/domain/validation/ValidTranslatedString.java rename to src/main/java/org/highmed/numportal/domain/validation/ValidTranslatedString.java index 31dcf11f1..a85830779 100644 --- a/src/main/java/de/vitagroup/num/domain/validation/ValidTranslatedString.java +++ b/src/main/java/org/highmed/numportal/domain/validation/ValidTranslatedString.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.domain.validation; +package org.highmed.numportal.domain.validation; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -6,8 +6,9 @@ import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.validation.Constraint; -import javax.validation.Payload; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; @Constraint(validatedBy = TranslatedStringValidator.class) @Target({ FIELD }) diff --git a/src/main/java/de/vitagroup/num/events/DeactivateUserEvent.java b/src/main/java/org/highmed/numportal/events/DeactivateUserEvent.java similarity index 93% rename from src/main/java/de/vitagroup/num/events/DeactivateUserEvent.java rename to src/main/java/org/highmed/numportal/events/DeactivateUserEvent.java index 2564fe8cb..f2e5b4bd3 100644 --- a/src/main/java/de/vitagroup/num/events/DeactivateUserEvent.java +++ b/src/main/java/org/highmed/numportal/events/DeactivateUserEvent.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.events; +package org.highmed.numportal.events; import org.springframework.context.ApplicationEvent; diff --git a/src/main/java/de/vitagroup/num/listeners/DeactivateUserListener.java b/src/main/java/org/highmed/numportal/listeners/DeactivateUserListener.java similarity index 82% rename from src/main/java/de/vitagroup/num/listeners/DeactivateUserListener.java rename to src/main/java/org/highmed/numportal/listeners/DeactivateUserListener.java index 2da0889f6..6da5a284c 100644 --- a/src/main/java/de/vitagroup/num/listeners/DeactivateUserListener.java +++ b/src/main/java/org/highmed/numportal/listeners/DeactivateUserListener.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.listeners; +package org.highmed.numportal.listeners; -import de.vitagroup.num.events.DeactivateUserEvent; -import de.vitagroup.num.service.UserDetailsService; +import org.highmed.numportal.events.DeactivateUserEvent; +import org.highmed.numportal.service.UserDetailsService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationListener; diff --git a/src/main/java/de/vitagroup/num/listeners/UserCacheInit.java b/src/main/java/org/highmed/numportal/listeners/UserCacheInit.java similarity index 89% rename from src/main/java/de/vitagroup/num/listeners/UserCacheInit.java rename to src/main/java/org/highmed/numportal/listeners/UserCacheInit.java index f2e9f83fd..51f9101bc 100644 --- a/src/main/java/de/vitagroup/num/listeners/UserCacheInit.java +++ b/src/main/java/org/highmed/numportal/listeners/UserCacheInit.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.listeners; +package org.highmed.numportal.listeners; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.service.UserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; diff --git a/src/main/java/de/vitagroup/num/mapper/AqlMapper.java b/src/main/java/org/highmed/numportal/mapper/AqlMapper.java similarity index 79% rename from src/main/java/de/vitagroup/num/mapper/AqlMapper.java rename to src/main/java/org/highmed/numportal/mapper/AqlMapper.java index f114f944b..3fa9c3e40 100644 --- a/src/main/java/de/vitagroup/num/mapper/AqlMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/AqlMapper.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.dto.AqlCategoryDto; -import de.vitagroup.num.domain.dto.AqlDto; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.domain.dto.AqlCategoryDto; +import org.highmed.numportal.domain.dto.AqlDto; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.service.UserService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; diff --git a/src/main/java/de/vitagroup/num/mapper/CohortMapper.java b/src/main/java/org/highmed/numportal/mapper/CohortMapper.java similarity index 81% rename from src/main/java/de/vitagroup/num/mapper/CohortMapper.java rename to src/main/java/org/highmed/numportal/mapper/CohortMapper.java index 47e7bcdd9..42a54de32 100644 --- a/src/main/java/de/vitagroup/num/mapper/CohortMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/CohortMapper.java @@ -1,17 +1,18 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import java.util.stream.Collectors; -import javax.annotation.PostConstruct; +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.Type; import lombok.AllArgsConstructor; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import java.util.stream.Collectors; + @Component @AllArgsConstructor public class CohortMapper { diff --git a/src/main/java/de/vitagroup/num/mapper/CommentMapper.java b/src/main/java/org/highmed/numportal/mapper/CommentMapper.java similarity index 74% rename from src/main/java/de/vitagroup/num/mapper/CommentMapper.java rename to src/main/java/org/highmed/numportal/mapper/CommentMapper.java index dd4ad0e9f..b2c409e9d 100644 --- a/src/main/java/de/vitagroup/num/mapper/CommentMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/CommentMapper.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Comment; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.CommentDto; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.domain.dto.CommentDto; +import org.highmed.numportal.domain.model.Comment; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.service.UserService; import lombok.AllArgsConstructor; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; diff --git a/src/main/java/de/vitagroup/num/mapper/OrganizationMapper.java b/src/main/java/org/highmed/numportal/mapper/OrganizationMapper.java similarity index 74% rename from src/main/java/de/vitagroup/num/mapper/OrganizationMapper.java rename to src/main/java/org/highmed/numportal/mapper/OrganizationMapper.java index 7a0e5f946..8afe9b45f 100644 --- a/src/main/java/de/vitagroup/num/mapper/OrganizationMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/OrganizationMapper.java @@ -1,15 +1,15 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.MailDomain; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.dto.OrganizationDto; -import java.util.stream.Collectors; - -import de.vitagroup.num.service.OrganizationService; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.model.MailDomain; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.service.OrganizationService; import lombok.AllArgsConstructor; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; +import java.util.stream.Collectors; + @Component @AllArgsConstructor public class OrganizationMapper { diff --git a/src/main/java/de/vitagroup/num/mapper/ProjectMapper.java b/src/main/java/org/highmed/numportal/mapper/ProjectMapper.java similarity index 80% rename from src/main/java/de/vitagroup/num/mapper/ProjectMapper.java rename to src/main/java/org/highmed/numportal/mapper/ProjectMapper.java index 8a4740c73..7aae32e86 100644 --- a/src/main/java/de/vitagroup/num/mapper/ProjectMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/ProjectMapper.java @@ -1,16 +1,17 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.attachment.service.AttachmentService; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.ProjectDto; -import de.vitagroup.num.service.UserService; -import javax.annotation.PostConstruct; +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.domain.dto.ProjectDto; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.service.UserService; import lombok.AllArgsConstructor; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + @Component @AllArgsConstructor public class ProjectMapper { diff --git a/src/main/java/de/vitagroup/num/mapper/ProjectViewMapper.java b/src/main/java/org/highmed/numportal/mapper/ProjectViewMapper.java similarity index 70% rename from src/main/java/de/vitagroup/num/mapper/ProjectViewMapper.java rename to src/main/java/org/highmed/numportal/mapper/ProjectViewMapper.java index 5379f4481..abde79bbd 100644 --- a/src/main/java/de/vitagroup/num/mapper/ProjectViewMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/ProjectViewMapper.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.ProjectViewTO; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.domain.dto.ProjectViewTO; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.service.UserService; import lombok.AllArgsConstructor; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; diff --git a/src/main/java/de/vitagroup/num/mapper/TemplateMapper.java b/src/main/java/org/highmed/numportal/mapper/TemplateMapper.java similarity index 84% rename from src/main/java/de/vitagroup/num/mapper/TemplateMapper.java rename to src/main/java/org/highmed/numportal/mapper/TemplateMapper.java index 9286fad09..02a4b86cb 100644 --- a/src/main/java/de/vitagroup/num/mapper/TemplateMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/TemplateMapper.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.dto.TemplateInfoDto; -import de.vitagroup.num.domain.dto.TemplateMetadataDto; +import org.highmed.numportal.domain.dto.TemplateInfoDto; +import org.highmed.numportal.domain.dto.TemplateMetadataDto; import lombok.AllArgsConstructor; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; import org.springframework.stereotype.Component; diff --git a/src/main/java/de/vitagroup/num/mapper/UserDetailsMapper.java b/src/main/java/org/highmed/numportal/mapper/UserDetailsMapper.java similarity index 81% rename from src/main/java/de/vitagroup/num/mapper/UserDetailsMapper.java rename to src/main/java/org/highmed/numportal/mapper/UserDetailsMapper.java index eb14be41a..f59aa86a8 100644 --- a/src/main/java/de/vitagroup/num/mapper/UserDetailsMapper.java +++ b/src/main/java/org/highmed/numportal/mapper/UserDetailsMapper.java @@ -1,13 +1,14 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.UserDetailsDto; -import javax.annotation.PostConstruct; +import org.highmed.numportal.domain.dto.UserDetailsDto; +import org.highmed.numportal.domain.model.admin.UserDetails; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + @Slf4j @Component @AllArgsConstructor diff --git a/src/main/java/de/vitagroup/num/properties/ClamAVProperties.java b/src/main/java/org/highmed/numportal/properties/ClamAVProperties.java similarity index 94% rename from src/main/java/de/vitagroup/num/properties/ClamAVProperties.java rename to src/main/java/org/highmed/numportal/properties/ClamAVProperties.java index 353e940b6..0baaef44c 100644 --- a/src/main/java/de/vitagroup/num/properties/ClamAVProperties.java +++ b/src/main/java/org/highmed/numportal/properties/ClamAVProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/properties/ConsentProperties.java b/src/main/java/org/highmed/numportal/properties/ConsentProperties.java similarity index 87% rename from src/main/java/de/vitagroup/num/properties/ConsentProperties.java rename to src/main/java/org/highmed/numportal/properties/ConsentProperties.java index b4df2ae37..beab3d092 100644 --- a/src/main/java/de/vitagroup/num/properties/ConsentProperties.java +++ b/src/main/java/org/highmed/numportal/properties/ConsentProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/properties/CorsProperties.java b/src/main/java/org/highmed/numportal/properties/CorsProperties.java similarity index 89% rename from src/main/java/de/vitagroup/num/properties/CorsProperties.java rename to src/main/java/org/highmed/numportal/properties/CorsProperties.java index 076a75510..0c2bec60d 100644 --- a/src/main/java/de/vitagroup/num/properties/CorsProperties.java +++ b/src/main/java/org/highmed/numportal/properties/CorsProperties.java @@ -1,11 +1,12 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; -import java.util.ArrayList; -import java.util.List; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import java.util.ArrayList; +import java.util.List; + @Data @Configuration @ConfigurationProperties(prefix = "cors") diff --git a/src/main/java/de/vitagroup/num/properties/EhrBaseProperties.java b/src/main/java/org/highmed/numportal/properties/EhrBaseProperties.java similarity index 65% rename from src/main/java/de/vitagroup/num/properties/EhrBaseProperties.java rename to src/main/java/org/highmed/numportal/properties/EhrBaseProperties.java index 16221486e..e784c7eab 100644 --- a/src/main/java/de/vitagroup/num/properties/EhrBaseProperties.java +++ b/src/main/java/org/highmed/numportal/properties/EhrBaseProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -14,4 +14,10 @@ public class EhrBaseProperties { private String username; private String password; + + private String adminUsername; + + private String adminPassword; + + private String idPath = "ehr_status/subject/external_ref/id/value"; } diff --git a/src/main/java/de/vitagroup/num/properties/FttpProperties.java b/src/main/java/org/highmed/numportal/properties/FttpProperties.java similarity index 91% rename from src/main/java/de/vitagroup/num/properties/FttpProperties.java rename to src/main/java/org/highmed/numportal/properties/FttpProperties.java index 81ccaa696..8b2e00bdf 100644 --- a/src/main/java/de/vitagroup/num/properties/FttpProperties.java +++ b/src/main/java/org/highmed/numportal/properties/FttpProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/properties/NumProperties.java b/src/main/java/org/highmed/numportal/properties/NumProperties.java similarity index 83% rename from src/main/java/de/vitagroup/num/properties/NumProperties.java rename to src/main/java/org/highmed/numportal/properties/NumProperties.java index f92f8a713..3235fb92f 100644 --- a/src/main/java/de/vitagroup/num/properties/NumProperties.java +++ b/src/main/java/org/highmed/numportal/properties/NumProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -13,7 +13,6 @@ public class NumProperties { private String locale; private String url; - private String systemStatusUrl; private Map userManualUrl; } diff --git a/src/main/java/de/vitagroup/num/properties/PrivacyProperties.java b/src/main/java/org/highmed/numportal/properties/PrivacyProperties.java similarity index 82% rename from src/main/java/de/vitagroup/num/properties/PrivacyProperties.java rename to src/main/java/org/highmed/numportal/properties/PrivacyProperties.java index 5071bc805..ad5eb2442 100644 --- a/src/main/java/de/vitagroup/num/properties/PrivacyProperties.java +++ b/src/main/java/org/highmed/numportal/properties/PrivacyProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -9,6 +9,7 @@ @ConfigurationProperties(prefix = "privacy") public class PrivacyProperties { + private boolean enabled = true; private int minHits = 50; private String pseudonymitySecret; private int pseudonomityChunksSize = 20; diff --git a/src/main/java/de/vitagroup/num/properties/PseudonymsPsnWorkflowProperties.java b/src/main/java/org/highmed/numportal/properties/PseudonymsPsnWorkflowProperties.java similarity index 91% rename from src/main/java/de/vitagroup/num/properties/PseudonymsPsnWorkflowProperties.java rename to src/main/java/org/highmed/numportal/properties/PseudonymsPsnWorkflowProperties.java index 49ed66a8c..b901cfc59 100644 --- a/src/main/java/de/vitagroup/num/properties/PseudonymsPsnWorkflowProperties.java +++ b/src/main/java/org/highmed/numportal/properties/PseudonymsPsnWorkflowProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/properties/SwaggerProperties.java b/src/main/java/org/highmed/numportal/properties/SwaggerProperties.java similarity index 90% rename from src/main/java/de/vitagroup/num/properties/SwaggerProperties.java rename to src/main/java/org/highmed/numportal/properties/SwaggerProperties.java index d4e9207ae..126f3dd35 100644 --- a/src/main/java/de/vitagroup/num/properties/SwaggerProperties.java +++ b/src/main/java/org/highmed/numportal/properties/SwaggerProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.properties; +package org.highmed.numportal.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/service/AqlService.java b/src/main/java/org/highmed/numportal/service/AqlService.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/AqlService.java rename to src/main/java/org/highmed/numportal/service/AqlService.java index dc177fe5d..b9fbdadb7 100644 --- a/src/main/java/de/vitagroup/num/service/AqlService.java +++ b/src/main/java/org/highmed/numportal/service/AqlService.java @@ -1,42 +1,42 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.model.AqlCategory; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.SlimAqlDto; -import de.vitagroup.num.domain.repository.AqlCategoryRepository; -import de.vitagroup.num.domain.repository.AqlRepository; -import de.vitagroup.num.domain.specification.AqlSpecification; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.PrivacyException; -import de.vitagroup.num.service.exception.ResourceNotFound; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.SlimAqlDto; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.AqlCategoryRepository; +import org.highmed.numportal.domain.repository.AqlRepository; +import org.highmed.numportal.domain.specification.AqlSpecification; +import org.highmed.numportal.properties.PrivacyProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.ehrbase.aql.parser.AqlParseException; import org.ehrbase.aqleditor.dto.aql.QueryValidationResponse; import org.ehrbase.aqleditor.dto.aql.Result; import org.ehrbase.aqleditor.service.AqlEditorAqlService; +import org.ehrbase.openehr.sdk.aql.parser.AqlParseException; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.PrivacyException; +import org.highmed.numportal.service.exception.ResourceNotFound; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.data.domain.*; import org.springframework.data.jpa.domain.JpaSort; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.transaction.Transactional; import java.time.OffsetDateTime; import java.util.*; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j @Service diff --git a/src/main/java/de/vitagroup/num/service/CohortService.java b/src/main/java/org/highmed/numportal/service/CohortService.java similarity index 81% rename from src/main/java/de/vitagroup/num/service/CohortService.java rename to src/main/java/org/highmed/numportal/service/CohortService.java index 9ff01e1aa..06340ade6 100644 --- a/src/main/java/de/vitagroup/num/service/CohortService.java +++ b/src/main/java/org/highmed/numportal/service/CohortService.java @@ -1,43 +1,47 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import de.vitagroup.num.domain.dto.CohortSizeDto; -import de.vitagroup.num.domain.dto.TemplateSizeRequestDto; -import de.vitagroup.num.domain.repository.CohortRepository; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.PrivacyException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.executors.CohortExecutor; -import de.vitagroup.num.service.policy.EhrPolicy; -import de.vitagroup.num.service.policy.Policy; -import de.vitagroup.num.service.policy.ProjectPolicyService; -import de.vitagroup.num.service.policy.TemplatesPolicy; +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.dto.CohortSizeDto; +import org.highmed.numportal.domain.dto.TemplateSizeRequestDto; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.repository.CohortRepository; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.properties.PrivacyProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.*; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.condition.ComparisonOperatorCondition; +import org.ehrbase.openehr.sdk.aql.dto.condition.LogicalOperatorCondition; +import org.ehrbase.openehr.sdk.aql.dto.condition.WhereCondition; +import org.ehrbase.openehr.sdk.aql.dto.operand.Operand; +import org.ehrbase.openehr.sdk.aql.dto.operand.QueryParameter; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.PrivacyException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.executors.CohortExecutor; +import org.highmed.numportal.service.policy.EhrPolicy; +import org.highmed.numportal.service.policy.Policy; +import org.highmed.numportal.service.policy.ProjectPolicyService; +import org.highmed.numportal.service.policy.TemplatesPolicy; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j @Service @@ -157,7 +161,7 @@ private Map determineTemplatesHits( private void getTemplateHits(Set ehrIds, Map hits, String templateId) { try { - AqlDto aql = templateService.createSelectCompositionQuery(templateId); + AqlQuery aql = templateService.createSelectCompositionQuery(templateId); List policies = new LinkedList<>(); policies.add(EhrPolicy.builder().cohortEhrIds(ehrIds).build()); @@ -165,7 +169,7 @@ private void getTemplateHits(Set ehrIds, Map hits, Stri policyService.apply(aql, policies); Set templateHits = - ehrBaseService.retrieveEligiblePatientIds(new AqlBinder().bind(aql).getLeft().buildAql()); + ehrBaseService.retrieveEligiblePatientIds(AqlRenderer.render(aql)); hits.put(templateId, templateHits != null ? templateHits.size() : 0); } catch (Exception e) { @@ -217,19 +221,19 @@ private void validateCohortParameters(CohortGroupDto cohortGroupDto) { throw new BadRequestException(CohortGroup.class, INVALID_COHORT_GROUP_AQL_MISSING); } Set parameterNames = new HashSet<>(); - AqlDto aqlDto = new AqlToDtoParser().parse(cohortGroupDto.getQuery().getQuery()); - ConditionDto conditionDto = aqlDto.getWhere(); - if (conditionDto instanceof ConditionComparisonOperatorDto) { - Value value = ((ConditionComparisonOperatorDto) conditionDto).getValue(); - if (value instanceof ParameterValue parameterValue) { + AqlQuery aqlDto = AqlQueryParser.parse(cohortGroupDto.getQuery().getQuery()); + WhereCondition conditionDto = aqlDto.getWhere(); + if (conditionDto instanceof ComparisonOperatorCondition) { + Operand value = ((ComparisonOperatorCondition) conditionDto).getValue(); + if (value instanceof QueryParameter parameterValue) { parameterNames.add(parameterValue.getName()); } - } else if (conditionDto instanceof ConditionLogicalOperatorDto) { - List values = ((ConditionLogicalOperatorDto) conditionDto).getValues(); - for (ConditionDto v : values) { - if (v instanceof ConditionComparisonOperatorDto) { - Value value = ((ConditionComparisonOperatorDto) v).getValue(); - if (value instanceof ParameterValue parameterValue) { + } else if (conditionDto instanceof LogicalOperatorCondition) { + List values = ((LogicalOperatorCondition) conditionDto).getValues(); + for (WhereCondition v : values) { + if (v instanceof ComparisonOperatorCondition) { + Operand value = ((ComparisonOperatorCondition) v).getValue(); + if (value instanceof QueryParameter parameterValue) { parameterNames.add(parameterValue.getName()); } } diff --git a/src/main/java/de/vitagroup/num/service/CommentService.java b/src/main/java/org/highmed/numportal/service/CommentService.java similarity index 76% rename from src/main/java/de/vitagroup/num/service/CommentService.java rename to src/main/java/org/highmed/numportal/service/CommentService.java index c2e70a1b2..299ef7615 100644 --- a/src/main/java/de/vitagroup/num/service/CommentService.java +++ b/src/main/java/org/highmed/numportal/service/CommentService.java @@ -1,26 +1,20 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_DELETE_COMMENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COMMENT_EDIT_FOR_COMMENT_WITH_ID_IS_NOT_ALLOWED_COMMENT_HAS_DIFFERENT_AUTHOR; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COMMENT_NOT_FOUND; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_COMMENT_ID; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_DOES_NOT_EXIST; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_NOT_FOUND; +import org.highmed.numportal.domain.model.Comment; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.CommentRepository; +import lombok.AllArgsConstructor; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.stereotype.Service; import java.time.OffsetDateTime; import java.util.List; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.stereotype.Service; - -import de.vitagroup.num.domain.model.Comment; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.repository.CommentRepository; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import lombok.AllArgsConstructor; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Service @AllArgsConstructor diff --git a/src/main/java/de/vitagroup/num/service/ContentService.java b/src/main/java/org/highmed/numportal/service/ContentService.java similarity index 88% rename from src/main/java/de/vitagroup/num/service/ContentService.java rename to src/main/java/org/highmed/numportal/service/ContentService.java index ec65040db..d06581350 100644 --- a/src/main/java/de/vitagroup/num/service/ContentService.java +++ b/src/main/java/org/highmed/numportal/service/ContentService.java @@ -1,30 +1,28 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Content; -import de.vitagroup.num.domain.model.ContentType; -import de.vitagroup.num.domain.dto.CardDto; -import de.vitagroup.num.domain.dto.MetricsDto; -import de.vitagroup.num.domain.dto.NavigationItemDto; -import de.vitagroup.num.domain.dto.ProjectInfoDto; -import de.vitagroup.num.domain.repository.ContentItemRepository; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.SystemException; +import org.highmed.numportal.domain.dto.CardDto; +import org.highmed.numportal.domain.dto.MetricsDto; +import org.highmed.numportal.domain.dto.NavigationItemDto; +import org.highmed.numportal.domain.dto.ProjectInfoDto; +import org.highmed.numportal.domain.model.Content; +import org.highmed.numportal.domain.model.ContentType; +import org.highmed.numportal.domain.repository.ContentItemRepository; +import lombok.extern.slf4j.Slf4j; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.SystemException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -import org.ehrbase.response.openehr.QueryResponseData; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_PARSE_CARD; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_PARSE_NAVIGATION_CONTENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_SAVE_CARD; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_SAVE_NAVIGATION_CONTENT; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j @Service diff --git a/src/main/java/de/vitagroup/num/service/OrganizationService.java b/src/main/java/org/highmed/numportal/service/OrganizationService.java similarity index 94% rename from src/main/java/de/vitagroup/num/service/OrganizationService.java rename to src/main/java/org/highmed/numportal/service/OrganizationService.java index 456e505b0..85f1c3177 100644 --- a/src/main/java/de/vitagroup/num/service/OrganizationService.java +++ b/src/main/java/org/highmed/numportal/service/OrganizationService.java @@ -1,33 +1,33 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.MailDomain; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.repository.MailDomainRepository; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.specification.OrganizationSpecification; -import de.vitagroup.num.events.DeactivateUserEvent; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.model.MailDomain; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.MailDomainRepository; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.specification.OrganizationSpecification; +import org.highmed.numportal.events.DeactivateUserEvent; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.*; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.transaction.Transactional; import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; /** Service responsible for retrieving organization information from the terminology server */ @Slf4j diff --git a/src/main/java/de/vitagroup/num/service/ProjectDocCreator.java b/src/main/java/org/highmed/numportal/service/ProjectDocCreator.java similarity index 90% rename from src/main/java/de/vitagroup/num/service/ProjectDocCreator.java rename to src/main/java/org/highmed/numportal/service/ProjectDocCreator.java index b744a78ac..cb9cd6f4f 100644 --- a/src/main/java/de/vitagroup/num/service/ProjectDocCreator.java +++ b/src/main/java/org/highmed/numportal/service/ProjectDocCreator.java @@ -1,15 +1,21 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.ProjectCategories; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.ProjectDto; -import de.vitagroup.num.domain.dto.TemplateInfoDto; -import de.vitagroup.num.domain.dto.UserDetailsDto; -import de.vitagroup.num.domain.repository.CohortRepository; -import de.vitagroup.num.service.exception.SystemException; +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.dto.ProjectDto; +import org.highmed.numportal.domain.dto.TemplateInfoDto; +import org.highmed.numportal.domain.dto.UserDetailsDto; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.Type; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.repository.CohortRepository; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.exception.SystemException; +import org.springframework.context.MessageSource; +import org.springframework.stereotype.Component; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; @@ -19,13 +25,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.springframework.context.MessageSource; -import org.springframework.stereotype.Component; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CAN_T_FIND_THE_COHORT_BY_ID; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CAN_T_FIND_THE_COHORT_BY_ID; @Component @AllArgsConstructor diff --git a/src/main/java/de/vitagroup/num/service/ProjectService.java b/src/main/java/org/highmed/numportal/service/ProjectService.java similarity index 96% rename from src/main/java/de/vitagroup/num/service/ProjectService.java rename to src/main/java/org/highmed/numportal/service/ProjectService.java index 4e1ad8005..b7cd77834 100644 --- a/src/main/java/de/vitagroup/num/service/ProjectService.java +++ b/src/main/java/org/highmed/numportal/service/ProjectService.java @@ -1,28 +1,20 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.attachment.service.AttachmentService; -import de.vitagroup.num.attachment.domain.dto.LightAttachmentDto; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.domain.model.*; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.domain.repository.ProjectTransitionRepository; -import de.vitagroup.num.domain.specification.ProjectSpecification; -import de.vitagroup.num.mapper.ProjectMapper; -import de.vitagroup.num.properties.ConsentProperties; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.atna.AtnaService; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.ehrbase.ResponseFilter; -import de.vitagroup.num.service.email.ZarsService; -import de.vitagroup.num.service.exception.*; -import de.vitagroup.num.service.executors.CohortQueryLister; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.*; -import de.vitagroup.num.service.policy.*; +import org.highmed.numportal.attachment.domain.dto.LightAttachmentDto; +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.domain.repository.ProjectTransitionRepository; +import org.highmed.numportal.domain.specification.ProjectSpecification; +import org.highmed.numportal.mapper.ProjectMapper; +import org.highmed.numportal.properties.ConsentProperties; +import org.highmed.numportal.properties.PrivacyProperties; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; @@ -30,22 +22,31 @@ import org.apache.commons.csv.CSVPrinter; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.atna.AtnaService; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.ehrbase.ResponseFilter; +import org.highmed.numportal.service.email.ZarsService; +import org.highmed.numportal.service.exception.*; +import org.highmed.numportal.service.executors.CohortQueryLister; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.*; +import org.highmed.numportal.service.policy.*; +import org.highmed.numportal.service.exception.*; import org.modelmapper.ModelMapper; import org.springframework.data.domain.*; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; -import javax.transaction.Transactional; -import javax.validation.constraints.NotNull; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -60,8 +61,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static java.util.Objects.nonNull; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Service @Slf4j @@ -128,7 +129,7 @@ public class ProjectService { @Transactional - public boolean deleteProject(Long projectId, String userId, List roles) { + public boolean deleteProject(Long projectId, String userId, List roles) throws ForbiddenException { userDetailsService.checkIsUserApproved(userId); var project = @@ -248,7 +249,7 @@ private List executeCustomConfiguration(String query, Long pr private List retrieveTemplateData( Set ehrIds, String templateId, Long projectId, Boolean usedOutsideEu) { try { - AqlDto aql = templateService.createSelectCompositionQuery(templateId); + AqlQuery aql = templateService.createSelectCompositionQuery(templateId); List policies = collectProjectPolicies(ehrIds, Map.of(templateId, templateId), usedOutsideEu); @@ -280,7 +281,7 @@ public List executeAql(String query, Long projectId, String u Set ehrIds = cohortService.executeCohort(project.getCohort().getId(), project.isUsedOutsideEu()); - AqlDto aql = new AqlToDtoParser().parse(query); + AqlQuery aql = AqlQueryParser.parse(query); List policies = collectProjectPolicies(ehrIds, project.getTemplates(), project.isUsedOutsideEu()); diff --git a/src/main/java/org/highmed/numportal/service/TemplateService.java b/src/main/java/org/highmed/numportal/service/TemplateService.java new file mode 100644 index 000000000..a3651c2bf --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/TemplateService.java @@ -0,0 +1,109 @@ +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.dto.TemplateMetadataDto; +import org.highmed.numportal.mapper.TemplateMapper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.ehrbase.aqleditor.dto.containment.ContainmentDto; +import org.ehrbase.aqleditor.service.AqlEditorContainmentService; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression; +import org.ehrbase.openehr.sdk.aql.dto.operand.IdentifiedPath; +import org.ehrbase.openehr.sdk.aql.dto.operand.StringPrimitive; +import org.ehrbase.openehr.sdk.aql.dto.path.AndOperatorPredicate; +import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPathUtil; +import org.ehrbase.openehr.sdk.aql.dto.path.ComparisonOperatorPredicate; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectClause; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.util.AqlQueryConstants; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_FIND_TEMPLATE; + +@Service +@AllArgsConstructor +public class TemplateService { + + private final EhrBaseService ehrBaseService; + + private final TemplateMapper templateMapper; + + private final UserDetailsService userDetailsService; + + private final AqlEditorContainmentService aqlEditorContainmentService; + + /** + * Retrieves a list of all available templates metadata information + * + * @return getAllTemplatesMetadata(String userId) + */ + public List getAllTemplatesMetadata(String userId) { + userDetailsService.checkIsUserApproved(userId); + + List templateMetaDataDtos = ehrBaseService.getAllTemplatesMetadata(); + return templateMetaDataDtos.stream() + .map(templateMapper::convertToTemplateMetadataDto) + .collect(Collectors.toList()); + } + + public AqlQuery createSelectCompositionQuery(String templateId) { + + try { + ContainmentDto containmentDto = aqlEditorContainmentService.buildContainment(templateId); + if (containmentDto != null && StringUtils.isNotEmpty(containmentDto.getArchetypeId())) { + return createQuery(containmentDto.getArchetypeId()); + } else { + throw new BadRequestException(TemplateService.class, CANNOT_FIND_TEMPLATE, String.format(CANNOT_FIND_TEMPLATE, templateId)); + } + } catch (SystemException e) { + throw new SystemException(TemplateService.class, CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID, + String.format(CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID, templateId)); + } + } + + private AqlQuery createQuery(String archetypeId) { + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.COMPOSITION_TYPE); + containmentClassExpression.setIdentifier(AqlQueryConstants.COMPOSITION_CONTAINMENT_IDENTIFIER); + IdentifiedPath identifiedPath = new IdentifiedPath(); + identifiedPath.setRoot(containmentClassExpression); + + // generate select expression + SelectClause selectClause = new SelectClause(); + SelectExpression se = new SelectExpression(); + se.setColumnExpression(identifiedPath); + se.setAlias("F1"); + selectClause.setStatement(List.of(se)); + + // generate from expression + ContainmentClassExpression from = new ContainmentClassExpression(); + from.setType(AqlQueryConstants.EHR_TYPE); + from.setIdentifier(AqlQueryConstants.EHR_CONTAINMENT_IDENTIFIER); + + ContainmentClassExpression contains = new ContainmentClassExpression(); + contains.setType(AqlQueryConstants.COMPOSITION_TYPE); + contains.setIdentifier(AqlQueryConstants.COMPOSITION_CONTAINMENT_IDENTIFIER); + + List fromPredList = new ArrayList<>(); + ComparisonOperatorPredicate fromPred = new ComparisonOperatorPredicate(AqlObjectPathUtil.ARCHETYPE_NODE_ID, + ComparisonOperatorPredicate.PredicateComparisonOperator.EQ, new StringPrimitive(archetypeId)); + fromPredList.add(new AndOperatorPredicate(List.of(fromPred))); + contains.setPredicates(fromPredList); + from.setContains(contains); + + AqlQuery aqlQuery = new AqlQuery(); + aqlQuery.setSelect(selectClause); + aqlQuery.setFrom(from); + + return aqlQuery; + } +} diff --git a/src/main/java/de/vitagroup/num/service/UserDetailsService.java b/src/main/java/org/highmed/numportal/service/UserDetailsService.java similarity index 89% rename from src/main/java/de/vitagroup/num/service/UserDetailsService.java rename to src/main/java/org/highmed/numportal/service/UserDetailsService.java index 54480ed13..f413e8d10 100644 --- a/src/main/java/de/vitagroup/num/service/UserDetailsService.java +++ b/src/main/java/org/highmed/numportal/service/UserDetailsService.java @@ -1,37 +1,37 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.domain.specification.UserDetailsSpecification; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.exception.SystemException; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.NewUserNotification; -import de.vitagroup.num.service.notification.dto.NewUserWithoutOrganizationNotification; -import de.vitagroup.num.service.notification.dto.Notification; -import de.vitagroup.num.service.notification.dto.account.AccountApprovalNotification; -import de.vitagroup.num.service.notification.dto.account.AccountStatusChangedNotification; -import de.vitagroup.num.service.notification.dto.account.OrganizationUpdateNotification; +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; +import org.highmed.numportal.domain.specification.UserDetailsSpecification; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.NewUserNotification; +import org.highmed.numportal.service.notification.dto.NewUserWithoutOrganizationNotification; +import org.highmed.numportal.service.notification.dto.Notification; +import org.highmed.numportal.service.notification.dto.account.AccountApprovalNotification; +import org.highmed.numportal.service.notification.dto.account.AccountStatusChangedNotification; +import org.highmed.numportal.service.notification.dto.account.OrganizationUpdateNotification; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.transaction.Transactional; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static java.util.Objects.nonNull; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j @Service diff --git a/src/main/java/de/vitagroup/num/service/UserService.java b/src/main/java/org/highmed/numportal/service/UserService.java similarity index 95% rename from src/main/java/de/vitagroup/num/service/UserService.java rename to src/main/java/org/highmed/numportal/service/UserService.java index bb812b70a..a6eed2dc8 100644 --- a/src/main/java/de/vitagroup/num/service/UserService.java +++ b/src/main/java/org/highmed/numportal/service/UserService.java @@ -1,29 +1,30 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.EntityGroup; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.Translation; -import de.vitagroup.num.domain.model.admin.Role; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.SearchFilter; -import de.vitagroup.num.domain.dto.UserNameDto; -import de.vitagroup.num.domain.repository.TranslationRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.domain.specification.UserDetailsSpecification; -import de.vitagroup.num.mapper.OrganizationMapper; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.exception.SystemException; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.Notification; -import de.vitagroup.num.service.notification.dto.account.RolesUpdateNotification; -import de.vitagroup.num.service.notification.dto.account.UserNameUpdateNotification; -import de.vitagroup.num.web.feign.KeycloakFeign; +package org.highmed.numportal.service; + +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.SearchFilter; +import org.highmed.numportal.domain.dto.UserNameDto; +import org.highmed.numportal.domain.model.EntityGroup; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.Translation; +import org.highmed.numportal.domain.model.admin.Role; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.TranslationRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; +import org.highmed.numportal.domain.specification.UserDetailsSpecification; +import org.highmed.numportal.mapper.OrganizationMapper; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.Notification; +import org.highmed.numportal.service.notification.dto.account.RolesUpdateNotification; +import org.highmed.numportal.service.notification.dto.account.UserNameUpdateNotification; +import org.highmed.numportal.web.feign.KeycloakFeign; import feign.FeignException; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; @@ -37,10 +38,9 @@ import org.springframework.data.domain.*; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Nullable; -import javax.transaction.Transactional; -import javax.validation.constraints.NotNull; import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.ZoneId; @@ -49,9 +49,9 @@ import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j @Service diff --git a/src/main/java/de/vitagroup/num/service/atna/AtnaProperties.java b/src/main/java/org/highmed/numportal/service/atna/AtnaProperties.java similarity index 85% rename from src/main/java/de/vitagroup/num/service/atna/AtnaProperties.java rename to src/main/java/org/highmed/numportal/service/atna/AtnaProperties.java index e0b570c1f..8ef3b490f 100644 --- a/src/main/java/de/vitagroup/num/service/atna/AtnaProperties.java +++ b/src/main/java/org/highmed/numportal/service/atna/AtnaProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.atna; +package org.highmed.numportal.service.atna; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/de/vitagroup/num/service/atna/AtnaService.java b/src/main/java/org/highmed/numportal/service/atna/AtnaService.java similarity index 97% rename from src/main/java/de/vitagroup/num/service/atna/AtnaService.java rename to src/main/java/org/highmed/numportal/service/atna/AtnaService.java index 49cafe30b..0d30a744c 100644 --- a/src/main/java/de/vitagroup/num/service/atna/AtnaService.java +++ b/src/main/java/org/highmed/numportal/service/atna/AtnaService.java @@ -1,11 +1,8 @@ -package de.vitagroup.num.service.atna; +package org.highmed.numportal.service.atna; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Project; -import java.util.List; -import javax.annotation.Nullable; -import javax.annotation.PostConstruct; +import org.highmed.numportal.domain.model.Project; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.openehealth.ipf.commons.audit.AuditException; @@ -19,6 +16,10 @@ import org.openehealth.ipf.commons.audit.types.EventType; import org.springframework.stereotype.Service; +import javax.annotation.Nullable; +import javax.annotation.PostConstruct; +import java.util.List; + @Service @Slf4j public class AtnaService { diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/CompositionFlattener.java b/src/main/java/org/highmed/numportal/service/ehrbase/CompositionFlattener.java similarity index 84% rename from src/main/java/de/vitagroup/num/service/ehrbase/CompositionFlattener.java rename to src/main/java/org/highmed/numportal/service/ehrbase/CompositionFlattener.java index 0f6865e33..f4158b10a 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/CompositionFlattener.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/CompositionFlattener.java @@ -1,17 +1,17 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.nedap.archie.rm.composition.Composition; -import de.vitagroup.num.service.exception.SystemException; import lombok.RequiredArgsConstructor; -import org.ehrbase.client.templateprovider.ClientTemplateProvider; -import org.ehrbase.serialisation.flatencoding.FlatFormat; -import org.ehrbase.serialisation.flatencoding.FlatJasonProvider; -import org.ehrbase.serialisation.flatencoding.FlatJson; -import org.ehrbase.util.exception.SdkException; -import org.ehrbase.webtemplate.model.WebTemplate; -import org.ehrbase.webtemplate.templateprovider.CachedTemplateProvider; +import org.ehrbase.openehr.sdk.client.templateprovider.ClientTemplateProvider; +import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatFormat; +import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatJasonProvider; +import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatJson; +import org.ehrbase.openehr.sdk.util.exception.SdkException; +import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate; +import org.ehrbase.openehr.sdk.webtemplate.templateprovider.CachedTemplateProvider; +import org.highmed.numportal.service.exception.SystemException; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.springframework.stereotype.Component; @@ -27,8 +27,8 @@ import java.util.Map; import java.util.Optional; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS_COMPOSITION_MISSING_TEMPLATE_ID; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS_COMPOSITION_MISSING_TEMPLATE_ID; @Component @RequiredArgsConstructor diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilder.java b/src/main/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilder.java similarity index 90% rename from src/main/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilder.java rename to src/main/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilder.java index b9668a41a..ecd87aa40 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilder.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilder.java @@ -1,20 +1,16 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.nedap.archie.rm.composition.Composition; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.ehrbase.response.openehr.QueryResponseData; -import org.ehrbase.serialisation.jsonencoding.CanonicalJson; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; import org.springframework.stereotype.Component; +import java.util.*; + @Component @AllArgsConstructor @Slf4j diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/EhrBaseService.java b/src/main/java/org/highmed/numportal/service/ehrbase/EhrBaseService.java similarity index 62% rename from src/main/java/de/vitagroup/num/service/ehrbase/EhrBaseService.java rename to src/main/java/org/highmed/numportal/service/ehrbase/EhrBaseService.java index d20655fa9..8d5ba8b81 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/EhrBaseService.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/EhrBaseService.java @@ -1,72 +1,69 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.SystemException; +import com.nedap.archie.rm.support.identification.UUID; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.Pair; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.ParameterValue; -import org.ehrbase.aql.dto.select.SelectDto; -import org.ehrbase.aql.dto.select.SelectFieldDto; -import org.ehrbase.aql.dto.select.SelectStatementDto; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.client.aql.field.EhrFields; -import org.ehrbase.client.aql.query.EntityQuery; -import org.ehrbase.client.aql.query.NativeQuery; -import org.ehrbase.client.aql.query.Query; -import org.ehrbase.client.aql.record.Record; -import org.ehrbase.client.exception.ClientException; -import org.ehrbase.client.exception.WrongStatusCodeException; -import org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; -import org.ehrbase.response.openehr.QueryResponseData; -import org.ehrbase.response.openehr.TemplatesResponseData; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression; +import org.ehrbase.openehr.sdk.aql.dto.operand.IdentifiedPath; +import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPath; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClient; +import org.ehrbase.openehr.sdk.generator.commons.aql.query.NativeQuery; +import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; +import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record; +import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.TemplatesResponseData; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; +import org.ehrbase.openehr.sdk.util.exception.ClientException; +import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.properties.EhrBaseProperties; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.util.AqlQueryConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.stream.Collectors; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; + /** * Service using the EhrBaseSDK to talk to the EhrBaseAPI */ -import lombok.extern.slf4j.Slf4j; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; - @Slf4j @Service public class EhrBaseService { private static final Aql ALL_PATIENTS_IDS = - Aql.builder().query("select e/ehr_id/value from ehr e").build(); + Aql.builder().query("select e/ehr_id/value from ehr e").build(); - private static final String COMPOSITION_VALUE = "COMPOSITION"; private static final String COMPOSITION_KEY = "_type"; private static final String NAME = "name"; private static final String PATH = "path"; private static final String PSEUDONYM = "pseudonym"; - private static final String EHR_STATUS_PATH = "/ehr_status/subject/external_ref/id/value"; private final DefaultRestClient restClient; private final CompositionResponseDataBuilder compositionResponseDataBuilder; private final Pseudonymity pseudonymity; + private final EhrBaseProperties ehrBaseProperties; @Autowired public EhrBaseService( - DefaultRestClient restClient, - CompositionResponseDataBuilder compositionResponseDataBuilder, - @Lazy Pseudonymity pseudonymity) { + DefaultRestClient restClient, + CompositionResponseDataBuilder compositionResponseDataBuilder, + @Lazy Pseudonymity pseudonymity, + EhrBaseProperties ehrBaseProperties) { this.restClient = restClient; this.compositionResponseDataBuilder = compositionResponseDataBuilder; this.pseudonymity = pseudonymity; + this.ehrBaseProperties = ehrBaseProperties; } /** @@ -82,18 +79,24 @@ public Set retrieveEligiblePatientIds(Aql aql) { public Set retrieveEligiblePatientIds(String query) { log.debug("EhrBase retrieve ehr ids for query: {} ", query); - AqlDto dto = new AqlToDtoParser().parse(query); - SelectFieldDto selectStatementDto = new SelectFieldDto(); - selectStatementDto.setAqlPath(EhrFields.EHR_ID().getPath()); - selectStatementDto.setContainmentId(dto.getEhr().getContainmentId()); - SelectDto selectDto = new SelectDto(); - selectDto.setStatement(List.of(selectStatementDto)); - dto.setSelect(selectDto); - Pair, List> pair = new AqlBinder().bind(dto); + AqlQuery dto = AqlQueryParser.parse(query); + SelectExpression selectExpression = new SelectExpression(); + IdentifiedPath ehrIdPath = new IdentifiedPath(); + ehrIdPath.setPath(AqlObjectPath.parse(AqlQueryConstants.EHR_ID_PATH)); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.EHR_TYPE); + containmentClassExpression.setIdentifier(AqlQueryConstants.EHR_CONTAINMENT_IDENTIFIER); + ehrIdPath.setRoot(containmentClassExpression); + + selectExpression.setColumnExpression(ehrIdPath); + + dto.getSelect().setStatement(List.of(selectExpression)); + log.info("Generated query for retrieveEligiblePatientIds {} ", AqlRenderer.render(dto)); try { - List results = restClient.aqlEndpoint().execute(pair.getLeft()); - return results.stream().map(result -> result.value(0).toString()).collect(Collectors.toSet()); + List> results = restClient.aqlEndpoint().execute(Query.buildNativeQuery(AqlRenderer.render(dto), UUID.class)); + return results.stream().map(result -> result.value1().getValue()).collect(Collectors.toSet()); } catch (WrongStatusCodeException e) { log.error(INVALID_AQL_QUERY, e.getMessage(), e); throw new WrongStatusCodeException("EhrBaseService.class", 93, 1); @@ -106,28 +109,25 @@ public Set retrieveEligiblePatientIds(String query) { /** * Executes a raw aql query - * * @param aqlDto The aql query * @return QueryResponseData */ - public List executeRawQuery(AqlDto aqlDto, Long projectId) { + public List executeRawQuery(AqlQuery aqlDto, Long projectId) { addSelectSecondlevelPseudonyms(aqlDto); - Query query = new AqlBinder().bind(aqlDto).getLeft(); + String query = AqlRenderer.render(aqlDto); try { - try { log.info( - String.format( - "[AQL QUERY] EHR request query: %s ", - new AqlBinder().bind(aqlDto).getLeft().buildAql())); + String.format( + "[AQL QUERY] EHR request query: %s ", query)); } catch (Exception e) { log.error("Error parsing query while logging", e); } log.debug("EhrBase call to execute raw query: {}", query); - QueryResponseData response = restClient.aqlEndpoint().executeRaw(query); + QueryResponseData response = restClient.aqlEndpoint().executeRaw(Query.buildNativeQuery(query)); return flattenIfCompositionPresent(response, projectId); } catch (WrongStatusCodeException e) { @@ -157,14 +157,21 @@ public QueryResponseData executePlainQuery(String queryString) { } } - private void addSelectSecondlevelPseudonyms(AqlDto aqlDto) { - SelectDto selectDto = aqlDto.getSelect(); - List selectStatementDtos = selectDto.getStatement(); - SelectFieldDto pseudosStatement = new SelectFieldDto(); - pseudosStatement.setAqlPath(EHR_STATUS_PATH); - pseudosStatement.setContainmentId(aqlDto.getEhr().getContainmentId()); - selectStatementDtos.add(0, pseudosStatement); - selectDto.setStatement(selectStatementDtos); + private void addSelectSecondlevelPseudonyms(AqlQuery aqlDto) { + SelectExpression selectExpression = new SelectExpression(); + IdentifiedPath ehrIdPath = new IdentifiedPath(); + ehrIdPath.setPath(AqlObjectPath.parse(ehrBaseProperties.getIdPath())); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.EHR_TYPE); + containmentClassExpression.setIdentifier(AqlQueryConstants.EHR_CONTAINMENT_IDENTIFIER); + ehrIdPath.setRoot(containmentClassExpression); + + selectExpression.setColumnExpression(ehrIdPath); + List existingExpressions = new ArrayList<>(aqlDto.getSelect().getStatement()); + existingExpressions.add(0, selectExpression); + + aqlDto.getSelect().setStatement(existingExpressions); } public Set getAllPatientIds() { @@ -255,19 +262,19 @@ private List getAndRemoveEhrStatusColumn(QueryResponseData compositions) throw new BadRequestException(EhrBaseService.class, NO_DATA_COLUMNS_IN_THE_QUERY_RESULT); } String ehrStatusPath = columns.get(0).get(PATH); - if (ehrStatusPath == null || !ehrStatusPath.equals(EHR_STATUS_PATH)) { + if (ehrStatusPath == null || !ehrStatusPath.equals("/" + ehrBaseProperties.getIdPath())) { throw new SystemException(EhrBaseService.class, QUERY_RESULT_DOESN_T_CONTAIN_EHR_STATUS_COLUMN); } columns.remove(0); return compositions.getRows().stream() - .map(row -> row.remove(0)) - .map(String.class::cast) - .collect(Collectors.toList()); + .map(row -> row.remove(0)) + .map(String.class::cast) + .collect(Collectors.toList()); } private boolean isComposition(Object object) { return object instanceof Map - && ((Map) object).containsKey(COMPOSITION_KEY) - && ((Map) object).get(COMPOSITION_KEY).equals(COMPOSITION_VALUE); + && ((Map) object).containsKey(COMPOSITION_KEY) + && ((Map) object).get(COMPOSITION_KEY).equals(AqlQueryConstants.COMPOSITION_TYPE); } -} +} \ No newline at end of file diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/ParameterService.java b/src/main/java/org/highmed/numportal/service/ehrbase/ParameterService.java similarity index 73% rename from src/main/java/de/vitagroup/num/service/ehrbase/ParameterService.java rename to src/main/java/org/highmed/numportal/service/ehrbase/ParameterService.java index 890b5fb0f..15bcfa648 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/ParameterService.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/ParameterService.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.Version; @@ -15,22 +15,24 @@ import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; import com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration; import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; -import de.vitagroup.num.domain.dto.ParameterOptionsDto; -import de.vitagroup.num.service.UserDetailsService; +import com.nedap.archie.rm.support.identification.ObjectVersionId; +import org.highmed.numportal.domain.dto.ParameterOptionsDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.containment.ContainmentDto; -import org.ehrbase.aql.dto.orderby.OrderByExpressionDto; -import org.ehrbase.aql.dto.orderby.OrderByExpressionSymbol; -import org.ehrbase.aql.dto.select.SelectDto; -import org.ehrbase.aql.dto.select.SelectFieldDto; -import org.ehrbase.client.openehrclient.VersionUid; -import org.ehrbase.client.openehrclient.defaultrestclient.TemporalAccessorDeSerializer; -import org.ehrbase.client.openehrclient.defaultrestclient.VersionUidDeSerializer; -import org.ehrbase.serialisation.jsonencoding.JacksonUtil; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression; +import org.ehrbase.openehr.sdk.aql.dto.operand.IdentifiedPath; +import org.ehrbase.openehr.sdk.aql.dto.orderby.OrderByExpression; +import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPath; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectClause; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.TemporalAccessorDeSerializer; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.VersionUidDeSerializer; +import org.ehrbase.openehr.sdk.serialisation.jsonencoding.ArchieObjectMapperProvider; +import org.highmed.numportal.service.util.AqlQueryConstants; +import org.highmed.numportal.service.UserDetailsService; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachePut; import org.springframework.scheduling.annotation.Scheduled; @@ -46,10 +48,6 @@ @RequiredArgsConstructor public class ParameterService { - private static final String SELECT = "Select"; - - private static final String SELECT_DISTINCT = "Select distinct"; - private static final String VALUE_DEFINING_CODE = "/value/defining_code/code_string"; private static final String VALUE_VALUE = "/value/value"; @@ -71,9 +69,9 @@ public class ParameterService { private final UserDetailsService userDetailsService; private static ObjectMapper buildAqlObjectMapper() { - var objectMapper = JacksonUtil.getObjectMapper(); + var objectMapper = ArchieObjectMapperProvider.getObjectMapper().copy(); var module = new SimpleModule("openEHR", new Version(1, 0, 0, null, null, null)); - module.addDeserializer(VersionUid.class, new VersionUidDeSerializer()); + module.addDeserializer(ObjectVersionId.class, new VersionUidDeSerializer()); module.addDeserializer(TemporalAccessor.class, new TemporalAccessorDeSerializer()); objectMapper.registerModule(module); return objectMapper; @@ -82,7 +80,6 @@ private static ObjectMapper buildAqlObjectMapper() { @CachePut(value = PARAMETERS_CACHE, key = "#aqlPath") public ParameterOptionsDto getParameterValues(String userId, String aqlPath, String archetypeId) { userDetailsService.checkIsUserApproved(userId); - if (aqlPath.endsWith(VALUE_VALUE)) { return getParameters(aqlPath, archetypeId, VALUE_VALUE); } else if (aqlPath.endsWith(VALUE_MAGNITUDE)) { @@ -110,9 +107,14 @@ public void evictParametersCache() { } private ParameterOptionsDto getParameters(String aqlPath, String archetypeId, String postfix) { - var query = - createQueryString(aqlPath.substring(0, aqlPath.length() - postfix.length()), archetypeId); - + String query; + if(aqlPath.startsWith("/")) { + query = + createQueryString(aqlPath.substring(1, aqlPath.length() - postfix.length()), archetypeId); + } else { + query = + createQueryString(aqlPath.substring(0, aqlPath.length() - postfix.length()), archetypeId); + } try { log.info( String.format( @@ -173,31 +175,45 @@ private ParameterOptionsDto getParameters(String aqlPath, String archetypeId, St /** Create the aql query for retrieving all distinct existing values of a certain aql path */ private String createQueryString(String aqlPath, String archetypeId) { - var aql = new AqlDto(); - - var selectFieldDto = new SelectFieldDto(); - selectFieldDto.setAqlPath(aqlPath); - selectFieldDto.setContainmentId(1); - - var select = new SelectDto(); - select.setStatement(List.of(selectFieldDto)); - - var contains = new ContainmentDto(); - contains.setArchetypeId(archetypeId); - contains.setId(1); - - var orderByExpressionDto = new OrderByExpressionDto(); - orderByExpressionDto.setStatement(selectFieldDto); - orderByExpressionDto.setSymbol(OrderByExpressionSymbol.ASC); - - List orderByList = new LinkedList<>(); + var aql = new AqlQuery(); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setIdentifier("c0"); + IdentifiedPath path = new IdentifiedPath(); + path.setPath(AqlObjectPath.parse(aqlPath)); + path.setRoot(containmentClassExpression); + + // generate select expression + SelectClause selectClause = new SelectClause(); + SelectExpression se = new SelectExpression(); + se.setColumnExpression(path); + se.setAlias("F1"); + selectClause.setStatement(List.of(se)); + selectClause.setDistinct(true); + + // generate from expression + ContainmentClassExpression from = new ContainmentClassExpression(); + from.setType(AqlQueryConstants.EHR_TYPE); + from.setIdentifier(AqlQueryConstants.EHR_CONTAINMENT_IDENTIFIER); + + // generate contains expression + ContainmentClassExpression contains = new ContainmentClassExpression(); + contains.setType(StringUtils.substringBetween(archetypeId, "openEHR-EHR-", ".")); + contains.setIdentifier("c0"+"[" + archetypeId + "]"); + + from.setContains(contains); + + var orderByExpressionDto = new OrderByExpression(); + orderByExpressionDto.setStatement(path); + orderByExpressionDto.setSymbol(OrderByExpression.OrderByDirection.ASC); + + List orderByList = new LinkedList<>(); orderByList.add(orderByExpressionDto); - aql.setSelect(select); - aql.setContains(contains); + aql.setSelect(selectClause); + aql.setFrom(from); aql.setOrderBy(orderByList); - String query = new AqlBinder().bind(aql).getLeft().buildAql(); - return insertSelect(query); + return AqlRenderer.render(aql); } private void convertDvCodedText(DvCodedText data, ParameterOptionsDto dto, String postfix) { @@ -240,8 +256,4 @@ private void convertDvDateTime(ParameterOptionsDto dto) { private void convertTime(ParameterOptionsDto dto) { dto.setType("DV_TIME"); } - private String insertSelect(String query) { - var result = StringUtils.substringAfter(query, SELECT); - return new StringBuilder(result).insert(0, SELECT_DISTINCT).toString(); - } } diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/Pseudonymity.java b/src/main/java/org/highmed/numportal/service/ehrbase/Pseudonymity.java similarity index 96% rename from src/main/java/de/vitagroup/num/service/ehrbase/Pseudonymity.java rename to src/main/java/org/highmed/numportal/service/ehrbase/Pseudonymity.java index e26329a79..3d6f355a2 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/Pseudonymity.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/Pseudonymity.java @@ -1,10 +1,9 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; import ca.uhn.fhir.context.FhirContext; -import de.vitagroup.num.properties.FttpProperties; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.properties.PseudonymsPsnWorkflowProperties; -import de.vitagroup.num.service.exception.ResourceNotFound; +import org.highmed.numportal.properties.FttpProperties; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.properties.PseudonymsPsnWorkflowProperties; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; @@ -18,6 +17,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; +import org.highmed.numportal.service.exception.ResourceNotFound; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Parameters; import org.springframework.beans.factory.annotation.Value; @@ -55,6 +55,9 @@ public class Pseudonymity { private boolean fake3rdPartyPseudonymEnabled; public List getPseudonyms(List secondLevelPseudonyms, Long projectId) { + if (!privacyProperties.isEnabled()) { + return secondLevelPseudonyms; + } List result = new LinkedList<>(); // I guess Greisfwald restricted the number of original params per request List> chunks = ListUtils.partition(secondLevelPseudonyms, privacyProperties.getPseudonomityChunksSize()); diff --git a/src/main/java/de/vitagroup/num/service/ehrbase/ResponseFilter.java b/src/main/java/org/highmed/numportal/service/ehrbase/ResponseFilter.java similarity index 73% rename from src/main/java/de/vitagroup/num/service/ehrbase/ResponseFilter.java rename to src/main/java/org/highmed/numportal/service/ehrbase/ResponseFilter.java index 9eda7a09c..4d616aa6d 100644 --- a/src/main/java/de/vitagroup/num/service/ehrbase/ResponseFilter.java +++ b/src/main/java/org/highmed/numportal/service/ehrbase/ResponseFilter.java @@ -1,18 +1,23 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.*; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import javax.annotation.PostConstruct; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + @Component @NoArgsConstructor @Slf4j @@ -23,10 +28,12 @@ public class ResponseFilter { @PostConstruct public void initialize() { try { - File pathResource = new ClassPathResource("resultfilters/pathfilters.txt").getFile(); - pathFilters = new HashSet<>(Files.readAllLines(pathResource.toPath())); - File regexpResource = new ClassPathResource("resultfilters/regexpfilters.txt").getFile(); - regexpFilters = Files.readAllLines(regexpResource.toPath()).stream().map(Pattern::compile).collect( + BufferedReader pathResource = new BufferedReader(new InputStreamReader( + new ClassPathResource("resultfilters/pathfilters.txt").getInputStream(), StandardCharsets.UTF_8)); + pathFilters = new HashSet<>(pathResource.lines().toList()); + BufferedReader regexpResource = new BufferedReader(new InputStreamReader( + new ClassPathResource("resultfilters/regexpfilters.txt").getInputStream(), StandardCharsets.UTF_8)); + regexpFilters = regexpResource.lines().map(Pattern::compile).collect( Collectors.toList()); } catch (IOException e) { log.error("Failed to read project data filters, can't filter results."); @@ -35,7 +42,7 @@ public void initialize() { public List filterResponse(List queryResponseDataList) { if(pathFilters == null){ - return new ArrayList<>(); + return queryResponseDataList; } List resultList = new ArrayList<>(); for (QueryResponseData queryResponseData : queryResponseDataList) { @@ -75,4 +82,4 @@ private boolean keepColumn(Map column) { } return regexpFilters.stream().filter(regexp -> regexp.matcher(path).matches()).findFirst().isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/de/vitagroup/num/service/email/EmailProperties.java b/src/main/java/org/highmed/numportal/service/email/EmailProperties.java similarity index 78% rename from src/main/java/de/vitagroup/num/service/email/EmailProperties.java rename to src/main/java/org/highmed/numportal/service/email/EmailProperties.java index 622758d71..92c0812b1 100644 --- a/src/main/java/de/vitagroup/num/service/email/EmailProperties.java +++ b/src/main/java/org/highmed/numportal/service/email/EmailProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.email; +package org.highmed.numportal.service.email; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -9,5 +9,6 @@ @ConfigurationProperties(prefix = "spring.mail") public class EmailProperties { + private boolean enabled = true; private String from; } diff --git a/src/main/java/de/vitagroup/num/service/email/EmailService.java b/src/main/java/org/highmed/numportal/service/email/EmailService.java similarity index 88% rename from src/main/java/de/vitagroup/num/service/email/EmailService.java rename to src/main/java/org/highmed/numportal/service/email/EmailService.java index 7cd4236fa..65e16d800 100644 --- a/src/main/java/de/vitagroup/num/service/email/EmailService.java +++ b/src/main/java/org/highmed/numportal/service/email/EmailService.java @@ -1,8 +1,7 @@ -package de.vitagroup.num.service.email; +package org.highmed.numportal.service.email; -import java.nio.charset.StandardCharsets; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.MimeMessage; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.core.io.ByteArrayResource; @@ -10,6 +9,8 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; +import java.nio.charset.StandardCharsets; + @Slf4j @Service @AllArgsConstructor @@ -19,6 +20,9 @@ public class EmailService { private final EmailProperties emailProperties; public void sendEmail(String subject, String htmlBody, String to) { + if (!emailProperties.isEnabled()) { + return; + } MimeMessage message = javaMailSender.createMimeMessage(); @@ -44,6 +48,9 @@ public void sendEmailWithAttachment( String attachment, String filename, String contentType) { + if (!emailProperties.isEnabled()) { + return; + } MimeMessage message = javaMailSender.createMimeMessage(); diff --git a/src/main/java/de/vitagroup/num/service/email/MessageSourceWrapper.java b/src/main/java/org/highmed/numportal/service/email/MessageSourceWrapper.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/email/MessageSourceWrapper.java rename to src/main/java/org/highmed/numportal/service/email/MessageSourceWrapper.java index 28f48381f..86cd9a7d4 100644 --- a/src/main/java/de/vitagroup/num/service/email/MessageSourceWrapper.java +++ b/src/main/java/org/highmed/numportal/service/email/MessageSourceWrapper.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.email; +package org.highmed.numportal.service.email; import lombok.AllArgsConstructor; import org.springframework.context.MessageSource; diff --git a/src/main/java/de/vitagroup/num/service/email/ZarsProperties.java b/src/main/java/org/highmed/numportal/service/email/ZarsProperties.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/email/ZarsProperties.java rename to src/main/java/org/highmed/numportal/service/email/ZarsProperties.java index 2dc31716a..10fcfdbd8 100644 --- a/src/main/java/de/vitagroup/num/service/email/ZarsProperties.java +++ b/src/main/java/org/highmed/numportal/service/email/ZarsProperties.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.email; +package org.highmed.numportal.service.email; import lombok.Data; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; diff --git a/src/main/java/de/vitagroup/num/service/email/ZarsService.java b/src/main/java/org/highmed/numportal/service/email/ZarsService.java similarity index 93% rename from src/main/java/de/vitagroup/num/service/email/ZarsService.java rename to src/main/java/org/highmed/numportal/service/email/ZarsService.java index 5b217c46f..b21fdb2dd 100644 --- a/src/main/java/de/vitagroup/num/service/email/ZarsService.java +++ b/src/main/java/org/highmed/numportal/service/email/ZarsService.java @@ -1,27 +1,27 @@ -package de.vitagroup.num.service.email; +package org.highmed.numportal.service.email; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.dto.ZarsInfoDto; -import java.io.IOException; -import java.io.StringWriter; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.domain.dto.ZarsInfoDto; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.context.MessageSource; import org.springframework.core.io.ClassPathResource; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; + @Service @Slf4j @AllArgsConstructor @@ -39,8 +39,7 @@ public class ZarsService { @PostConstruct public void initialize() { try { - var resource = new ClassPathResource("ZARSHeaders.json").getFile(); - var json = new String(Files.readAllBytes(resource.toPath())); + var json = new String(new ClassPathResource("ZARSHeaders.json").getInputStream().readAllBytes()); zarsHeaders = objectMapper.readValue(json, String[].class); } catch (IOException e) { log.error("Failed to read ZARS headers file, can't send updates to ZARS!"); diff --git a/src/main/java/de/vitagroup/num/service/exception/BadCredentialsException.java b/src/main/java/org/highmed/numportal/service/exception/BadCredentialsException.java similarity index 82% rename from src/main/java/de/vitagroup/num/service/exception/BadCredentialsException.java rename to src/main/java/org/highmed/numportal/service/exception/BadCredentialsException.java index be326b190..b882829e3 100644 --- a/src/main/java/de/vitagroup/num/service/exception/BadCredentialsException.java +++ b/src/main/java/org/highmed/numportal/service/exception/BadCredentialsException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/BadRequestException.java b/src/main/java/org/highmed/numportal/service/exception/BadRequestException.java similarity index 92% rename from src/main/java/de/vitagroup/num/service/exception/BadRequestException.java rename to src/main/java/org/highmed/numportal/service/exception/BadRequestException.java index 553f8501c..32fe15da3 100644 --- a/src/main/java/de/vitagroup/num/service/exception/BadRequestException.java +++ b/src/main/java/org/highmed/numportal/service/exception/BadRequestException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/CustomException.java b/src/main/java/org/highmed/numportal/service/exception/CustomException.java similarity index 78% rename from src/main/java/de/vitagroup/num/service/exception/CustomException.java rename to src/main/java/org/highmed/numportal/service/exception/CustomException.java index 2f5c09dbc..9825ea377 100644 --- a/src/main/java/de/vitagroup/num/service/exception/CustomException.java +++ b/src/main/java/org/highmed/numportal/service/exception/CustomException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/CustomizedExceptionHandler.java b/src/main/java/org/highmed/numportal/service/exception/CustomizedExceptionHandler.java similarity index 82% rename from src/main/java/de/vitagroup/num/service/exception/CustomizedExceptionHandler.java rename to src/main/java/org/highmed/numportal/service/exception/CustomizedExceptionHandler.java index d2eaa4056..107d0c4b8 100644 --- a/src/main/java/de/vitagroup/num/service/exception/CustomizedExceptionHandler.java +++ b/src/main/java/org/highmed/numportal/service/exception/CustomizedExceptionHandler.java @@ -1,21 +1,24 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; -import de.vitagroup.num.service.exception.dto.ErrorDetails; import lombok.extern.slf4j.Slf4j; -import org.ehrbase.client.exception.WrongStatusCodeException; +import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; +import org.highmed.numportal.service.exception.dto.ErrorDetails; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.security.access.AccessDeniedException; -import org.springframework.validation.BindException; +import org.springframework.validation.method.ParameterErrors; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; +import org.springframework.web.method.annotation.HandlerMethodValidationException; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import java.util.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static java.util.Objects.nonNull; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @Slf4j public class CustomizedExceptionHandler extends ResponseEntityExceptionHandler { @@ -164,9 +167,25 @@ public ResponseEntity handleBadRequestErrors( return ResponseEntity.status( HttpStatus.BAD_REQUEST ).body( errorDetails ); } - @ExceptionHandler({ForbiddenException.class, AccessDeniedException.class}) - public ResponseEntity handleForbiddenErrors( - ForbiddenException exception) { + @ExceptionHandler(AccessDeniedException.class) + public ResponseEntity handleAccessDeniedException(AccessDeniedException exception) { + + var description = exception.getMessage(); + var errors = Map.of( "Error Message", + nonNull(exception.getMessage()) ? exception.getMessage() : description); + ErrorDetails errorDetails = ErrorDetails + .builder() + .messageId(-1) + .argumentsList(new ArrayList<>()) + .message(exception.getMessage()) + .details(errors) + .build(); + log.debug(exception.getMessage(), exception); + return new ResponseEntity<>(errorDetails, new HttpHeaders(), HttpStatus.FORBIDDEN); + } + + @ExceptionHandler(ForbiddenException.class) + public ResponseEntity handleForbiddenErrors(ForbiddenException exception) { var className = nonNull(exception.getEntity()) ? exception.getEntity().getSimpleName() : null; var description = exception.getMessage(); @@ -284,11 +303,9 @@ public ResponseEntity handleWrongStatus(WrongStatusCodeException e return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorDetails); } @Override - protected ResponseEntity handleBindException(BindException exception, HttpHeaders headers, - HttpStatus status, WebRequest request) { - + protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { Map errors = new HashMap<>(); - exception.getFieldErrors() + ex.getFieldErrors() .forEach( error -> errors.put( error.getField(), error.getDefaultMessage() ) ); ErrorDetails errorDetails = ErrorDetails @@ -298,4 +315,27 @@ protected ResponseEntity handleBindException(BindException exception, Ht .build(); return ResponseEntity.status( HttpStatus.BAD_REQUEST ).body( errorDetails ); } + + @Override + protected ResponseEntity handleHandlerMethodValidationException(HandlerMethodValidationException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { + Map errors = new HashMap<>(); + for (final var validation : ex.getAllValidationResults()) { + if (validation instanceof ParameterErrors) { + ParameterErrors parameterErrors = (ParameterErrors) validation; + parameterErrors.getFieldErrors().forEach(fieldError -> errors.put(fieldError.getField(), fieldError.getDefaultMessage())); + } else { + final String parameterName = validation.getMethodParameter().getParameterName(); + validation + .getResolvableErrors() + .forEach( + error -> errors.put(parameterName, error.getDefaultMessage())); + } + } + ErrorDetails errorDetails = ErrorDetails + .builder() + .message("Validation failed") + .details(errors) + .build(); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorDetails); + } } diff --git a/src/main/java/de/vitagroup/num/service/exception/EntityNotFoundException.java b/src/main/java/org/highmed/numportal/service/exception/EntityNotFoundException.java similarity index 81% rename from src/main/java/de/vitagroup/num/service/exception/EntityNotFoundException.java rename to src/main/java/org/highmed/numportal/service/exception/EntityNotFoundException.java index 9cea4e1ac..bf7fb75d4 100644 --- a/src/main/java/de/vitagroup/num/service/exception/EntityNotFoundException.java +++ b/src/main/java/org/highmed/numportal/service/exception/EntityNotFoundException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/dto/ExceptionDto.java b/src/main/java/org/highmed/numportal/service/exception/ExceptionDto.java similarity index 78% rename from src/main/java/de/vitagroup/num/service/exception/dto/ExceptionDto.java rename to src/main/java/org/highmed/numportal/service/exception/ExceptionDto.java index 29c56ab6b..7ecd7ed4c 100644 --- a/src/main/java/de/vitagroup/num/service/exception/dto/ExceptionDto.java +++ b/src/main/java/org/highmed/numportal/service/exception/ExceptionDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.dto; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/ForbiddenException.java b/src/main/java/org/highmed/numportal/service/exception/ForbiddenException.java similarity index 93% rename from src/main/java/de/vitagroup/num/service/exception/ForbiddenException.java rename to src/main/java/org/highmed/numportal/service/exception/ForbiddenException.java index 9cadb770c..e2ab583b1 100644 --- a/src/main/java/de/vitagroup/num/service/exception/ForbiddenException.java +++ b/src/main/java/org/highmed/numportal/service/exception/ForbiddenException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/IllegalArgumentException.java b/src/main/java/org/highmed/numportal/service/exception/IllegalArgumentException.java similarity index 89% rename from src/main/java/de/vitagroup/num/service/exception/IllegalArgumentException.java rename to src/main/java/org/highmed/numportal/service/exception/IllegalArgumentException.java index ee853ebb3..baeb43ad3 100644 --- a/src/main/java/de/vitagroup/num/service/exception/IllegalArgumentException.java +++ b/src/main/java/org/highmed/numportal/service/exception/IllegalArgumentException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/PrivacyException.java b/src/main/java/org/highmed/numportal/service/exception/PrivacyException.java similarity index 88% rename from src/main/java/de/vitagroup/num/service/exception/PrivacyException.java rename to src/main/java/org/highmed/numportal/service/exception/PrivacyException.java index 870aa1c82..7179d5ca6 100644 --- a/src/main/java/de/vitagroup/num/service/exception/PrivacyException.java +++ b/src/main/java/org/highmed/numportal/service/exception/PrivacyException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/ResourceNotFound.java b/src/main/java/org/highmed/numportal/service/exception/ResourceNotFound.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/exception/ResourceNotFound.java rename to src/main/java/org/highmed/numportal/service/exception/ResourceNotFound.java index 3de032ae1..57904bde2 100644 --- a/src/main/java/de/vitagroup/num/service/exception/ResourceNotFound.java +++ b/src/main/java/org/highmed/numportal/service/exception/ResourceNotFound.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/SameEntityExistsException.java b/src/main/java/org/highmed/numportal/service/exception/SameEntityExistsException.java similarity index 81% rename from src/main/java/de/vitagroup/num/service/exception/SameEntityExistsException.java rename to src/main/java/org/highmed/numportal/service/exception/SameEntityExistsException.java index 9407820d6..04bbbd5e0 100644 --- a/src/main/java/de/vitagroup/num/service/exception/SameEntityExistsException.java +++ b/src/main/java/org/highmed/numportal/service/exception/SameEntityExistsException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/SystemException.java b/src/main/java/org/highmed/numportal/service/exception/SystemException.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/exception/SystemException.java rename to src/main/java/org/highmed/numportal/service/exception/SystemException.java index 7943d82a0..3118375ab 100644 --- a/src/main/java/de/vitagroup/num/service/exception/SystemException.java +++ b/src/main/java/org/highmed/numportal/service/exception/SystemException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/TokenIsNotValidException.java b/src/main/java/org/highmed/numportal/service/exception/TokenIsNotValidException.java similarity index 81% rename from src/main/java/de/vitagroup/num/service/exception/TokenIsNotValidException.java rename to src/main/java/org/highmed/numportal/service/exception/TokenIsNotValidException.java index b56ac65c1..ee226a3cd 100644 --- a/src/main/java/de/vitagroup/num/service/exception/TokenIsNotValidException.java +++ b/src/main/java/org/highmed/numportal/service/exception/TokenIsNotValidException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/UserUnauthorizedException.java b/src/main/java/org/highmed/numportal/service/exception/UserUnauthorizedException.java similarity index 87% rename from src/main/java/de/vitagroup/num/service/exception/UserUnauthorizedException.java rename to src/main/java/org/highmed/numportal/service/exception/UserUnauthorizedException.java index c4b6a12bc..340159a5d 100644 --- a/src/main/java/de/vitagroup/num/service/exception/UserUnauthorizedException.java +++ b/src/main/java/org/highmed/numportal/service/exception/UserUnauthorizedException.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; -import de.vitagroup.num.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.model.admin.UserDetails; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.extern.log4j.Log4j2; diff --git a/src/main/java/de/vitagroup/num/service/exception/UsernameNotFoundOrNoLongerActiveException.java b/src/main/java/org/highmed/numportal/service/exception/UsernameNotFoundOrNoLongerActiveException.java similarity index 83% rename from src/main/java/de/vitagroup/num/service/exception/UsernameNotFoundOrNoLongerActiveException.java rename to src/main/java/org/highmed/numportal/service/exception/UsernameNotFoundOrNoLongerActiveException.java index 86faf9805..d0ff27cac 100644 --- a/src/main/java/de/vitagroup/num/service/exception/UsernameNotFoundOrNoLongerActiveException.java +++ b/src/main/java/org/highmed/numportal/service/exception/UsernameNotFoundOrNoLongerActiveException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/dto/ErrorDetails.java b/src/main/java/org/highmed/numportal/service/exception/dto/ErrorDetails.java similarity index 92% rename from src/main/java/de/vitagroup/num/service/exception/dto/ErrorDetails.java rename to src/main/java/org/highmed/numportal/service/exception/dto/ErrorDetails.java index 74db06789..1e5b8009f 100644 --- a/src/main/java/de/vitagroup/num/service/exception/dto/ErrorDetails.java +++ b/src/main/java/org/highmed/numportal/service/exception/dto/ErrorDetails.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.dto; +package org.highmed.numportal.service.exception.dto; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/de/vitagroup/num/service/exception/ExceptionDto.java b/src/main/java/org/highmed/numportal/service/exception/dto/ExceptionDto.java similarity index 77% rename from src/main/java/de/vitagroup/num/service/exception/ExceptionDto.java rename to src/main/java/org/highmed/numportal/service/exception/dto/ExceptionDto.java index 5f0be7a2d..5521b1363 100644 --- a/src/main/java/de/vitagroup/num/service/exception/ExceptionDto.java +++ b/src/main/java/org/highmed/numportal/service/exception/dto/ExceptionDto.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception; +package org.highmed.numportal.service.exception.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/BadCredentialsException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/BadCredentialsException.java similarity index 77% rename from src/main/java/de/vitagroup/num/service/exception/implementation/BadCredentialsException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/BadCredentialsException.java index 7a847c2d3..b01e54a15 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/BadCredentialsException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/BadCredentialsException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/CustomException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/CustomException.java similarity index 73% rename from src/main/java/de/vitagroup/num/service/exception/implementation/CustomException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/CustomException.java index 59bb310be..b5f731aac 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/CustomException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/CustomException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/EntityNotFoundException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/EntityNotFoundException.java similarity index 77% rename from src/main/java/de/vitagroup/num/service/exception/implementation/EntityNotFoundException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/EntityNotFoundException.java index 826921505..d2f066e16 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/EntityNotFoundException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/EntityNotFoundException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/SameEntityExistsException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/SameEntityExistsException.java similarity index 77% rename from src/main/java/de/vitagroup/num/service/exception/implementation/SameEntityExistsException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/SameEntityExistsException.java index 45f8c4e77..028ed9089 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/SameEntityExistsException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/SameEntityExistsException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/TokenIsNotValidException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/TokenIsNotValidException.java similarity index 77% rename from src/main/java/de/vitagroup/num/service/exception/implementation/TokenIsNotValidException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/TokenIsNotValidException.java index 66ea593cd..9377293d8 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/TokenIsNotValidException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/TokenIsNotValidException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java b/src/main/java/org/highmed/numportal/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java similarity index 79% rename from src/main/java/de/vitagroup/num/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java rename to src/main/java/org/highmed/numportal/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java index e01ada6b8..f08ed2635 100644 --- a/src/main/java/de/vitagroup/num/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java +++ b/src/main/java/org/highmed/numportal/service/exception/implementation/UsernameNotFoundOrNoLongerActiveException.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.exception.implementation; +package org.highmed.numportal.service.exception.implementation; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/de/vitagroup/num/service/executors/AqlExecutor.java b/src/main/java/org/highmed/numportal/service/executors/AqlExecutor.java similarity index 75% rename from src/main/java/de/vitagroup/num/service/executors/AqlExecutor.java rename to src/main/java/org/highmed/numportal/service/executors/AqlExecutor.java index d35af5759..1d325c839 100644 --- a/src/main/java/de/vitagroup/num/service/executors/AqlExecutor.java +++ b/src/main/java/org/highmed/numportal/service/executors/AqlExecutor.java @@ -1,28 +1,25 @@ -package de.vitagroup.num.service.executors; - -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.properties.ConsentProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.policy.EuropeanConsentPolicy; -import de.vitagroup.num.service.policy.ProjectPolicyService; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +package org.highmed.numportal.service.executors; + +import org.highmed.numportal.domain.model.CohortAql; +import org.highmed.numportal.properties.ConsentProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.SetUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.aql.util.AqlUtil; -import org.ehrbase.client.aql.parameter.ParameterValue; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.ehrbase.openehr.sdk.aql.util.AqlUtil; +import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.policy.EuropeanConsentPolicy; +import org.highmed.numportal.service.policy.ProjectPolicyService; import org.springframework.stereotype.Service; +import java.util.*; + @Slf4j @Service @AllArgsConstructor @@ -52,7 +49,7 @@ public Set execute( } private void applyPolicy(CohortAql cohortAql) { - AqlDto aql = new AqlToDtoParser().parse(cohortAql.getQuery()); + AqlQuery aql = AqlQueryParser.parse(cohortAql.getQuery()); projectPolicyService.apply( aql, List.of( @@ -60,7 +57,7 @@ private void applyPolicy(CohortAql cohortAql) { .oid(consentProperties.getAllowUsageOutsideEuOid()) .build())); - cohortAql.setQuery(new AqlBinder().bind(aql).getLeft().buildAql()); + cohortAql.setQuery(AqlRenderer.render(aql)); } private String addParameters(Map parameters, String query) { diff --git a/src/main/java/de/vitagroup/num/service/executors/CohortExecutor.java b/src/main/java/org/highmed/numportal/service/executors/CohortExecutor.java similarity index 76% rename from src/main/java/de/vitagroup/num/service/executors/CohortExecutor.java rename to src/main/java/org/highmed/numportal/service/executors/CohortExecutor.java index 1362ae4eb..462e0fd7d 100644 --- a/src/main/java/de/vitagroup/num/service/executors/CohortExecutor.java +++ b/src/main/java/org/highmed/numportal/service/executors/CohortExecutor.java @@ -1,19 +1,20 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.IllegalArgumentException; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.Type; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.SetUtils; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.IllegalArgumentException; import org.springframework.stereotype.Service; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_EXECUTE_AN_EMPTY_COHORT; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_EXECUTE_AN_EMPTY_COHORT; @Slf4j @Service diff --git a/src/main/java/de/vitagroup/num/service/executors/CohortQueryLister.java b/src/main/java/org/highmed/numportal/service/executors/CohortQueryLister.java similarity index 80% rename from src/main/java/de/vitagroup/num/service/executors/CohortQueryLister.java rename to src/main/java/org/highmed/numportal/service/executors/CohortQueryLister.java index fc9b6942e..4687e18c7 100644 --- a/src/main/java/de/vitagroup/num/service/executors/CohortQueryLister.java +++ b/src/main/java/org/highmed/numportal/service/executors/CohortQueryLister.java @@ -1,18 +1,19 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Type; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.validation.constraints.NotNull; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortAql; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.Type; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @Service @Slf4j @AllArgsConstructor diff --git a/src/main/java/de/vitagroup/num/service/executors/SetOperationsService.java b/src/main/java/org/highmed/numportal/service/executors/SetOperationsService.java similarity index 82% rename from src/main/java/de/vitagroup/num/service/executors/SetOperationsService.java rename to src/main/java/org/highmed/numportal/service/executors/SetOperationsService.java index 636b495f4..db11a9d69 100644 --- a/src/main/java/de/vitagroup/num/service/executors/SetOperationsService.java +++ b/src/main/java/org/highmed/numportal/service/executors/SetOperationsService.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.service.exception.IllegalArgumentException; +import org.highmed.numportal.domain.model.Operator; import org.apache.commons.collections4.CollectionUtils; +import org.highmed.numportal.service.exception.IllegalArgumentException; import org.springframework.stereotype.Service; import java.util.HashSet; @@ -10,7 +10,7 @@ import java.util.Objects; import java.util.Set; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.RELATIVE_COMPLEMENT_REQUIRES_TWO_VALID_SETS; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.RELATIVE_COMPLEMENT_REQUIRES_TWO_VALID_SETS; @Service public class SetOperationsService { diff --git a/src/main/java/de/vitagroup/num/service/logger/AuditLog.java b/src/main/java/org/highmed/numportal/service/logger/AuditLog.java similarity index 86% rename from src/main/java/de/vitagroup/num/service/logger/AuditLog.java rename to src/main/java/org/highmed/numportal/service/logger/AuditLog.java index c9fbdf4bc..b4e3ffae6 100644 --- a/src/main/java/de/vitagroup/num/service/logger/AuditLog.java +++ b/src/main/java/org/highmed/numportal/service/logger/AuditLog.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.logger; +package org.highmed.numportal.service.logger; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/de/vitagroup/num/service/logger/NumLogger.java b/src/main/java/org/highmed/numportal/service/logger/NumLogger.java similarity index 95% rename from src/main/java/de/vitagroup/num/service/logger/NumLogger.java rename to src/main/java/org/highmed/numportal/service/logger/NumLogger.java index 98ae2b0bc..d5621333f 100644 --- a/src/main/java/de/vitagroup/num/service/logger/NumLogger.java +++ b/src/main/java/org/highmed/numportal/service/logger/NumLogger.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.logger; +package org.highmed.numportal.service.logger; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -135,12 +135,12 @@ private RequestMethod getRequestMethod(JoinPoint point) { for (Annotation annotation : method.getDeclaredAnnotations()) { if (annotation .annotationType() - .isAnnotationPresent(org.springframework.web.bind.annotation.RequestMapping.class)) { + .isAnnotationPresent(RequestMapping.class)) { RequestMapping[] mappings = annotation .annotationType() - .getAnnotationsByType(org.springframework.web.bind.annotation.RequestMapping.class); + .getAnnotationsByType(RequestMapping.class); if (mappings.length > 0) { RequestMethod[] methods = mappings[0].method(); diff --git a/src/main/java/de/vitagroup/num/service/notification/NotificationService.java b/src/main/java/org/highmed/numportal/service/notification/NotificationService.java similarity index 79% rename from src/main/java/de/vitagroup/num/service/notification/NotificationService.java rename to src/main/java/org/highmed/numportal/service/notification/NotificationService.java index a65c49e4f..964f0429b 100644 --- a/src/main/java/de/vitagroup/num/service/notification/NotificationService.java +++ b/src/main/java/org/highmed/numportal/service/notification/NotificationService.java @@ -1,16 +1,17 @@ -package de.vitagroup.num.service.notification; +package org.highmed.numportal.service.notification; -import de.vitagroup.num.properties.NumProperties; -import de.vitagroup.num.service.email.EmailService; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; -import java.util.List; +import org.highmed.numportal.properties.NumProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.email.EmailService; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import java.util.List; + @Slf4j @Service @AllArgsConstructor diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/NewUserNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/NewUserNotification.java similarity index 95% rename from src/main/java/de/vitagroup/num/service/notification/dto/NewUserNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/NewUserNotification.java index 092f2ac8c..7a6ef52b9 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/NewUserNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/NewUserNotification.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; import java.time.Year; import java.util.Iterator; diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/NewUserWithoutOrganizationNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/NewUserWithoutOrganizationNotification.java similarity index 92% rename from src/main/java/de/vitagroup/num/service/notification/dto/NewUserWithoutOrganizationNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/NewUserWithoutOrganizationNotification.java index 38ab5b227..e90285582 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/NewUserWithoutOrganizationNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/NewUserWithoutOrganizationNotification.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.time.Year; public class NewUserWithoutOrganizationNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/Notification.java b/src/main/java/org/highmed/numportal/service/notification/dto/Notification.java similarity index 94% rename from src/main/java/de/vitagroup/num/service/notification/dto/Notification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/Notification.java index cbccb9250..0e720a88d 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/Notification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/Notification.java @@ -1,10 +1,11 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.net.MalformedURLException; -import java.net.URL; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.net.MalformedURLException; +import java.net.URL; @Slf4j public abstract class Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectApprovalRequestNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectApprovalRequestNotification.java similarity index 93% rename from src/main/java/de/vitagroup/num/service/notification/dto/ProjectApprovalRequestNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/ProjectApprovalRequestNotification.java index 90edce5a9..949b43233 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectApprovalRequestNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectApprovalRequestNotification.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.time.Year; public class ProjectApprovalRequestNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectCloseNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectCloseNotification.java similarity index 92% rename from src/main/java/de/vitagroup/num/service/notification/dto/ProjectCloseNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/ProjectCloseNotification.java index bcbdc45b4..a8821f140 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectCloseNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectCloseNotification.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.time.Year; public class ProjectCloseNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStartNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStartNotification.java similarity index 93% rename from src/main/java/de/vitagroup/num/service/notification/dto/ProjectStartNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/ProjectStartNotification.java index ede9ca771..436655d4e 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStartNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStartNotification.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.time.Year; public class ProjectStartNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeNotification.java similarity index 92% rename from src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeNotification.java index e0c85c3f0..b9e4e3f34 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeNotification.java @@ -1,9 +1,10 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import java.time.Year; +import org.highmed.numportal.domain.model.ProjectStatus; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; + +import java.time.Year; public class ProjectStatusChangeNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeRequestNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeRequestNotification.java similarity index 89% rename from src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeRequestNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeRequestNotification.java index e04690fcb..fa5e4633f 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/ProjectStatusChangeRequestNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/ProjectStatusChangeRequestNotification.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.service.notification.dto; +package org.highmed.numportal.service.notification.dto; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.service.email.MessageSourceWrapper; +import org.highmed.numportal.domain.model.ProjectStatus; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; import java.time.Year; diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/account/AccountApprovalNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/account/AccountApprovalNotification.java similarity index 86% rename from src/main/java/de/vitagroup/num/service/notification/dto/account/AccountApprovalNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/account/AccountApprovalNotification.java index 3c042b008..3f87e9f6f 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/account/AccountApprovalNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/account/AccountApprovalNotification.java @@ -1,9 +1,10 @@ -package de.vitagroup.num.service.notification.dto.account; +package org.highmed.numportal.service.notification.dto.account; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; + +import java.time.Year; public class AccountApprovalNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/account/AccountStatusChangedNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/account/AccountStatusChangedNotification.java similarity index 91% rename from src/main/java/de/vitagroup/num/service/notification/dto/account/AccountStatusChangedNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/account/AccountStatusChangedNotification.java index bc70227bc..e23b9b10c 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/account/AccountStatusChangedNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/account/AccountStatusChangedNotification.java @@ -1,8 +1,8 @@ -package de.vitagroup.num.service.notification.dto.account; +package org.highmed.numportal.service.notification.dto.account; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; import java.time.Year; diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/account/OrganizationUpdateNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/account/OrganizationUpdateNotification.java similarity index 88% rename from src/main/java/de/vitagroup/num/service/notification/dto/account/OrganizationUpdateNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/account/OrganizationUpdateNotification.java index 23a8737d9..7300fc262 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/account/OrganizationUpdateNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/account/OrganizationUpdateNotification.java @@ -1,9 +1,10 @@ -package de.vitagroup.num.service.notification.dto.account; +package org.highmed.numportal.service.notification.dto.account; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; + +import java.time.Year; public class OrganizationUpdateNotification extends Notification { diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/account/RolesUpdateNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/account/RolesUpdateNotification.java similarity index 93% rename from src/main/java/de/vitagroup/num/service/notification/dto/account/RolesUpdateNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/account/RolesUpdateNotification.java index f42436424..d0b7038a2 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/account/RolesUpdateNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/account/RolesUpdateNotification.java @@ -1,11 +1,11 @@ -package de.vitagroup.num.service.notification.dto.account; +package org.highmed.numportal.service.notification.dto.account; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; +import org.highmed.numportal.domain.model.Roles; import lombok.Builder; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; import java.time.Year; import java.util.HashMap; diff --git a/src/main/java/de/vitagroup/num/service/notification/dto/account/UserNameUpdateNotification.java b/src/main/java/org/highmed/numportal/service/notification/dto/account/UserNameUpdateNotification.java similarity index 86% rename from src/main/java/de/vitagroup/num/service/notification/dto/account/UserNameUpdateNotification.java rename to src/main/java/org/highmed/numportal/service/notification/dto/account/UserNameUpdateNotification.java index 5c0622752..4752e1f1a 100644 --- a/src/main/java/de/vitagroup/num/service/notification/dto/account/UserNameUpdateNotification.java +++ b/src/main/java/org/highmed/numportal/service/notification/dto/account/UserNameUpdateNotification.java @@ -1,9 +1,10 @@ -package de.vitagroup.num.service.notification.dto.account; +package org.highmed.numportal.service.notification.dto.account; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.Notification; -import java.time.Year; import lombok.Builder; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.Notification; + +import java.time.Year; public class UserNameUpdateNotification extends Notification { diff --git a/src/main/java/org/highmed/numportal/service/policy/EhrPolicy.java b/src/main/java/org/highmed/numportal/service/policy/EhrPolicy.java new file mode 100644 index 000000000..e5f75540e --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/policy/EhrPolicy.java @@ -0,0 +1,59 @@ +package org.highmed.numportal.service.policy; + +import lombok.Builder; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression; +import org.ehrbase.openehr.sdk.aql.dto.operand.IdentifiedPath; +import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPath; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.util.AqlQueryConstants; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.COHORT_SIZE_CANNOT_BE_0; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.INVALID_AQL; + +/** Restricts the aql to a set of ehr ids defined by the project cohort */ +@Slf4j +public class EhrPolicy extends Policy { + + + private Set cohortEhrIds; + + @Builder + public EhrPolicy(Set cohortEhrIds) { + this.cohortEhrIds = cohortEhrIds; + } + + @Override + public boolean apply(AqlQuery aql) { + if (aql == null) { + throw new SystemException(EhrPolicy.class, INVALID_AQL); + } + + if (CollectionUtils.isEmpty(cohortEhrIds)) { + throw new SystemException(EhrPolicy.class, COHORT_SIZE_CANNOT_BE_0); + } + + IdentifiedPath select = new IdentifiedPath(); + select.setPath(AqlObjectPath.parse(AqlQueryConstants.EHR_ID_PATH)); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.EHR_TYPE); + containmentClassExpression.setIdentifier(AqlQueryConstants.EHR_CONTAINMENT_IDENTIFIER); + select.setRoot(containmentClassExpression); + + SelectExpression se = new SelectExpression(); + se.setColumnExpression(select); + + logAqlQuery(log, aql, "[AQL QUERY] Aql before executing EhrPolicy: %s "); + extendWhereClause(aql, List.of(se), toSimpleValueList(new ArrayList<>(cohortEhrIds))); + logAqlQuery(log, aql, "[AQL QUERY] Aql after executing EhrPolicy: %s "); + return true; + } +} diff --git a/src/main/java/org/highmed/numportal/service/policy/EuropeanConsentPolicy.java b/src/main/java/org/highmed/numportal/service/policy/EuropeanConsentPolicy.java new file mode 100644 index 000000000..0bf5b608c --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/policy/EuropeanConsentPolicy.java @@ -0,0 +1,48 @@ +package org.highmed.numportal.service.policy; + +import lombok.Builder; +import lombok.extern.slf4j.Slf4j; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.operand.Primitive; +import org.highmed.numportal.service.exception.SystemException; + +import java.util.List; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.INVALID_AQL; + +/** + * Restricts the aql to a particular oid which defines the user consent for project data being used + * outside the European Union + */ +@Slf4j +public class EuropeanConsentPolicy extends Policy { + + private static final String FEEDER_AUDIT_PATH = + "feeder_audit/feeder_system_audit/other_details[openEHR-EHR-ITEM_TREE.generic.v1]/items[at0001]/value/id"; + + private String oid; + + @Builder + public EuropeanConsentPolicy(String oid) { + this.oid = oid; + } + + @Override + public boolean apply(AqlQuery aql) { + if (oid == null) { + throw new SystemException(EuropeanConsentPolicy.class, CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED); + } + + if (aql == null) { + throw new SystemException(EuropeanConsentPolicy.class, INVALID_AQL); + } + + logAqlQuery(log, aql,"[AQL QUERY] Aql before executing EuropeanConsentPolicy: %s "); + List oidValues = toSimpleValueList(List.of(oid)); + restrictAqlWithCompositionAttribute(aql, FEEDER_AUDIT_PATH, oidValues); + + logAqlQuery(log, aql,"[AQL QUERY] Aql after executing EuropeanConsentPolicy: %s "); + return true; + } +} diff --git a/src/main/java/org/highmed/numportal/service/policy/Policy.java b/src/main/java/org/highmed/numportal/service/policy/Policy.java new file mode 100644 index 000000000..7d30d4c26 --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/policy/Policy.java @@ -0,0 +1,216 @@ +package org.highmed.numportal.service.policy; + +import org.apache.commons.collections.CollectionUtils; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.condition.LogicalOperatorCondition; +import org.ehrbase.openehr.sdk.aql.dto.condition.MatchesCondition; +import org.ehrbase.openehr.sdk.aql.dto.condition.WhereCondition; +import org.ehrbase.openehr.sdk.aql.dto.containment.Containment; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentSetOperator; +import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentSetOperatorSymbol; +import org.ehrbase.openehr.sdk.aql.dto.operand.IdentifiedPath; +import org.ehrbase.openehr.sdk.aql.dto.operand.MatchesOperand; +import org.ehrbase.openehr.sdk.aql.dto.operand.Primitive; +import org.ehrbase.openehr.sdk.aql.dto.operand.StringPrimitive; +import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPath; +import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.highmed.numportal.service.util.AqlQueryConstants; +import org.slf4j.Logger; + +import java.util.*; +import java.util.stream.Collectors; + +/** Defines a certain project policy to be applied to an aql query */ +public abstract class Policy { + + public abstract boolean apply(AqlQuery aql); + + protected void restrictAqlWithCompositionAttribute(AqlQuery aql, String attributePath, List attributeValues) { + + List whereClauseSelectFields = new LinkedList<>(); + + ContainmentClassExpression originalFrom = (ContainmentClassExpression) aql.getFrom(); + Containment contains = originalFrom.getContains(); + + int nextContainmentId = findNextContainmentId(contains); + + if (contains != null) { + List compositions = findCompositionsIdentifier(contains); + + if (CollectionUtils.isNotEmpty(compositions)) { + compositions.forEach( + id -> { + IdentifiedPath selectFieldDto = new IdentifiedPath(); + selectFieldDto.setPath(AqlObjectPath.parse(attributePath)); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.COMPOSITION_TYPE); + containmentClassExpression.setIdentifier(id); + selectFieldDto.setRoot(containmentClassExpression); + + SelectExpression se = new SelectExpression(); + se.setColumnExpression(selectFieldDto); + whereClauseSelectFields.add(se); + }); + + } else { + extendContainsClause(aql, whereClauseSelectFields, contains, nextContainmentId, attributePath); + } + } else { + createContainsClause(aql, whereClauseSelectFields, nextContainmentId, attributePath); + } + extendWhereClause(aql, whereClauseSelectFields, attributeValues); + } + + protected void createContainsClause(AqlQuery aql, List whereClauseSelectFields, int nextContainmentId, String attrPath) { + IdentifiedPath selectField = new IdentifiedPath(); + selectField.setPath(AqlObjectPath.parse(attrPath)); + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.COMPOSITION_TYPE); + containmentClassExpression.setIdentifier("c" + nextContainmentId); + selectField.setRoot(containmentClassExpression); + + SelectExpression se = new SelectExpression(); + se.setColumnExpression(selectField); + whereClauseSelectFields.add(se); + + ContainmentClassExpression from = (ContainmentClassExpression) aql.getFrom(); + from.setContains(containmentClassExpression); + } + + protected void extendWhereClause(AqlQuery aql, List selectExpressions, List values) { + List whereConditions = new ArrayList<>(); + + selectExpressions.forEach( + selectFieldDto -> { + MatchesCondition matches = new MatchesCondition(); + matches.setStatement((IdentifiedPath) selectFieldDto.getColumnExpression()); + List operands = values.stream() + .map(v -> new StringPrimitive(v.getValue().toString())) + .collect(Collectors.toList()); + matches.setValues(operands); + whereConditions.add(matches); + }); + + LogicalOperatorCondition newWhere = new LogicalOperatorCondition(); + newWhere.setValues(new ArrayList<>()); + newWhere.setSymbol(LogicalOperatorCondition.ConditionLogicalOperatorSymbol.AND); + + WhereCondition where = aql.getWhere(); + if (where != null) { + newWhere.getValues().add(where); + } + + if (CollectionUtils.isNotEmpty(whereConditions)) { + newWhere.getValues().addAll(whereConditions); + } + aql.setWhere(newWhere); + } + + protected void extendContainsClause(AqlQuery aql, List whereClauseSelectFields, Containment contains, int nextContainmentId, String attrPath) { + IdentifiedPath path = new IdentifiedPath(); + path.setPath(AqlObjectPath.parse(attrPath)); + + SelectExpression se = new SelectExpression(); + se.setColumnExpression(path); + whereClauseSelectFields.add(se); + + ContainmentSetOperator newContains = new ContainmentSetOperator(); + newContains.setValues(new ArrayList<>()); + + + ContainmentClassExpression containmentClassExpression = new ContainmentClassExpression(); + containmentClassExpression.setType(AqlQueryConstants.COMPOSITION_TYPE); + containmentClassExpression.setIdentifier("c" + nextContainmentId); + path.setRoot(containmentClassExpression); + + newContains.setSymbol(ContainmentSetOperatorSymbol.AND); + newContains.getValues().add(containmentClassExpression); + newContains.getValues().add(contains); + + ((ContainmentClassExpression) aql.getFrom()).setContains(newContains); + } + + protected List toSimpleValueList(Collection list) { + return list.stream() + .map(StringPrimitive::new) + .collect(Collectors.toList()); + } + + protected List findCompositionsIdentifier(Containment dto) { + if (dto == null) { + return null; + } + + List compositions = new LinkedList<>(); + + Queue queue = new ArrayDeque<>(); + queue.add(dto); + + while (!queue.isEmpty()) { + Containment current = queue.remove(); + + if (current instanceof ContainmentSetOperator containmentLogicalOperator) { + + queue.addAll(containmentLogicalOperator.getValues()); + + } else if (current instanceof ContainmentClassExpression containmentDto) { + + if (containmentDto.getType().toUpperCase().contains(AqlQueryConstants.COMPOSITION_TYPE)) { + compositions.add(containmentDto.getIdentifier()); + } + + if (containmentDto.getContains() != null) { + queue.add(containmentDto.getContains()); + } + } + } + return compositions; + } + + protected Integer findNextContainmentId(Containment dto) { + + if (dto == null) { + return 1; + } + + Queue queue = new ArrayDeque<>(); + queue.add(dto); + + int nextId = 0; + + while (!queue.isEmpty()) { + Containment current = queue.remove(); + + if (current instanceof ContainmentSetOperator containmentLogicalOperator) { + queue.addAll(containmentLogicalOperator.getValues()); + } else if (current instanceof ContainmentClassExpression containmentDto) { + String identifier = containmentDto.getIdentifier(); + String[] identifierId = identifier.split("\\D"); + if (identifierId.length > 2) { + int currentId = Integer.getInteger(identifierId[1]); + if (currentId > nextId) { + nextId = currentId; + } + } + if (containmentDto.getContains() != null) { + queue.add(containmentDto.getContains()); + } + } + } + return nextId + 1; + } + + protected void logAqlQuery(Logger log, AqlQuery aql, String logMessage) { + try { + log.debug( + String.format(logMessage, + AqlRenderer.render(aql))); + } catch (Exception e) { + log.error("Cannot parse aql query while logging", e); + } + } +} diff --git a/src/main/java/de/vitagroup/num/service/policy/ProjectPolicyService.java b/src/main/java/org/highmed/numportal/service/policy/ProjectPolicyService.java similarity index 70% rename from src/main/java/de/vitagroup/num/service/policy/ProjectPolicyService.java rename to src/main/java/org/highmed/numportal/service/policy/ProjectPolicyService.java index 35f43ee78..f46c8bbc0 100644 --- a/src/main/java/de/vitagroup/num/service/policy/ProjectPolicyService.java +++ b/src/main/java/org/highmed/numportal/service/policy/ProjectPolicyService.java @@ -1,25 +1,25 @@ -package de.vitagroup.num.service.policy; - -import java.util.List; +package org.highmed.numportal.service.policy; import lombok.extern.slf4j.Slf4j; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; import org.springframework.stereotype.Service; +import java.util.List; + @Slf4j @Service public class ProjectPolicyService { private static final String ERROR_MESSAGE = "Cannot parse aql query while logging"; - public void apply(AqlDto aql, List policies) { + public void apply(AqlQuery aql, List policies) { try { log.info( String.format( "[AQL QUERY] Aql before executing project policies: %s ", - new AqlBinder().bind(aql).getLeft().buildAql())); + AqlRenderer.render(aql))); } catch (Exception e) { log.error(ERROR_MESSAGE, e); } @@ -30,7 +30,7 @@ public void apply(AqlDto aql, List policies) { log.info( String.format( "[AQL QUERY] Aql after executing project policies: %s ", - new AqlBinder().bind(aql).getLeft().buildAql())); + AqlRenderer.render(aql))); } catch (Exception e) { log.error(ERROR_MESSAGE, e); } diff --git a/src/main/java/org/highmed/numportal/service/policy/TemplatesPolicy.java b/src/main/java/org/highmed/numportal/service/policy/TemplatesPolicy.java new file mode 100644 index 000000000..f59c432be --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/policy/TemplatesPolicy.java @@ -0,0 +1,48 @@ +package org.highmed.numportal.service.policy; + +import lombok.Builder; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.MapUtils; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.operand.Primitive; +import org.highmed.numportal.service.exception.SystemException; + +import java.util.List; +import java.util.Map; + +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.INVALID_AQL; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.NO_TEMPLATES_ATTACHED_TO_THE_PROJECT; + +/** Restricts the aql to a set of templates defined by the project */ +@Slf4j +public class TemplatesPolicy extends Policy { + + private static final String TEMPLATE_ID_PATH = "archetype_details/template_id/value"; + + private Map templatesMap; + + @Builder + public TemplatesPolicy(Map templatesMap) { + this.templatesMap = templatesMap; + } + + @Override + public boolean apply(AqlQuery aql) { + if (MapUtils.isEmpty(templatesMap)) { + log.error(NO_TEMPLATES_ATTACHED_TO_THE_PROJECT); + return true; + } + + if (aql == null) { + throw new SystemException(TemplatesPolicy.class, INVALID_AQL); + } + + logAqlQuery(log, aql,"[AQL QUERY] Aql before executing TemplatesPolicy: %s "); + + List templateValues = toSimpleValueList(templatesMap.keySet()); + restrictAqlWithCompositionAttribute(aql, TEMPLATE_ID_PATH, templateValues); + + logAqlQuery(log, aql,"[AQL QUERY] Aql after executing TemplatesPolicy: %s "); + return true; + } +} diff --git a/src/main/java/org/highmed/numportal/service/util/AqlQueryConstants.java b/src/main/java/org/highmed/numportal/service/util/AqlQueryConstants.java new file mode 100644 index 000000000..a86e6cedf --- /dev/null +++ b/src/main/java/org/highmed/numportal/service/util/AqlQueryConstants.java @@ -0,0 +1,13 @@ +package org.highmed.numportal.service.util; + +public class AqlQueryConstants { + + public static final String EHR_CONTAINMENT_IDENTIFIER = "e"; + public static final String COMPOSITION_TYPE = "COMPOSITION"; + public static final String EHR_TYPE = "EHR"; + public static final String COMPOSITION_CONTAINMENT_IDENTIFIER = "c0"; + public static final String EHR_ID_PATH = "ehr_id/value"; + + private AqlQueryConstants() { + } +} diff --git a/src/main/java/de/vitagroup/num/web/config/ApplicationSecurity.java b/src/main/java/org/highmed/numportal/web/config/ApplicationSecurity.java similarity index 66% rename from src/main/java/de/vitagroup/num/web/config/ApplicationSecurity.java rename to src/main/java/org/highmed/numportal/web/config/ApplicationSecurity.java index 657640317..46607e453 100644 --- a/src/main/java/de/vitagroup/num/web/config/ApplicationSecurity.java +++ b/src/main/java/org/highmed/numportal/web/config/ApplicationSecurity.java @@ -1,12 +1,14 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; @@ -16,23 +18,19 @@ public class ApplicationSecurity { private static final String[] AUTH_WHITELIST = {"/swagger-*/**", "/v2/**", "/v3/**", "/admin/health", - "/admin/log-level", "/admin/log-level/*", "/admin/external-urls", "/admin/services-status"}; + "/admin/log-level", "/admin/log-level/*", "/admin/manuel-url", "/admin/services-status"}; @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { httpSecurity - .httpBasic().disable() - .formLogin().disable() - .authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .oauth2ResourceServer().jwt() - .jwtAuthenticationConverter(new AuthorizationConverter()) - .and() - .and() - .sessionManagement(sessionManagement -> - sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) - .cors(); + .httpBasic(AbstractHttpConfigurer::disable) + .formLogin(AbstractHttpConfigurer::disable); + httpSecurity + .authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated()) + .oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt -> + jwt.jwtAuthenticationConverter(new AuthorizationConverter()))) + .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .cors(Customizer.withDefaults()); return httpSecurity.build(); } @Bean @@ -45,7 +43,5 @@ public WebSecurityCustomizer webSecurityCustomizer() { .requestMatchers(HttpMethod.GET, "/content/metrics") .requestMatchers(HttpMethod.GET, "/actuator/health/**") .requestMatchers(HttpMethod.GET, "/actuator/info**"); - - } } diff --git a/src/main/java/de/vitagroup/num/web/config/AuthorizationConverter.java b/src/main/java/org/highmed/numportal/web/config/AuthorizationConverter.java similarity index 97% rename from src/main/java/de/vitagroup/num/web/config/AuthorizationConverter.java rename to src/main/java/org/highmed/numportal/web/config/AuthorizationConverter.java index 90449183b..26d4a14fe 100644 --- a/src/main/java/de/vitagroup/num/web/config/AuthorizationConverter.java +++ b/src/main/java/org/highmed/numportal/web/config/AuthorizationConverter.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; import java.util.Collection; import java.util.List; diff --git a/src/main/java/de/vitagroup/num/web/config/CorsConfig.java b/src/main/java/org/highmed/numportal/web/config/CorsConfig.java similarity index 92% rename from src/main/java/de/vitagroup/num/web/config/CorsConfig.java rename to src/main/java/org/highmed/numportal/web/config/CorsConfig.java index 5eb3a4596..8d2a3f6f8 100644 --- a/src/main/java/de/vitagroup/num/web/config/CorsConfig.java +++ b/src/main/java/org/highmed/numportal/web/config/CorsConfig.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; -import de.vitagroup.num.properties.CorsProperties; +import org.highmed.numportal.properties.CorsProperties; import java.util.Collections; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/de/vitagroup/num/web/config/FeignClientConfig.java b/src/main/java/org/highmed/numportal/web/config/FeignClientConfig.java similarity index 71% rename from src/main/java/de/vitagroup/num/web/config/FeignClientConfig.java rename to src/main/java/org/highmed/numportal/web/config/FeignClientConfig.java index 3d73a14f5..d2f530219 100644 --- a/src/main/java/de/vitagroup/num/web/config/FeignClientConfig.java +++ b/src/main/java/org/highmed/numportal/web/config/FeignClientConfig.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; -import de.vitagroup.num.web.feign.KeycloakFeign; +import org.highmed.numportal.web.feign.KeycloakFeign; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/de/vitagroup/num/web/config/Role.java b/src/main/java/org/highmed/numportal/web/config/Role.java similarity index 97% rename from src/main/java/de/vitagroup/num/web/config/Role.java rename to src/main/java/org/highmed/numportal/web/config/Role.java index 6f7535ba2..5c0cb1da9 100644 --- a/src/main/java/de/vitagroup/num/web/config/Role.java +++ b/src/main/java/org/highmed/numportal/web/config/Role.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; public class Role { public static final String SUPER_ADMIN = "hasRole('SUPER_ADMIN')"; diff --git a/src/main/java/de/vitagroup/num/web/config/SwaggerConfig.java b/src/main/java/org/highmed/numportal/web/config/SwaggerConfig.java similarity index 92% rename from src/main/java/de/vitagroup/num/web/config/SwaggerConfig.java rename to src/main/java/org/highmed/numportal/web/config/SwaggerConfig.java index 171fe8c17..1ab7f7933 100644 --- a/src/main/java/de/vitagroup/num/web/config/SwaggerConfig.java +++ b/src/main/java/org/highmed/numportal/web/config/SwaggerConfig.java @@ -1,6 +1,6 @@ -package de.vitagroup.num.web.config; +package org.highmed.numportal.web.config; -import de.vitagroup.num.properties.SwaggerProperties; +import org.highmed.numportal.properties.SwaggerProperties; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.security.OAuthFlow; @@ -8,7 +8,7 @@ import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import lombok.AllArgsConstructor; -import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.models.GroupedOpenApi; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,7 +17,7 @@ public class SwaggerConfig { private static final String SEC_CONFIG_NAME = "oauth_setting"; - private static final String NUM_PACKAGES_TO_SCAN = "de.vitagroup.num.web.controller"; + private static final String NUM_PACKAGES_TO_SCAN = "org.highmed.numportal.web.controller"; private final SwaggerProperties swaggerProperties; diff --git a/src/main/java/de/vitagroup/num/web/controller/AdminController.java b/src/main/java/org/highmed/numportal/web/controller/AdminController.java similarity index 76% rename from src/main/java/de/vitagroup/num/web/controller/AdminController.java rename to src/main/java/org/highmed/numportal/web/controller/AdminController.java index 4d5a3af13..3a884aab7 100644 --- a/src/main/java/de/vitagroup/num/web/controller/AdminController.java +++ b/src/main/java/org/highmed/numportal/web/controller/AdminController.java @@ -1,30 +1,26 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; -import de.vitagroup.num.NumPortalApplication; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.SetupType; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.UserNameDto; -import de.vitagroup.num.properties.NumProperties; -import de.vitagroup.num.service.SetupHealthiness; -import de.vitagroup.num.service.UserDetailsService; -import de.vitagroup.num.service.UserService; -import de.vitagroup.num.service.ehrbase.Pseudonymity; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; -import de.vitagroup.num.web.feign.KeycloakFeign; +import org.highmed.numportal.NumPortalApplication; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.UserNameDto; +import org.highmed.numportal.properties.NumProperties; +import org.highmed.numportal.service.UserDetailsService; +import org.highmed.numportal.service.UserService; +import org.highmed.numportal.service.ehrbase.Pseudonymity; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; +import org.highmed.numportal.web.config.Role; +import org.highmed.numportal.web.feign.KeycloakFeign; import org.slf4j.LoggerFactory; -import org.springframework.boot.actuate.health.HealthEndpoint; -import org.springframework.boot.actuate.health.Status; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; @@ -41,8 +37,8 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import java.io.*; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -58,61 +54,34 @@ public class AdminController extends CustomizedExceptionHandler { private static final String SUCCESS_REPLY = "Success"; private static final String EMAIL_CLAIM = "email"; - private static final String CHECK_FOR_ANNOUNCEMENTS = "CHECK_FOR_ANNOUNCEMENTS"; private final UserService userService; private final UserDetailsService userDetailsService; - private final HealthEndpoint healthEndpoint; private final Pseudonymity pseudonymity; private final NumProperties numProperties; - private final SetupHealthiness healthiness; - @GetMapping(value = "external-urls", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(description = "Returns value for health status endpoint URL and user manual URL") + @GetMapping(value = "manuel-url", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(description = "Returns value for user manual URL") public ResponseEntity> getExternalUrls(){ - java.util.Map map = new HashMap<>(); - map.put("systemStatusUrl", numProperties.getSystemStatusUrl()); + Map map = new HashMap<>(); map.put("userManualUrl", numProperties.getUserManualUrl()); return ResponseEntity.ok(map); } - @GetMapping(value = "services-status", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(description = "Returns value for healths of different microservices") - public ResponseEntity> getServicesStatus( - final @RequestParam(value = "setup", defaultValue = "PREPROD") SetupType setup){ - Map map = healthiness.checkHealth(setup); - if(map.values().stream().filter(s -> s.length() > 0).findFirst().isEmpty()) { - map.put(CHECK_FOR_ANNOUNCEMENTS, healthiness.checkForAnnouncements()); - return ResponseEntity.ok(map); - } else { - map.put(CHECK_FOR_ANNOUNCEMENTS, healthiness.checkForAnnouncements()); - return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(map); - } - } - - @GetMapping("health") - public ResponseEntity health() { - if (healthEndpoint.health().getStatus() == Status.UP) { - return ResponseEntity.ok(healthEndpoint.health().getStatus()); - } else { - return ResponseEntity.badRequest().body(healthEndpoint.health().getStatus()); - } - } - @GetMapping("/log-level") public ResponseEntity getLogLevel() { - Logger numLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(NumPortalApplication.class.getPackageName()); + Logger numLogger = (Logger) LoggerFactory.getLogger(NumPortalApplication.class.getPackageName()); return ResponseEntity.ok(numLogger.getLevel()); } @PostMapping("/log-level/{logLevel}") public ResponseEntity setLogLevel(@NotNull @PathVariable String logLevel) { - Logger numLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(NumPortalApplication.class.getPackageName()); + Logger numLogger = (Logger) LoggerFactory.getLogger(NumPortalApplication.class.getPackageName()); Level level = Level.valueOf(logLevel); numLogger.setLevel(level);//Default log level is DEBUG. If {logLevel} == Wrong Status if (Level.DEBUG.equals(level) || Level.INFO.equals(level)) { @@ -142,7 +111,7 @@ public ResponseEntity getUser( @GetMapping("user/{userId}/role") @Operation(description = "Retrieves the roles of the given user") @PreAuthorize(Role.SUPER_ADMIN_OR_ORGANIZATION_ADMIN) - public ResponseEntity> getRolesOfUser( + public ResponseEntity> getRolesOfUser( @AuthenticationPrincipal @NotNull Jwt principal, @NotNull @PathVariable String userId) { return ResponseEntity.ok(userService.getUserRoles(userId, principal.getSubject())); } diff --git a/src/main/java/de/vitagroup/num/web/controller/AqlController.java b/src/main/java/org/highmed/numportal/web/controller/AqlController.java similarity index 89% rename from src/main/java/de/vitagroup/num/web/controller/AqlController.java rename to src/main/java/org/highmed/numportal/web/controller/AqlController.java index 082e72af4..7ce5c252b 100644 --- a/src/main/java/de/vitagroup/num/web/controller/AqlController.java +++ b/src/main/java/org/highmed/numportal/web/controller/AqlController.java @@ -1,18 +1,18 @@ -package de.vitagroup.num.web.controller; - -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.model.AqlCategory; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.mapper.AqlMapper; -import de.vitagroup.num.service.AqlService; -import de.vitagroup.num.service.ehrbase.ParameterService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; +package org.highmed.numportal.web.controller; + +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.mapper.AqlMapper; +import org.highmed.numportal.service.AqlService; +import org.highmed.numportal.service.ehrbase.ParameterService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import lombok.AllArgsConstructor; +import org.highmed.numportal.web.config.Role; import org.modelmapper.ModelMapper; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -24,9 +24,9 @@ import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.stream.Collectors; @@ -46,7 +46,7 @@ public class AqlController extends CustomizedExceptionHandler { @Operation(description = "Retrieves public or owned aql query by id.") @PreAuthorize(Role.MANAGER_OR_STUDY_COORDINATOR_OR_RESEARCHER_OR_CRITERIA_EDITOR) public ResponseEntity getAqlById( - @AuthenticationPrincipal @NotNull Jwt principal, @NotNull @NotEmpty @PathVariable Long id) { + @AuthenticationPrincipal @NotNull Jwt principal, @NotNull @PathVariable Long id) { return ResponseEntity.ok( mapper.convertToDto(aqlService.getAqlById(id, principal.getSubject()))); } @@ -68,7 +68,7 @@ public ResponseEntity createAql( @PreAuthorize(Role.CRITERIA_EDITOR) public ResponseEntity updateAql( @AuthenticationPrincipal @NotNull Jwt principal, - @PathVariable("id") Long aqlId, + @NotNull @PathVariable("id") Long aqlId, @Valid @NotNull @RequestBody AqlDto aqlDto) { var aql = aqlService.updateAql(mapper.convertToEntity(aqlDto), aqlId, principal.getSubject(), aqlDto.getCategoryId()); @@ -79,7 +79,7 @@ public ResponseEntity updateAql( @DeleteMapping("/{id}") @Operation(description = "Delete AQL criteria") @PreAuthorize(Role.CRITERIA_EDITOR_OR_SUPER_ADMIN) - public void deleteAql(@AuthenticationPrincipal @NotNull Jwt principal, @PathVariable Long id) { + public void deleteAql(@AuthenticationPrincipal @NotNull Jwt principal, @NotNull @PathVariable Long id) { aqlService.deleteById(id, principal.getSubject(), Roles.extractRoles(principal)); } @@ -124,7 +124,7 @@ public ResponseEntity getAqlSize(@AuthenticationPrincipal @NotNull Jwt pri @Operation(description = "Creates a category. If there is an id in the DTO, it is ignored.") @PreAuthorize(Role.CRITERIA_EDITOR) public ResponseEntity createCategory(@AuthenticationPrincipal @NotNull Jwt principal, - @Valid @NotNull @RequestBody AqlCategoryDto aqlCategoryDto) { + @Valid @NotNull @RequestBody AqlCategoryDto aqlCategoryDto) { var aqlCategory = aqlService.createAqlCategory(principal.getSubject(), AqlCategory.builder().name(aqlCategoryDto.getName()).build()); return ResponseEntity.ok(modelMapper.map(aqlCategory, AqlCategoryDto.class)); diff --git a/src/main/java/de/vitagroup/num/web/controller/CohortController.java b/src/main/java/org/highmed/numportal/web/controller/CohortController.java similarity index 86% rename from src/main/java/de/vitagroup/num/web/controller/CohortController.java rename to src/main/java/org/highmed/numportal/web/controller/CohortController.java index 84d1b214e..db8862ab3 100644 --- a/src/main/java/de/vitagroup/num/web/controller/CohortController.java +++ b/src/main/java/org/highmed/numportal/web/controller/CohortController.java @@ -1,23 +1,25 @@ -package de.vitagroup.num.web.controller; - -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import de.vitagroup.num.domain.dto.CohortSizeDto; -import de.vitagroup.num.domain.dto.TemplateSizeRequestDto; -import de.vitagroup.num.mapper.CohortMapper; -import de.vitagroup.num.service.CohortService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.exception.dto.ErrorDetails; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; +package org.highmed.numportal.web.controller; + +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.dto.CohortSizeDto; +import org.highmed.numportal.domain.dto.TemplateSizeRequestDto; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.mapper.CohortMapper; +import org.highmed.numportal.service.CohortService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.exception.dto.ErrorDetails; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.highmed.numportal.web.config.Role; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,8 +28,6 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.WebRequest; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; import java.util.Map; import java.util.Map.Entry; import java.util.stream.Collectors; @@ -141,7 +141,7 @@ public ResponseEntity getCohortGroupSizeWithDistribution( * @return */ @Override - protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) { log.warn("Request for {} failed with error message {} ", request.getDescription(false), ex.getMessage()); Map errors = Map.of("Error", "error.missing_request_body"); ErrorDetails errorDetails = ErrorDetails diff --git a/src/main/java/de/vitagroup/num/web/controller/ContentController.java b/src/main/java/org/highmed/numportal/web/controller/ContentController.java similarity index 89% rename from src/main/java/de/vitagroup/num/web/controller/ContentController.java rename to src/main/java/org/highmed/numportal/web/controller/ContentController.java index 56e7d5165..4508ebf9d 100644 --- a/src/main/java/de/vitagroup/num/web/controller/ContentController.java +++ b/src/main/java/org/highmed/numportal/web/controller/ContentController.java @@ -1,20 +1,23 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.CardDto; -import de.vitagroup.num.domain.dto.MetricsDto; -import de.vitagroup.num.domain.dto.NavigationItemDto; -import de.vitagroup.num.domain.dto.ProjectInfoDto; -import de.vitagroup.num.service.ContentService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.web.config.Role; +import org.highmed.numportal.domain.dto.CardDto; +import org.highmed.numportal.domain.dto.MetricsDto; +import org.highmed.numportal.domain.dto.NavigationItemDto; +import org.highmed.numportal.domain.dto.ProjectInfoDto; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.service.ContentService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; +import org.highmed.numportal.web.config.Role; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -23,9 +26,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/de/vitagroup/num/web/controller/NumAttachmentController.java b/src/main/java/org/highmed/numportal/web/controller/NumAttachmentController.java similarity index 86% rename from src/main/java/de/vitagroup/num/web/controller/NumAttachmentController.java rename to src/main/java/org/highmed/numportal/web/controller/NumAttachmentController.java index 20a88f65e..8423e4304 100644 --- a/src/main/java/de/vitagroup/num/web/controller/NumAttachmentController.java +++ b/src/main/java/org/highmed/numportal/web/controller/NumAttachmentController.java @@ -1,15 +1,15 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.dto.LightAttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; -import de.vitagroup.num.attachment.service.AttachmentService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.dto.LightAttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.highmed.numportal.web.config.Role; import org.modelmapper.ModelMapper; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.*; @@ -20,9 +20,8 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -52,7 +51,7 @@ public ResponseEntity createAttachment(@AuthenticationPrincipal @NotNull @PreAuthorize(Role.STUDY_COORDINATOR) @PostMapping(path = "/{projectId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity createMultipleAttachments(@AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long projectId, + @NotNull @PathVariable Long projectId, @ModelAttribute @Valid LightAttachmentDto lightDto) throws IOException { attachmentService.saveAttachments(projectId, principal.getSubject(), lightDto, false); return ResponseEntity.ok("ok"); @@ -61,7 +60,7 @@ public ResponseEntity createMultipleAttachments(@AuthenticationPrincipal @AuditLog(description = "Get a list of all attachments for one project (by projectId)") @Operation(description = "Get a list of all attachments for one project (by projectId)") @GetMapping("/project/{projectId}") - public ResponseEntity> listAllAttachments(@NotNull @NotEmpty @PathVariable Long projectId) { + public ResponseEntity> listAllAttachments(@NotNull @PathVariable Long projectId) { return ResponseEntity.ok(attachmentService.getAttachmentsBy(projectId).stream() .map(attachment -> modelMapper.map(attachment, AttachmentDto.class)) .collect(Collectors.toList())); @@ -89,7 +88,7 @@ public void deleteAql(@AuthenticationPrincipal @NotNull Jwt principal, @PathVari @AuditLog(description = "Download attachment") @Operation(description = "Download attachment with given id") @GetMapping("/{attachmentId}") - public ResponseEntity downloadAttachment(@NotNull @NotEmpty @PathVariable Long attachmentId) { + public ResponseEntity downloadAttachment(@NotNull @PathVariable Long attachmentId) { Attachment attachment = attachmentService.getAttachmentById(attachmentId); HttpHeaders header = new HttpHeaders(); header.setContentDisposition(ContentDisposition.builder("attachment").filename(attachment.getName()).build()); diff --git a/src/main/java/de/vitagroup/num/web/controller/OrganizationController.java b/src/main/java/org/highmed/numportal/web/controller/OrganizationController.java similarity index 82% rename from src/main/java/de/vitagroup/num/web/controller/OrganizationController.java rename to src/main/java/org/highmed/numportal/web/controller/OrganizationController.java index f1549f160..fc4aaafb5 100644 --- a/src/main/java/de/vitagroup/num/web/controller/OrganizationController.java +++ b/src/main/java/org/highmed/numportal/web/controller/OrganizationController.java @@ -1,17 +1,17 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.mapper.OrganizationMapper; -import de.vitagroup.num.service.OrganizationService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.mapper.OrganizationMapper; +import org.highmed.numportal.service.OrganizationService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import lombok.AllArgsConstructor; +import org.highmed.numportal.web.config.Role; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -22,9 +22,8 @@ import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.stream.Collectors; @@ -47,8 +46,7 @@ public ResponseEntity> getAllMailDomainsForActiveOrganizations() { @AuditLog @GetMapping("/{id}") @Operation(description = "Retrieves an organization by external id") - public ResponseEntity getOrganizationById( - @NotNull @NotEmpty @PathVariable Long id) { + public ResponseEntity getOrganizationById(@NotNull @PathVariable Long id) { return ResponseEntity.ok(mapper.convertToDto(organizationService.getOrganizationById(id))); } @@ -102,9 +100,8 @@ public ResponseEntity createOrganization( @PutMapping(value = "/{id}") @Operation(description = "Updates an organization") @PreAuthorize(Role.SUPER_ADMIN_OR_ORGANIZATION_ADMIN) - public ResponseEntity updateOrganization( - @AuthenticationPrincipal @NotNull Jwt principal, - @PathVariable("id") Long organizationId, + public ResponseEntity updateOrganization(@AuthenticationPrincipal @NotNull Jwt principal, + @NotNull @PathVariable("id") Long organizationId, @Valid @NotNull @RequestBody OrganizationDto organizationDto) { return ResponseEntity.ok( mapper.convertToDto( @@ -120,7 +117,7 @@ public ResponseEntity updateOrganization( @DeleteMapping(value = "/{id}") @PreAuthorize(Role.SUPER_ADMIN) public void deleteOrganization(@AuthenticationPrincipal @NotNull Jwt principal, - @PathVariable("id") Long organizationId) { + @NotNull @PathVariable("id") Long organizationId) { organizationService.deleteOrganization(organizationId, principal.getSubject()); } } diff --git a/src/main/java/de/vitagroup/num/web/controller/ProfileController.java b/src/main/java/org/highmed/numportal/web/controller/ProfileController.java similarity index 75% rename from src/main/java/de/vitagroup/num/web/controller/ProfileController.java rename to src/main/java/org/highmed/numportal/web/controller/ProfileController.java index e338923a2..b2afc2f78 100644 --- a/src/main/java/de/vitagroup/num/web/controller/ProfileController.java +++ b/src/main/java/org/highmed/numportal/web/controller/ProfileController.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.service.UserService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.service.UserService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @RestController @RequestMapping(value = "/profile", produces = "application/json") diff --git a/src/main/java/de/vitagroup/num/web/controller/ProjectController.java b/src/main/java/org/highmed/numportal/web/controller/ProjectController.java similarity index 89% rename from src/main/java/de/vitagroup/num/web/controller/ProjectController.java rename to src/main/java/org/highmed/numportal/web/controller/ProjectController.java index 4a7b6a01c..9012b9eb9 100644 --- a/src/main/java/de/vitagroup/num/web/controller/ProjectController.java +++ b/src/main/java/org/highmed/numportal/web/controller/ProjectController.java @@ -1,23 +1,25 @@ -package de.vitagroup.num.web.controller; - -import de.vitagroup.num.domain.model.Comment; -import de.vitagroup.num.domain.model.ExportType; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.mapper.CommentMapper; -import de.vitagroup.num.mapper.ProjectMapper; -import de.vitagroup.num.mapper.ProjectViewMapper; -import de.vitagroup.num.service.CommentService; -import de.vitagroup.num.service.ProjectService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.logger.AuditLog; -import de.vitagroup.num.web.config.Role; +package org.highmed.numportal.web.controller; + +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.domain.model.Comment; +import org.highmed.numportal.domain.model.ExportType; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.mapper.CommentMapper; +import org.highmed.numportal.mapper.ProjectMapper; +import org.highmed.numportal.mapper.ProjectViewMapper; +import org.highmed.numportal.service.CommentService; +import org.highmed.numportal.service.ProjectService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import org.highmed.numportal.web.config.Role; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -35,15 +37,12 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.util.List; import java.util.Locale; import java.util.Optional; import java.util.stream.Collectors; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_NOT_FOUND; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.PROJECT_NOT_FOUND; @RestController @AllArgsConstructor @@ -76,7 +75,7 @@ public ResponseEntity> getProjects(@AuthenticationPrincipal @Operation(description = "Retrieves a project by id") @PreAuthorize(Role.STUDY_COORDINATOR_OR_RESEARCHER_OR_APPROVER) public ResponseEntity getProjectById(@AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long id) { + @NotNull @PathVariable Long id) { Optional project = projectService.getProjectById(principal.getSubject(), id); if (project.isEmpty()) { @@ -161,7 +160,7 @@ public ResponseEntity updateMultipartProject( public ResponseEntity executeAql( @AuthenticationPrincipal @NotNull Jwt principal, @RequestBody @Valid RawQueryDto query, - @NotNull @NotEmpty @PathVariable Long projectId, + @NotNull @PathVariable Long projectId, @RequestParam(required = false) Boolean defaultConfiguration) { return ResponseEntity.ok( projectService.retrieveData( @@ -190,7 +189,7 @@ public ResponseEntity executeManagerProject( public ResponseEntity exportResults( @AuthenticationPrincipal @NotNull Jwt principal, @RequestBody @Valid RawQueryDto query, - @NotNull @NotEmpty @PathVariable Long projectId, + @NotNull @PathVariable Long projectId, @RequestParam(required = false) Boolean defaultConfiguration, @RequestParam(required = false) @Parameter( description = "A string defining the output format. Valid values are 'csv' and 'json'. Default is csv.") @@ -228,7 +227,7 @@ public ResponseEntity exportManagerResults( @PreAuthorize(Role.STUDY_COORDINATOR_OR_RESEARCHER_OR_APPROVER) public ResponseEntity> getComments( @AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long projectId) { + @NotNull @PathVariable Long projectId) { return ResponseEntity.ok( commentService.getComments(projectId, principal.getSubject()).stream() .map(commentMapper::convertToDto) @@ -241,8 +240,8 @@ public ResponseEntity> getComments( @PreAuthorize(Role.STUDY_COORDINATOR_OR_RESEARCHER_OR_APPROVER) public ResponseEntity addComment( @AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long projectId, - @Valid @NotNull @RequestBody CommentDto commentDto) { + @NotNull @PathVariable Long projectId, + @Valid @RequestBody CommentDto commentDto) { Comment comment = commentService.createComment( @@ -257,8 +256,8 @@ public ResponseEntity addComment( @PreAuthorize(Role.STUDY_COORDINATOR_OR_RESEARCHER_OR_APPROVER) public ResponseEntity updateComment( @AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long projectId, - @NotNull @NotEmpty @PathVariable Long commentId, + @NotNull @PathVariable Long projectId, + @NotNull @PathVariable Long commentId, @Valid @NotNull @RequestBody CommentDto commentDto) { Comment comment = @@ -276,8 +275,8 @@ public ResponseEntity updateComment( @PreAuthorize(Role.STUDY_COORDINATOR_OR_RESEARCHER_OR_APPROVER) public void deleteComment( @AuthenticationPrincipal @NotNull Jwt principal, - @NotNull @NotEmpty @PathVariable Long projectId, - @NotNull @NotEmpty @PathVariable Long commentId) { + @NotNull @PathVariable Long projectId, + @NotNull @PathVariable Long commentId) { commentService.deleteComment(commentId, projectId, principal.getSubject()); } diff --git a/src/main/java/de/vitagroup/num/web/controller/TemplateController.java b/src/main/java/org/highmed/numportal/web/controller/TemplateController.java similarity index 75% rename from src/main/java/de/vitagroup/num/web/controller/TemplateController.java rename to src/main/java/org/highmed/numportal/web/controller/TemplateController.java index cf6af1325..eb2b03dea 100644 --- a/src/main/java/de/vitagroup/num/web/controller/TemplateController.java +++ b/src/main/java/org/highmed/numportal/web/controller/TemplateController.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.web.controller; +package org.highmed.numportal.web.controller; -import de.vitagroup.num.domain.dto.TemplateMetadataDto; -import de.vitagroup.num.service.TemplateService; -import de.vitagroup.num.service.exception.CustomizedExceptionHandler; -import de.vitagroup.num.service.logger.AuditLog; +import org.highmed.numportal.domain.dto.TemplateMetadataDto; +import org.highmed.numportal.service.TemplateService; +import org.highmed.numportal.service.exception.CustomizedExceptionHandler; +import org.highmed.numportal.service.logger.AuditLog; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; @Controller diff --git a/src/main/java/de/vitagroup/num/web/feign/KeycloakFeign.java b/src/main/java/org/highmed/numportal/web/feign/KeycloakFeign.java similarity index 90% rename from src/main/java/de/vitagroup/num/web/feign/KeycloakFeign.java rename to src/main/java/org/highmed/numportal/web/feign/KeycloakFeign.java index 0270b0195..b10abc13d 100644 --- a/src/main/java/de/vitagroup/num/web/feign/KeycloakFeign.java +++ b/src/main/java/org/highmed/numportal/web/feign/KeycloakFeign.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.web.feign; +package org.highmed.numportal.web.feign; -import de.vitagroup.num.domain.model.admin.Role; -import de.vitagroup.num.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.Role; +import org.highmed.numportal.domain.model.admin.User; import java.util.Map; import java.util.Set; diff --git a/src/main/java/de/vitagroup/num/web/feign/config/ClientTokenProvider.java b/src/main/java/org/highmed/numportal/web/feign/config/ClientTokenProvider.java similarity index 97% rename from src/main/java/de/vitagroup/num/web/feign/config/ClientTokenProvider.java rename to src/main/java/org/highmed/numportal/web/feign/config/ClientTokenProvider.java index 18e0aecbe..87bfa2329 100644 --- a/src/main/java/de/vitagroup/num/web/feign/config/ClientTokenProvider.java +++ b/src/main/java/org/highmed/numportal/web/feign/config/ClientTokenProvider.java @@ -1,6 +1,7 @@ -package de.vitagroup.num.web.feign.config; +package org.highmed.numportal.web.feign.config; import java.util.Collection; + import lombok.AllArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; diff --git a/src/main/java/de/vitagroup/num/web/feign/config/FeignInterceptor.java b/src/main/java/org/highmed/numportal/web/feign/config/FeignInterceptor.java similarity index 93% rename from src/main/java/de/vitagroup/num/web/feign/config/FeignInterceptor.java rename to src/main/java/org/highmed/numportal/web/feign/config/FeignInterceptor.java index 4de09b87d..bd0c91ca4 100644 --- a/src/main/java/de/vitagroup/num/web/feign/config/FeignInterceptor.java +++ b/src/main/java/org/highmed/numportal/web/feign/config/FeignInterceptor.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.web.feign.config; +package org.highmed.numportal.web.feign.config; import feign.RequestInterceptor; import feign.RequestTemplate; diff --git a/src/main/java/de/vitagroup/num/web/feign/config/OAuth2Configuration.java b/src/main/java/org/highmed/numportal/web/feign/config/OAuth2Configuration.java similarity index 90% rename from src/main/java/de/vitagroup/num/web/feign/config/OAuth2Configuration.java rename to src/main/java/org/highmed/numportal/web/feign/config/OAuth2Configuration.java index 2c2c231c2..5e37f65fc 100644 --- a/src/main/java/de/vitagroup/num/web/feign/config/OAuth2Configuration.java +++ b/src/main/java/org/highmed/numportal/web/feign/config/OAuth2Configuration.java @@ -1,10 +1,10 @@ -package de.vitagroup.num.web.feign.config; +package org.highmed.numportal.web.feign.config; import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties; -import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter; +import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -28,8 +28,7 @@ public OAuth2AuthorizedClientManager authorizedClientManager(OAuth2ClientPropert OAuth2AuthorizedClientProviderBuilder.builder().clientCredentials().build(); List registrations = - new ArrayList<>( - OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); + new ArrayList<>(new OAuth2ClientPropertiesMapper(properties).asClientRegistrations().values()); InMemoryClientRegistrationRepository clientRegistrationRepository = new InMemoryClientRegistrationRepository(registrations); diff --git a/src/main/java/de/vitagroup/num/web/feign/config/TokenProvider.java b/src/main/java/org/highmed/numportal/web/feign/config/TokenProvider.java similarity index 74% rename from src/main/java/de/vitagroup/num/web/feign/config/TokenProvider.java rename to src/main/java/org/highmed/numportal/web/feign/config/TokenProvider.java index 3981eeba9..cefc3a90a 100644 --- a/src/main/java/de/vitagroup/num/web/feign/config/TokenProvider.java +++ b/src/main/java/org/highmed/numportal/web/feign/config/TokenProvider.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.web.feign.config; +package org.highmed.numportal.web.feign.config; import org.springframework.security.oauth2.core.OAuth2AccessToken; diff --git a/src/main/resources/application-deploy.yml b/src/main/resources/application-deploy.yml index a36d2a93d..ef7fbf3b5 100644 --- a/src/main/resources/application-deploy.yml +++ b/src/main/resources/application-deploy.yml @@ -17,7 +17,7 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: ${KEYCLOAK_ENDPOINT}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs + jwk-set-uri: ${KEYCLOAK_ENDPOINT}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs client: registration: userStoreClient: @@ -25,7 +25,7 @@ spring: client-secret: ${KEYCLOAK_CLIENT_SECRET} provider: userStoreClient: - token-uri: ${KEYCLOAK_ENDPOINT}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token + token-uri: ${KEYCLOAK_ENDPOINT}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token mail: host: ${EMAIL_HOST} port: ${EMAIL_PORT} @@ -45,12 +45,12 @@ management: port: ${MANAGEMENT_PORT} userstore: - url: ${KEYCLOAK_ENDPOINT}/auth/admin/realms/${KEYCLOAK_REALM} + url: ${KEYCLOAK_ENDPOINT}/admin/realms/${KEYCLOAK_REALM} swagger: oauth2: - token-uri: ${KEYCLOAK_CANONICAL_URL}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token - auth-uri: ${KEYCLOAK_CANONICAL_URL}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/auth + token-uri: ${KEYCLOAK_CANONICAL_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token + auth-uri: ${KEYCLOAK_CANONICAL_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/auth client-name: ${SWAGGER_OAUTH2_CLIENT-NAME} client-secret: ${SWAGGER_OAUTH2_CLIENT-NAME} @@ -58,6 +58,8 @@ ehrbase: rest-api-url: ${EHRBASE_ENDPOINT}/ehrbase/ username: ${EHRBASE_USER} password: ${EHRBASE_PASSWORD} + adminUsername: ${EHRBASE_ADMIN_USER} + adminPassword: ${EHRBASE_ADMIN_PASSWORD} privacy: minHits: ${PRIVACY_MIN_HITS} @@ -74,7 +76,6 @@ zars: num: url: ${NUM_URL} locale: ${NUM_LOCALE} - systemStatusUrl: ${STATUS_URL} userManualUrl: DE: ${USER_MANUAL_URL_DE} EN: ${USER_MANUAL_URL_EN} @@ -105,4 +106,8 @@ pseudonymity: clamAV: host: ${CLAMAV_HOST} - port: ${CLAMAV_PORT} \ No newline at end of file + port: ${CLAMAV_PORT} + +logging: + level: + org.highmed.numportal: ${LOG_LEVEL} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 0f6ba2a06..ace7f238e 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -25,19 +25,20 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/certs + jwk-set-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/certs client: registration: userStoreClient: authorization-grant-type: client_credentials client-id: num-portal - client-secret: 89dddc8f-0f25-4faf-a58d-6cda681f6ed3 + client-secret: ZO29JPc5OLIZ29Rv83tEHOdxiAt2P9eC provider: userStoreClient: - token-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/token + token-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/token mvc: log-request-details: false mail: + enabled: false host: smtp.gmail.com port: 587 username: numportalwebapp@gmail.com @@ -53,17 +54,16 @@ spring: swagger: oauth2: - token-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/token - auth-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/auth - client-name: numPortalWebapp - client-secret: numPortalWebapp + token-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/token + auth-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/auth + client-name: num-portal + client-secret: num-portal userstore: - url: ${keycloak.url}/auth/admin/realms/crr + url: ${keycloak.url}/admin/realms/crr keycloak: - #url: http://localhost:8180 - url: https://keycloak.dev.num-codex.de + url: http://localhost:8180 feign: client: @@ -75,7 +75,7 @@ feign: logging: level: - de.vitagroup.num: DEBUG + org.highmed.numportal: DEBUG ehrbase: rest-api-url: http://localhost:8080/ehrbase/ @@ -83,6 +83,7 @@ ehrbase: password: SuperSecretPassword privacy: + enabled: false minHits: 1 pseudonymitySecret: AVmnrinfsVDRigh4QGrsDFbs43a pseudonomityChunksSize: 20 @@ -99,9 +100,8 @@ zars: num: url: http://localhost:8180 locale: en - systemStatusUrl: https://health.num-codex.de/ # if true a second database is configured for attachments - check configs for numportal-attachment enableAttachmentDatabase: true user-service: - delete-users-cron: 0 0 5 * * * \ No newline at end of file + delete-users-cron: 0 0 5 * * * diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6dff2667b..481ead81e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -43,7 +43,7 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/certs + jwk-set-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/certs client: registration: userStoreClient: @@ -52,7 +52,7 @@ spring: client-secret: 89dddc8f-0f25-4faf-a58d-6cda681f6ed3 provider: userStoreClient: - token-uri: ${keycloak.url}/auth/realms/crr/protocol/openid-connect/token + token-uri: ${keycloak.url}/realms/crr/protocol/openid-connect/token mail: host: smtp.gmail.com port: 587 @@ -93,16 +93,16 @@ springdoc: client-secret: num-portal-webapp swagger: oauth2: - token-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/token - auth-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/auth + token-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/token + auth-uri: ${keycloak.url}/realms/Num/protocol/openid-connect client-name: num-portal-webapp client-secret: num-portal-webapp userstore: - url: ${keycloak.url}/auth/admin/realms/crr + url: ${keycloak.url}/admin/realms/crr keycloak: - url: https://keycloak.dev.num-codex.de + url: ${keycloak.url} hapi: fhir: @@ -129,8 +129,9 @@ logging: level: org.springframework.web: info # DEBUG enables keycloak feign logging - de.vitagroup.num.web.feign.KeycloakFeign: INFO - de.vitagroup.num: INFO + org.highmed.numportal.web.feign.KeycloakFeign: INFO + org.highmed.numportal: INFO + atna: enabled: false @@ -146,6 +147,9 @@ ehrbase: rest-api-url: http://localhost:8080/ehrbase/ username: ehrbase-user password: SuperSecretPassword + adminUsername: ehrbase-admin + adminPassword: EvenMoreSecretPassword + cors: allowedOrigins: @@ -156,10 +160,8 @@ privacy: pseudonomityChunksSize: 50 num: - url: https://dev.num-codex.de/home + url: ${NUM_URL} locale: en - systemStatusUrl: https://health.num-codex.de/ - statusCakeUrl: https://app.statuscake.com/Workfloor/PublicReportHandler.php?PublicID= userManualUrl: DE: 'https://num-portal-webapp.readthedocs.io/de/latest/' EN: 'https://num-portal-webapp.readthedocs.io/en/latest/' @@ -189,7 +191,7 @@ fttp: requestpsnworkflow: params: study: num - source: codex + source: ${PSNWORKFLOW_SOURCE} target: extern_ apikey: iCZdh7ZWuf8ms)vvBgU-IaLi4 event: num.get_extern_psn diff --git a/src/main/resources/resourcebundle/resource.properties b/src/main/resources/resourcebundle/resource.properties index 92464c253..ef536a2fb 100644 --- a/src/main/resources/resourcebundle/resource.properties +++ b/src/main/resources/resourcebundle/resource.properties @@ -1,18 +1,18 @@ -mail.user-without-organization.subject=NUM CODEX - new user without organization -mail.user-without-organization.body=

Hello {0} {1}

{2} {3} {4} has registered in NUM CODEX. You now could select the organization of this user.

{5}

{6}

+mail.user-without-organization.subject=NUM RDP - new user without organization +mail.user-without-organization.body=

Hello {0} {1}

{2} {3} {4} has registered in NUM RDP. You now could select the organization of this user.

{5}

{6}

-mail.new-user.subject=NUM CODEX - new user -mail.new-user.body=

Hello {0} {1}

{2} {3} {4} has registered in NUM CODEX. You now could approve this user and set roles.

{5}

{6}

+mail.new-user.subject=NUM RDP - new user +mail.new-user.body=

Hello {0} {1}

{2} {3} {4} has registered in NUM RDP. You now could approve this user and set roles.

{5}

{6}

-mail.user-update.subject=NUM CODEX - User Account updated +mail.user-update.subject=NUM RDP - User Account updated mail.user-update.body=

Hello {0} {1}

Your account was updated by the admin. You can log in again here {3}

{2}

{3}

-mail.project-pending-approval.subject=NUM CODEX - Project request +mail.project-pending-approval.subject=NUM RDP - Project request mail.project-pending-approval.body=

Hello {0} {1}

{2} {3} requested an approval for project {4}.

{5}

{6}

-mail.project-start.subject=NUM CODEX - Project started +mail.project-start.subject=NUM RDP - Project started mail.project-start.body=

Hello {0} {1}

{2} {3} started the project {4}. You now can receive data in the project context.

{5}

{6}

-mail.project-close.subject=NUM CODEX - Project access changed +mail.project-close.subject=NUM RDP - Project access changed mail.project-close.body=

Hello {0} {1}

{2} {3} changed the project {4}. You cannot access the data in this project context.

{5}

{6}

-mail.project-status-change.subject=NUM CODEX - Project status changed +mail.project-status-change.subject=NUM RDP - Project status changed mail.project-status-change.body=

Hello {0} {1}

Your project {2} was changed to status {3} by {4} {5}.

{6}

{7}

-num.copyright=© Netzwerk Universitätsmedizin - CODEX - {0} +num.copyright=© Netzwerk Universitätsmedizin - RDP - {0} diff --git a/src/main/resources/resourcebundle/resource_de.properties b/src/main/resources/resourcebundle/resource_de.properties index 8b4fefa66..8d4b7e44d 100644 --- a/src/main/resources/resourcebundle/resource_de.properties +++ b/src/main/resources/resourcebundle/resource_de.properties @@ -1,42 +1,42 @@ -mail.user-account-approval.subject=NUM CODEX - Benutzeraccount überprüft +mail.user-account-approval.subject=NUM RDP - Benutzeraccount überprüft mail.user-account-approval.body=

Hallo {0} {1},

Ihr Account wurde vom Administrator {3}. Sie können sich nun hier anmelden: {5} .

{4}

{5}

-mail.user-roles-update.subject=NUM CODEX - Benutzerrollen geändert +mail.user-roles-update.subject=NUM RDP - Benutzerrollen geändert mail.user-roles.body=

Hallo {0} {1},

die Ihre Rollen wurden vom Administrator {4} angepasst. Sie können sich hier anmelden: {3}

Rollen entfernt: {6}

Rollen hinzugefügt: {7}

Ihre aktuellen Rollen: {8}

{2}

{3}

-mail.user-profile-update.subject=NUM CODEX - Name geändert +mail.user-profile-update.subject=NUM RDP - Name geändert mail.user-profile-update.body=

Hallo {0} {1},

Ihr Name wurde vom Admin {4} geändert. Sie können sich hier erneut einloggen: {3}

{2}

{3}

-mail.user-organization-update.subject=NUM CODEX - Benutzer Organisation zugeordnet +mail.user-organization-update.subject=NUM RDP - Benutzer Organisation zugeordnet mail.user-organization-update.body=

Hallo {0} {1},

Ihr Benutzeraccount wurde vom Admin {4} zur Organisation {6} zugeordnet. Sie können sich hier erneut einloggen: {3}

Vorige Organisation: {7}

{2}

{3}

-mail.user-without-organization.subject=NUM CODEX - new user without organization -mail.user-without-organization.body=

Hello {0} {1},

{2} {3} {4} has registered in NUM CODEX. You now could select the organization of this user.

{5}

{6}

+mail.user-without-organization.subject=NUM RDP - new user without organization +mail.user-without-organization.body=

Hello {0} {1},

{2} {3} {4} has registered in NUM RDP. You now could select the organization of this user.

{5}

{6}

-mail.new-user.subject=NUM CODEX - new user -mail.new-user.body=

Hallo {0} {1},

{2} {3} hat sich mit der E-Mail-Adresse {4} im NUM CODEX-Forschungsportal registriert. Bitte bestätigen Sie diesen Benutzer und vergeben Sie die zutreffenden Rollen.

Zusätzliche Informationen:

Gewünschte Rolle: {7}

Abteilungen(en): {8}

Sonstiges: {9}

{5}

{6}

+mail.new-user.subject=NUM RDP - new user +mail.new-user.body=

Hallo {0} {1},

{2} {3} hat sich mit der E-Mail-Adresse {4} im NUM RDP-Forschungsportal registriert. Bitte bestätigen Sie diesen Benutzer und vergeben Sie die zutreffenden Rollen.

Zusätzliche Informationen:

Gewünschte Rolle: {7}

Abteilungen(en): {8}

Sonstiges: {9}

{5}

{6}

-mail.project-pending-approval.subject=NUM CODEX - Genehmigungsanfrage Projekt +mail.project-pending-approval.subject=NUM RDP - Genehmigungsanfrage Projekt mail.project-pending-approval.body=

Hallo {0} {1},

{2} {3} hat eine Anfrage zur Genehmigung des Projekts: {4} gestellt. Bitte prüfen Sie das Projekt. Sie können das Projekt hier einsehen: {7}

{5}

{6}

-mail.project-status-change.subject=NUM CODEX - Statusänderung Projekt +mail.project-status-change.subject=NUM RDP - Statusänderung Projekt mail.project-status-change.body=

Hallo {0} {1},

der Status Ihres Projekts: {2} hat sich geändert.

Bisheriger Status: {9}

Neuer Status: {3}

Änderung durch: {4} {5}

Sie können das Projekt hier einsehen: {8}

{6}

{7}

-mail.project-start.subject=NUM CODEX - Projekt gestartet +mail.project-start.subject=NUM RDP - Projekt gestartet mail.project-start.body=

Hallo {0} {1},

{2} {3} hat die Zugriffsrechte auf das Projekt: {4} gestartet.Sie können nun Daten im Projektkontext abrufen.

Sie können das Projekt hier einsehen: {7}

{5}

{6}

-mail.project-close.subject=NUM CODEX - Projekt beendet +mail.project-close.subject=NUM RDP - Projekt beendet mail.project-close.body=

Hallo {0} {1},

{2} {3} hat die Zugriffsrechte auf das Projekt: {4} geändert. Sie haben keinen Zugriff mehr auf Daten in diesem Projektkontext.

{5}

{6}

-mail.user-account-active.subject=NUM CODEX - Ihr Benutzerkonto wurde aktiviert +mail.user-account-active.subject=NUM RDP - Ihr Benutzerkonto wurde aktiviert mail.user-account-active-body=

Hallo {0} {1},

Ihr Benutzerkonto auf {2} wurde vom Administrator {4} aktiviert.

Sie können sich jetzt auf {2} anmelden.

{5}

{2}

-mail.user-account-inactive.subject=NUM CODEX - Ihr Benutzerkonto wurde deaktiviert +mail.user-account-inactive.subject=NUM RDP - Ihr Benutzerkonto wurde deaktiviert mail.user-account-inactive.body=

Hallo {0} {1},

Ihr Benutzerkonto auf {2} wurde vom Administrator {4} deaktiviert.

Wenn es sich hierbei um einen Fehler handeln sollte, kontaktieren sie bitte den Administrator unter {3}.

{5}

{2}

-num.copyright=© Netzwerk Universitätsmedizin - CODEX - {0} +num.copyright=© Netzwerk Universitätsmedizin - RDP - {0} category.pediatrics=Pädiatrie category.symptomatology=Symptomatik diff --git a/src/main/resources/resourcebundle/resource_en.properties b/src/main/resources/resourcebundle/resource_en.properties index d558078ba..67777056f 100644 --- a/src/main/resources/resourcebundle/resource_en.properties +++ b/src/main/resources/resourcebundle/resource_en.properties @@ -1,41 +1,41 @@ -mail.user-account-approval.subject=NUM CODEX - User account approved +mail.user-account-approval.subject=NUM RDP - User account approved mail.user-account-approval.body=

Hello {0} {1},

Your account has been approved by admin {3}. You can now log in here: {5} .

{4}

{5}

-mail.user-roles-update.subject=NUM CODEX - User roles updated +mail.user-roles-update.subject=NUM RDP - User roles updated mail.user-roles.body=

Hello {0} {1},

your roles have been updated by admin {4}. You can now log in here: {3}

Roles removed: {6}

Roles added: {7}

Your current roles: {8}

{2}

{3}

-mail.user-profile-update.subject=NUM CODEX - User profile updated +mail.user-profile-update.subject=NUM RDP - User profile updated mail.user-profile-update.body=

Hello {0} {1},

Your name has been changed by the admin {4}. You can log in again here {3}

{2}

{3}

-mail.user-organization-update.subject=NUM CODEX - User assigned to organization +mail.user-organization-update.subject=NUM RDP - User assigned to organization mail.user-organization-update.body=

Hello {0} {1},

You have been assigned to the organization {6} by the admin {4}. You can log in again here {3}

Former organization: {7}

{2}

{3}

-mail.user-without-organization.subject=NUM CODEX - new user without organization -mail.user-without-organization.body=

Hello {0} {1},

{2} {3} {4} has registered in NUM CODEX. You now could select the organization of this user.

{5}

{6}

+mail.user-without-organization.subject=NUM RDP - new user without organization +mail.user-without-organization.body=

Hello {0} {1},

{2} {3} {4} has registered in NUM RDP. You now could select the organization of this user.

{5}

{6}

-mail.new-user.subject=NUM CODEX - new user -mail.new-user.body=

Hello {0} {1},

{2} {3} has registered with the email address {4} in the NUM CODEX research portal. Please approve this user and set the according roles.

Additional Information:

Desired role: {7}

Department(s): {8}

Additional information: {9}

{5}

{6}

+mail.new-user.subject=NUM RDP - new user +mail.new-user.body=

Hello {0} {1},

{2} {3} has registered with the email address {4} in the NUM RDP research portal. Please approve this user and set the according roles.

Additional Information:

Desired role: {7}

Department(s): {8}

Additional information: {9}

{5}

{6}

-mail.project-pending-approval.subject=NUM CODEX - project request +mail.project-pending-approval.subject=NUM RDP - project request mail.project-pending-approval.body=

Hello {0} {1},

{2} {3} requested an approval for project: {4}. Please look into the project. You can access the project here: {7}

{5}

{6}

-mail.project-status-change.subject=NUM CODEX - Project status changed +mail.project-status-change.subject=NUM RDP - Project status changed mail.project-status-change.body=

Hello {0} {1},

the state of your project: {2} has been changed.

Previous state: {9}

New state: {3}

Changed by: {4} {5}

You can access the project here: {8}

{6}

{7}

-mail.project-start.subject=NUM CODEX - Project started +mail.project-start.subject=NUM RDP - Project started mail.project-start.body=

Hello {0} {1},

{2} {3} started the project: {4}. You now can retrieve data in the project context.

You can access the project here: {7}

{5}

{6}

-mail.project-close.subject=NUM CODEX - Project access changed +mail.project-close.subject=NUM RDP - Project access changed mail.project-close.body=

Hello {0} {1},

{2} {3} changed the access to project: {4}. You can no longer access data in this project context.

{5}

{6}

-mail.user-account-active.subject=NUM CODEX - Your account has been activated +mail.user-account-active.subject=NUM RDP - Your account has been activated mail.user-account-active-body=

Hello {0} {1},

your account at {2} has been activated by admin {4}.

You can now log in here: {2}.

{5}

{2}

-mail.user-account-inactive.subject=NUM CODEX - Your account has been deactivated +mail.user-account-inactive.subject=NUM RDP - Your account has been deactivated mail.user-account-inactive.body=

Hello {0} {1},

your account at {2} has been deactivated by admin {4}.

If you believe this happened in error, please contact the admin at {3}.

{5}

{2}

-num.copyright=© Netzwerk Universitätsmedizin - CODEX - {0} +num.copyright=© Netzwerk Universitätsmedizin - RDP - {0} category.pediatrics=Pediatrics category.symptomatology=Symptomatology diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/AdminControllerIT.java b/src/test/java/de/vitagroup/num/integrationtesting/tests/AdminControllerIT.java deleted file mode 100644 index 9ece05a15..000000000 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/AdminControllerIT.java +++ /dev/null @@ -1,191 +0,0 @@ -package de.vitagroup.num.integrationtesting.tests; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.client.WireMock; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; -import de.vitagroup.num.service.SetupHealthiness; -import lombok.SneakyThrows; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultMatcher; - -import java.nio.charset.StandardCharsets; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static de.vitagroup.num.domain.model.Roles.*; -import static org.mockito.Mockito.when; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class AdminControllerIT extends IntegrationTest { - - @Autowired public MockMvc mockMvc; - - private static final String ADMIN_PATH = "/admin/user"; - - private static final String USER_ID = "b59e5edb-3121-4e0a-8ccb-af6798207a79"; - - private static final String USER_ID_TO_BE_APPROVED = "b59e5edb-3121-4e0a-8ccb-af6798207a73"; - @Autowired - private ObjectMapper mapper; - - @Mock - private SetupHealthiness setupHealthiness; - - @Test - @WithMockNumUser( - userId = USER_ID, - roles = {STUDY_COORDINATOR}) - public void shouldCreateUserOnFirstLoginSuccessfully() throws Exception { - stubFor( - WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a79") - .willReturn(okJson( - "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a79\",\"username\": \"new-user\"}"))); - stubFor(WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a79/role-mappings/realm") - .willReturn(okJson("[{\"id\":\"12345-2f04-4356-8f34-12345\",\"name\":\"STUDY_COORDINATOR\",\"composite\":false,\"clientRole\":false,\"containerId\":\"Num\"}]"))); - mockMvc - .perform( - post(String.format("%s/%s", ADMIN_PATH, USER_ID)) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); - } - - @Test - @SneakyThrows - @WithMockNumUser( - roles = {SUPER_ADMIN, ORGANIZATION_ADMIN}) - public void shouldApproveUserSuccessfully() { - stubFor( - WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73") - .willReturn(okJson( - "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a73\",\"username\": \"new-user\", \"firstname\":\"John\", \"email\": \"john.doe@vitagroup.ag\"}"))); - mockMvc - .perform( - post(String.format("%s/%s/%s", ADMIN_PATH, USER_ID_TO_BE_APPROVED, "approve")) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); - } - - @Test - @SneakyThrows - @WithMockNumUser(roles = {SUPER_ADMIN}) - public void shouldUpdateUserStatusSuccessfully() { - stubFor( - WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73") - .willReturn(okJson( - "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a73\",\"username\": \"new-user\", \"firstname\":\"John\", \"email\": \"john.doe@vitagroup.ag\", \"enabled\": \"true\"}"))); - stubFor(WireMock.put("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73").willReturn(okJson("[]"))); - stubFor(WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73/role-mappings/realm") - .willReturn(okJson("[{\"id\":\"12345-2f04-1156-8f34-12345\",\"name\":\"RESEARCHER\",\"composite\":false,\"clientRole\":false,\"containerId\":\"Num\"}]"))); - mockMvc - .perform( - post(String.format("%s/%s/%s", ADMIN_PATH, USER_ID_TO_BE_APPROVED, "status")) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(Boolean.FALSE)) - ).andExpect(status().isOk()); - } - - @Test - public void shouldGetExternalUrlsSuccessfully() throws Exception { - mockMvc - .perform( - get("/admin/external-urls") - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.systemStatusUrl").value("http://localhost:8099/health-url")) - .andExpect(jsonPath("$.userManualUrl.DE").value("user-manual-de")) - .andExpect(jsonPath("$.userManualUrl.EN").value("user-manual-en")); - } - - @Test - public void shouldGetServicesStatus() throws Exception { - stubFor( - WireMock.get("/health-url") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/NUM-Codex-Status.html"), - StandardCharsets.UTF_8)))); - stubFor( - WireMock.get("/statusCake?PublicID=Lmw50IEZ6s") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/statusCakeResponse.json"), - StandardCharsets.UTF_8)))); - //testSuccess("/admin/services-status", status().isOk());//PREPROD - testSuccess("/admin/services-status?setup=PROD", status().isOk()); - testFail("/admin/services-status?setup=STAGING", status().isServiceUnavailable()); - testFail("/admin/services-status?setup=DEV", status().isServiceUnavailable()); - } - - @Test - public void shouldGetAnnouncement() throws Exception { - stubFor( - WireMock.get("/health-url") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/NUM-Codex-Status.html"), - StandardCharsets.UTF_8)))); - stubFor( - WireMock.get("/statusCake?PublicID=Lmw50IEZ6s") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/statusCakeResponseWithAnnouncements.json"), - StandardCharsets.UTF_8)))); - mockMvc - .perform( - get("/admin/services-status?setup=PROD") - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("NUM").value("")) - .andExpect(jsonPath("EHRBASE").value("")) - .andExpect(jsonPath("FHIR_BRIDGE").value("")) - .andExpect(jsonPath("CHECK_FOR_ANNOUNCEMENTS").value("Please visit health.num-codex.de page for announcement. Date/Time - [13:30] Description - [Testing]")) - .andExpect(jsonPath("FE").value("")) - .andExpect(jsonPath("KEYCLOAK").value("")); - } - - private void testSuccess(String url, ResultMatcher status) throws Exception { - mockMvc - .perform( - get(url) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status) - .andExpect(jsonPath("NUM").value("")) - .andExpect(jsonPath("EHRBASE").value("")) - .andExpect(jsonPath("FHIR_BRIDGE").value("")) - .andExpect(jsonPath("FE").value("")) - .andExpect(jsonPath("KEYCLOAK").value("")); - } - - @Test - public void testException() { - when(setupHealthiness.checkForAnnouncements()).thenReturn("myParsedPage"); - Assert.assertEquals(setupHealthiness.checkForAnnouncements(), "myParsedPage"); - when(setupHealthiness.checkForAnnouncements()).thenThrow(new RuntimeException("PageNotParsed")); - try { - setupHealthiness.checkForAnnouncements(); - } catch (RuntimeException re){ - Assert.assertEquals("PageNotParsed", re.getMessage()); - } - } - - private void testFail(String url, ResultMatcher status) throws Exception { - mockMvc - .perform( - get(url) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status) - .andExpect(jsonPath("NUM").isNotEmpty()) - .andExpect(jsonPath("EHRBASE").isNotEmpty()) - .andExpect(jsonPath("FHIR_BRIDGE").isNotEmpty()) - .andExpect(jsonPath("FE").isNotEmpty()) - .andExpect(jsonPath("KEYCLOAK").isNotEmpty()); - } -} diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/HealthEndpointIT.java b/src/test/java/de/vitagroup/num/integrationtesting/tests/HealthEndpointIT.java deleted file mode 100644 index 572213921..000000000 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/HealthEndpointIT.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.vitagroup.num.integrationtesting.tests; - -import lombok.SneakyThrows; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class HealthEndpointIT extends IntegrationTest { - - @Autowired public MockMvc mockMvc; - - private static final String HEALTH_PATH = "/admin/health"; - - private static final String LOG_LEVEL_PATH = "/admin/log-level"; - - @Test - @SneakyThrows - public void healthEndPointTest() { - - mockMvc - .perform( - get(HEALTH_PATH) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isBadRequest()); - } - - @Test - @SneakyThrows - public void logLevelEndPointTest() { - - mockMvc - .perform( - post(LOG_LEVEL_PATH + "/DEBUG") - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)); - mockMvc - .perform( - get(LOG_LEVEL_PATH) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.levelStr").value("DEBUG")); - } - - @Test - @SneakyThrows - public void logLevelModifyEndPointTest() { - - mockMvc - .perform( - post(LOG_LEVEL_PATH + "/OFF") - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.levelStr").value("OFF")); - } - -} diff --git a/src/test/java/de/vitagroup/num/service/email/EmailServiceTest.java b/src/test/java/de/vitagroup/num/service/email/EmailServiceTest.java deleted file mode 100644 index 1eb2a511f..000000000 --- a/src/test/java/de/vitagroup/num/service/email/EmailServiceTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.vitagroup.num.service.email; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.mail.javamail.JavaMailSender; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; - -@RunWith(MockitoJUnitRunner.class) -public class EmailServiceTest { - - @Mock - private JavaMailSender javaMailSender; - @Mock - private EmailProperties emailProperties; - - @InjectMocks - private EmailService emailService; - - private MimeMessage message; - - @Before - public void setup() { - Mockito.when(emailProperties.getFrom()).thenReturn("support@vitagroup.de"); - message = new MimeMessage((Session) null); - Mockito.when(javaMailSender.createMimeMessage()).thenReturn(message); - } - - @Test - public void sendEmailTest() throws MessagingException { - emailService.sendEmail("Test subject", "test body", "testaccount@vitagroup.de"); - Assert.assertEquals("testaccount@vitagroup.de", message.getRecipients(Message.RecipientType.TO)[0].toString()); - Assert.assertEquals("Test subject", message.getSubject()); - } - - @Test - public void sendEmailWithAttachmentTest() throws MessagingException { - emailService.sendEmailWithAttachment("another test subject", "dummy email body", "testaccount2@vitagroup.de", "dummy file content", "dummyAttachment.txt","text/plain"); - Assert.assertEquals("testaccount2@vitagroup.de", message.getRecipients(Message.RecipientType.TO)[0].toString()); - Assert.assertEquals("another test subject", message.getSubject()); - Assert.assertEquals("text/plain", message.getContentType()); - } -} diff --git a/src/test/java/de/vitagroup/num/TestNumPortalApplication.java b/src/test/java/org/highmed/numportal/TestNumPortalApplication.java similarity index 70% rename from src/test/java/de/vitagroup/num/TestNumPortalApplication.java rename to src/test/java/org/highmed/numportal/TestNumPortalApplication.java index d284fa3b6..e683bebf1 100644 --- a/src/test/java/de/vitagroup/num/TestNumPortalApplication.java +++ b/src/test/java/org/highmed/numportal/TestNumPortalApplication.java @@ -1,16 +1,13 @@ -package de.vitagroup.num; +package org.highmed.numportal; -import de.vitagroup.num.config.database.NumAttachmentFlywayConfig; -import de.vitagroup.num.config.database.NumPortalAttachmentDatasourceConfiguration; -import de.vitagroup.num.listeners.UserCacheInit; -import de.vitagroup.num.service.atna.AtnaProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableAsync; +import org.highmed.numportal.listeners.UserCacheInit; +import org.highmed.numportal.service.atna.AtnaProperties; @SpringBootApplication @EnableConfigurationProperties({AtnaProperties.class}) diff --git a/src/test/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryTest.java b/src/test/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryTest.java rename to src/test/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryTest.java index a9eb59d43..40aa80eca 100644 --- a/src/test/java/de/vitagroup/num/attachment/domain/repository/AttachmentRepositoryTest.java +++ b/src/test/java/org/highmed/numportal/attachment/domain/repository/AttachmentRepositoryTest.java @@ -1,7 +1,9 @@ -package de.vitagroup.num.attachment.domain.repository; +package org.highmed.numportal.attachment.domain.repository; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.domain.repository.AttachmentRepositoryImpl; +import org.highmed.numportal.attachment.domain.repository.AttachmentRepositoryJpa; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; diff --git a/src/test/java/de/vitagroup/num/attachment/service/AttachmentServiceTest.java b/src/test/java/org/highmed/numportal/attachment/service/AttachmentServiceTest.java similarity index 89% rename from src/test/java/de/vitagroup/num/attachment/service/AttachmentServiceTest.java rename to src/test/java/org/highmed/numportal/attachment/service/AttachmentServiceTest.java index 981a14135..2f8f7b769 100644 --- a/src/test/java/de/vitagroup/num/attachment/service/AttachmentServiceTest.java +++ b/src/test/java/org/highmed/numportal/attachment/service/AttachmentServiceTest.java @@ -1,17 +1,11 @@ -package de.vitagroup.num.attachment.service; - -import de.vitagroup.num.attachment.AttachmentRepository; -import de.vitagroup.num.attachment.domain.dto.AttachmentDto; -import de.vitagroup.num.attachment.domain.dto.LightAttachmentDto; -import de.vitagroup.num.attachment.domain.model.Attachment; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.service.ProjectService; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ResourceNotFound; +package org.highmed.numportal.attachment.service; + +import org.highmed.numportal.attachment.AttachmentRepository; +import org.highmed.numportal.attachment.domain.dto.AttachmentDto; +import org.highmed.numportal.attachment.domain.dto.LightAttachmentDto; +import org.highmed.numportal.attachment.domain.model.Attachment; +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.attachment.service.FileScanService; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -23,21 +17,21 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.multipart.MultipartFile; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.service.ProjectService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; import java.io.IOException; -import java.util.List; import java.util.LinkedHashSet; +import java.util.List; import java.util.Optional; import java.util.Set; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.ATTACHMENT_LIMIT_REACHED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.DESCRIPTION_TOO_LONG; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.DOCUMENT_TYPE_MISMATCH; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_FILE_MISSING_CONTENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PDF_FILES_ARE_NOT_ATTACHED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PDF_FILE_SIZE_EXCEEDED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_NOT_FOUND; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.WRONG_PROJECT_STATUS; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; @RunWith(MockitoJUnitRunner.class) public class AttachmentServiceTest { diff --git a/src/test/java/de/vitagroup/num/attachment/service/ClamAVServiceTest.java b/src/test/java/org/highmed/numportal/attachment/service/ClamAVServiceTest.java similarity index 92% rename from src/test/java/de/vitagroup/num/attachment/service/ClamAVServiceTest.java rename to src/test/java/org/highmed/numportal/attachment/service/ClamAVServiceTest.java index 1824d255d..e6fa3d3a6 100644 --- a/src/test/java/de/vitagroup/num/attachment/service/ClamAVServiceTest.java +++ b/src/test/java/org/highmed/numportal/attachment/service/ClamAVServiceTest.java @@ -1,7 +1,6 @@ -package de.vitagroup.num.attachment.service; +package org.highmed.numportal.attachment.service; -import de.vitagroup.num.integrationtesting.config.ClamAVContainer; -import de.vitagroup.num.properties.ClamAVProperties; +import org.highmed.numportal.integrationtesting.config.ClamAVContainer; import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; @@ -11,6 +10,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.properties.ClamAVProperties; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/src/test/java/de/vitagroup/num/attachment/service/FileScanServiceTest.java b/src/test/java/org/highmed/numportal/attachment/service/FileScanServiceTest.java similarity index 89% rename from src/test/java/de/vitagroup/num/attachment/service/FileScanServiceTest.java rename to src/test/java/org/highmed/numportal/attachment/service/FileScanServiceTest.java index a6b78fe3f..ad8548442 100644 --- a/src/test/java/de/vitagroup/num/attachment/service/FileScanServiceTest.java +++ b/src/test/java/org/highmed/numportal/attachment/service/FileScanServiceTest.java @@ -1,7 +1,7 @@ -package de.vitagroup.num.attachment.service; +package org.highmed.numportal.attachment.service; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.SystemException; +import org.highmed.numportal.attachment.service.ClamAVService; +import org.highmed.numportal.attachment.service.FileScanService; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -10,6 +10,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.mock.web.MockMultipartFile; import org.springframework.web.multipart.MultipartFile; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.SystemException; import java.io.IOException; import java.io.InputStream; diff --git a/src/test/java/de/vitagroup/num/domain/RolesTest.java b/src/test/java/org/highmed/numportal/domain/RolesTest.java similarity index 93% rename from src/test/java/de/vitagroup/num/domain/RolesTest.java rename to src/test/java/org/highmed/numportal/domain/RolesTest.java index 8de418b98..b2b530a6e 100644 --- a/src/test/java/de/vitagroup/num/domain/RolesTest.java +++ b/src/test/java/org/highmed/numportal/domain/RolesTest.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.domain; +package org.highmed.numportal.domain; -import de.vitagroup.num.domain.model.Roles; import org.junit.Assert; import org.junit.Test; import org.springframework.security.oauth2.jwt.Jwt; +import org.highmed.numportal.domain.model.Roles; import java.time.Instant; import java.util.List; @@ -35,7 +35,7 @@ public void extractRolesTest() { .subject("user-uuid-1234") .issuedAt(Instant.now()) .claim("name", "John") - .claim("email", "john.doe@vitagroup.de") + .claim("email", "john.doe@highmed.org") .claim("realm_access", Map.of("roles", List.of(Roles.STUDY_APPROVER, Roles.STUDY_COORDINATOR))) .claim("username", "john.doe") .header("dummy", "dummy") @@ -51,7 +51,7 @@ public void shouldReturnEmptyListExtractRolesTest() { .subject("user-uuid-1234") .issuedAt(Instant.now()) .claim("name", "John") - .claim("email", "john.doe@vitagroup.de") + .claim("email", "john.doe@highmed.org") .claim("username", "john.doe") .header("dummy", "dummy") .build(); diff --git a/src/test/java/de/vitagroup/num/domain/dto/SearchCriteriaTest.java b/src/test/java/org/highmed/numportal/domain/dto/SearchCriteriaTest.java similarity index 89% rename from src/test/java/de/vitagroup/num/domain/dto/SearchCriteriaTest.java rename to src/test/java/org/highmed/numportal/domain/dto/SearchCriteriaTest.java index 34da2b09a..bb48fd88c 100644 --- a/src/test/java/de/vitagroup/num/domain/dto/SearchCriteriaTest.java +++ b/src/test/java/org/highmed/numportal/domain/dto/SearchCriteriaTest.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.domain.dto; +package org.highmed.numportal.domain.dto; -import de.vitagroup.num.service.exception.BadRequestException; +import org.highmed.numportal.domain.dto.SearchCriteria; import org.junit.Assert; import org.junit.Test; +import org.highmed.numportal.service.exception.BadRequestException; public class SearchCriteriaTest { diff --git a/src/test/java/de/vitagroup/num/domain/repository/ProjectRepositoryImplTest.java b/src/test/java/org/highmed/numportal/domain/repository/ProjectRepositoryImplTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/domain/repository/ProjectRepositoryImplTest.java rename to src/test/java/org/highmed/numportal/domain/repository/ProjectRepositoryImplTest.java index a9f01800b..49f38dcd9 100644 --- a/src/test/java/de/vitagroup/num/domain/repository/ProjectRepositoryImplTest.java +++ b/src/test/java/org/highmed/numportal/domain/repository/ProjectRepositoryImplTest.java @@ -1,9 +1,9 @@ -package de.vitagroup.num.domain.repository; +package org.highmed.numportal.domain.repository; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.specification.ProjectSpecification; +import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.*; +import org.highmed.numportal.domain.repository.ProjectRepositoryImpl; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -12,10 +12,11 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.specification.ProjectSpecification; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.*; import java.util.Collections; import java.util.List; diff --git a/src/test/java/de/vitagroup/num/domain/specification/AqlSpecificationTest.java b/src/test/java/org/highmed/numportal/domain/specification/AqlSpecificationTest.java similarity index 95% rename from src/test/java/de/vitagroup/num/domain/specification/AqlSpecificationTest.java rename to src/test/java/org/highmed/numportal/domain/specification/AqlSpecificationTest.java index 03008d885..a43fee327 100644 --- a/src/test/java/de/vitagroup/num/domain/specification/AqlSpecificationTest.java +++ b/src/test/java/org/highmed/numportal/domain/specification/AqlSpecificationTest.java @@ -1,16 +1,17 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchFilter; +import jakarta.persistence.criteria.*; +import org.highmed.numportal.domain.specification.AqlSpecification; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.domain.Sort; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchFilter; +import org.highmed.numportal.domain.model.Aql; -import javax.persistence.criteria.*; import java.util.HashMap; import java.util.HashSet; import java.util.Map; diff --git a/src/test/java/de/vitagroup/num/domain/specification/OrganizationSpecificationTest.java b/src/test/java/org/highmed/numportal/domain/specification/OrganizationSpecificationTest.java similarity index 80% rename from src/test/java/de/vitagroup/num/domain/specification/OrganizationSpecificationTest.java rename to src/test/java/org/highmed/numportal/domain/specification/OrganizationSpecificationTest.java index 6148ce1f1..71ebf10b6 100644 --- a/src/test/java/de/vitagroup/num/domain/specification/OrganizationSpecificationTest.java +++ b/src/test/java/org/highmed/numportal/domain/specification/OrganizationSpecificationTest.java @@ -1,16 +1,17 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Organization; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Root; +import org.highmed.numportal.domain.specification.OrganizationSpecification; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.Organization; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Root; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/de/vitagroup/num/domain/specification/ProjectSpecificationTest.java b/src/test/java/org/highmed/numportal/domain/specification/ProjectSpecificationTest.java similarity index 93% rename from src/test/java/de/vitagroup/num/domain/specification/ProjectSpecificationTest.java rename to src/test/java/org/highmed/numportal/domain/specification/ProjectSpecificationTest.java index 31886bbb9..19bce4dd1 100644 --- a/src/test/java/de/vitagroup/num/domain/specification/ProjectSpecificationTest.java +++ b/src/test/java/org/highmed/numportal/domain/specification/ProjectSpecificationTest.java @@ -1,18 +1,19 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchFilter; +import jakarta.persistence.criteria.*; +import org.highmed.numportal.domain.specification.ProjectSpecification; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.domain.Sort; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchFilter; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.Roles; -import javax.persistence.criteria.*; import java.util.*; @RunWith(MockitoJUnitRunner.class) diff --git a/src/test/java/de/vitagroup/num/domain/specification/UserDetailsSpecificationTest.java b/src/test/java/org/highmed/numportal/domain/specification/UserDetailsSpecificationTest.java similarity index 89% rename from src/test/java/de/vitagroup/num/domain/specification/UserDetailsSpecificationTest.java rename to src/test/java/org/highmed/numportal/domain/specification/UserDetailsSpecificationTest.java index b7722ac30..f2a4bdb8a 100644 --- a/src/test/java/de/vitagroup/num/domain/specification/UserDetailsSpecificationTest.java +++ b/src/test/java/org/highmed/numportal/domain/specification/UserDetailsSpecificationTest.java @@ -1,13 +1,14 @@ -package de.vitagroup.num.domain.specification; +package org.highmed.numportal.domain.specification; -import de.vitagroup.num.domain.model.admin.UserDetails; +import jakarta.persistence.criteria.*; +import org.highmed.numportal.domain.specification.UserDetailsSpecification; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.admin.UserDetails; -import javax.persistence.criteria.*; import java.util.HashSet; import java.util.Set; diff --git a/src/test/java/de/vitagroup/num/domain/validation/CohortValidatorTest.java b/src/test/java/org/highmed/numportal/domain/validation/CohortValidatorTest.java similarity index 94% rename from src/test/java/de/vitagroup/num/domain/validation/CohortValidatorTest.java rename to src/test/java/org/highmed/numportal/domain/validation/CohortValidatorTest.java index 69de83c6d..67c090b1b 100644 --- a/src/test/java/de/vitagroup/num/domain/validation/CohortValidatorTest.java +++ b/src/test/java/org/highmed/numportal/domain/validation/CohortValidatorTest.java @@ -1,23 +1,23 @@ -package de.vitagroup.num.domain.validation; +package org.highmed.numportal.domain.validation; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -import de.vitagroup.num.domain.dto.CohortAqlDto; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.domain.model.Type; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.ValidatorFactory; import org.junit.Before; import org.junit.Test; +import org.highmed.numportal.domain.dto.CohortAqlDto; +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.model.Operator; +import org.highmed.numportal.domain.model.Type; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; import java.util.List; import java.util.Set; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + public class CohortValidatorTest { private Validator validator; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/config/AttachmentPostgresqlContainer.java b/src/test/java/org/highmed/numportal/integrationtesting/config/AttachmentPostgresqlContainer.java similarity index 94% rename from src/test/java/de/vitagroup/num/integrationtesting/config/AttachmentPostgresqlContainer.java rename to src/test/java/org/highmed/numportal/integrationtesting/config/AttachmentPostgresqlContainer.java index 3c9f98ff6..a33d8e3ea 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/config/AttachmentPostgresqlContainer.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/config/AttachmentPostgresqlContainer.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.integrationtesting.config; +package org.highmed.numportal.integrationtesting.config; import org.testcontainers.containers.PostgreSQLContainer; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/config/ClamAVContainer.java b/src/test/java/org/highmed/numportal/integrationtesting/config/ClamAVContainer.java similarity index 92% rename from src/test/java/de/vitagroup/num/integrationtesting/config/ClamAVContainer.java rename to src/test/java/org/highmed/numportal/integrationtesting/config/ClamAVContainer.java index 517fde8e6..a8040e9cb 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/config/ClamAVContainer.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/config/ClamAVContainer.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.integrationtesting.config; +package org.highmed.numportal.integrationtesting.config; import lombok.extern.slf4j.Slf4j; import org.testcontainers.containers.GenericContainer; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/config/NumPostgresqlContainer.java b/src/test/java/org/highmed/numportal/integrationtesting/config/NumPostgresqlContainer.java similarity index 94% rename from src/test/java/de/vitagroup/num/integrationtesting/config/NumPostgresqlContainer.java rename to src/test/java/org/highmed/numportal/integrationtesting/config/NumPostgresqlContainer.java index 8394a9d27..cfe982520 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/config/NumPostgresqlContainer.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/config/NumPostgresqlContainer.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.integrationtesting.config; +package org.highmed.numportal.integrationtesting.config; import org.testcontainers.containers.PostgreSQLContainer; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/security/TokenGenerator.java b/src/test/java/org/highmed/numportal/integrationtesting/security/TokenGenerator.java similarity index 90% rename from src/test/java/de/vitagroup/num/integrationtesting/security/TokenGenerator.java rename to src/test/java/org/highmed/numportal/integrationtesting/security/TokenGenerator.java index 3d653ff0c..ed602e930 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/security/TokenGenerator.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/security/TokenGenerator.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.integrationtesting.security; +package org.highmed.numportal.integrationtesting.security; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.jwk.RSAKey; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUser.java b/src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUser.java similarity index 90% rename from src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUser.java rename to src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUser.java index c27eb5de6..cc0600ab0 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUser.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUser.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.integrationtesting.security; +package org.highmed.numportal.integrationtesting.security; + +import org.springframework.security.test.context.support.WithSecurityContext; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.springframework.security.test.context.support.WithSecurityContext; @Retention(RetentionPolicy.RUNTIME) @WithSecurityContext(factory = WithMockNumUserSecurityContextFactory.class) diff --git a/src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUserSecurityContextFactory.java b/src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUserSecurityContextFactory.java similarity index 96% rename from src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUserSecurityContextFactory.java rename to src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUserSecurityContextFactory.java index c72a5e0a9..ed522c0d6 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/security/WithMockNumUserSecurityContextFactory.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/security/WithMockNumUserSecurityContextFactory.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.integrationtesting.security; +package org.highmed.numportal.integrationtesting.security; import lombok.SneakyThrows; import org.springframework.security.core.GrantedAuthority; diff --git a/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java new file mode 100644 index 000000000..66a30d582 --- /dev/null +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java @@ -0,0 +1,102 @@ +package org.highmed.numportal.integrationtesting.tests; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.client.WireMock; +import lombok.SneakyThrows; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static org.highmed.numportal.domain.model.Roles.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class AdminControllerIT extends IntegrationTest { + + @Autowired public MockMvc mockMvc; + + private static final String ADMIN_PATH = "/admin/user"; + + private static final String USER_ID = "b59e5edb-3121-4e0a-8ccb-af6798207a79"; + + private static final String USER_ID_TO_BE_APPROVED = "b59e5edb-3121-4e0a-8ccb-af6798207a73"; + @Autowired + private ObjectMapper mapper; + + @Test + @WithMockNumUser( + userId = USER_ID, + roles = {STUDY_COORDINATOR}) + public void shouldCreateUserOnFirstLoginSuccessfully() throws Exception { + stubFor( + WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a79") + .willReturn(okJson( + "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a79\",\"username\": \"new-user\"}"))); + stubFor(WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a79/role-mappings/realm") + .willReturn(okJson("[{\"id\":\"12345-2f04-4356-8f34-12345\",\"name\":\"STUDY_COORDINATOR\",\"composite\":false,\"clientRole\":false,\"containerId\":\"Num\"}]"))); + mockMvc + .perform( + post(String.format("%s/%s", ADMIN_PATH, USER_ID)) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + } + + @Test + @SneakyThrows + @WithMockNumUser( + roles = {SUPER_ADMIN, ORGANIZATION_ADMIN}) + public void shouldApproveUserSuccessfully() { + stubFor( + WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73") + .willReturn(okJson( + "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a73\",\"username\": \"new-user\", \"firstname\":\"John\", \"email\": \"john.doe@highmed.org\"}"))); + mockMvc + .perform( + post(String.format("%s/%s/%s", ADMIN_PATH, USER_ID_TO_BE_APPROVED, "approve")) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + } + + @Test + @SneakyThrows + @WithMockNumUser(roles = {SUPER_ADMIN}) + public void shouldUpdateUserStatusSuccessfully() { + stubFor( + WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73") + .willReturn(okJson( + "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a73\",\"username\": \"new-user\", \"firstname\":\"John\", \"email\": \"john.doe@highmed.org\", \"enabled\": \"true\"}"))); + stubFor(WireMock.put("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73").willReturn(okJson("[]"))); + stubFor(WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a73/role-mappings/realm") + .willReturn(okJson("[{\"id\":\"12345-2f04-1156-8f34-12345\",\"name\":\"RESEARCHER\",\"composite\":false,\"clientRole\":false,\"containerId\":\"Num\"}]"))); + mockMvc + .perform( + post(String.format("%s/%s/%s", ADMIN_PATH, USER_ID_TO_BE_APPROVED, "status")) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(mapper.writeValueAsString(Boolean.FALSE)) + ).andExpect(status().isOk()); + } + + @Test + public void shouldGetExternalUrlsSuccessfully() throws Exception { + mockMvc + .perform( + get("/admin/manuel-url") + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.userManualUrl.DE").value("user-manual-de")) + .andExpect(jsonPath("$.userManualUrl.EN").value("user-manual-en")); + } + + +} diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/AqlControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/AqlControllerIT.java similarity index 96% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/AqlControllerIT.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/AqlControllerIT.java index 88eb2cf33..4e005d1bb 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/AqlControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/AqlControllerIT.java @@ -1,33 +1,37 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import de.vitagroup.num.domain.dto.AqlCategoryDto; -import de.vitagroup.num.domain.dto.AqlDto; -import de.vitagroup.num.domain.dto.ParameterOptionsDto; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; +import org.highmed.numportal.domain.dto.AqlCategoryDto; +import org.highmed.numportal.domain.dto.AqlDto; +import org.highmed.numportal.domain.dto.ParameterOptionsDto; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import static de.vitagroup.num.domain.model.Roles.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.highmed.numportal.domain.model.Roles.*; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +@Slf4j public class AqlControllerIT extends IntegrationTest { private static final String AQL_PATH = "/aql"; @@ -257,6 +261,8 @@ public void shouldRetrieveParameterValues() { .with(csrf())) .andExpect(status().isOk()) .andReturn(); + + assertThat(result.getResponse().getStatus(), is(HttpStatus.OK.value())); assertThat( result.getResponse().getContentAsString(), containsString("\"type\":\"DV_QUANTITY\"")); @@ -345,6 +351,7 @@ public void shouldRetrieveParameterValues() { @Test @SneakyThrows + @Ignore @WithMockNumUser(roles = {CRITERIA_EDITOR}) public void shouldSaveAndDeleteAqlCategorySuccessfully() { diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/CohortControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/CohortControllerIT.java similarity index 89% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/CohortControllerIT.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/CohortControllerIT.java index 3bd6206ba..025e0b3f0 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/CohortControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/CohortControllerIT.java @@ -1,24 +1,25 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; import com.google.common.collect.Lists; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.CohortAqlDto; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.domain.dto.CohortGroupDto; -import de.vitagroup.num.domain.model.*; -import de.vitagroup.num.domain.repository.AqlRepository; -import de.vitagroup.num.domain.repository.CohortRepository; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; +import org.highmed.numportal.domain.model.*; +import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import org.highmed.numportal.domain.dto.CohortAqlDto; +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.domain.dto.CohortGroupDto; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.AqlRepository; +import org.highmed.numportal.domain.repository.CohortRepository; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; import java.nio.charset.StandardCharsets; import java.time.LocalDate; @@ -26,7 +27,7 @@ import java.util.List; import java.util.Map; -import static de.vitagroup.num.domain.model.Roles.*; +import static org.highmed.numportal.domain.model.Roles.*; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -57,6 +58,7 @@ public void shouldNotAccessCohortApiWithWrongRole() { } @Test + @Ignore @SneakyThrows @WithMockNumUser(roles = {STUDY_APPROVER}) public void shouldAccessCohortApiWithRightRole() { @@ -106,6 +108,7 @@ public void shouldAccessCohortApiWithRightRole() { @Test @SneakyThrows + @Ignore @WithMockNumUser( userId = UNAUTHORIZED_USER_ID, roles = {STUDY_COORDINATOR}) @@ -155,6 +158,7 @@ public void shouldHandleInvalidCohort() { } @Test + @Ignore @SneakyThrows @WithMockNumUser(roles = {STUDY_COORDINATOR, MANAGER}) public void shouldHandleCohortWithNullParameter() { @@ -201,12 +205,12 @@ public void shouldHandleCohortWithNullParameter() { String cohortDtoJson = mapper.writeValueAsString(cohortGroupDto); WireMock.stubFor( WireMock.post("/ehrbase/rest/openehr/v1/query/aql/") - .withRequestBody(WireMock.containing("[openEHR-EHR-OBSERVATION.height.v2] where (c1/archetype_details/template_id/value = 'Körpergröße'")) + .withRequestBody(WireMock.containing("[openEHR-EHR-OBSERVATION.height.v2] WHERE (c1/archetype_details/template_id/value = 'Körpergröße'")) .willReturn( WireMock.okJson(IOUtils.toString(getClass().getResourceAsStream("/testdata/height_ehr_ids_result.json"), StandardCharsets.UTF_8)))); WireMock.stubFor(WireMock.post("/ehrbase/rest/openehr/v1/query/aql/") - .withRequestBody(WireMock.containing("Select e/ehr_id/value as F1 from EHR e")) + .withRequestBody(WireMock.containing("SELECT e/ehr_id/value FROM ehr e")) .willReturn(WireMock.okJson(IOUtils.toString(getClass().getResourceAsStream("/testdata/ehr_id_response.json"), StandardCharsets.UTF_8)))); diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/IntegrationTest.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/IntegrationTest.java similarity index 71% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/IntegrationTest.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/IntegrationTest.java index f19c7bf13..5c8e28ce5 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/IntegrationTest.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/IntegrationTest.java @@ -1,12 +1,12 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import de.vitagroup.num.TestNumPortalApplication; -import de.vitagroup.num.integrationtesting.config.AttachmentPostgresqlContainer; -import de.vitagroup.num.integrationtesting.config.NumPostgresqlContainer; -import de.vitagroup.num.integrationtesting.security.TokenGenerator; import lombok.SneakyThrows; +import org.highmed.numportal.TestNumPortalApplication; +import org.highmed.numportal.integrationtesting.config.AttachmentPostgresqlContainer; +import org.highmed.numportal.integrationtesting.config.NumPostgresqlContainer; +import org.highmed.numportal.integrationtesting.security.TokenGenerator; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; @@ -32,20 +32,20 @@ public abstract class IntegrationTest { public static final String UNAUTHORIZED_USER_ID = "b59e5edb-3121-4e0a-8ccb-af6798207a73"; private static final String IDENTITY_PROVIDER_URL = - "/auth/realms/Num/protocol/openid-connect/certs"; + "/realms/Num/protocol/openid-connect/certs"; private static final String IDENTITY_PROVIDER_TOKEN_ENDPOINT = - "/auth/realms/Num/protocol/openid-connect/token"; - private static final String USER_ENDPOINT_USER1 = "/auth/admin/realms/Num/users/user1"; - private static final String USER_ENDPOINT_USER2 = "/auth/admin/realms/Num/users/user2"; + "/realms/Num/protocol/openid-connect/token"; + private static final String USER_ENDPOINT_USER1 = "/admin/realms/Num/users/user1"; + private static final String USER_ENDPOINT_USER2 = "/admin/realms/Num/users/user2"; private static final String USER_ENDPOINT_ALL_APPROVERS = - "/auth/admin/realms/Num/roles/STUDY_APPROVER/users"; + "/admin/realms/Num/roles/STUDY_APPROVER/users"; private static final String EHR_BASE_URL = "/ehrbase/rest/openehr/v1/definition/template/adl1.4/"; @ClassRule - public static PostgreSQLContainer postgreSQLContainer = NumPostgresqlContainer.getInstance("numportal"); + public static PostgreSQLContainer postgreSQLContainer = NumPostgresqlContainer.getInstance("numportal"); @ClassRule - public static PostgreSQLContainer attachmentPostgreSQLContainer = AttachmentPostgresqlContainer.getInstance("num-attachment"); + public static PostgreSQLContainer attachmentPostgreSQLContainer = AttachmentPostgresqlContainer.getInstance("num-attachment"); @Autowired public MockMvc mockMvc; @Rule public WireMockRule wireMockRule = new WireMockRule(8099); @@ -75,10 +75,10 @@ public void setup() { .willReturn( okJson( "[{\"template_id\": \"IDCR - Immunisation summary.v0\",\"concept\": \"IDCR - Immunisation summary.v0\",\"archetype_id\": \"openEHR-EHR-COMPOSITION.health_summary.v1\",\"created_timestamp\": \"2020-11-25T16:19:37.812Z\"}]"))); - stubFor(WireMock.get("/auth/admin/realms/Num/roles/SUPER_ADMIN/users").willReturn(okJson("[]"))); + stubFor(WireMock.get("/admin/realms/Num/roles/SUPER_ADMIN/users").willReturn(okJson("[]"))); stubFor( - WireMock.get("/auth/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a72") + WireMock.get("/admin/realms/Num/users/b59e5edb-3121-4e0a-8ccb-af6798207a72") .willReturn(okJson( - "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a72\",\"username\": \"admin-user\", \"firstname\":\"Admin\", \"email\": \"admin.doe@vitagroup.ag\"}"))); + "{\"id\": \"b59e5edb-3121-4e0a-8ccb-af6798207a72\",\"username\": \"admin-user\", \"firstname\":\"Admin\", \"email\": \"admin.doe@highmed.org\"}"))); } } diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/OrganizationControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/OrganizationControllerIT.java similarity index 91% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/OrganizationControllerIT.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/OrganizationControllerIT.java index 3de8323ee..7185b812a 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/OrganizationControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/OrganizationControllerIT.java @@ -1,30 +1,30 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; import lombok.SneakyThrows; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Set; -import static de.vitagroup.num.domain.model.Roles.SUPER_ADMIN; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.highmed.numportal.domain.model.Roles.SUPER_ADMIN; public class OrganizationControllerIT extends IntegrationTest { @@ -167,8 +167,8 @@ public void shouldHandleGetAllMailDomainsForActiveOrganizations() { List domains = mapper.readValue(result.getResponse().getContentAsString(), List.class); Assert.assertTrue(domains.isEmpty()); OrganizationDto activeOrganization = OrganizationDto.builder() - .name("Organization Test Vita") - .mailDomains(Set.of(("vitagroup.test.ag"))) + .name("Organization Test HiGHmed") + .mailDomains(Set.of(("highmed.test.org"))) .active(Boolean.TRUE) .build(); String organizationJson = mapper.writeValueAsString(activeOrganization); @@ -191,11 +191,11 @@ public void shouldHandleGetAllMailDomainsForActiveOrganizations() { domains = mapper.readValue(result.getResponse().getContentAsString(), List.class); Assert.assertEquals(1, domains.size()); - Optional organization = organizationRepository.findByName("Organization Test Vita"); + Optional organization = organizationRepository.findByName("Organization Test HiGHmed"); OrganizationDto toUpdate = OrganizationDto.builder() - .name("Organization Test Vita") - .mailDomains(Set.of(("vitagroup.test.ag"))) + .name("Organization Test HiGHmed") + .mailDomains(Set.of(("highmed.test.org"))) .active(Boolean.FALSE) .build(); diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/ProjectControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/ProjectControllerIT.java similarity index 95% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/ProjectControllerIT.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/ProjectControllerIT.java index 4396e3a9d..78b17321a 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/ProjectControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/ProjectControllerIT.java @@ -1,22 +1,11 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.google.common.collect.Lists; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectCategories; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.ProjectDto; -import de.vitagroup.num.domain.dto.ProjectViewTO; -import de.vitagroup.num.domain.dto.TemplateInfoDto; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; import lombok.SneakyThrows; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -27,13 +16,24 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; +import org.highmed.numportal.domain.dto.ProjectDto; +import org.highmed.numportal.domain.dto.ProjectViewTO; +import org.highmed.numportal.domain.dto.TemplateInfoDto; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; import java.time.LocalDate; import java.util.List; import java.util.Optional; import java.util.Set; -import static de.vitagroup.num.domain.model.Roles.*; +import static org.highmed.numportal.domain.model.Roles.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; diff --git a/src/test/java/de/vitagroup/num/integrationtesting/tests/TemplateControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/TemplateControllerIT.java similarity index 87% rename from src/test/java/de/vitagroup/num/integrationtesting/tests/TemplateControllerIT.java rename to src/test/java/org/highmed/numportal/integrationtesting/tests/TemplateControllerIT.java index a7a3a6464..60865942f 100644 --- a/src/test/java/de/vitagroup/num/integrationtesting/tests/TemplateControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/TemplateControllerIT.java @@ -1,14 +1,14 @@ -package de.vitagroup.num.integrationtesting.tests; +package org.highmed.numportal.integrationtesting.tests; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.dto.TemplateMetadataDto; -import de.vitagroup.num.integrationtesting.security.WithMockNumUser; import lombok.SneakyThrows; +import org.highmed.numportal.integrationtesting.security.WithMockNumUser; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; +import org.highmed.numportal.domain.dto.TemplateMetadataDto; import java.util.List; diff --git a/src/test/java/de/vitagroup/num/mapper/AqlMapperTest.java b/src/test/java/org/highmed/numportal/mapper/AqlMapperTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/mapper/AqlMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/AqlMapperTest.java index 8de37177c..8f824974a 100644 --- a/src/test/java/de/vitagroup/num/mapper/AqlMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/AqlMapperTest.java @@ -1,23 +1,6 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; -import static org.mockito.Mockito.when; - -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.model.AqlCategory; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.AqlDto; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.repository.AqlRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.service.UserService; - -import java.time.OffsetDateTime; +import org.highmed.numportal.mapper.AqlMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,6 +9,24 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.AqlDto; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.AqlRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; +import org.highmed.numportal.service.UserService; + +import java.time.OffsetDateTime; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.hamcrest.core.IsNull.nullValue; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class AqlMapperTest { diff --git a/src/test/java/de/vitagroup/num/mapper/CohortMapperTest.java b/src/test/java/org/highmed/numportal/mapper/CohortMapperTest.java similarity index 86% rename from src/test/java/de/vitagroup/num/mapper/CohortMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/CohortMapperTest.java index 2c40eec00..d874961e0 100644 --- a/src/test/java/de/vitagroup/num/mapper/CohortMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/CohortMapperTest.java @@ -1,18 +1,7 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.domain.dto.CohortDto; -import de.vitagroup.num.service.AqlService; -import de.vitagroup.num.service.ProjectService; -import java.util.List; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.mapper.CohortMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,6 +10,15 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.CohortDto; +import org.highmed.numportal.service.AqlService; +import org.highmed.numportal.service.ProjectService; + +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; @RunWith(MockitoJUnitRunner.class) public class CohortMapperTest { diff --git a/src/test/java/de/vitagroup/num/mapper/CommentMapperTest.java b/src/test/java/org/highmed/numportal/mapper/CommentMapperTest.java similarity index 84% rename from src/test/java/de/vitagroup/num/mapper/CommentMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/CommentMapperTest.java index 308bb8765..e41d9867f 100644 --- a/src/test/java/de/vitagroup/num/mapper/CommentMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/CommentMapperTest.java @@ -1,11 +1,6 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Comment; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.CommentDto; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.mapper.CommentMapper; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -14,11 +9,17 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.CommentDto; +import org.highmed.numportal.domain.model.Comment; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.service.UserService; import java.time.OffsetDateTime; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; diff --git a/src/test/java/de/vitagroup/num/mapper/OrganizationMapperTest.java b/src/test/java/org/highmed/numportal/mapper/OrganizationMapperTest.java similarity index 68% rename from src/test/java/de/vitagroup/num/mapper/OrganizationMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/OrganizationMapperTest.java index a5d02b3c2..b872957e8 100644 --- a/src/test/java/de/vitagroup/num/mapper/OrganizationMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/OrganizationMapperTest.java @@ -1,9 +1,6 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.MailDomain; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.service.OrganizationService; +import org.highmed.numportal.mapper.OrganizationMapper; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,11 +9,15 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.model.MailDomain; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.service.OrganizationService; import java.util.Set; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.notNullValue; @RunWith(MockitoJUnitRunner.class) @@ -36,11 +37,11 @@ public void shouldConvertEntityToDto() { Organization entity = Organization.builder() .id(2L) .name("organization name") - .domains(Set.of(MailDomain.builder().name("vitagroup.ag").build())) + .domains(Set.of(MailDomain.builder().name("highmed.org").build())) .build(); OrganizationDto dto = organizationMapper.convertToDto(entity); assertThat(dto, notNullValue()); assertThat(dto.getId(), is(entity.getId())); - Assert.assertTrue(dto.getMailDomains().contains("vitagroup.ag")); + Assert.assertTrue(dto.getMailDomains().contains("highmed.org")); } } diff --git a/src/test/java/de/vitagroup/num/mapper/ProjectMapperTest.java b/src/test/java/org/highmed/numportal/mapper/ProjectMapperTest.java similarity index 86% rename from src/test/java/de/vitagroup/num/mapper/ProjectMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/ProjectMapperTest.java index 1109daa64..8c891278e 100644 --- a/src/test/java/de/vitagroup/num/mapper/ProjectMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/ProjectMapperTest.java @@ -1,14 +1,8 @@ -package de.vitagroup.num.mapper; - -import de.vitagroup.num.attachment.service.AttachmentService; -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.ProjectDto; -import de.vitagroup.num.domain.dto.TemplateInfoDto; -import de.vitagroup.num.service.UserService; +package org.highmed.numportal.mapper; + +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.mapper.ProjectMapper; +import org.highmed.numportal.mapper.TemplateMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -17,6 +11,14 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.ProjectDto; +import org.highmed.numportal.domain.dto.TemplateInfoDto; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.service.UserService; import java.util.List; import java.util.Map; diff --git a/src/test/java/de/vitagroup/num/mapper/ProjectViewMapperTest.java b/src/test/java/org/highmed/numportal/mapper/ProjectViewMapperTest.java similarity index 81% rename from src/test/java/de/vitagroup/num/mapper/ProjectViewMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/ProjectViewMapperTest.java index 49ae0dc9e..a935eacb3 100644 --- a/src/test/java/de/vitagroup/num/mapper/ProjectViewMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/ProjectViewMapperTest.java @@ -1,10 +1,6 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Project; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.ProjectViewTO; -import de.vitagroup.num.service.UserService; +import org.highmed.numportal.mapper.ProjectViewMapper; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,12 +10,17 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; - -import java.time.LocalDate; +import org.highmed.numportal.domain.dto.ProjectViewTO; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.service.UserService; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import java.time.LocalDate; + @RunWith(MockitoJUnitRunner.class) public class ProjectViewMapperTest { diff --git a/src/test/java/de/vitagroup/num/mapper/TemplateMapperTest.java b/src/test/java/org/highmed/numportal/mapper/TemplateMapperTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/mapper/TemplateMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/TemplateMapperTest.java index 9b6924a81..467eed118 100644 --- a/src/test/java/de/vitagroup/num/mapper/TemplateMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/TemplateMapperTest.java @@ -1,8 +1,7 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.dto.TemplateInfoDto; -import de.vitagroup.num.domain.dto.TemplateMetadataDto; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; +import org.highmed.numportal.mapper.TemplateMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,6 +9,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.TemplateInfoDto; +import org.highmed.numportal.domain.dto.TemplateMetadataDto; import java.time.OffsetDateTime; import java.util.HashMap; diff --git a/src/test/java/de/vitagroup/num/mapper/UserDetailsMapperTest.java b/src/test/java/org/highmed/numportal/mapper/UserDetailsMapperTest.java similarity index 87% rename from src/test/java/de/vitagroup/num/mapper/UserDetailsMapperTest.java rename to src/test/java/org/highmed/numportal/mapper/UserDetailsMapperTest.java index 08efadbd8..8a0d78763 100644 --- a/src/test/java/de/vitagroup/num/mapper/UserDetailsMapperTest.java +++ b/src/test/java/org/highmed/numportal/mapper/UserDetailsMapperTest.java @@ -1,8 +1,6 @@ -package de.vitagroup.num.mapper; +package org.highmed.numportal.mapper; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.UserDetailsDto; +import org.highmed.numportal.mapper.UserDetailsMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,9 +8,12 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.dto.UserDetailsDto; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.admin.UserDetails; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.notNullValue; @RunWith(MockitoJUnitRunner.class) diff --git a/src/test/java/de/vitagroup/num/service/AqlServiceTest.java b/src/test/java/org/highmed/numportal/service/AqlServiceTest.java similarity index 96% rename from src/test/java/de/vitagroup/num/service/AqlServiceTest.java rename to src/test/java/org/highmed/numportal/service/AqlServiceTest.java index e3ca7e8fd..f02d609fd 100644 --- a/src/test/java/de/vitagroup/num/service/AqlServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/AqlServiceTest.java @@ -1,24 +1,10 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.domain.model.AqlCategory; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.Language; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.dto.SlimAqlDto; -import de.vitagroup.num.domain.repository.AqlCategoryRepository; -import de.vitagroup.num.domain.repository.AqlRepository; -import de.vitagroup.num.domain.specification.AqlSpecification; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.*; import org.ehrbase.aqleditor.dto.aql.QueryValidationResponse; import org.ehrbase.aqleditor.dto.aql.Result; import org.ehrbase.aqleditor.service.AqlEditorAqlService; +import org.highmed.numportal.service.exception.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -31,16 +17,30 @@ import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.data.domain.*; import org.springframework.data.jpa.domain.JpaSort; +import org.highmed.numportal.domain.dto.Language; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.dto.SlimAqlDto; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.domain.model.AqlCategory; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.AqlCategoryRepository; +import org.highmed.numportal.domain.repository.AqlRepository; +import org.highmed.numportal.domain.specification.AqlSpecification; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.service.ehrbase.EhrBaseService; import java.time.OffsetDateTime; import java.util.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_ACCESS_THIS_RESOURCE_USER_IS_NOT_APPROVED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.notNullValue; import static org.mockito.Mockito.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_ACCESS_THIS_RESOURCE_USER_IS_NOT_APPROVED; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; @RunWith(MockitoJUnitRunner.class) public class AqlServiceTest { diff --git a/src/test/java/de/vitagroup/num/service/CohortServiceTest.java b/src/test/java/org/highmed/numportal/service/CohortServiceTest.java similarity index 95% rename from src/test/java/de/vitagroup/num/service/CohortServiceTest.java rename to src/test/java/org/highmed/numportal/service/CohortServiceTest.java index 048c01263..475a7bd46 100644 --- a/src/test/java/de/vitagroup/num/service/CohortServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/CohortServiceTest.java @@ -1,18 +1,11 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.domain.model.*; -import de.vitagroup.num.domain.repository.CohortRepository; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.domain.templates.ExceptionsTemplate; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.*; -import de.vitagroup.num.service.executors.CohortExecutor; -import de.vitagroup.num.service.policy.ProjectPolicyService; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.response.openehr.QueryResponseData; +package org.highmed.numportal.service; + +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.service.exception.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -20,20 +13,28 @@ import org.mockito.*; import org.mockito.junit.MockitoJUnitRunner; import org.modelmapper.ModelMapper; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.CohortRepository; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.domain.templates.ExceptionsTemplate; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.executors.CohortExecutor; +import org.highmed.numportal.service.policy.ProjectPolicyService; import java.util.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_ACCESS_THIS_RESOURCE_USER_IS_NOT_APPROVED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_ACCESS_THIS_RESOURCE_USER_IS_NOT_APPROVED; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; @RunWith(MockitoJUnitRunner.class) public class CohortServiceTest { @@ -87,7 +88,7 @@ public class CohortServiceTest { private final String Q1 = "Select c0 as test from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; private final String Q2 = "SELECT c0 as GECCO_Personendaten " + "FROM EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.registereintrag.v1] contains CLUSTER c1[openEHR-EHR-CLUSTER.person_birth_data_iso.v0] " + - "WHERE (c0/archetype_details/template_id/value = 'GECCO_Personendaten'"; + "WHERE c0/archetype_details/template_id/value = 'GECCO_Personendaten'"; private final String Q3 = "SELECT c0 as GECCO_Personendaten " + "FROM EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.registereintrag.v1] contains CLUSTER c1[openEHR-EHR-CLUSTER.person_birth_data_iso.v0] " + @@ -470,7 +471,7 @@ public void getSizePerTemplatesTest() { String query = "SELECT c0 as GECCO_Personendaten " + "FROM EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.registereintrag.v1] " + "contains CLUSTER c1[openEHR-EHR-CLUSTER.person_birth_data_iso.v0] " + - "WHERE (c0/archetype_details/template_id/value = 'GECCO_Personendaten' and c1/items[at0001]/value/value > $Geburtsdatum"; + "WHERE (c0/archetype_details/template_id/value = 'GECCO_Personendaten' and c1/items[at0001]/value/value > $Geburtsdatum)"; when(aqlService.existsById(99L)).thenReturn(true); CohortDto cohortDto = CohortDto.builder() .cohortGroup(CohortGroupDto.builder() @@ -490,7 +491,7 @@ public void getSizePerTemplatesTest() { .build(); when(cohortExecutor.execute(any(Cohort.class), Mockito.eq(false))) .thenReturn(Set.of("1", "2", "3", "4", "5")); - org.ehrbase.aql.dto.AqlDto aqlDto = new AqlToDtoParser().parse(query); + AqlQuery aqlDto = AqlQueryParser.parse(query); when(templateService.createSelectCompositionQuery(Mockito.eq("Alter"))).thenReturn(aqlDto); when(ehrBaseService.retrieveEligiblePatientIds(Mockito.any(String.class))).thenReturn(Set.of("id1", "id2", "id3")); cohortService.getSizePerTemplates(approvedUser.getUserId(), requestDto); diff --git a/src/test/java/de/vitagroup/num/service/CommentServiceTest.java b/src/test/java/org/highmed/numportal/service/CommentServiceTest.java similarity index 87% rename from src/test/java/de/vitagroup/num/service/CommentServiceTest.java rename to src/test/java/org/highmed/numportal/service/CommentServiceTest.java index fbd8f92c2..0790d2b53 100644 --- a/src/test/java/de/vitagroup/num/service/CommentServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/CommentServiceTest.java @@ -1,21 +1,8 @@ -package de.vitagroup.num.service; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_DELETE_COMMENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COMMENT_EDIT_FOR_COMMENT_WITH_ID_IS_NOT_ALLOWED_COMMENT_HAS_DIFFERENT_AUTHOR; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COMMENT_NOT_FOUND; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_COMMENT_ID; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_DOES_NOT_EXIST; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.PROJECT_NOT_FOUND; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThrows; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.time.OffsetDateTime; -import java.util.Optional; +package org.highmed.numportal.service; -import de.vitagroup.num.domain.model.Project; +import org.highmed.numportal.service.CommentService; +import org.highmed.numportal.service.ProjectService; +import org.highmed.numportal.service.UserDetailsService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,14 +11,24 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.dao.EmptyResultDataAccessException; +import org.highmed.numportal.domain.model.Comment; +import org.highmed.numportal.domain.model.Project; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.CommentRepository; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; -import de.vitagroup.num.domain.model.Comment; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.repository.CommentRepository; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; +import java.time.OffsetDateTime; +import java.util.Optional; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; +import static org.junit.Assert.assertThrows; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class CommentServiceTest { diff --git a/src/test/java/de/vitagroup/num/service/ContentServiceTest.java b/src/test/java/org/highmed/numportal/service/ContentServiceTest.java similarity index 90% rename from src/test/java/de/vitagroup/num/service/ContentServiceTest.java rename to src/test/java/org/highmed/numportal/service/ContentServiceTest.java index 89cf7de12..f7615c5f3 100644 --- a/src/test/java/de/vitagroup/num/service/ContentServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/ContentServiceTest.java @@ -1,41 +1,38 @@ -package de.vitagroup.num.service; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_PARSE_CARD; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_PARSE_NAVIGATION_CONTENT; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_SAVE_CARD; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COULDN_T_SAVE_NAVIGATION_CONTENT; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +package org.highmed.numportal.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Content; -import de.vitagroup.num.domain.model.ContentType; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.CardDto; -import de.vitagroup.num.domain.dto.CardDto.LocalizedPart; -import de.vitagroup.num.domain.dto.MetricsDto; -import de.vitagroup.num.domain.dto.NavigationItemDto; -import de.vitagroup.num.domain.repository.ContentItemRepository; +import org.apache.logging.log4j.util.Strings; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.*; +import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.dto.CardDto; +import org.highmed.numportal.domain.dto.CardDto.LocalizedPart; +import org.highmed.numportal.domain.dto.MetricsDto; +import org.highmed.numportal.domain.dto.NavigationItemDto; +import org.highmed.numportal.domain.model.Content; +import org.highmed.numportal.domain.model.ContentType; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.ContentItemRepository; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.SystemException; import java.net.MalformedURLException; import java.net.URL; import java.util.*; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.SystemException; -import joptsimple.internal.Strings; -import org.ehrbase.response.openehr.QueryResponseData; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.*; -import org.mockito.junit.MockitoJUnitRunner; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) public class ContentServiceTest { diff --git a/src/test/java/de/vitagroup/num/service/EhrBaseServiceTest.java b/src/test/java/org/highmed/numportal/service/EhrBaseServiceTest.java similarity index 64% rename from src/test/java/de/vitagroup/num/service/EhrBaseServiceTest.java rename to src/test/java/org/highmed/numportal/service/EhrBaseServiceTest.java index 38a5df510..234068ffa 100644 --- a/src/test/java/de/vitagroup/num/service/EhrBaseServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/EhrBaseServiceTest.java @@ -1,23 +1,18 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.Aql; -import de.vitagroup.num.service.ehrbase.CompositionResponseDataBuilder; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.ehrbase.Pseudonymity; -import de.vitagroup.num.service.exception.SystemException; -import org.ehrbase.aql.parser.AqlParseException; -import org.ehrbase.aql.parser.AqlToDtoParser; -import org.ehrbase.client.aql.field.AqlFieldImp; -import org.ehrbase.client.aql.query.EntityQuery; -import org.ehrbase.client.aql.query.Query; -import org.ehrbase.client.aql.record.Record; -import org.ehrbase.client.exception.ClientException; -import org.ehrbase.client.exception.WrongStatusCodeException; -import org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; -import org.ehrbase.response.openehr.QueryResponseData; -import org.ehrbase.response.openehr.TemplatesResponseData; +import org.ehrbase.openehr.sdk.aql.parser.AqlParseException; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClient; +import org.ehrbase.openehr.sdk.generator.commons.aql.query.NativeQuery; +import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; +import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.TemplatesResponseData; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; +import org.ehrbase.openehr.sdk.util.exception.ClientException; +import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; +import org.highmed.numportal.properties.EhrBaseProperties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,6 +21,11 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.Aql; +import org.highmed.numportal.service.ehrbase.CompositionResponseDataBuilder; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.ehrbase.Pseudonymity; +import org.highmed.numportal.service.exception.SystemException; import java.util.ArrayList; import java.util.Collections; @@ -53,38 +53,38 @@ public class EhrBaseServiceTest { @Mock private Pseudonymity pseudonymity; + @Mock + private EhrBaseProperties ehrBaseProperties; + @InjectMocks private EhrBaseService ehr; private static final String GOOD_QUERY = - "Select c0 as test from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; - - private static final String BAD_QUERY = - "Select c0 as test contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; + "Select c0 as test from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; @Test(expected = WrongStatusCodeException.class) public void shouldHandleBadAqlQuery() { when(restClient.aqlEndpoint().execute(any(Query.class))) - .thenThrow(WrongStatusCodeException.class); + .thenThrow(WrongStatusCodeException.class); ehr.retrieveEligiblePatientIds(Aql.builder().query("SELECT e/ehr_id/value FROM EHR e").build()); } @Test(expected = AqlParseException.class) public void shouldHandleMalformedAqlQuery() { when(restClient.aqlEndpoint().execute(any(Query.class))) - .thenThrow(WrongStatusCodeException.class); + .thenThrow(WrongStatusCodeException.class); ehr.retrieveEligiblePatientIds(Aql.builder().query("SLECT e/ehr_id/value FROM EHR e").build()); } + @Test public void shouldReplaceSelect() { when(restClient.aqlEndpoint().execute(any(Query.class))).thenReturn(Collections.emptyList()); ehr.retrieveEligiblePatientIds(Aql.builder().query("SELECT e/ehr_id FROM EHR e").build()); - ArgumentCaptor> queryArgumentCaptor = - ArgumentCaptor.forClass(EntityQuery.class); + ArgumentCaptor> queryArgumentCaptor = + ArgumentCaptor.forClass(NativeQuery.class); verify(restClient.aqlEndpoint(), times(1)).execute(queryArgumentCaptor.capture()); - AqlFieldImp fieldImp = (AqlFieldImp) queryArgumentCaptor.getValue().fields()[0]; - assertThat(fieldImp.getPath(), is("/ehr_id/value")); + assertThat(queryArgumentCaptor.getValue().buildAql(), is("SELECT e/ehr_id/value FROM EHR e")); } @Test @@ -109,20 +109,21 @@ public void shouldHandleExceptionWhenRetrieveAllTemplates() { public void shouldFlattenResultsWhenContainsComposition() { QueryResponseData compositionsQueryResponseData = new QueryResponseData(); List> columns = - new ArrayList<>(List.of(Map.of("path", "/ehr_status/subject/external_ref/id/value"), Map.of("uuid", "c/uuid"))); + new ArrayList<>(List.of(Map.of("path", "/ehr_status/subject/external_ref/id/value"), Map.of("uuid", "c/uuid"))); List> rows = - List.of( - new ArrayList<>(List.of("testehrId", Map.of("_type", "COMPOSITION", "uuid", "12345"))), - new ArrayList<>(List.of("testehrId2", Map.of("_type", "COMPOSITION", "uuid", "bla")))); + List.of( + new ArrayList<>(List.of("testehrId", Map.of("_type", "COMPOSITION", "uuid", "12345"))), + new ArrayList<>(List.of("testehrId2", Map.of("_type", "COMPOSITION", "uuid", "bla")))); compositionsQueryResponseData.setColumns(columns); compositionsQueryResponseData.setRows(rows); + when(ehrBaseProperties.getIdPath()).thenReturn("ehr_status/subject/external_ref/id/value"); when(restClient.aqlEndpoint().executeRaw(Query.buildNativeQuery(any()))) - .thenReturn(compositionsQueryResponseData); + .thenReturn(compositionsQueryResponseData); when(compositionResponseDataBuilder.build(any())).thenReturn(compositionsQueryResponseData); - ehr.executeRawQuery(new AqlToDtoParser().parse(GOOD_QUERY), 1L); + ehr.executeRawQuery(AqlQueryParser.parse(GOOD_QUERY), 1L); verify(compositionResponseDataBuilder, times(1)).build(any()); } @@ -131,23 +132,25 @@ public void shouldNotFlattenResults() { QueryResponseData response = new QueryResponseData(); response.setColumns( - new ArrayList<>(List.of(Map.of("path", "/ehr_status/subject/external_ref/id/value"), Map.of("uuid", "c/uuid")))); + new ArrayList<>(List.of(Map.of("path", "/ehr_status/subject/external_ref/id/value"), Map.of("uuid", "c/uuid")))); response.setRows(List.of( - new ArrayList<>(List.of("testehrid1", Map.of("_type", "OBSERVATION", "uuid", "12345"))), - new ArrayList<>(List.of("testehrid2", Map.of("_type", "SECTION", "uuid", "bla"))))); + new ArrayList<>(List.of("testehrid1", Map.of("_type", "OBSERVATION", "uuid", "12345"))), + new ArrayList<>(List.of("testehrid2", Map.of("_type", "SECTION", "uuid", "bla"))))); + when(ehrBaseProperties.getIdPath()).thenReturn("ehr_status/subject/external_ref/id/value"); when(restClient.aqlEndpoint().executeRaw(Query.buildNativeQuery(any()))) - .thenReturn(response); + .thenReturn(response); - ehr.executeRawQuery(new AqlToDtoParser().parse(GOOD_QUERY), 1L); + ehr.executeRawQuery(AqlQueryParser.parse(GOOD_QUERY), 1L); verify(compositionResponseDataBuilder, times(0)).build(any()); } @Test(expected = SystemException.class) public void shouldHandleClientExceptionWhenExecutingAql() { + when(ehrBaseProperties.getIdPath()).thenReturn("path/to/config"); when(restClient.aqlEndpoint().executeRaw(Query.buildNativeQuery(any()))) - .thenThrow(ClientException.class); - ehr.executeRawQuery(new AqlToDtoParser().parse(GOOD_QUERY), 1L); + .thenThrow(ClientException.class); + ehr.executeRawQuery(AqlQueryParser.parse(GOOD_QUERY), 1L); } @Test(expected = SystemException.class) public void shouldHandleClientExceptionWhenConnectToEhrBase() { @@ -160,7 +163,7 @@ public void shouldHandleClientExceptionWhenConnectToEhrBase() { public void shouldHandleWrongStatusCodeExceptionWhenExecutingAql(){ when(restClient.aqlEndpoint().executeRaw(Query.buildNativeQuery(any()))) .thenThrow(WrongStatusCodeException.class); - ehr.executeRawQuery(new AqlToDtoParser().parse(GOOD_QUERY), 1L); + ehr.executeRawQuery(AqlQueryParser.parse(GOOD_QUERY), 1L); } @Test(expected = WrongStatusCodeException.class) @@ -194,4 +197,4 @@ public void setup() { when(restClient.templateEndpoint().findAllTemplates()).thenReturn(templatesResponseData); when(pseudonymity.getPseudonyms(anyList(), anyLong())).thenReturn(List.of("codex_43DG23", "codex_43DG22")); } -} +} \ No newline at end of file diff --git a/src/test/java/de/vitagroup/num/service/OrganizationServiceTest.java b/src/test/java/org/highmed/numportal/service/OrganizationServiceTest.java similarity index 94% rename from src/test/java/de/vitagroup/num/service/OrganizationServiceTest.java rename to src/test/java/org/highmed/numportal/service/OrganizationServiceTest.java index 6fc6d85e5..b17ebe062 100644 --- a/src/test/java/de/vitagroup/num/service/OrganizationServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/OrganizationServiceTest.java @@ -1,18 +1,5 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.MailDomain; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.dto.SearchCriteria; -import de.vitagroup.num.domain.repository.MailDomainRepository; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.specification.OrganizationSpecification; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.exception.SystemException; +package org.highmed.numportal.service; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -27,12 +14,25 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.SearchCriteria; +import org.highmed.numportal.domain.model.MailDomain; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.MailDomainRepository; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.specification.OrganizationSpecification; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.exception.SystemException; import java.util.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -205,14 +205,14 @@ public void shouldHandleNotUniqueOrganizationName() { public void shouldHandleNotUniqueMailDomain() { organizationService.create( "approvedUserId", - OrganizationDto.builder().name("Organization").mailDomains(Set.of("vitagroup.ag")).build()); + OrganizationDto.builder().name("Organization").mailDomains(Set.of("highmed.org")).build()); } @Test(expected = BadRequestException.class) public void shouldHandleNotUniqueMailDomainInMixCase() { organizationService.create( "approvedUserId", - OrganizationDto.builder().name("Organization").mailDomains(Set.of("vitagroup.ag")).build()); + OrganizationDto.builder().name("Organization").mailDomains(Set.of("highmed.org")).build()); } @Test @@ -277,7 +277,7 @@ public void shouldHandleExistingEmailDomain() { 3L, OrganizationDto.builder() .name("Good name") - .mailDomains(Set.of("some mail domain name", "vitagroup.ag")) + .mailDomains(Set.of("some mail domain name", "highmed.org")) .build(), List.of(Roles.SUPER_ADMIN), "approvedUserId"); @@ -461,9 +461,9 @@ public void setup() { when(organizationRepository.findById(33L)) .thenReturn(Optional.of(Organization.builder().id(33L).active(Boolean.TRUE).name("Organization name").build())); - when(mailDomainRepository.findByName("vitagroup.ag")) + when(mailDomainRepository.findByName("highmed.org")) .thenReturn(Optional.of(MailDomain.builder() - .name("vitagroup.ag") + .name("highmed.org") .organization(Organization.builder().id(33L).build()) .build())); } diff --git a/src/test/java/de/vitagroup/num/service/ProjectDocCreatorTest.java b/src/test/java/org/highmed/numportal/service/ProjectDocCreatorTest.java similarity index 85% rename from src/test/java/de/vitagroup/num/service/ProjectDocCreatorTest.java rename to src/test/java/org/highmed/numportal/service/ProjectDocCreatorTest.java index 403e4d1bc..7ff863a52 100644 --- a/src/test/java/de/vitagroup/num/service/ProjectDocCreatorTest.java +++ b/src/test/java/org/highmed/numportal/service/ProjectDocCreatorTest.java @@ -1,11 +1,8 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.dto.ProjectDto; -import de.vitagroup.num.domain.dto.UserDetailsDto; -import de.vitagroup.num.domain.model.*; -import de.vitagroup.num.domain.repository.CohortRepository; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.service.ProjectDocCreator; +import org.highmed.numportal.service.UserService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,6 +11,11 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.context.MessageSource; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.dto.ProjectDto; +import org.highmed.numportal.domain.dto.UserDetailsDto; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.repository.CohortRepository; import java.io.IOException; import java.time.OffsetDateTime; diff --git a/src/test/java/de/vitagroup/num/service/ProjectServiceTest.java b/src/test/java/org/highmed/numportal/service/ProjectServiceTest.java similarity index 90% rename from src/test/java/de/vitagroup/num/service/ProjectServiceTest.java rename to src/test/java/org/highmed/numportal/service/ProjectServiceTest.java index 7a3c753db..c1fd83ddc 100644 --- a/src/test/java/de/vitagroup/num/service/ProjectServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/ProjectServiceTest.java @@ -1,39 +1,20 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.attachment.service.AttachmentService; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.domain.model.*; -import de.vitagroup.num.domain.repository.ProjectRepository; -import de.vitagroup.num.domain.specification.ProjectSpecification; -import de.vitagroup.num.mapper.ProjectMapper; -import de.vitagroup.num.properties.ConsentProperties; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.service.atna.AtnaService; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.ehrbase.ResponseFilter; -import de.vitagroup.num.service.exception.*; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.Notification; -import de.vitagroup.num.service.notification.dto.ProjectCloseNotification; -import de.vitagroup.num.service.notification.dto.ProjectStartNotification; -import de.vitagroup.num.service.notification.dto.ProjectStatusChangeRequestNotification; -import de.vitagroup.num.service.policy.ProjectPolicyService; -import org.ehrbase.aql.binder.AqlBinder; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorDto; -import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorSymbol; -import org.ehrbase.aql.dto.condition.MatchesOperatorDto; -import org.ehrbase.aql.dto.condition.SimpleValue; -import org.ehrbase.aql.dto.select.SelectFieldDto; -import org.ehrbase.aql.parser.AqlParseException; -import org.ehrbase.aql.parser.AqlToDtoParser; import org.ehrbase.aqleditor.service.AqlEditorAqlService; -import org.ehrbase.client.aql.field.EhrFields; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.condition.LogicalOperatorCondition; +import org.ehrbase.openehr.sdk.aql.dto.condition.MatchesCondition; +import org.ehrbase.openehr.sdk.aql.dto.operand.Primitive; +import org.ehrbase.openehr.sdk.aql.parser.AqlParseException; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.ehrbase.openehr.sdk.aql.render.AqlRenderer; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.attachment.service.AttachmentService; +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.service.exception.*; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; @@ -47,6 +28,22 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.util.MultiValueMap; import org.springframework.web.multipart.MultipartFile; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.ProjectRepository; +import org.highmed.numportal.domain.specification.ProjectSpecification; +import org.highmed.numportal.mapper.ProjectMapper; +import org.highmed.numportal.properties.ConsentProperties; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.service.atna.AtnaService; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.ehrbase.ResponseFilter; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.Notification; +import org.highmed.numportal.service.notification.dto.ProjectCloseNotification; +import org.highmed.numportal.service.notification.dto.ProjectStartNotification; +import org.highmed.numportal.service.notification.dto.ProjectStatusChangeRequestNotification; +import org.highmed.numportal.service.policy.ProjectPolicyService; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -61,13 +58,13 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import static de.vitagroup.num.domain.model.ProjectStatus.*; -import static de.vitagroup.num.domain.model.Roles.*; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; +import static org.highmed.numportal.domain.model.ProjectStatus.*; +import static org.highmed.numportal.domain.model.Roles.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -109,7 +106,7 @@ public class ProjectServiceTest { private static final String QUERY_5 = "SELECT c0 as openEHR_EHR_COMPOSITION_self_monitoring_v0, c1 as openEHR_EHR_COMPOSITION_report_v1 FROM EHR e contains (COMPOSITION c0[openEHR-EHR-COMPOSITION.self_monitoring.v0] and COMPOSITION c2[openEHR-EHR-COMPOSITION.self_monitoring.v0] and COMPOSITION c1[openEHR-EHR-COMPOSITION.report.v1])"; - @Captor ArgumentCaptor aqlDtoArgumentCaptor; + @Captor ArgumentCaptor aqlDtoArgumentCaptor; @Mock private ProjectRepository projectRepository; @@ -164,24 +161,17 @@ public class ProjectServiceTest { public void shouldCorrectlyValidateInvalidQuery() { String query = "Select e/ehr_id/value as F1, c0 as F1 from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; - new AqlToDtoParser().parse(query); + AqlQueryParser.parse(query); } @Test - @Ignore( - value = "This should pass when https://github.com/ehrbase/openEHR_SDK/issues/216 is fixed") public void shouldCorrectlyGenerateAliases() { String query = "Select c0 as F1 from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; - AqlDto dto = new AqlToDtoParser().parse(query); - - SelectFieldDto selectFieldDto = new SelectFieldDto(); - selectFieldDto.setAqlPath(EhrFields.EHR_ID().getPath()); - selectFieldDto.setContainmentId(dto.getEhr().getContainmentId()); - dto.getSelect().getStatement().add(0, selectFieldDto); + AqlQuery dto = AqlQueryParser.parse(query); - String editedQuery = new AqlBinder().bind(dto).getLeft().buildAql(); + String editedQuery = AqlRenderer.render(dto); Matcher matcher = Pattern.compile("F1").matcher(editedQuery); @@ -333,29 +323,29 @@ public void shouldBeConsistentInParsingAql() { + "and c0/archetype_details/template_id/value matches {'Corona_Anamnese'} " + "and c1/archetype_details/template_id/value matches {'Corona_Anamnese'})"; - AqlDto initialDto = new AqlToDtoParser().parse(initialQuery); + AqlQuery initialDto = AqlQueryParser.parse(initialQuery); assertThat(initialDto.getWhere(), notNullValue()); - assertThat(((ConditionLogicalOperatorDto) initialDto.getWhere()).getValues(), notNullValue()); - assertThat(((ConditionLogicalOperatorDto) initialDto.getWhere()).getValues().size(), is(3)); + assertThat(((LogicalOperatorCondition) initialDto.getWhere()).getValues(), notNullValue()); + assertThat(((LogicalOperatorCondition) initialDto.getWhere()).getValues().size(), is(3)); - String initialDtoToString = new AqlBinder().bind(initialDto).getLeft().buildAql(); - AqlDto parsedQuery = new AqlToDtoParser().parse(initialDtoToString); + String initialDtoToString = AqlRenderer.render(initialDto); + AqlQuery parsedQuery = AqlQueryParser.parse(initialDtoToString); assertThat(parsedQuery.getWhere(), notNullValue()); - assertThat(((ConditionLogicalOperatorDto) parsedQuery.getWhere()).getValues(), notNullValue()); - assertThat(((ConditionLogicalOperatorDto) parsedQuery.getWhere()).getValues().size(), is(3)); + assertThat(((LogicalOperatorCondition) parsedQuery.getWhere()).getValues(), notNullValue()); + assertThat(((LogicalOperatorCondition) parsedQuery.getWhere()).getValues().size(), is(3)); } @Test public void shouldHandleQuery5() { - AqlDto initialQueryDto = new AqlToDtoParser().parse(QUERY_5); + AqlQuery initialQueryDto = AqlQueryParser.parse(QUERY_5); assertThat(initialQueryDto, notNullValue()); assertThat(initialQueryDto.getWhere(), nullValue()); projectService.executeAql(QUERY_5, 2L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQuery = aqlDtoArgumentCaptor.getValue(); + AqlQuery restrictedQuery = aqlDtoArgumentCaptor.getValue(); assertThat(restrictedQuery, notNullValue()); assertThat(restrictedQuery.getWhere(), notNullValue()); @@ -367,7 +357,7 @@ public void shouldHandleQuery5() { public void shouldExecuteAqlForProjectOutsideEU() { projectService.executeAql(QUERY_5, 33L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQuery = aqlDtoArgumentCaptor.getValue(); + AqlQuery restrictedQuery = aqlDtoArgumentCaptor.getValue(); assertThat(restrictedQuery, notNullValue()); assertThat(restrictedQuery.getWhere(), notNullValue()); @@ -392,76 +382,76 @@ public void shouldNotExecuteIfProjectNotPublished() { public void shouldHandleQuery3() { projectService.executeAql(QUERY_3, 2L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQuery = aqlDtoArgumentCaptor.getValue(); + AqlQuery restrictedQuery = aqlDtoArgumentCaptor.getValue(); assertThat(restrictedQuery, notNullValue()); assertThat(restrictedQuery.getWhere(), notNullValue()); - ConditionLogicalOperatorDto conditionDto0 = - (ConditionLogicalOperatorDto) restrictedQuery.getWhere(); - assertThat(conditionDto0.getSymbol(), is(ConditionLogicalOperatorSymbol.AND)); + LogicalOperatorCondition conditionDto0 = + (LogicalOperatorCondition) restrictedQuery.getWhere(); + assertThat(conditionDto0.getSymbol(), is(LogicalOperatorCondition.ConditionLogicalOperatorSymbol.AND)); assertThat(conditionDto0.getValues().size(), is(3)); - ConditionLogicalOperatorDto conditionDto = - (ConditionLogicalOperatorDto) conditionDto0.getValues().get(0); + LogicalOperatorCondition conditionDto = + (LogicalOperatorCondition) conditionDto0.getValues().get(0); assertThat(conditionDto.getValues().size(), is(1)); assertTrue( conditionDto.getValues().stream() - .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesOperatorDto)); + .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesCondition)); - MatchesOperatorDto ehrMatches = (MatchesOperatorDto) conditionDto.getValues().get(0); + MatchesCondition ehrMatches = (MatchesCondition) conditionDto.getValues().get(0); assertThat(ehrMatches.getValues().size(), is(2)); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_1))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_1))); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_2))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_2))); - MatchesOperatorDto templatesMatches = (MatchesOperatorDto) conditionDto0.getValues().get(1); + MatchesCondition templatesMatches = (MatchesCondition) conditionDto0.getValues().get(1); assertThat(templatesMatches.getValues().size(), is(1)); assertTrue( templatesMatches.getValues().stream() - .anyMatch(t -> ((SimpleValue) t).getValue().equals(CORONA_TEMPLATE))); + .anyMatch(t -> ((Primitive) t).getValue().equals(CORONA_TEMPLATE))); } @Test public void shouldHandleQuery4() { projectService.executeAql(QUERY_4, 2L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQuery = aqlDtoArgumentCaptor.getValue(); + AqlQuery restrictedQuery = aqlDtoArgumentCaptor.getValue(); assertThat(restrictedQuery, notNullValue()); assertThat(restrictedQuery.getWhere(), notNullValue()); - ConditionLogicalOperatorDto conditionDto0 = - (ConditionLogicalOperatorDto) restrictedQuery.getWhere(); - assertThat(conditionDto0.getSymbol(), is(ConditionLogicalOperatorSymbol.AND)); + LogicalOperatorCondition conditionDto0 = + (LogicalOperatorCondition) restrictedQuery.getWhere(); + assertThat(conditionDto0.getSymbol(), is(LogicalOperatorCondition.ConditionLogicalOperatorSymbol.AND)); assertThat(conditionDto0.getValues().size(), is(4)); - ConditionLogicalOperatorDto conditionDto = - (ConditionLogicalOperatorDto) conditionDto0.getValues().get(0); + LogicalOperatorCondition conditionDto = + (LogicalOperatorCondition) conditionDto0.getValues().get(0); assertThat(conditionDto.getValues().size(), is(1)); assertTrue( conditionDto.getValues().stream() - .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesOperatorDto)); + .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesCondition)); - MatchesOperatorDto ehrMatches = (MatchesOperatorDto) conditionDto.getValues().get(0); + MatchesCondition ehrMatches = (MatchesCondition) conditionDto.getValues().get(0); assertThat(ehrMatches.getValues().size(), is(2)); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_1))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_1))); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_2))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_2))); - MatchesOperatorDto templatesMatches = (MatchesOperatorDto) conditionDto0.getValues().get(1); + MatchesCondition templatesMatches = (MatchesCondition) conditionDto0.getValues().get(1); assertThat(templatesMatches.getValues().size(), is(1)); assertTrue( templatesMatches.getValues().stream() - .anyMatch(t -> ((SimpleValue) t).getValue().equals(CORONA_TEMPLATE))); + .anyMatch(t -> ((Primitive) t).getValue().equals(CORONA_TEMPLATE))); } @Test(expected = BadRequestException.class) @@ -479,19 +469,19 @@ public void shouldCorrectlyRestrictQueryWithContainsAndNoComposition() { projectService.executeAql(QUERY_2, 4L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQueryDto = aqlDtoArgumentCaptor.getValue(); - String restrictedQuery = new AqlBinder().bind(restrictedQueryDto).getLeft().buildAql(); + AqlQuery restrictedQueryDto = aqlDtoArgumentCaptor.getValue(); + String restrictedQuery = AqlRenderer.render(restrictedQueryDto); - new AqlToDtoParser().parse(restrictedQuery); + AqlQueryParser.parse(restrictedQuery); String expectedQuery = - "Select e/ehr_id/value as F1, " - + "o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value as F2, " - + "o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value as F3 " - + "from EHR e " - + "contains (COMPOSITION c0 and SECTION s4[openEHR-EHR-SECTION.adhoc.v1] " - + "contains OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]) " - + "where (e/ehr_id/value matches {'47dc21a2-7076-4a57-89dc-bd83729ed52f'} and c0/archetype_details/template_id/value matches {'Corona_Anamnese'})"; + "SELECT e/ehr_id/value AS F1, " + + "o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value AS F2, " + + "o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value AS F3 " + + "FROM EHR e " + + "CONTAINS (COMPOSITION c1 AND (SECTION s4[openEHR-EHR-SECTION.adhoc.v1] " + + "CONTAINS OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0])) " + + "WHERE ((e/ehr_id/value MATCHES {'47dc21a2-7076-4a57-89dc-bd83729ed52f'}) AND c1/archetype_details/template_id/value MATCHES {'Corona_Anamnese'})"; assertEquals(restrictedQuery, expectedQuery); } @@ -500,10 +490,10 @@ public void shouldCorrectlyRestrictQueryWithContainsAndNoComposition() { public void shouldCorrectlyRestrictBasicQuery() { projectService.executeAql(QUERY_BASIC, 2L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQueryDto = aqlDtoArgumentCaptor.getValue(); - String restrictedQuery = new AqlBinder().bind(restrictedQueryDto).getLeft().buildAql(); + AqlQuery restrictedQueryDto = aqlDtoArgumentCaptor.getValue(); + String restrictedQuery = AqlRenderer.render(restrictedQueryDto); - new AqlToDtoParser().parse(restrictedQuery); + AqlQueryParser.parse(restrictedQuery); } @Test @@ -511,36 +501,36 @@ public void shouldCorrectlyRestrictQuery() { projectService.executeAql(QUERY_1, 2L, "approvedCoordinatorId"); Mockito.verify(ehrBaseService).executeRawQuery(aqlDtoArgumentCaptor.capture(), any()); - AqlDto restrictedQuery = aqlDtoArgumentCaptor.getValue(); + AqlQuery restrictedQuery = aqlDtoArgumentCaptor.getValue(); assertThat(restrictedQuery.getWhere(), notNullValue()); - ConditionLogicalOperatorDto conditionDto0 = - (ConditionLogicalOperatorDto) restrictedQuery.getWhere(); - assertThat(conditionDto0.getSymbol(), is(ConditionLogicalOperatorSymbol.AND)); + LogicalOperatorCondition conditionDto0 = + (LogicalOperatorCondition) restrictedQuery.getWhere(); + assertThat(conditionDto0.getSymbol(), is(LogicalOperatorCondition.ConditionLogicalOperatorSymbol.AND)); assertThat(conditionDto0.getValues().size(), is(2)); - ConditionLogicalOperatorDto conditionDto = - (ConditionLogicalOperatorDto) conditionDto0.getValues().get(0); + LogicalOperatorCondition conditionDto = + (LogicalOperatorCondition) conditionDto0.getValues().get(0); assertThat(conditionDto.getValues().size(), is(1)); assertTrue( conditionDto.getValues().stream() - .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesOperatorDto)); + .anyMatch(conditionDto1 -> conditionDto1 instanceof MatchesCondition)); - MatchesOperatorDto ehrMatches = (MatchesOperatorDto) conditionDto.getValues().get(0); + MatchesCondition ehrMatches = (MatchesCondition) conditionDto.getValues().get(0); assertEquals(2, ehrMatches.getValues().size()); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_1))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_1))); assertTrue( ehrMatches.getValues().stream() - .anyMatch(e -> ((SimpleValue) e).getValue().equals(EHR_ID_2))); + .anyMatch(e -> ((Primitive) e).getValue().equals(EHR_ID_2))); - MatchesOperatorDto templatesMatches = (MatchesOperatorDto) conditionDto0.getValues().get(1); + MatchesCondition templatesMatches = (MatchesCondition) conditionDto0.getValues().get(1); assertThat(templatesMatches.getValues().size(), is(1)); assertTrue( templatesMatches.getValues().stream() - .anyMatch(t -> ((SimpleValue) t).getValue().equals(CORONA_TEMPLATE))); + .anyMatch(t -> ((Primitive) t).getValue().equals(CORONA_TEMPLATE))); } @Test @@ -745,12 +735,12 @@ private void setupDataForProjectsWithPagination() { .build(); Project pr2 = Project.builder().id(2L) .name("project name two") - .status(ProjectStatus.PUBLISHED) + .status(PUBLISHED) .coordinator(anotherCoordinator) .build(); Project pr3 = Project.builder().id(3L) .name("project name blaaa") - .status(ProjectStatus.PUBLISHED) + .status(PUBLISHED) .coordinator(anotherCoordinator) .build(); when(userService.getOwner("anotherCoordinatorId")).thenReturn(User.builder().id("anotherCoordinatorId").firstName("Coordinator first name").build()); @@ -894,7 +884,7 @@ public void shouldAllowStudyDraftToPendingTransition() { User userOne = User.builder() .firstName("John") .lastName("Doe") - .email("john.doe@vitagorup.de") + .email("john.doe@highmed.org") .approved(true) .build(); Mockito.when(userService.getByRole(STUDY_APPROVER)).thenReturn(Set.of(userOne)); @@ -1299,7 +1289,7 @@ public void shouldSuccessfullyExecuteManagerProject() { projectService.executeManagerProject( cohortDto, List.of(CORONA_TEMPLATE), userDetails.getUserId()); - assertThat(result, is("[]")); + assertThat(result, is("[{\"name\":\"Corona_Anamnese\",\"columns\":null,\"rows\":null}]")); } @Test @@ -1497,11 +1487,11 @@ public void shouldGetLatestProjectsInfoTest() { .id(3L).build()) .build()); Mockito.when(projectRepository.findByStatusInOrderByCreateDateDesc(Arrays.asList(ProjectStatus.APPROVED, - ProjectStatus.PUBLISHED, ProjectStatus.CLOSED), PageRequest.of(0, 10))) + PUBLISHED, CLOSED), PageRequest.of(0, 10))) .thenReturn(Arrays.asList(pr1,pr2)); projectService.getLatestProjectsInfo(10, roles); verify(projectRepository, times(1)).findByStatusInOrderByCreateDateDesc(Arrays.asList(ProjectStatus.APPROVED, - ProjectStatus.PUBLISHED, ProjectStatus.CLOSED), PageRequest.of(0, 10)); + PUBLISHED, CLOSED), PageRequest.of(0, 10)); } @Test @@ -1551,7 +1541,7 @@ public void archiveProjectTest() { Optional.of( Project.builder() .id(5L) - .status(ProjectStatus.CLOSED) + .status(CLOSED) .coordinator(UserDetails.builder().userId("approvedCoordinatorId").approved(true).build()) .build())); projectService.archiveProject(5L, "approvedCoordinatorId", List.of(STUDY_COORDINATOR)); @@ -1616,7 +1606,7 @@ public void getExportHeadersAsCSVTest() { @Test public void getExportResponseBodyAsJsonTest() { - AqlDto aqlDto = new AqlToDtoParser().parse(QUERY_5); + AqlQuery aqlDto = AqlQueryParser.parse(QUERY_5); when(templateService.createSelectCompositionQuery(Mockito.any())).thenReturn(aqlDto); projectService.getExportResponseBody("select * from dummy", 2L, "approvedCoordinatorId", ExportType.json, true); Mockito.verify(cohortService, times(1)).executeCohort(Mockito.any(Cohort.class), Mockito.eq(false)); @@ -1739,7 +1729,7 @@ public void setup() { .id("researcher2") .firstName("f2") .lastName("l2") - .email("em2@vitagroup.ag") + .email("em2@highmed.org") .build(); UserDetails researcher = UserDetails.builder() .userId("researcher2") @@ -1753,7 +1743,7 @@ public void setup() { .id("researcher1") .firstName("f1") .lastName("l1") - .email("em1@vitagroup.ag") + .email("em1@highmed.org") .build()); UserDetails approvedCoordinator = diff --git a/src/test/java/de/vitagroup/num/service/TemplateServiceTest.java b/src/test/java/org/highmed/numportal/service/TemplateServiceTest.java similarity index 78% rename from src/test/java/de/vitagroup/num/service/TemplateServiceTest.java rename to src/test/java/org/highmed/numportal/service/TemplateServiceTest.java index 66adee98f..9b2f55d2e 100644 --- a/src/test/java/de/vitagroup/num/service/TemplateServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/TemplateServiceTest.java @@ -1,32 +1,33 @@ -package de.vitagroup.num.service; +package org.highmed.numportal.service; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_FIND_TEMPLATE; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.time.OffsetDateTime; -import java.util.List; - -import de.vitagroup.num.service.exception.SystemException; import org.ehrbase.aqleditor.dto.containment.ContainmentDto; import org.ehrbase.aqleditor.service.AqlEditorContainmentService; -import org.ehrbase.response.ehrscape.TemplateMetaDataDto; +import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; +import org.highmed.numportal.service.TemplateService; +import org.highmed.numportal.service.UserDetailsService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.dto.TemplateMetadataDto; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.mapper.TemplateMapper; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.SystemException; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.TemplateMetadataDto; -import de.vitagroup.num.mapper.TemplateMapper; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.BadRequestException; +import java.time.OffsetDateTime; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_CREATE_QUERY_FOR_TEMPLATE_WITH_ID; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_FIND_TEMPLATE; @RunWith(MockitoJUnitRunner.class) public class TemplateServiceTest { diff --git a/src/test/java/de/vitagroup/num/service/UserDetailsServiceTest.java b/src/test/java/org/highmed/numportal/service/UserDetailsServiceTest.java similarity index 85% rename from src/test/java/de/vitagroup/num/service/UserDetailsServiceTest.java rename to src/test/java/org/highmed/numportal/service/UserDetailsServiceTest.java index 48cc7ad04..c19e547c6 100644 --- a/src/test/java/de/vitagroup/num/service/UserDetailsServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/UserDetailsServiceTest.java @@ -1,23 +1,8 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.OrganizationDto; -import de.vitagroup.num.domain.repository.OrganizationRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.domain.specification.UserDetailsSpecification; -import de.vitagroup.num.domain.templates.ExceptionsTemplate; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.exception.SystemException; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.NewUserNotification; -import de.vitagroup.num.service.notification.dto.Notification; -import de.vitagroup.num.service.notification.dto.account.AccountApprovalNotification; -import de.vitagroup.num.service.notification.dto.account.AccountStatusChangedNotification; -import de.vitagroup.num.service.notification.dto.account.OrganizationUpdateNotification; +package org.highmed.numportal.service; + +import org.highmed.numportal.service.OrganizationService; +import org.highmed.numportal.service.UserDetailsService; +import org.highmed.numportal.service.UserService; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,6 +11,24 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.highmed.numportal.domain.dto.OrganizationDto; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.OrganizationRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; +import org.highmed.numportal.domain.specification.UserDetailsSpecification; +import org.highmed.numportal.domain.templates.ExceptionsTemplate; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.NewUserNotification; +import org.highmed.numportal.service.notification.dto.Notification; +import org.highmed.numportal.service.notification.dto.account.AccountApprovalNotification; +import org.highmed.numportal.service.notification.dto.account.AccountStatusChangedNotification; +import org.highmed.numportal.service.notification.dto.account.OrganizationUpdateNotification; import java.util.HashSet; import java.util.List; @@ -50,7 +53,8 @@ public class UserDetailsServiceTest { @Captor ArgumentCaptor> notificationCaptor; - @InjectMocks UserDetailsService userDetailsService; + @InjectMocks + UserDetailsService userDetailsService; @Before public void setup() { @@ -145,14 +149,14 @@ public void shouldSendNotificationWhenApprovingUser() { @Test public void shouldSendNotificationWhenCreateUserDetails() { - String userEmail = "dummyUser@vitagroup.de"; + String userEmail = "dummyUser@highmed.org"; String userId = "dummyUserId"; Organization organization = Organization.builder() .id(9L) - .name("Organization VitaGroup") + .name("Organization HiGHmed") .build(); OrganizationDto organizationDto = OrganizationDto.builder() - .name("Organization VitaGroup") + .name("Organization HiGHmed") .id(9L) .build(); when(organizationService.resolveOrganization(userEmail)).thenReturn(Optional.of(organization)); @@ -168,7 +172,7 @@ public void shouldSendNotificationWhenCreateUserDetails() { User organizationAdmin = User.builder() .firstName("organization admin") .lastName("lastname") - .email("organization-admin@vitagroup.de") + .email("organization-admin@highmed.org") .organization(organizationDto) .build(); when(userDetailsRepository.save(any())).thenReturn(UserDetails.builder() @@ -264,7 +268,7 @@ public void sendAccountStatusChangedNotificationsTest() { .id("someUserId") .firstName("John") .lastName("Doe") - .email("john.doe@vitagroup.ag") + .email("john.doe@highmed.org") .approved(true) .build(); User loggedInUser = @@ -272,7 +276,7 @@ public void sendAccountStatusChangedNotificationsTest() { .id("loggedInUser") .firstName("Admin") .lastName("Doe") - .email("admin.doe@vitagroup.ag") + .email("admin.doe@highmed.org") .approved(true) .build(); when(userService.getUserById("someUserId", false)).thenReturn(user); diff --git a/src/test/java/de/vitagroup/num/service/UserServiceTest.java b/src/test/java/org/highmed/numportal/service/UserServiceTest.java similarity index 96% rename from src/test/java/de/vitagroup/num/service/UserServiceTest.java rename to src/test/java/org/highmed/numportal/service/UserServiceTest.java index 08d2b1228..7645baa8f 100644 --- a/src/test/java/de/vitagroup/num/service/UserServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/UserServiceTest.java @@ -1,28 +1,10 @@ -package de.vitagroup.num.service; - -import de.vitagroup.num.domain.model.EntityGroup; -import de.vitagroup.num.domain.model.Organization; -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.domain.model.Translation; -import de.vitagroup.num.domain.model.admin.Role; -import de.vitagroup.num.domain.model.admin.User; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.*; -import de.vitagroup.num.domain.repository.TranslationRepository; -import de.vitagroup.num.domain.repository.UserDetailsRepository; -import de.vitagroup.num.domain.specification.UserDetailsSpecification; -import de.vitagroup.num.mapper.OrganizationMapper; -import de.vitagroup.num.service.exception.BadRequestException; -import de.vitagroup.num.service.exception.ForbiddenException; -import de.vitagroup.num.service.exception.ResourceNotFound; -import de.vitagroup.num.service.exception.SystemException; -import de.vitagroup.num.service.notification.NotificationService; -import de.vitagroup.num.service.notification.dto.Notification; -import de.vitagroup.num.service.notification.dto.account.RolesUpdateNotification; -import de.vitagroup.num.service.notification.dto.account.UserNameUpdateNotification; -import de.vitagroup.num.web.feign.KeycloakFeign; +package org.highmed.numportal.service; + import feign.FeignException; import feign.Request; +import org.highmed.numportal.domain.dto.*; +import org.highmed.numportal.service.UserDetailsService; +import org.highmed.numportal.service.UserService; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -35,6 +17,26 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.highmed.numportal.domain.model.EntityGroup; +import org.highmed.numportal.domain.model.Organization; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.domain.model.Translation; +import org.highmed.numportal.domain.model.admin.Role; +import org.highmed.numportal.domain.model.admin.User; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.domain.repository.TranslationRepository; +import org.highmed.numportal.domain.repository.UserDetailsRepository; +import org.highmed.numportal.domain.specification.UserDetailsSpecification; +import org.highmed.numportal.mapper.OrganizationMapper; +import org.highmed.numportal.service.exception.BadRequestException; +import org.highmed.numportal.service.exception.ForbiddenException; +import org.highmed.numportal.service.exception.ResourceNotFound; +import org.highmed.numportal.service.exception.SystemException; +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.Notification; +import org.highmed.numportal.service.notification.dto.account.RolesUpdateNotification; +import org.highmed.numportal.service.notification.dto.account.UserNameUpdateNotification; +import org.highmed.numportal.web.feign.KeycloakFeign; import java.nio.charset.Charset; import java.time.LocalDateTime; @@ -43,14 +45,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; -import static de.vitagroup.num.service.UserService.TRANSLATION_CACHE; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.USER_NOT_FOUND; +import static org.highmed.numportal.service.UserService.TRANSLATION_CACHE; @RunWith(MockitoJUnitRunner.class) public class UserServiceTest { @@ -728,7 +730,7 @@ public void searchUsersWithPaginationAsSuperAdminTest() { UserDetailsSpecification capturedInput = argumentCaptor.getValue(); Assert.assertEquals(Boolean.FALSE, capturedInput.getApproved()); User firstUser = users.getContent().get(0); - Assert.assertEquals("ana-maria.doe@vitagroup.ag", firstUser.getEmail()); + Assert.assertEquals("ana-maria.doe@highmed.org", firstUser.getEmail()); } private void mockDataSearchUsers() { @@ -761,7 +763,7 @@ private void mockDataSearchUsers() { .id("userId-one") .firstName("John") .lastName("doe") - .email("john.doe@vitagroup.ag") + .email("john.doe@highmed.org") .createdTimestamp(System.currentTimeMillis()) .roles(Set.of(Roles.RESEARCHER, Roles.STUDY_COORDINATOR, Roles.CRITERIA_EDITOR)) .enabled(true) @@ -770,7 +772,7 @@ private void mockDataSearchUsers() { .firstName("Ana") .lastName("Doe") .id("userId-two") - .email("ana-maria.doe@vitagroup.ag") + .email("ana-maria.doe@highmed.org") .createdTimestamp(System.currentTimeMillis()) .roles(Set.of(Roles.ORGANIZATION_ADMIN, Roles.STUDY_COORDINATOR, Roles.CRITERIA_EDITOR)) .enabled(true) @@ -779,7 +781,7 @@ private void mockDataSearchUsers() { .firstName("Elena") .lastName("Doe") .id("userId-three") - .email("willi.doe@vitagroup.ag") + .email("willi.doe@highmed.org") .createdTimestamp(System.currentTimeMillis()) .roles(Set.of(Roles.RESEARCHER)) .enabled(false) @@ -788,7 +790,7 @@ private void mockDataSearchUsers() { .firstName("Mike") .lastName("Doe") .id("userId-four") - .email("mike.doe@vitagroup.ag") + .email("mike.doe@highmed.org") .createdTimestamp(System.currentTimeMillis()) .roles(Set.of(Roles.RESEARCHER)) .enabled(false) @@ -926,7 +928,7 @@ public void searchUsersWithPaginationByRoleAndMail() { Map filter = new HashMap<>(); filter.put(SearchCriteria.FILTER_USER_WITH_ROLES_KEY, "true"); filter.put(SearchCriteria.FILTER_BY_ROLES, "RESEARCHER"); - filter.put(SearchCriteria.FILTER_SEARCH_BY_KEY, "vitagroup"); + filter.put(SearchCriteria.FILTER_SEARCH_BY_KEY, "highmed"); SearchCriteria searchCriteria = SearchCriteria.builder() .filter(filter) @@ -1099,7 +1101,7 @@ public void refreshUsersCacheTest() { .id("userId-one") .firstName("John") .lastName("doe") - .email("john.doe@vitagroup.ag") + .email("john.doe@highmed.org") .createdTimestamp(System.currentTimeMillis()) .build()); Mockito.when(cacheManager.getCache("users")).thenReturn(usersCache); diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/CompositionFlattenerTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/CompositionFlattenerTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/service/ehrbase/CompositionFlattenerTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/CompositionFlattenerTest.java index dac0401a0..06f8d3985 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/CompositionFlattenerTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/CompositionFlattenerTest.java @@ -1,23 +1,12 @@ -package de.vitagroup.num.service.ehrbase; - -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS_COMPOSITION_MISSING_TEMPLATE_ID; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; +package org.highmed.numportal.service.ehrbase; import com.nedap.archie.rm.archetyped.Archetyped; import com.nedap.archie.rm.composition.Composition; -import de.vitagroup.num.service.exception.SystemException; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Optional; import lombok.SneakyThrows; import org.apache.xmlbeans.XmlException; -import org.ehrbase.client.templateprovider.ClientTemplateProvider; -import org.ehrbase.serialisation.jsonencoding.CanonicalJson; +import org.ehrbase.openehr.sdk.client.templateprovider.ClientTemplateProvider; +import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; +import org.highmed.numportal.service.ehrbase.CompositionFlattener; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -27,11 +16,25 @@ import org.mockito.junit.MockitoJUnitRunner; import org.openehr.schemas.v1.TemplateDocument; import org.testcontainers.shaded.org.apache.commons.io.IOUtils; +import org.highmed.numportal.service.exception.SystemException; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Optional; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_PARSE_RESULTS_COMPOSITION_MISSING_TEMPLATE_ID; @RunWith(MockitoJUnitRunner.class) public class CompositionFlattenerTest { - @Mock ClientTemplateProvider clientTemplateProvider; + @Mock + ClientTemplateProvider clientTemplateProvider; @InjectMocks private CompositionFlattener flattener; diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilderTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilderTest.java similarity index 91% rename from src/test/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilderTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilderTest.java index 73e09bd06..ab5be76e0 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/CompositionResponseDataBuilderTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/CompositionResponseDataBuilderTest.java @@ -1,29 +1,32 @@ -package de.vitagroup.num.service.ehrbase; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; +package org.highmed.numportal.service.ehrbase; import com.fasterxml.jackson.databind.ObjectMapper; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.ehrbase.CompositionResponseDataBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; + @RunWith(MockitoJUnitRunner.class) public class CompositionResponseDataBuilderTest { @Spy public ObjectMapper mapper; - @Spy @InjectMocks CompositionResponseDataBuilder builder; + @Spy @InjectMocks + CompositionResponseDataBuilder builder; private static final Map COMP_1 = Map.of( diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/ParameterServiceTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/ParameterServiceTest.java similarity index 86% rename from src/test/java/de/vitagroup/num/service/ehrbase/ParameterServiceTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/ParameterServiceTest.java index 8f58fee94..a7bb808b4 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/ParameterServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/ParameterServiceTest.java @@ -1,9 +1,8 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; -import de.vitagroup.num.domain.model.admin.UserDetails; -import de.vitagroup.num.domain.dto.ParameterOptionsDto; -import de.vitagroup.num.service.UserDetailsService; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.ehrbase.ParameterService; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -16,6 +15,9 @@ import org.mockito.MockitoAnnotations; import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCache; +import org.highmed.numportal.domain.dto.ParameterOptionsDto; +import org.highmed.numportal.domain.model.admin.UserDetails; +import org.highmed.numportal.service.UserDetailsService; import java.util.*; @@ -54,14 +56,13 @@ public class ParameterServiceTest { private static final String AQL_PATH_UNITS = "/items[at0001]/value/units"; private static final String AQL_PATH_VALUE_VALUE_ORDINAL = "/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/value"; - private static final String AQL_CODE_QUERY = "Select distinct e0/data[at0002]/items[at0019] as F1 from EHR e contains EVALUATION e0[openEHR-EHR-EVALUATION.gender.v1] order by e0/data[at0002]/items[at0019] ASCENDING"; - private static final String AQL_MAGNITUDE_QUERY = "Select distinct o0/data[at0001]/events[at0002]/data[at0003]/items[at0004] as F1 from EHR e contains OBSERVATION o0[openEHR-EHR-OBSERVATION.height.v2] order by o0/data[at0001]/events[at0002]/data[at0003]/items[at0004] ASCENDING"; - private static final String AQL_VALUE_UNITS_QUERY = "Select distinct c0/items[at0001] as F1 from EHR e contains CLUSTER c0[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1] order by c0/items[at0001] ASCENDING"; - private static final String AQL_VALUE_VALUE_QUERY = "Select distinct c0/items[at0001] as F1 from EHR e contains CLUSTER c0[openEHR-EHR-CLUSTER.person_birth_data_iso.v0] order by c0/items[at0001] ASCENDING"; - private static final String AQL_VALUE_QUERY = "Select distinct o0/data[at0001]/events[at0006]/time as F1 from EHR e contains OBSERVATION o0[openEHR-EHR-OBSERVATION.blood_pressure.v2] order by o0/data[at0001]/events[at0006]/time ASCENDING"; - private static final String AQL_VALUE_VALUE_ORDINAL_QUERY = "Select distinct o0/data[at0001]/events[at0002]/data[at0003]/items[at0004] as F1 from EHR e contains OBSERVATION o0[openEHR-EHR-OBSERVATION.clinical_frailty_scale.v1] order by o0/data[at0001]/events[at0002]/data[at0003]/items[at0004] ASCENDING"; - - private static final String AQL_VALUE_SYMBOL_QUERY = "Select distinct c0/items[at0009] as F1 from EHR e contains CLUSTER c0[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1] order by c0/items[at0009] ASCENDING"; + private static final String AQL_CODE_QUERY = "SELECT DISTINCT c0/data[at0002]/items[at0019] AS F1 FROM EHR e CONTAINS EVALUATION c0[openEHR-EHR-EVALUATION.gender.v1] ORDER BY c0/data[at0002]/items[at0019] ASC"; + private static final String AQL_MAGNITUDE_QUERY = "SELECT DISTINCT c0/data[at0001]/events[at0002]/data[at0003]/items[at0004] AS F1 FROM EHR e CONTAINS OBSERVATION c0[openEHR-EHR-OBSERVATION.height.v2] ORDER BY c0/data[at0001]/events[at0002]/data[at0003]/items[at0004] ASC"; + private static final String AQL_VALUE_UNITS_QUERY = "SELECT DISTINCT c0/items[at0001] AS F1 FROM EHR e CONTAINS CLUSTER c0[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1] ORDER BY c0/items[at0001] ASC"; + private static final String AQL_VALUE_VALUE_QUERY = "SELECT DISTINCT c0/items[at0001] AS F1 FROM EHR e CONTAINS CLUSTER c0[openEHR-EHR-CLUSTER.person_birth_data_iso.v0] ORDER BY c0/items[at0001] ASC"; + private static final String AQL_VALUE_QUERY = "SELECT DISTINCT c0/data[at0001]/events[at0006]/time AS F1 FROM EHR e CONTAINS OBSERVATION c0[openEHR-EHR-OBSERVATION.blood_pressure.v2] ORDER BY c0/data[at0001]/events[at0006]/time ASC"; + private static final String AQL_VALUE_VALUE_ORDINAL_QUERY = "SELECT DISTINCT c0/data[at0001]/events[at0002]/data[at0003]/items[at0004] AS F1 FROM EHR e CONTAINS OBSERVATION c0[openEHR-EHR-OBSERVATION.clinical_frailty_scale.v1] ORDER BY c0/data[at0001]/events[at0002]/data[at0003]/items[at0004] ASC"; + private static final String AQL_VALUE_SYMBOL_QUERY = "SELECT DISTINCT c0/items[at0009] AS F1 FROM EHR e CONTAINS CLUSTER c0[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1] ORDER BY c0/items[at0009] ASC"; @Parameterized.Parameter() public String aqlPath; diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/PseudonimytyCodexPSNTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/PseudonimytyCodexPSNTest.java similarity index 88% rename from src/test/java/de/vitagroup/num/service/ehrbase/PseudonimytyCodexPSNTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/PseudonimytyCodexPSNTest.java index 3b1f06d88..18e9690bc 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/PseudonimytyCodexPSNTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/PseudonimytyCodexPSNTest.java @@ -1,10 +1,7 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; -import de.vitagroup.num.config.FttpClientConfig; -import de.vitagroup.num.properties.FttpProperties; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.properties.PseudonymsPsnWorkflowProperties; import org.apache.commons.io.IOUtils; +import org.highmed.numportal.service.ehrbase.Pseudonymity; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,6 +10,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import org.highmed.numportal.config.FttpClientConfig; +import org.highmed.numportal.properties.FttpProperties; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.properties.PseudonymsPsnWorkflowProperties; import java.io.*; import java.time.LocalDateTime; diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/PseudonymityTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/PseudonymityTest.java similarity index 92% rename from src/test/java/de/vitagroup/num/service/ehrbase/PseudonymityTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/PseudonymityTest.java index 91c4c3a13..175863a38 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/PseudonymityTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/PseudonymityTest.java @@ -1,12 +1,8 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.XmlParser; -import de.vitagroup.num.properties.FttpProperties; -import de.vitagroup.num.properties.PrivacyProperties; -import de.vitagroup.num.properties.PseudonymsPsnWorkflowProperties; -import de.vitagroup.num.service.exception.ResourceNotFound; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; import org.apache.http.client.methods.CloseableHttpResponse; @@ -15,9 +11,11 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.message.BasicStatusLine; +import org.highmed.numportal.service.ehrbase.Pseudonymity; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.StringType; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,6 +24,10 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; +import org.highmed.numportal.properties.FttpProperties; +import org.highmed.numportal.properties.PrivacyProperties; +import org.highmed.numportal.properties.PseudonymsPsnWorkflowProperties; +import org.highmed.numportal.service.exception.ResourceNotFound; import java.io.IOException; import java.util.Arrays; @@ -72,6 +74,13 @@ public void getPseudonyms() throws IOException { setupTestDataWithMissingPseudonym(); } + @Test + public void getPseudonymsWhenPrivacyDisabled() throws IOException { + when(privacyProperties.isEnabled()).thenReturn(false); + Assert.assertEquals(Arrays.asList("codex_WX6QAM", "codex_ABCDE1", "123"), + pseudonymity.getPseudonyms(Arrays.asList("codex_WX6QAM", "codex_ABCDE1", "123"), 100L)); + } + @Test(expected = ResourceNotFound.class) public void getPseudonymsAndExpectNotFoundWhenMissingPseudonym() throws IOException { ReflectionTestUtils.setField(pseudonymity, "fake3rdPartyPseudonymEnabled", false); @@ -141,6 +150,7 @@ public void setup() { when(fhirContext.newXmlParser()).thenReturn(xmlParser); when(privacyProperties.getPseudonymitySecret()).thenReturn("testSecret123"); when(privacyProperties.getPseudonomityChunksSize()).thenReturn(5); + when(privacyProperties.isEnabled()).thenReturn(true); } private Parameters mockErrorParameters() { diff --git a/src/test/java/de/vitagroup/num/service/ehrbase/ResponseFilterTest.java b/src/test/java/org/highmed/numportal/service/ehrbase/ResponseFilterTest.java similarity index 95% rename from src/test/java/de/vitagroup/num/service/ehrbase/ResponseFilterTest.java rename to src/test/java/org/highmed/numportal/service/ehrbase/ResponseFilterTest.java index cc8cf2f99..a8f6923e4 100644 --- a/src/test/java/de/vitagroup/num/service/ehrbase/ResponseFilterTest.java +++ b/src/test/java/org/highmed/numportal/service/ehrbase/ResponseFilterTest.java @@ -1,6 +1,7 @@ -package de.vitagroup.num.service.ehrbase; +package org.highmed.numportal.service.ehrbase; -import org.ehrbase.response.openehr.QueryResponseData; +import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; +import org.highmed.numportal.service.ehrbase.ResponseFilter; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/org/highmed/numportal/service/email/EmailServiceTest.java b/src/test/java/org/highmed/numportal/service/email/EmailServiceTest.java new file mode 100644 index 000000000..8d530c600 --- /dev/null +++ b/src/test/java/org/highmed/numportal/service/email/EmailServiceTest.java @@ -0,0 +1,70 @@ +package org.highmed.numportal.service.email; + +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.Session; +import jakarta.mail.internet.MimeMessage; +import org.highmed.numportal.service.email.EmailProperties; +import org.highmed.numportal.service.email.EmailService; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.mail.javamail.JavaMailSender; + +@RunWith(MockitoJUnitRunner.class) +public class EmailServiceTest { + + @Mock + private JavaMailSender javaMailSender; + @Mock + private EmailProperties emailProperties; + + @InjectMocks + private EmailService emailService; + + private MimeMessage message; + + @Before + public void setup() { + Mockito.when(emailProperties.getFrom()).thenReturn("support@highmed.org"); + Mockito.when(emailProperties.isEnabled()).thenReturn(true); + message = new MimeMessage((Session) null); + Mockito.when(javaMailSender.createMimeMessage()).thenReturn(message); + } + + @Test + public void sendEmailTest() throws MessagingException { + emailService.sendEmail("Test subject", "test body", "testaccount@highmed.org"); + Assert.assertEquals("testaccount@highmed.org", message.getRecipients(Message.RecipientType.TO)[0].toString()); + Assert.assertEquals("Test subject", message.getSubject()); + Mockito.verify(javaMailSender).send(message); + } + + @Test + public void sendEmailWithAttachmentTest() throws MessagingException { + emailService.sendEmailWithAttachment("another test subject", "dummy email body", "testaccount2@highmed.org", "dummy file content", "dummyAttachment.txt","text/plain"); + Assert.assertEquals("testaccount2@highmed.org", message.getRecipients(Message.RecipientType.TO)[0].toString()); + Assert.assertEquals("another test subject", message.getSubject()); + Assert.assertEquals("text/plain", message.getContentType()); + Mockito.verify(javaMailSender).send(message); + } + + @Test + public void sendEmailWhenEmailIsDisabledTest() throws MessagingException { + Mockito.when(emailProperties.isEnabled()).thenReturn(false); + emailService.sendEmail("Test subject", "test body", "testaccount@highmed.org"); + Mockito.verifyNoMoreInteractions(javaMailSender); + } + + @Test + public void sendEmailWithAttachmentWhenEmailIsDisabledTest() throws MessagingException { + Mockito.when(emailProperties.isEnabled()).thenReturn(false); + emailService.sendEmailWithAttachment("another test subject", "dummy email body", "testaccount2@highmed.org", "dummy file content", "dummyAttachment.txt","text/plain"); + Mockito.verifyNoMoreInteractions(javaMailSender); + } +} diff --git a/src/test/java/de/vitagroup/num/service/executors/AqlExecutorTest.java b/src/test/java/org/highmed/numportal/service/executors/AqlExecutorTest.java similarity index 82% rename from src/test/java/de/vitagroup/num/service/executors/AqlExecutorTest.java rename to src/test/java/org/highmed/numportal/service/executors/AqlExecutorTest.java index 29453edb8..6742bfe40 100644 --- a/src/test/java/de/vitagroup/num/service/executors/AqlExecutorTest.java +++ b/src/test/java/org/highmed/numportal/service/executors/AqlExecutorTest.java @@ -1,9 +1,6 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.properties.ConsentProperties; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.policy.ProjectPolicyService; +import org.highmed.numportal.service.executors.AqlExecutor; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,6 +8,10 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.CohortAql; +import org.highmed.numportal.properties.ConsentProperties; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.policy.ProjectPolicyService; import java.util.Collections; import java.util.Map; @@ -33,7 +34,7 @@ public class AqlExecutorTest { @InjectMocks private AqlExecutor aqlExecutor; - private final String Q1 = "Select c0 as test from EHR e contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; + private final String Q1 = "SELECT c0 AS test FROM EHR e CONTAINS COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]"; @Before public void setup() { diff --git a/src/test/java/de/vitagroup/num/service/executors/CohortExecutorTest.java b/src/test/java/org/highmed/numportal/service/executors/CohortExecutorTest.java similarity index 90% rename from src/test/java/de/vitagroup/num/service/executors/CohortExecutorTest.java rename to src/test/java/org/highmed/numportal/service/executors/CohortExecutorTest.java index 9ef3c0a41..6c50f7fc6 100644 --- a/src/test/java/de/vitagroup/num/service/executors/CohortExecutorTest.java +++ b/src/test/java/org/highmed/numportal/service/executors/CohortExecutorTest.java @@ -1,20 +1,9 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.mockito.Mockito.when; - -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.domain.model.Type; -import de.vitagroup.num.service.ehrbase.EhrBaseService; -import de.vitagroup.num.service.exception.IllegalArgumentException; -import java.util.List; -import java.util.Map; -import java.util.Set; +import org.highmed.numportal.domain.model.*; +import org.highmed.numportal.service.executors.AqlExecutor; +import org.highmed.numportal.service.executors.CohortExecutor; +import org.highmed.numportal.service.executors.SetOperationsService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,6 +11,17 @@ import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.service.ehrbase.EhrBaseService; +import org.highmed.numportal.service.exception.IllegalArgumentException; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class CohortExecutorTest { diff --git a/src/test/java/de/vitagroup/num/service/executors/CohortQueryListerTest.java b/src/test/java/org/highmed/numportal/service/executors/CohortQueryListerTest.java similarity index 85% rename from src/test/java/de/vitagroup/num/service/executors/CohortQueryListerTest.java rename to src/test/java/org/highmed/numportal/service/executors/CohortQueryListerTest.java index 140d318eb..ecebf2e6f 100644 --- a/src/test/java/de/vitagroup/num/service/executors/CohortQueryListerTest.java +++ b/src/test/java/org/highmed/numportal/service/executors/CohortQueryListerTest.java @@ -1,14 +1,15 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import de.vitagroup.num.domain.model.Cohort; -import de.vitagroup.num.domain.model.CohortAql; -import de.vitagroup.num.domain.model.CohortGroup; -import de.vitagroup.num.domain.model.Type; +import org.highmed.numportal.service.executors.CohortQueryLister; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.Cohort; +import org.highmed.numportal.domain.model.CohortAql; +import org.highmed.numportal.domain.model.CohortGroup; +import org.highmed.numportal.domain.model.Type; import java.util.List; diff --git a/src/test/java/de/vitagroup/num/service/executors/SetOperationsServiceTest.java b/src/test/java/org/highmed/numportal/service/executors/SetOperationsServiceTest.java similarity index 94% rename from src/test/java/de/vitagroup/num/service/executors/SetOperationsServiceTest.java rename to src/test/java/org/highmed/numportal/service/executors/SetOperationsServiceTest.java index e90575418..9eb376e1d 100644 --- a/src/test/java/de/vitagroup/num/service/executors/SetOperationsServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/executors/SetOperationsServiceTest.java @@ -1,18 +1,22 @@ -package de.vitagroup.num.service.executors; +package org.highmed.numportal.service.executors; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -import de.vitagroup.num.domain.model.Operator; -import de.vitagroup.num.service.exception.IllegalArgumentException; import org.apache.commons.collections4.SetUtils; +import org.highmed.numportal.service.executors.SetOperationsService; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.Operator; +import org.highmed.numportal.service.exception.IllegalArgumentException; -import java.util.*; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; @RunWith(MockitoJUnitRunner.class) public class SetOperationsServiceTest { diff --git a/src/test/java/de/vitagroup/num/service/logger/NumLoggerTest.java b/src/test/java/org/highmed/numportal/service/logger/NumLoggerTest.java similarity index 94% rename from src/test/java/de/vitagroup/num/service/logger/NumLoggerTest.java rename to src/test/java/org/highmed/numportal/service/logger/NumLoggerTest.java index 26843c0d5..758c27a0e 100644 --- a/src/test/java/de/vitagroup/num/service/logger/NumLoggerTest.java +++ b/src/test/java/org/highmed/numportal/service/logger/NumLoggerTest.java @@ -1,7 +1,9 @@ -package de.vitagroup.num.service.logger; +package org.highmed.numportal.service.logger; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.reflect.MethodSignature; +import org.highmed.numportal.service.logger.AuditLog; +import org.highmed.numportal.service.logger.NumLogger; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -59,7 +61,7 @@ public void logMethodCallReturnTrue() throws NoSuchMethodException { .subject("user-uuid-12345") .issuedAt(Instant.now()) .claim("name", "John") - .claim("email", "john.doe@vitagroup.de") + .claim("email", "john.doe@highmed.org") .claim("username", "john.doe") .header("dummy", "dummy") .build(); diff --git a/src/test/java/de/vitagroup/num/service/notification/NotificationServiceTest.java b/src/test/java/org/highmed/numportal/service/notification/NotificationServiceTest.java similarity index 72% rename from src/test/java/de/vitagroup/num/service/notification/NotificationServiceTest.java rename to src/test/java/org/highmed/numportal/service/notification/NotificationServiceTest.java index c0c234bac..7c607191c 100644 --- a/src/test/java/de/vitagroup/num/service/notification/NotificationServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/notification/NotificationServiceTest.java @@ -1,20 +1,22 @@ -package de.vitagroup.num.service.notification; - -import de.vitagroup.num.domain.model.Roles; -import de.vitagroup.num.properties.NumProperties; -import de.vitagroup.num.service.email.EmailService; -import de.vitagroup.num.service.email.MessageSourceWrapper; -import de.vitagroup.num.service.notification.dto.*; -import de.vitagroup.num.service.notification.dto.account.AccountApprovalNotification; -import de.vitagroup.num.service.notification.dto.account.AccountStatusChangedNotification; -import de.vitagroup.num.service.notification.dto.account.RolesUpdateNotification; -import de.vitagroup.num.service.notification.dto.account.UserNameUpdateNotification; +package org.highmed.numportal.service.notification; + +import org.highmed.numportal.service.notification.NotificationService; +import org.highmed.numportal.service.notification.dto.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.domain.model.Roles; +import org.highmed.numportal.properties.NumProperties; +import org.highmed.numportal.service.email.EmailService; +import org.highmed.numportal.service.email.MessageSourceWrapper; +import org.highmed.numportal.service.notification.dto.account.AccountApprovalNotification; +import org.highmed.numportal.service.notification.dto.account.AccountStatusChangedNotification; +import org.highmed.numportal.service.notification.dto.account.RolesUpdateNotification; +import org.highmed.numportal.service.notification.dto.account.UserNameUpdateNotification; import java.util.Arrays; import java.util.Collections; @@ -38,58 +40,56 @@ public class NotificationServiceTest { @Before public void setUp() { - when((messageSource.getMessage(any()))).thenReturn("Any content"); + when((numProperties.getUrl())).thenReturn("https://dev.num-codex.de/home"); + when(messageSource.getMessage(any())).thenReturn("Any content"); when((messageSource.getMessage(anyString(), any()))).thenReturn("Any content"); when((messageSource.getMessage(any(), any(), any(), any(), any(), any(),any()))).thenReturn("Any content"); } @Test public void shouldSendOneEmailPerNotification() { - when((numProperties.getUrl())).thenReturn("Portal url"); - notificationService.send( List.of( - AccountApprovalNotification.builder().recipientEmail("john.doe@vita.ag").build(), - UserNameUpdateNotification.builder().recipientEmail("jane.doe@vita.ag").build())); + AccountApprovalNotification.builder().recipientEmail("john.doe@highmed.org").build(), + UserNameUpdateNotification.builder().recipientEmail("jane.doe@highmed.org").build())); verify(emailService, times(2)).sendEmail(anyString(), anyString(), anyString()); } @Test public void shouldSendEmailsPerNotification() { - when((numProperties.getUrl())).thenReturn("Portal url"); - + when(messageSource.getMessage(anyString(), any(Object[].class))).thenReturn("Another body content"); notificationService.send( List.of( - ProjectStartNotification.builder().recipientEmail("john.doe@vita.ag").build(), - ProjectCloseNotification.builder().recipientEmail("jane.doe@vita.ag").build(), - ProjectStatusChangeNotification.builder().recipientEmail("anne.doe@vita.ag").build(), + ProjectStartNotification.builder().recipientEmail("john.doe@highmed.org").build(), + ProjectCloseNotification.builder().recipientEmail("jane.doe@highmed.org").build(), + ProjectStatusChangeNotification.builder().recipientEmail("anne.doe@highmed.org").build(), ProjectApprovalRequestNotification.builder() - .recipientEmail("ann.doe@vita.ag") + .recipientEmail("ann.doe@highmed.org") .build(), RolesUpdateNotification.builder() - .recipientEmail("recipient.email@vita.ag") + .recipientEmail("recipient.email@highmed.org") .rolesAdded(Arrays.asList(Roles.RESEARCHER, Roles.STUDY_APPROVER)) .rolesRemoved(Collections.emptyList()) .allRoles(Collections.emptyList()) .build(), ProjectStatusChangeRequestNotification.changeRequestBuilder() .projectId(99L) - .recipientEmail("coordinator@vita.ag") + .recipientEmail("coordinator@highmed.org") .build(), NewUserNotification.builder() - .newUserEmail("newAccount@vita.ag") + .newUserEmail("newAccount@highmed.org") .newUserFirstName("super firstname") .newUserLastName("lastname") .requestedRoles(List.of("Researcher")) .department("some department") - .recipientEmail("recipient@vita.ag") + .recipientEmail("recipient@highmed.org") .build(), AccountStatusChangedNotification.builder() - .recipientEmail("john.doe@vitagroup.ag") + .recipientEmail("john.doe@highmed.org") .recipientFirstName("John") .recipientLastName("Doe") - .adminEmail("admin@vitagroup.ag") + .adminEmail("admin@highmed.org") .adminFullName("Super Admin") .userCurrentStatus(true) .build() @@ -100,15 +100,15 @@ public void shouldSendEmailsPerNotification() { @Test public void shouldNotSendEmailsWhenRecipientMissing() { - when((numProperties.getUrl())).thenReturn("Portal url"); - + when(messageSource.getMessage(Mockito.eq("mail.project-pending-approval.body"), any(Object[].class))).thenReturn("Any body content"); notificationService.send( List.of( ProjectStartNotification.builder().build(), ProjectCloseNotification.builder().build(), ProjectStatusChangeNotification.builder().build(), ProjectApprovalRequestNotification.builder() - .recipientEmail("ann.doe@vita.ag") + .recipientEmail("ann.doe@highmed.org") + .projectId(9L) .build())); verify(emailService, times(1)).sendEmail(anyString(), anyString(), anyString()); diff --git a/src/test/java/de/vitagroup/num/service/policy/EhrPolicyTest.java b/src/test/java/org/highmed/numportal/service/policy/EhrPolicyTest.java similarity index 65% rename from src/test/java/de/vitagroup/num/service/policy/EhrPolicyTest.java rename to src/test/java/org/highmed/numportal/service/policy/EhrPolicyTest.java index 3e7c293ee..e517f0936 100644 --- a/src/test/java/de/vitagroup/num/service/policy/EhrPolicyTest.java +++ b/src/test/java/org/highmed/numportal/service/policy/EhrPolicyTest.java @@ -1,17 +1,16 @@ -package de.vitagroup.num.service.policy; +package org.highmed.numportal.service.policy; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.COHORT_SIZE_CANNOT_BE_0; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; -import static org.mockito.Mockito.when; - -import org.ehrbase.aql.dto.AqlDto; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.highmed.numportal.service.policy.EhrPolicy; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.service.exception.SystemException; -import de.vitagroup.num.service.exception.SystemException; -import de.vitagroup.num.service.policy.EhrPolicy; +import static org.mockito.Mockito.when; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.COHORT_SIZE_CANNOT_BE_0; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.INVALID_AQL; @RunWith(MockitoJUnitRunner.class) public class EhrPolicyTest { @@ -20,7 +19,7 @@ public class EhrPolicyTest { @Test(expected = SystemException.class) public void applyAqlDtoIsNull() { - AqlDto aqlDto = new AqlDto(); + AqlQuery aqlDto = new AqlQuery(); ehrPolicy.apply(aqlDto); when(ehrPolicy.apply(aqlDto)) .thenThrow(new SystemException(EhrPolicy.class, COHORT_SIZE_CANNOT_BE_0)); diff --git a/src/test/java/de/vitagroup/num/service/policy/EuropeanConsentPolicyTest.java b/src/test/java/org/highmed/numportal/service/policy/EuropeanConsentPolicyTest.java similarity index 66% rename from src/test/java/de/vitagroup/num/service/policy/EuropeanConsentPolicyTest.java rename to src/test/java/org/highmed/numportal/service/policy/EuropeanConsentPolicyTest.java index 0bd42220b..b8bd7d03e 100644 --- a/src/test/java/de/vitagroup/num/service/policy/EuropeanConsentPolicyTest.java +++ b/src/test/java/org/highmed/numportal/service/policy/EuropeanConsentPolicyTest.java @@ -1,15 +1,17 @@ -package de.vitagroup.num.service.policy; +package org.highmed.numportal.service.policy; -import de.vitagroup.num.service.exception.SystemException; -import org.ehrbase.aql.dto.AqlDto; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.highmed.numportal.service.policy.EhrPolicy; +import org.highmed.numportal.service.policy.EuropeanConsentPolicy; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.service.exception.SystemException; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; import static org.mockito.Mockito.when; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED; +import static org.highmed.numportal.domain.templates.ExceptionsTemplate.INVALID_AQL; @RunWith(MockitoJUnitRunner.class) public class EuropeanConsentPolicyTest { @@ -19,7 +21,7 @@ public class EuropeanConsentPolicyTest { @Test(expected = SystemException.class) public void applyAqlDtoIsNull() { EuropeanConsentPolicy europeanConsentPolicy = EuropeanConsentPolicy.builder().build(); - AqlDto aqlDto = new AqlDto(); + AqlQuery aqlDto = new AqlQuery(); when(europeanConsentPolicy.apply(aqlDto)) .thenThrow(new SystemException(EhrPolicy.class, CANNOT_CHECK_CONSENT_FOR_DATA_USAGE_OUTSIDE_THE_EUROPEAN_UNION_OID_NOT_CONFIGURED)); europeanConsentPolicy.apply(aqlDto); diff --git a/src/test/java/de/vitagroup/num/service/policy/ProjectPolicyServiceTest.java b/src/test/java/org/highmed/numportal/service/policy/ProjectPolicyServiceTest.java similarity index 68% rename from src/test/java/de/vitagroup/num/service/policy/ProjectPolicyServiceTest.java rename to src/test/java/org/highmed/numportal/service/policy/ProjectPolicyServiceTest.java index 39d27f43c..8e9f571a1 100644 --- a/src/test/java/de/vitagroup/num/service/policy/ProjectPolicyServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/policy/ProjectPolicyServiceTest.java @@ -1,8 +1,11 @@ -package de.vitagroup.num.service.policy; +package org.highmed.numportal.service.policy; -import org.ehrbase.aql.dto.AqlDto; -import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorDto; -import org.ehrbase.aql.parser.AqlToDtoParser; +import org.ehrbase.openehr.sdk.aql.dto.AqlQuery; +import org.ehrbase.openehr.sdk.aql.dto.condition.LogicalOperatorCondition; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.highmed.numportal.service.policy.EuropeanConsentPolicy; +import org.highmed.numportal.service.policy.ProjectPolicyService; +import org.highmed.numportal.service.policy.TemplatesPolicy; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,7 +29,7 @@ public class ProjectPolicyServiceTest { @Test public void applyTest() { - AqlDto aqlDto = new AqlToDtoParser().parse(Q1); + AqlQuery aqlDto = AqlQueryParser.parse(Q1); Assert.assertNull(aqlDto.getWhere()); projectPolicyService.apply(aqlDto, List.of( TemplatesPolicy.builder() @@ -35,7 +38,7 @@ public void applyTest() { EuropeanConsentPolicy.builder().oid("dummy-oid") .build())); Assert.assertNotNull(aqlDto.getWhere()); - ConditionLogicalOperatorDto where = (ConditionLogicalOperatorDto) aqlDto.getWhere(); + LogicalOperatorCondition where = (LogicalOperatorCondition)aqlDto.getWhere(); Assert.assertEquals(2, where.getValues().size()); } } diff --git a/src/test/java/de/vitagroup/num/service/policy/TemplatesPolicyTest.java b/src/test/java/org/highmed/numportal/service/policy/TemplatesPolicyTest.java similarity index 70% rename from src/test/java/de/vitagroup/num/service/policy/TemplatesPolicyTest.java rename to src/test/java/org/highmed/numportal/service/policy/TemplatesPolicyTest.java index 0e4ccec5b..8125ca174 100644 --- a/src/test/java/de/vitagroup/num/service/policy/TemplatesPolicyTest.java +++ b/src/test/java/org/highmed/numportal/service/policy/TemplatesPolicyTest.java @@ -1,18 +1,16 @@ -package de.vitagroup.num.service.policy; +package org.highmed.numportal.service.policy; -import static de.vitagroup.num.domain.templates.ExceptionsTemplate.INVALID_AQL; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; - -import org.ehrbase.aql.dto.AqlDto; +import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser; +import org.highmed.numportal.service.policy.TemplatesPolicy; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import org.highmed.numportal.service.exception.SystemException; -import de.vitagroup.num.service.exception.SystemException; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertTrue; @RunWith(MockitoJUnitRunner.class) public class TemplatesPolicyTest { @@ -22,8 +20,6 @@ public void applyAqlDtoIsNull() { Map templatesMap = new HashMap<>(); templatesMap.put("1", "1"); TemplatesPolicy templatesPolicy = TemplatesPolicy.builder().templatesMap(templatesMap).build(); - when(templatesPolicy.apply(null)) - .thenThrow(new SystemException(TemplatesPolicy.class, INVALID_AQL)); templatesPolicy.apply(null); } @@ -38,7 +34,7 @@ public void applyAqlDtoIsNotNull() { Map templatesMap = new HashMap<>(); templatesMap.put("1", "1"); TemplatesPolicy templatesPolicy = TemplatesPolicy.builder().templatesMap(templatesMap).build(); - assertTrue(templatesPolicy.apply(new AqlDto())); + assertTrue(templatesPolicy.apply(AqlQueryParser.parse("select e from Ehr e"))); } } diff --git a/src/test/java/de/vitagroup/num/service/zars/MemoryAppender.java b/src/test/java/org/highmed/numportal/service/zars/MemoryAppender.java similarity index 91% rename from src/test/java/de/vitagroup/num/service/zars/MemoryAppender.java rename to src/test/java/org/highmed/numportal/service/zars/MemoryAppender.java index 7e6df6a38..d5ec7d8c2 100644 --- a/src/test/java/de/vitagroup/num/service/zars/MemoryAppender.java +++ b/src/test/java/org/highmed/numportal/service/zars/MemoryAppender.java @@ -1,4 +1,4 @@ -package de.vitagroup.num.service.zars; +package org.highmed.numportal.service.zars; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; diff --git a/src/test/java/de/vitagroup/num/service/zars/TestMessageSource.java b/src/test/java/org/highmed/numportal/service/zars/TestMessageSource.java similarity index 89% rename from src/test/java/de/vitagroup/num/service/zars/TestMessageSource.java rename to src/test/java/org/highmed/numportal/service/zars/TestMessageSource.java index f72d34d50..d7ca551a0 100644 --- a/src/test/java/de/vitagroup/num/service/zars/TestMessageSource.java +++ b/src/test/java/org/highmed/numportal/service/zars/TestMessageSource.java @@ -1,8 +1,9 @@ -package de.vitagroup.num.service.zars; +package org.highmed.numportal.service.zars; -import java.nio.charset.StandardCharsets; import org.springframework.context.support.ReloadableResourceBundleMessageSource; +import java.nio.charset.StandardCharsets; + public class TestMessageSource extends ReloadableResourceBundleMessageSource { public TestMessageSource() { diff --git a/src/test/java/de/vitagroup/num/service/zars/ZarsServiceTest.java b/src/test/java/org/highmed/numportal/service/zars/ZarsServiceTest.java similarity index 84% rename from src/test/java/de/vitagroup/num/service/zars/ZarsServiceTest.java rename to src/test/java/org/highmed/numportal/service/zars/ZarsServiceTest.java index 9622131d5..3dec4c9dc 100644 --- a/src/test/java/de/vitagroup/num/service/zars/ZarsServiceTest.java +++ b/src/test/java/org/highmed/numportal/service/zars/ZarsServiceTest.java @@ -1,20 +1,9 @@ -package de.vitagroup.num.service.zars; - -import static org.junit.jupiter.api.Assertions.assertTrue; +package org.highmed.numportal.service.zars; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import com.fasterxml.jackson.databind.ObjectMapper; -import de.vitagroup.num.domain.model.ProjectCategories; -import de.vitagroup.num.domain.model.ProjectStatus; -import de.vitagroup.num.domain.dto.ZarsInfoDto; -import de.vitagroup.num.service.email.EmailService; -import de.vitagroup.num.service.email.ZarsProperties; -import de.vitagroup.num.service.email.ZarsService; - -import java.time.LocalDate; -import java.util.Set; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,6 +13,17 @@ import org.mockito.junit.MockitoJUnitRunner; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; +import org.highmed.numportal.domain.dto.ZarsInfoDto; +import org.highmed.numportal.domain.model.ProjectCategories; +import org.highmed.numportal.domain.model.ProjectStatus; +import org.highmed.numportal.service.email.EmailService; +import org.highmed.numportal.service.email.ZarsProperties; +import org.highmed.numportal.service.email.ZarsService; + +import java.time.LocalDate; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.assertTrue; @RunWith(MockitoJUnitRunner.class) public class ZarsServiceTest { diff --git a/src/test/resources/application-itest.yml b/src/test/resources/application-itest.yml index aee498e71..59e065d01 100644 --- a/src/test/resources/application-itest.yml +++ b/src/test/resources/application-itest.yml @@ -31,7 +31,7 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/certs + jwk-set-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/certs client: registration: userStoreClient: @@ -40,7 +40,7 @@ spring: client-secret: bc1843c0-3c57-4c2c-9b40-ac38e6dd545e provider: userStoreClient: - token-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/token + token-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/token mail: host: smtp.gmail.com port: 587 @@ -57,13 +57,13 @@ spring: swagger: oauth2: - token-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/token - auth-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/auth + token-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/token + auth-uri: ${keycloak.url}/realms/Num/protocol/openid-connect client-name: numPortalWebapp client-secret: numPortalWebapp userstore: - url: ${keycloak.url}/auth/admin/realms/Num + url: ${keycloak.url}/admin/realms/Num keycloak: url: http://localhost:8099 @@ -95,6 +95,8 @@ ehrbase: rest-api-url: http://localhost:8099/ehrbase/ username: ehrbase-user password: SuperSecretPassword + adminUsername: ehrbase-admin + adminPassword: EvenMoreSecretPassword cors: allowedOrigins: @@ -128,8 +130,6 @@ consent: allow-usage-outside-eu-oid: 2.16.840.1.113883.3.1937.777.24.5.1.37 num: - systemStatusUrl: 'http://localhost:8099/health-url' - statusCakeUrl: 'http://localhost:8099/statusCake?PublicID=' userManualUrl: DE: 'user-manual-de' EN: 'user-manual-en' diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 825ea2c8e..93e816124 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -27,7 +27,7 @@ spring: oauth2: resourceserver: jwt: - jwk-set-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/certs + jwk-set-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/certs client: registration: userStoreClient: @@ -36,7 +36,7 @@ spring: client-secret: bc1843c0-3c57-4c2c-9b40-ac38e6dd545e provider: userStoreClient: - token-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/token + token-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/token mail: host: smtp.gmail.com port: 587 @@ -53,13 +53,13 @@ spring: swagger: oauth2: - token-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/token - auth-uri: ${keycloak.url}/auth/realms/Num/protocol/openid-connect/auth + token-uri: ${keycloak.url}/realms/Num/protocol/openid-connect/token + auth-uri: ${keycloak.url}/realms/Num/protocol/openid-connect client-name: numPortalWebapp client-secret: numPortalWebapp userstore: - url: ${keycloak.url}/auth/admin/realms/Num + url: ${keycloak.url}/admin/realms/Num keycloak: url: http://localhost:8099 diff --git a/src/test/resources/health-check/NUM-Codex-Status.html b/src/test/resources/health-check/NUM-Codex-Status.html deleted file mode 100644 index 6d469b79f..000000000 --- a/src/test/resources/health-check/NUM-Codex-Status.html +++ /dev/null @@ -1,577 +0,0 @@ - - - - - - - - - - - - NUM Codex Status - - - - - - - -
- -
- -
- - - -
-
- -
-

Announcements

- -
- -
-

Uptime History

-
- - - - - - - - - - - -
StatusNameRateOct 07Oct 08Oct 09Oct 10Oct 11Oct 12Oct 13
CODEX NUM Pre-Prod - Backend5m
CODEX NUM Pre-Prod - DSF FHIR5m
CODEX NUM Pre-Prod - Ehrbase5m
CODEX NUM Pre-Prod - FHIR-Bridge5m
CODEX NUM Pre-Prod - Frontend5m
CODEX NUM PreProd - Keycloak5m
CODEX NUM Prod - Backend5m
CODEX NUM Prod - DSF FHIR5m
CODEX NUM Prod - Ehrbase5m
CODEX NUM Prod - FHIR-Bridge5m
CODEX NUM Prod - Frontend5m
CODEX NUM Prod - Keycloak5m
-
-
- - All times reported in the Europe/Berlin timezone -

-
- -
- - - - - -
-

7 Day Uptime

-
99.98%
-
-
-
-
- - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/health-check/statusCakeResponse.json b/src/test/resources/health-check/statusCakeResponse.json deleted file mode 100644 index 1790ef46d..000000000 --- a/src/test/resources/health-check/statusCakeResponse.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "Twitter": "", - "ShowAd": false, - "Facebook": "", - "BG": "rgb(245, 245, 245)", - "HeadBG": "rgb(248, 248, 248)", - "BlockHead": "rgb(100, 100, 100)", - "Announce": "

Imprint<\/a><\/p>

Data Protection<\/a><\/p>", - "Client": "105620", - "Skin": "", - "Orbs": 1, - "Title": "NUM Codex Status", - "LogoImage": "https:\/\/app.statuscake.com\/Uploads\/Logos\/9304102.png", - "Dates": ["Oct 07", "Oct 08", "Oct 09", "Oct 10", "Oct 11", "Oct 12", "Oct 13"], - "TestData": [{ - "TestID": "6670021", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Backend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6921168", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - DSF FHIR", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6744350", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Ehrbase", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 99.29, 100, 100, 100] - }, { - "TestID": "6750399", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - FHIR-Bridge", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "5892740", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Frontend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6783127", - "CheckRate": "300", - "Name": "CODEX NUM PreProd - Keycloak", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6761875", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Backend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6657055", - "CheckRate": "300", - "Name": "CODEX NUM Prod - DSF FHIR", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6748871", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Ehrbase", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6750495", - "CheckRate": "300", - "Name": "CODEX NUM Prod - FHIR-Bridge", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 99.3, 100, 100, 100] - }, { - "TestID": "6139213", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Frontend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6657053", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Keycloak", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - } - ] -} diff --git a/src/test/resources/health-check/statusCakeResponseWithAnnouncements.json b/src/test/resources/health-check/statusCakeResponseWithAnnouncements.json deleted file mode 100644 index 9790bf2c3..000000000 --- a/src/test/resources/health-check/statusCakeResponseWithAnnouncements.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "Twitter": "", - "ShowAd": false, - "Facebook": "", - "BG": "rgb(245, 245, 245)", - "HeadBG": "rgb(248, 248, 248)", - "BlockHead": "rgb(100, 100, 100)", - "Announce": "


Date/TimeDescription
13:30Testing

Imprint<\/a><\/p>

Data Protection<\/a><\/p>", - "Client": "105620", - "Skin": "", - "Orbs": 1, - "Title": "NUM Codex Status", - "LogoImage": "https:\/\/app.statuscake.com\/Uploads\/Logos\/9304102.png", - "Dates": ["Oct 07", "Oct 08", "Oct 09", "Oct 10", "Oct 11", "Oct 12", "Oct 13"], - "TestData": [{ - "TestID": "6670021", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Backend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6921168", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - DSF FHIR", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6744350", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Ehrbase", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 99.29, 100, 100, 100] - }, { - "TestID": "6750399", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - FHIR-Bridge", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "5892740", - "CheckRate": "300", - "Name": "CODEX NUM Pre-Prod - Frontend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6783127", - "CheckRate": "300", - "Name": "CODEX NUM PreProd - Keycloak", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6761875", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Backend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6657055", - "CheckRate": "300", - "Name": "CODEX NUM Prod - DSF FHIR", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6748871", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Ehrbase", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6750495", - "CheckRate": "300", - "Name": "CODEX NUM Prod - FHIR-Bridge", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 99.3, 100, 100, 100] - }, { - "TestID": "6139213", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Frontend", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - }, { - "TestID": "6657053", - "CheckRate": "300", - "Name": "CODEX NUM Prod - Keycloak", - "TestType": "HTTP", - "Status": "Up", - "Uptime": [100, 100, 100, 100, 100, 100, 100] - } - ] -} diff --git a/src/test/resources/testdata/expected.json b/src/test/resources/testdata/expected.json index 7fc5b5a57..c0bfa51ab 100644 --- a/src/test/resources/testdata/expected.json +++ b/src/test/resources/testdata/expected.json @@ -1,6 +1,4 @@ { - "meta" : null, - "q" : null, "columns" : [ { "path" : "c1/k4", "name" : "c1/k4"