From 377d7e9e31c0cecf679424fac0b6dcef7894f3c1 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Struewer <j.n.struewer@gmail.com> Date: Thu, 25 Jul 2024 14:53:20 +0200 Subject: [PATCH 1/9] build: created multi project setup based on gradle's composite guide --- .dockerignore | 4 +- .env | 10 -- .gitignore | 2 +- Dockerfile | 2 +- README.md | 2 +- app/backend/build.gradle.kts | 84 +++++++++++ .../iem/app}/DataProviderApplication.kt | 4 +- .../de/fraunhofer/iem/app}/StartUpHandler.kt | 18 +-- .../iem/app}/configuration/ApiPaths.kt | 2 +- .../configuration/DirectoryPathsProperties.kt | 2 +- .../iem/app}/configuration/InitialProjects.kt | 2 +- .../configuration/OpenCodeApiProperties.kt | 2 +- .../OpenCodeGitlabApiProperties.kt | 2 +- .../configuration/security/ApiKeyService.kt | 2 +- .../app}/configuration/security/JwtService.kt | 4 +- .../security/SecurityProperties.kt | 2 +- .../security/WebSecurityConfiguration.kt | 4 +- .../gitlab/controller/GitlabController.kt | 10 +- .../iem/app}/gitlab/dto/CommitStats.kt | 2 +- .../iem/app/gitlab/dto/MemberDto.kt | 6 + .../gitlab/dto/RepositoryChangedRequestDto.kt | 2 +- .../app}/gitlab/enumeration/AccessLevel.kt | 2 +- .../app}/gitlab/service/OpenCodeGitlabApi.kt | 18 +-- .../iem/app}/kpi/dto/KPIHierarchyEdgeDto.kt | 2 +- .../app}/kpi/dto/KPITreeChildResponseDto.kt | 2 +- .../iem/app}/kpi/dto/KPITreeResponseDto.kt | 2 +- .../iem/app}/kpi/dto/KpiCalculationDto.kt | 9 +- .../iem/app/kpi/dto/RawValueKpiCreateDto.kt | 17 +++ .../iem/app}/kpi/entity/KPIEntity.kt | 12 +- .../iem/app}/kpi/enumeration/KpiKind.kt | 6 +- .../iem/app}/kpi/service/KPIService.kt | 30 ++-- .../AggregationKPICalculationStrategy.kt | 6 +- .../kpi/strategy/KPICalculationStrategy.kt | 4 +- .../strategy/MaximumKPICalculationStrategy.kt | 6 +- .../strategy/RatioKPICalculationStrategy.kt | 6 +- .../RawValueKPICalculationStrategy.kt | 10 ++ .../iem/app}/logger/DefaultLogger.kt | 2 +- .../controller/RepositoryController.kt | 30 ++-- .../iem/app}/repository/dto/OkResponseDto.kt | 2 +- .../iem/app/repository/dto/RawKpiDto.kt | 5 + .../repository/dto/RepositoryConsentDto.kt | 2 +- .../repository/dto/RepositoryCreateDto.kt | 4 +- .../repository/dto/RepositoryDetailsDto.kt | 2 +- .../repository/dto/RepositoryResponseDto.kt | 2 +- .../repository/dto/ScoreCardResponseDto.kt | 8 + .../app/repository/dto/ToolRunResponseDto.kt | 5 + .../repository/entity/RepositoryEntity.kt | 4 +- .../repository/RepositoryRepository.kt | 4 +- .../repository/service/RepositoryService.kt | 30 ++-- .../app}/tool/controller/ToolController.kt | 8 +- .../iem/app}/tool/dto/CreateToolDto.kt | 6 +- .../fraunhofer/iem/app/tool/dto/FindingDto.kt | 3 + .../de/fraunhofer/iem/app/tool/dto/ToolDto.kt | 11 ++ .../iem/app}/tool/entity/ToolEntity.kt | 6 +- .../iem/app}/tool/enumeration/ToolType.kt | 6 +- .../app}/tool/repository/ToolRepository.kt | 4 +- .../iem/app}/tool/service/ToolService.kt | 14 +- .../iem/app}/toolRun/dto/LanguageDto.kt | 2 +- .../iem/app}/toolRun/dto/ToolRunDto.kt | 6 +- .../iem/app}/toolRun/entity/LanguageEntity.kt | 2 +- .../iem/app}/toolRun/entity/ToolRunEntity.kt | 9 +- .../toolRun/repository/ToolRunRepository.kt | 4 +- .../app}/toolRun/service/ToolRunService.kt | 20 +-- .../service/RepositoryDetailsService.kt | 10 +- .../app}/tools/occmd/enumeration/Checks.kt | 2 +- .../app}/tools/occmd/json/RawResultJson.kt | 2 +- .../tools/occmd/json/SecretResultsJson.kt | 2 +- .../app}/tools/occmd/json/ToolSecretJson.kt | 2 +- .../tools/occmd/json/ToolSecretResultJson.kt | 2 +- .../app}/tools/occmd/service/OccmdService.kt | 14 +- .../app}/tools/ort/dto/VulnerabilityDto.kt | 2 +- .../iem/app}/tools/ort/json/DataJson.kt | 2 +- .../iem/app}/tools/ort/json/OrtJson.kt | 4 +- .../iem/app}/tools/ort/json/ReferenceJson.kt | 2 +- .../iem/app}/tools/ort/json/ResultJson.kt | 2 +- .../iem/app}/tools/ort/service/OrtService.kt | 24 ++- .../app}/user/dto/UserDetailsResponseDto.kt | 2 +- .../iem/app}/user/dto/UserResponseDto.kt | 2 +- .../iem/app/user/dto/ValidateUserDto.kt | 3 + .../iem/app}/user/service/UserService.kt | 8 +- .../iem/app}/utilities/HttpClientWrapper.kt | 2 +- .../main/resources/application-dev.properties | 1 - .../resources/application-local.properties | 0 .../resources/application-prod.properties | 0 .../src}/main/resources/scripts/occmd.sh | 0 .../AggregationKPICalculationStrategyTest.kt | 0 .../tools/ort/service/OrtServiceTest.kt | 0 .../tools/ort/service/ortExample.json | 0 .../test/resources/application.properties | 0 {tools => app/backend/tools}/db/Dockerfile | 0 {tools => app/backend/tools}/db/api.json | 0 .../backend/tools}/db/docker-compose.yml | 2 +- .../backend/tools}/db/json-server.json | 0 {tools => app/backend/tools}/occmd/Dockerfile | 0 .../backend/tools}/occmd/occmdcfg.ini | 0 app/settings.gradle.kts | 3 + build.gradle.kts | 141 +----------------- kpi-calculator/core/build.gradle.kts | 21 +++ kpi-calculator/core/src/main/kotlin/Main.kt | 5 + kpi-calculator/settings.gradle.kts | 3 + settings.gradle.kts | 6 + .../iem/dataprovider/gitlab/dto/MemberDto.kt | 6 - .../kpi/dto/RawValueKpiCreateDto.kt | 18 --- .../RawValueKPICalculationStrategy.kt | 9 -- .../dataprovider/repository/dto/RawKpiDto.kt | 5 - .../repository/dto/ScoreCardResponseDto.kt | 8 - .../repository/dto/ToolRunResponseDto.kt | 5 - .../iem/dataprovider/tool/dto/FindingDto.kt | 3 - .../iem/dataprovider/tool/dto/ToolDto.kt | 11 -- .../dataprovider/user/dto/ValidateUserDto.kt | 3 - 110 files changed, 405 insertions(+), 433 deletions(-) delete mode 100644 .env create mode 100644 app/backend/build.gradle.kts rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/DataProviderApplication.kt (82%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/StartUpHandler.kt (74%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/ApiPaths.kt (93%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/DirectoryPathsProperties.kt (95%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/InitialProjects.kt (93%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/OpenCodeApiProperties.kt (93%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/OpenCodeGitlabApiProperties.kt (94%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/security/ApiKeyService.kt (95%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/security/JwtService.kt (93%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/security/SecurityProperties.kt (92%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/configuration/security/WebSecurityConfiguration.kt (96%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/gitlab/controller/GitlabController.kt (67%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/gitlab/dto/CommitStats.kt (62%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/MemberDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/gitlab/dto/RepositoryChangedRequestDto.kt (54%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/gitlab/enumeration/AccessLevel.kt (91%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/gitlab/service/OpenCodeGitlabApi.kt (89%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/dto/KPIHierarchyEdgeDto.kt (78%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/dto/KPITreeChildResponseDto.kt (71%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/dto/KPITreeResponseDto.kt (94%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/dto/KpiCalculationDto.kt (86%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/RawValueKpiCreateDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/entity/KPIEntity.kt (82%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/enumeration/KpiKind.kt (98%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/service/KPIService.kt (91%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/strategy/AggregationKPICalculationStrategy.kt (90%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/strategy/KPICalculationStrategy.kt (54%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/strategy/MaximumKPICalculationStrategy.kt (79%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/kpi/strategy/RatioKPICalculationStrategy.kt (78%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RawValueKPICalculationStrategy.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/logger/DefaultLogger.kt (86%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/controller/RepositoryController.kt (89%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/dto/OkResponseDto.kt (50%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RawKpiDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/dto/RepositoryConsentDto.kt (50%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/dto/RepositoryCreateDto.kt (78%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/dto/RepositoryDetailsDto.kt (75%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/dto/RepositoryResponseDto.kt (70%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ScoreCardResponseDto.kt create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ToolRunResponseDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/entity/RepositoryEntity.kt (90%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/repository/RepositoryRepository.kt (80%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/repository/service/RepositoryService.kt (81%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/controller/ToolController.kt (69%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/dto/CreateToolDto.kt (50%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/FindingDto.kt create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/ToolDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/entity/ToolEntity.kt (82%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/enumeration/ToolType.kt (93%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/repository/ToolRepository.kt (77%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tool/service/ToolService.kt (69%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/dto/LanguageDto.kt (56%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/dto/ToolRunDto.kt (84%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/entity/LanguageEntity.kt (89%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/entity/ToolRunEntity.kt (79%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/repository/ToolRunRepository.kt (77%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/toolRun/service/ToolRunService.kt (90%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/gitlab/service/RepositoryDetailsService.kt (62%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/enumeration/Checks.kt (87%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/json/RawResultJson.kt (88%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/json/SecretResultsJson.kt (79%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/json/ToolSecretJson.kt (81%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/json/ToolSecretResultJson.kt (82%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/occmd/service/OccmdService.kt (91%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/dto/VulnerabilityDto.kt (66%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/json/DataJson.kt (86%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/json/OrtJson.kt (58%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/json/ReferenceJson.kt (84%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/json/ResultJson.kt (91%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/tools/ort/service/OrtService.kt (76%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/user/dto/UserDetailsResponseDto.kt (89%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/user/dto/UserResponseDto.kt (84%) create mode 100644 app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/ValidateUserDto.kt rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/user/service/UserService.kt (85%) rename {src/main/kotlin/de/fraunhofer/iem/dataprovider => app/backend/src/main/kotlin/de/fraunhofer/iem/app}/utilities/HttpClientWrapper.kt (93%) rename {src => app/backend/src}/main/resources/application-dev.properties (99%) rename {src => app/backend/src}/main/resources/application-local.properties (100%) rename {src => app/backend/src}/main/resources/application-prod.properties (100%) rename {src => app/backend/src}/main/resources/scripts/occmd.sh (100%) rename {src => app/backend/src}/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt (100%) rename {src => app/backend/src}/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt (100%) rename {src => app/backend/src}/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json (100%) rename {src => app/backend/src}/test/resources/application.properties (100%) rename {tools => app/backend/tools}/db/Dockerfile (100%) rename {tools => app/backend/tools}/db/api.json (100%) rename {tools => app/backend/tools}/db/docker-compose.yml (90%) rename {tools => app/backend/tools}/db/json-server.json (100%) rename {tools => app/backend/tools}/occmd/Dockerfile (100%) rename {tools => app/backend/tools}/occmd/occmdcfg.ini (100%) create mode 100644 app/settings.gradle.kts create mode 100644 kpi-calculator/core/build.gradle.kts create mode 100644 kpi-calculator/core/src/main/kotlin/Main.kt create mode 100644 kpi-calculator/settings.gradle.kts delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/MemberDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/RawValueKpiCreateDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RawValueKPICalculationStrategy.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RawKpiDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ScoreCardResponseDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ToolRunResponseDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/FindingDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/ToolDto.kt delete mode 100644 src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/ValidateUserDto.kt diff --git a/.dockerignore b/.dockerignore index 958acdc5..7a12d08c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -.env +app/backend/.env docker-compose.yml # from .gitignore @@ -9,4 +9,4 @@ bin **/.env **/.DS_Store src/test/testResults/* -tools/db/cockroach-data +app/backend/tools/db/cockroach-data diff --git a/.env b/.env deleted file mode 100644 index 6c10d6a4..00000000 --- a/.env +++ /dev/null @@ -1,10 +0,0 @@ -# exclude from git with: -# git update-index --skip-worktree .env -# revert: -# git update-index --no-skip-worktree .env -# -# e.g. oc000... from https://keycloak.opencode.de/auth/realms/osr/account/#/personal-info -SECRET_OC_GL_USER= -# https://gitlab.opencode.de/-/user_settings/personal_access_tokens -# with read_api, read_user, read_repository, read_registry -SECRET_OC_GL_APIKEY= diff --git a/.gitignore b/.gitignore index 8c38c5bb..68465b42 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ bin **/.env **/.DS_Store src/test/testResults/* -tools/db/cockroach-data +app/backend/tools/db/cockroach-data diff --git a/Dockerfile b/Dockerfile index 3b0a1851..21504e4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,7 @@ RUN set -eux; \ mkdir -p /occmd/resources/checks/checked_in_binaries/blacklist; \ git clone --depth 1 https://gitlab.opencode.de/opencode-analyzer/occmd-checked_in_binaries-blacklist /app/resources/checks/checked_in_binaries/blacklist; -COPY tools/occmd/occmdcfg.ini . +COPY app/backend/tools/occmd/occmdcfg.ini . VOLUME /tmp diff --git a/README.md b/README.md index 6c2f6204..f52c9b9e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ opencode 1. [add ssh key for authentification and commit signing](https://gitlab.opencode.de/-/user_settings/ssh_keys) 2. install Docker & test if "docker compose" (v2) is working. [docker-compose is v1 which does currently work but is not recommended](https://docs.docker.com/compose/migrate/#docker-compose-vs-docker-compose) - its suggested to install an alias for compose `printf "\nalias compose='%s'\n" "docker compose" >> ~/.bash_aliases` reload with `source ~/.bash_aliases` -3. read and fill [.env](./.env) +3. read and fill [.env](app/backend/.env) 4. exclude env from git index via `git update-index --skip-worktree .env` 5. `docker compose up` which starts opencode-db-1 and data-provider diff --git a/app/backend/build.gradle.kts b/app/backend/build.gradle.kts new file mode 100644 index 00000000..b4a26875 --- /dev/null +++ b/app/backend/build.gradle.kts @@ -0,0 +1,84 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +val springVersion = "3.3.1" + +plugins { + id("org.springframework.boot") version "3.3.1" + id("io.spring.dependency-management") version "1.1.6" + id("org.jetbrains.kotlin.plugin.allopen") version "2.0.20-Beta2" + kotlin("jvm") version "2.0.0" + kotlin("plugin.spring") version "2.0.20-Beta2" + kotlin("plugin.jpa") version "2.0.20-Beta2" + kotlin("plugin.serialization") version "2.0.0" +} + +allOpen { + annotation("javax.persistence.Entity") + annotation("javax.persistence.Embeddable") + annotation("javax.persistence.MappedSuperclass") + annotation("jakarta.persistence.Entity") + annotation("jakarta.persistence.Embeddable") + annotation("jakarta.persistence.MappedSuperclass") +} + +group = "de.fraunhofer.iem" +version = "0.0.2-SNAPSHOT" +java.sourceCompatibility = JavaVersion.VERSION_21 +configurations { + compileOnly { + extendsFrom(configurations.annotationProcessor.get()) + } +} + +repositories { + mavenCentral() +} + +val coroutineVersion = "1.9.0-RC" +val ktorVersion = "2.3.12" +dependencies { + implementation("de.fraunhofer.iem:core:0.0.2-SNAPSHOT") + implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion") + implementation("org.springframework.boot:spring-boot-starter-validation:$springVersion") + implementation("org.springframework.boot:spring-boot-starter-security:$springVersion") + implementation("org.springframework.boot:spring-boot-starter-webflux:$springVersion") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.1") + implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive:$coroutineVersion") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutineVersion") + implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:2.5.0") + implementation("org.gitlab4j:gitlab4j-api:6.0.0-rc.5") + implementation("org.eclipse.jgit:org.eclipse.jgit:6.10.0.202406032230-r") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") + implementation("org.springframework.boot:spring-boot-starter-actuator:$springVersion") + implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") + implementation("io.ktor:ktor-client-cio-jvm:$ktorVersion") + implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") + implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") + implementation("com.auth0:java-jwt:4.4.0") + developmentOnly("org.springframework.boot:spring-boot-devtools:$springVersion") + runtimeOnly("org.postgresql:postgresql:42.7.3") + testImplementation("org.springframework.boot:spring-boot-starter-test:$springVersion") { + exclude(module = "mockito-core") + exclude(group = "org.junit.vintage", module = "junit-vintage-engine") + } + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3") + testImplementation("io.ktor:ktor-client-mock-jvm:$ktorVersion") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3") + testRuntimeOnly("com.h2database:h2:2.2.224") + testImplementation("com.ninja-squad:springmockk:4.0.2") + testImplementation("org.springframework.security:spring-security-test:6.1.5") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion") +} + +tasks.withType<KotlinCompile> { + kotlinOptions { + freeCompilerArgs = listOf("-Xjsr305=strict") + jvmTarget = "21" + } +} + +tasks.withType<Test> { + useJUnitPlatform() +} diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/DataProviderApplication.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/DataProviderApplication.kt similarity index 82% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/DataProviderApplication.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/DataProviderApplication.kt index 66c55e71..2fc0c68c 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/DataProviderApplication.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/DataProviderApplication.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider +package de.fraunhofer.iem.app import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.context.properties.ConfigurationPropertiesScan @@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories import org.springframework.transaction.annotation.EnableTransactionManagement @SpringBootApplication -@ConfigurationPropertiesScan("de.fraunhofer.iem.dataprovider.configuration") +@ConfigurationPropertiesScan("de.fraunhofer.iem.app.configuration") @EnableTransactionManagement @EnableJpaRepositories class DataProviderApplication diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/StartUpHandler.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt similarity index 74% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/StartUpHandler.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt index c3f509b8..6224dff2 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/StartUpHandler.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt @@ -1,11 +1,12 @@ -package de.fraunhofer.iem.dataprovider +package de.fraunhofer.iem.app -import de.fraunhofer.iem.dataprovider.configuration.InitialProjects -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryConsentDto -import de.fraunhofer.iem.dataprovider.repository.service.RepositoryService -import de.fraunhofer.iem.dataprovider.tool.service.ToolService -import de.fraunhofer.iem.dataprovider.toolRun.service.ToolRunService +import de.fraunhofer.iem.app.configuration.InitialProjects +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.dto.RepositoryConsentDto +import de.fraunhofer.iem.app.repository.service.RepositoryService +import de.fraunhofer.iem.app.tool.service.ToolService +import de.fraunhofer.iem.app.toolRun.service.ToolRunService +import de.fraunhofer.iem.sayHello import kotlinx.coroutines.* import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener @@ -23,8 +24,7 @@ class StartUpHandler( @EventListener(ApplicationReadyEvent::class) suspend fun queryProjects() { - - + sayHello() withContext(Dispatchers.IO) { logger.info("Creating tools in db") toolService.createAllTools() diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/ApiPaths.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/ApiPaths.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/ApiPaths.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/ApiPaths.kt index aa70c7e0..ce4dd0a9 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/ApiPaths.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/ApiPaths.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration +package de.fraunhofer.iem.app.configuration object ApiPaths { private const val BASE = "/api" diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/DirectoryPathsProperties.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/DirectoryPathsProperties.kt similarity index 95% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/DirectoryPathsProperties.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/DirectoryPathsProperties.kt index b09be70c..f256beeb 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/DirectoryPathsProperties.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/DirectoryPathsProperties.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration +package de.fraunhofer.iem.app.configuration import jakarta.annotation.PostConstruct import jakarta.validation.constraints.NotBlank diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/InitialProjects.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/InitialProjects.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/InitialProjects.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/InitialProjects.kt index 07b929f7..97348a35 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/InitialProjects.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/InitialProjects.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration +package de.fraunhofer.iem.app.configuration import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationPropertiesScan diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeApiProperties.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeApiProperties.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeApiProperties.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeApiProperties.kt index 5f013e1b..78acc823 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeApiProperties.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeApiProperties.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration +package de.fraunhofer.iem.app.configuration import jakarta.annotation.PostConstruct import jakarta.validation.constraints.NotBlank diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeGitlabApiProperties.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeGitlabApiProperties.kt similarity index 94% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeGitlabApiProperties.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeGitlabApiProperties.kt index 99f6d921..9f749e3c 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/OpenCodeGitlabApiProperties.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/OpenCodeGitlabApiProperties.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration +package de.fraunhofer.iem.app.configuration import jakarta.annotation.PostConstruct import jakarta.validation.constraints.NotBlank diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/ApiKeyService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/ApiKeyService.kt similarity index 95% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/ApiKeyService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/ApiKeyService.kt index 907257db..38581c07 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/ApiKeyService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/ApiKeyService.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration.security +package de.fraunhofer.iem.app.configuration.security import org.springframework.http.HttpStatus import org.springframework.stereotype.Component diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/JwtService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/JwtService.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/JwtService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/JwtService.kt index daef2205..66058617 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/JwtService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/JwtService.kt @@ -1,11 +1,11 @@ -package de.fraunhofer.iem.dataprovider.configuration.security +package de.fraunhofer.iem.app.configuration.security import com.auth0.jwt.JWT import com.auth0.jwt.JWTVerifier import com.auth0.jwt.algorithms.Algorithm import com.auth0.jwt.exceptions.JWTCreationException import com.auth0.jwt.exceptions.JWTVerificationException -import de.fraunhofer.iem.dataprovider.logger.getLogger +import de.fraunhofer.iem.app.logger.getLogger import org.springframework.stereotype.Service data class JwtContentDto(val gitlabId: Long) { diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/SecurityProperties.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/SecurityProperties.kt similarity index 92% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/SecurityProperties.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/SecurityProperties.kt index 525dfc63..95c31296 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/SecurityProperties.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/SecurityProperties.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.configuration.security +package de.fraunhofer.iem.app.configuration.security import jakarta.validation.constraints.NotBlank import org.hibernate.validator.constraints.Length diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/WebSecurityConfiguration.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/WebSecurityConfiguration.kt similarity index 96% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/WebSecurityConfiguration.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/WebSecurityConfiguration.kt index 4267af1b..dd6afa6c 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/configuration/security/WebSecurityConfiguration.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/configuration/security/WebSecurityConfiguration.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.configuration.security +package de.fraunhofer.iem.app.configuration.security -import de.fraunhofer.iem.dataprovider.configuration.ApiPaths +import de.fraunhofer.iem.app.configuration.ApiPaths import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/controller/GitlabController.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/controller/GitlabController.kt similarity index 67% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/controller/GitlabController.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/controller/GitlabController.kt index b0ebd27c..d0856fd7 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/controller/GitlabController.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/controller/GitlabController.kt @@ -1,9 +1,9 @@ -package de.fraunhofer.iem.dataprovider.gitlab.controller +package de.fraunhofer.iem.app.gitlab.controller -import de.fraunhofer.iem.dataprovider.configuration.ApiPaths -import de.fraunhofer.iem.dataprovider.gitlab.dto.RepositoryChangedRequestDto -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.toolRun.service.ToolRunService +import de.fraunhofer.iem.app.configuration.ApiPaths +import de.fraunhofer.iem.app.gitlab.dto.RepositoryChangedRequestDto +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.toolRun.service.ToolRunService import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/CommitStats.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/CommitStats.kt similarity index 62% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/CommitStats.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/CommitStats.kt index 0df21936..f7c0a9c7 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/CommitStats.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/CommitStats.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.gitlab.dto +package de.fraunhofer.iem.app.gitlab.dto data class CommitStats(val numberOfCommits: Int, val numberOfSignedCommits: Int) diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/MemberDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/MemberDto.kt new file mode 100644 index 00000000..fd5faf86 --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/MemberDto.kt @@ -0,0 +1,6 @@ +package de.fraunhofer.iem.app.gitlab.dto + +import de.fraunhofer.iem.app.gitlab.enumeration.AccessLevel + + +data class MemberDto(val id: Long, val name: String, val accessLevel: AccessLevel) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/RepositoryChangedRequestDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/RepositoryChangedRequestDto.kt similarity index 54% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/RepositoryChangedRequestDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/RepositoryChangedRequestDto.kt index 1b1862fc..c552d4ea 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/RepositoryChangedRequestDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/dto/RepositoryChangedRequestDto.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.gitlab.dto +package de.fraunhofer.iem.app.gitlab.dto data class RepositoryChangedRequestDto(val projectId: Long) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/enumeration/AccessLevel.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/enumeration/AccessLevel.kt similarity index 91% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/enumeration/AccessLevel.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/enumeration/AccessLevel.kt index 1e0dafb4..f93437ea 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/enumeration/AccessLevel.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/enumeration/AccessLevel.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.gitlab.enumeration +package de.fraunhofer.iem.app.gitlab.enumeration enum class AccessLevel(val value: Int) { INVALID(-1), diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/service/OpenCodeGitlabApi.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/service/OpenCodeGitlabApi.kt similarity index 89% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/service/OpenCodeGitlabApi.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/service/OpenCodeGitlabApi.kt index 60e1a490..7f30cd69 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/service/OpenCodeGitlabApi.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/gitlab/service/OpenCodeGitlabApi.kt @@ -1,12 +1,12 @@ -package de.fraunhofer.iem.dataprovider.gitlab.service - -import de.fraunhofer.iem.dataprovider.configuration.OpenCodeGitlabApiProperties -import de.fraunhofer.iem.dataprovider.gitlab.dto.CommitStats -import de.fraunhofer.iem.dataprovider.gitlab.dto.MemberDto -import de.fraunhofer.iem.dataprovider.gitlab.enumeration.AccessLevel -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryCreateDto -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryDetailsDto +package de.fraunhofer.iem.app.gitlab.service + +import de.fraunhofer.iem.app.configuration.OpenCodeGitlabApiProperties +import de.fraunhofer.iem.app.gitlab.dto.CommitStats +import de.fraunhofer.iem.app.gitlab.dto.MemberDto +import de.fraunhofer.iem.app.gitlab.enumeration.AccessLevel +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.dto.RepositoryCreateDto +import de.fraunhofer.iem.app.repository.dto.RepositoryDetailsDto import kotlinx.coroutines.* import org.gitlab4j.api.GitLabApi import org.gitlab4j.api.models.Commit diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPIHierarchyEdgeDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPIHierarchyEdgeDto.kt similarity index 78% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPIHierarchyEdgeDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPIHierarchyEdgeDto.kt index cc042cbf..07b2f8a9 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPIHierarchyEdgeDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPIHierarchyEdgeDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.kpi.dto +package de.fraunhofer.iem.app.kpi.dto data class KPIHierarchyEdgeDto( val from: KpiCalculationDto, diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeChildResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeChildResponseDto.kt similarity index 71% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeChildResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeChildResponseDto.kt index 6113f733..96058ac0 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeChildResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeChildResponseDto.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.kpi.dto +package de.fraunhofer.iem.app.kpi.dto data class KPITreeChildResponseDto(val kpi: KPITreeResponseDto, val plannedWeight: Double, val actualWeight: Double) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeResponseDto.kt similarity index 94% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeResponseDto.kt index a1c82980..b3148cda 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KPITreeResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KPITreeResponseDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.kpi.dto +package de.fraunhofer.iem.app.kpi.dto const val DEFAULT_LOW_SCORE_THRESHOLD = 20 diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KpiCalculationDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KpiCalculationDto.kt similarity index 86% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KpiCalculationDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KpiCalculationDto.kt index 03f234f2..0d3a7ae2 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/KpiCalculationDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/KpiCalculationDto.kt @@ -1,12 +1,11 @@ -package de.fraunhofer.iem.dataprovider.kpi.dto +package de.fraunhofer.iem.app.kpi.dto -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind -import de.fraunhofer.iem.dataprovider.kpi.strategy.KPICalculationStrategy -import de.fraunhofer.iem.dataprovider.logger.getLogger +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.logger.getLogger class KpiCalculationDto( val kind: KpiKind, - private val calculationStrategy: KPICalculationStrategy? = null, + private val calculationStrategy: de.fraunhofer.iem.app.kpi.strategy.KPICalculationStrategy? = null, private var isEmpty: Boolean = true, private var value: Int? = null ) { diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/RawValueKpiCreateDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/RawValueKpiCreateDto.kt new file mode 100644 index 00000000..cc91d6a1 --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/dto/RawValueKpiCreateDto.kt @@ -0,0 +1,17 @@ +package de.fraunhofer.iem.app.kpi.dto + +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity +import java.sql.Timestamp +import java.time.Instant + +data class RawValueKpiCreateDto(val kind: KpiKind, val score: Int) { + fun toDbObject(toolRun: ToolRunEntity): de.fraunhofer.iem.app.kpi.entity.KPIEntity { + return de.fraunhofer.iem.app.kpi.entity.KPIEntity( + kind = this.kind, + score = this.score, + createdAt = Timestamp.from(Instant.now()), + toolRunEntity = toolRun + ) + } +} diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/entity/KPIEntity.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/entity/KPIEntity.kt similarity index 82% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/entity/KPIEntity.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/entity/KPIEntity.kt index 74b070a4..f288d98f 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/entity/KPIEntity.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/entity/KPIEntity.kt @@ -1,9 +1,9 @@ -package de.fraunhofer.iem.dataprovider.kpi.entity +package de.fraunhofer.iem.app.kpi.entity -import de.fraunhofer.iem.dataprovider.kpi.dto.KpiCalculationDto -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind -import de.fraunhofer.iem.dataprovider.kpi.strategy.RawValueKPICalculationStrategy -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity +import de.fraunhofer.iem.app.kpi.dto.KpiCalculationDto +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.kpi.strategy.RawValueKPICalculationStrategy +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity import jakarta.persistence.* import org.hibernate.annotations.CurrentTimestamp import org.hibernate.generator.EventType @@ -49,7 +49,7 @@ class KPIEntity( val thisEffectiveClass = if (this is HibernateProxy) this.hibernateLazyInitializer.persistentClass else this.javaClass if (thisEffectiveClass != oEffectiveClass) return false - other as KPIEntity + other as de.fraunhofer.iem.app.kpi.entity.KPIEntity return id != null && id == other.id } diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/enumeration/KpiKind.kt similarity index 98% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/enumeration/KpiKind.kt index 5e0a6437..5ce7ddd6 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/enumeration/KpiKind.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.kpi.enumeration +package de.fraunhofer.iem.app.kpi.enumeration -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeChildResponseDto -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeResponseDto +import de.fraunhofer.iem.app.kpi.dto.KPITreeChildResponseDto +import de.fraunhofer.iem.app.kpi.dto.KPITreeResponseDto enum class KpiKind { // Raw Value KPIs diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/service/KPIService.kt similarity index 91% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/service/KPIService.kt index 6aaac16a..35e64833 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/service/KPIService.kt @@ -1,18 +1,18 @@ -package de.fraunhofer.iem.dataprovider.kpi.service - -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeChildResponseDto -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeResponseDto -import de.fraunhofer.iem.dataprovider.kpi.dto.KpiCalculationDto -import de.fraunhofer.iem.dataprovider.kpi.dto.RawValueKpiCreateDto -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind -import de.fraunhofer.iem.dataprovider.kpi.strategy.AggregationKPICalculationStrategy -import de.fraunhofer.iem.dataprovider.kpi.strategy.MaximumKPICalculationStrategy -import de.fraunhofer.iem.dataprovider.kpi.strategy.RatioKPICalculationStrategy -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryDetailsDto -import de.fraunhofer.iem.dataprovider.tools.occmd.enumeration.Checks -import de.fraunhofer.iem.dataprovider.tools.occmd.json.RawResultJson -import de.fraunhofer.iem.dataprovider.tools.ort.dto.VulnerabilityDto +package de.fraunhofer.iem.app.kpi.service + +import de.fraunhofer.iem.app.kpi.dto.KPITreeChildResponseDto +import de.fraunhofer.iem.app.kpi.dto.KPITreeResponseDto +import de.fraunhofer.iem.app.kpi.dto.KpiCalculationDto +import de.fraunhofer.iem.app.kpi.dto.RawValueKpiCreateDto +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.kpi.strategy.AggregationKPICalculationStrategy +import de.fraunhofer.iem.app.kpi.strategy.MaximumKPICalculationStrategy +import de.fraunhofer.iem.app.kpi.strategy.RatioKPICalculationStrategy +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.dto.RepositoryDetailsDto +import de.fraunhofer.iem.app.tools.occmd.enumeration.Checks +import de.fraunhofer.iem.app.tools.occmd.json.RawResultJson +import de.fraunhofer.iem.app.tools.ort.dto.VulnerabilityDto import org.springframework.stereotype.Service @Service diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategy.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategy.kt similarity index 90% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategy.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategy.kt index 157e8d97..6eab9093 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategy.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategy.kt @@ -1,8 +1,8 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy +package de.fraunhofer.iem.app.kpi.strategy -import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto +import de.fraunhofer.iem.app.kpi.dto.KPIHierarchyEdgeDto -class AggregationKPICalculationStrategy : KPICalculationStrategy { +class AggregationKPICalculationStrategy : de.fraunhofer.iem.app.kpi.strategy.KPICalculationStrategy { /** * This function calculates the aggregate sum of all given children. diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/KPICalculationStrategy.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/KPICalculationStrategy.kt similarity index 54% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/KPICalculationStrategy.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/KPICalculationStrategy.kt index d80d4c55..8d31a145 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/KPICalculationStrategy.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/KPICalculationStrategy.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy +package de.fraunhofer.iem.app.kpi.strategy -import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto +import de.fraunhofer.iem.app.kpi.dto.KPIHierarchyEdgeDto fun interface KPICalculationStrategy { fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Pair<Int, List<KPIHierarchyEdgeDto>> diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/MaximumKPICalculationStrategy.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/MaximumKPICalculationStrategy.kt similarity index 79% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/MaximumKPICalculationStrategy.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/MaximumKPICalculationStrategy.kt index b22771ae..a82be9b5 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/MaximumKPICalculationStrategy.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/MaximumKPICalculationStrategy.kt @@ -1,8 +1,8 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy +package de.fraunhofer.iem.app.kpi.strategy -import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto +import de.fraunhofer.iem.app.kpi.dto.KPIHierarchyEdgeDto -class MaximumKPICalculationStrategy : KPICalculationStrategy { +class MaximumKPICalculationStrategy : de.fraunhofer.iem.app.kpi.strategy.KPICalculationStrategy { // TODO: Currently it's tailored to the maximum dependency vulnerability score, this should change in the future @Suppress("MagicNumber") override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Pair<Int, List<KPIHierarchyEdgeDto>> { diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RatioKPICalculationStrategy.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RatioKPICalculationStrategy.kt similarity index 78% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RatioKPICalculationStrategy.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RatioKPICalculationStrategy.kt index ec398d3e..d6f80d0e 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RatioKPICalculationStrategy.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RatioKPICalculationStrategy.kt @@ -1,8 +1,8 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy +package de.fraunhofer.iem.app.kpi.strategy -import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto +import de.fraunhofer.iem.app.kpi.dto.KPIHierarchyEdgeDto -class RatioKPICalculationStrategy : KPICalculationStrategy { +class RatioKPICalculationStrategy : de.fraunhofer.iem.app.kpi.strategy.KPICalculationStrategy { @Suppress("MagicNumber") override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Pair<Int, List<KPIHierarchyEdgeDto>> { if (children.size != 2) { diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RawValueKPICalculationStrategy.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RawValueKPICalculationStrategy.kt new file mode 100644 index 00000000..0bb577e7 --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/kpi/strategy/RawValueKPICalculationStrategy.kt @@ -0,0 +1,10 @@ +package de.fraunhofer.iem.app.kpi.strategy + +import de.fraunhofer.iem.app.kpi.dto.KPIHierarchyEdgeDto + +class RawValueKPICalculationStrategy(private val value: Int) : + de.fraunhofer.iem.app.kpi.strategy.KPICalculationStrategy { + override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Pair<Int, List<KPIHierarchyEdgeDto>> { + return Pair(this.value, children) + } +} diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/logger/DefaultLogger.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/logger/DefaultLogger.kt similarity index 86% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/logger/DefaultLogger.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/logger/DefaultLogger.kt index a74c62d9..7b33f28f 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/logger/DefaultLogger.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/logger/DefaultLogger.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.logger +package de.fraunhofer.iem.app.logger import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/controller/RepositoryController.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt similarity index 89% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/controller/RepositoryController.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt index 8a4cb378..9a8154b2 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/controller/RepositoryController.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/controller/RepositoryController.kt @@ -1,18 +1,18 @@ -package de.fraunhofer.iem.dataprovider.repository.controller - -import de.fraunhofer.iem.dataprovider.configuration.ApiPaths -import de.fraunhofer.iem.dataprovider.configuration.security.JwtContentDto -import de.fraunhofer.iem.dataprovider.configuration.security.JwtService -import de.fraunhofer.iem.dataprovider.gitlab.service.OpenCodeGitlabApi -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeResponseDto -import de.fraunhofer.iem.dataprovider.kpi.service.KPIService -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.dto.* -import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity -import de.fraunhofer.iem.dataprovider.repository.service.RepositoryService -import de.fraunhofer.iem.dataprovider.toolRun.service.ToolRunService -import de.fraunhofer.iem.dataprovider.user.dto.ValidateUserDto -import de.fraunhofer.iem.dataprovider.user.service.UserService +package de.fraunhofer.iem.app.repository.controller + +import de.fraunhofer.iem.app.configuration.ApiPaths +import de.fraunhofer.iem.app.configuration.security.JwtContentDto +import de.fraunhofer.iem.app.configuration.security.JwtService +import de.fraunhofer.iem.app.gitlab.service.OpenCodeGitlabApi +import de.fraunhofer.iem.app.kpi.dto.KPITreeResponseDto +import de.fraunhofer.iem.app.kpi.service.KPIService +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.dto.* +import de.fraunhofer.iem.app.repository.entity.RepositoryEntity +import de.fraunhofer.iem.app.repository.service.RepositoryService +import de.fraunhofer.iem.app.toolRun.service.ToolRunService +import de.fraunhofer.iem.app.user.dto.ValidateUserDto +import de.fraunhofer.iem.app.user.service.UserService import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.springframework.http.HttpHeaders diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/OkResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/OkResponseDto.kt similarity index 50% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/OkResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/OkResponseDto.kt index 11c3b397..08f26a88 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/OkResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/OkResponseDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.repository.dto +package de.fraunhofer.iem.app.repository.dto data class OkResponseDto( val status: Int = 200 diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RawKpiDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RawKpiDto.kt new file mode 100644 index 00000000..b3f66072 --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RawKpiDto.kt @@ -0,0 +1,5 @@ +package de.fraunhofer.iem.app.repository.dto + +import de.fraunhofer.iem.app.kpi.dto.KpiCalculationDto + +data class RawKpiDto(val rawKpis: List<KpiCalculationDto>) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryConsentDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryConsentDto.kt similarity index 50% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryConsentDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryConsentDto.kt index a9851d3b..c5094313 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryConsentDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryConsentDto.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.repository.dto +package de.fraunhofer.iem.app.repository.dto data class RepositoryConsentDto(val consent: Boolean) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryCreateDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryCreateDto.kt similarity index 78% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryCreateDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryCreateDto.kt index db7639e3..803e7c38 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryCreateDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryCreateDto.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.repository.dto +package de.fraunhofer.iem.app.repository.dto -import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity +import de.fraunhofer.iem.app.repository.entity.RepositoryEntity data class RepositoryCreateDto( val name: String, diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryDetailsDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryDetailsDto.kt similarity index 75% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryDetailsDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryDetailsDto.kt index 1eb7e8e4..11728527 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryDetailsDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryDetailsDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.repository.dto +package de.fraunhofer.iem.app.repository.dto data class RepositoryDetailsDto( val projectId: Long, diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryResponseDto.kt similarity index 70% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryResponseDto.kt index dc901744..19fa5b22 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RepositoryResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/RepositoryResponseDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.repository.dto +package de.fraunhofer.iem.app.repository.dto import java.util.* diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ScoreCardResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ScoreCardResponseDto.kt new file mode 100644 index 00000000..dd5680cd --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ScoreCardResponseDto.kt @@ -0,0 +1,8 @@ +package de.fraunhofer.iem.app.repository.dto + +import de.fraunhofer.iem.app.kpi.dto.KPITreeResponseDto + +data class ScoreCardResponseDto( + val repository: RepositoryResponseDto, + val kpis: KPITreeResponseDto? +) diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ToolRunResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ToolRunResponseDto.kt new file mode 100644 index 00000000..c4dc6b0a --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/dto/ToolRunResponseDto.kt @@ -0,0 +1,5 @@ +package de.fraunhofer.iem.app.repository.dto + +import de.fraunhofer.iem.app.toolRun.dto.ToolRunDto + +data class ToolRunResponseDto(val isProjectMember: Boolean = false, val toolRun: ToolRunDto) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/entity/RepositoryEntity.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/entity/RepositoryEntity.kt similarity index 90% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/entity/RepositoryEntity.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/entity/RepositoryEntity.kt index d0dfbcf7..5e848d6c 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/entity/RepositoryEntity.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/entity/RepositoryEntity.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.repository.entity +package de.fraunhofer.iem.app.repository.entity -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity import jakarta.persistence.* import org.hibernate.annotations.CurrentTimestamp import org.hibernate.annotations.UpdateTimestamp diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/repository/RepositoryRepository.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/repository/RepositoryRepository.kt similarity index 80% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/repository/RepositoryRepository.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/repository/RepositoryRepository.kt index 2be547e6..57f08e6a 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/repository/RepositoryRepository.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/repository/RepositoryRepository.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.repository.repository +package de.fraunhofer.iem.app.repository.repository -import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity +import de.fraunhofer.iem.app.repository.entity.RepositoryEntity import org.springframework.data.jpa.repository.JpaRepository import org.springframework.transaction.annotation.Propagation.MANDATORY import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/service/RepositoryService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/service/RepositoryService.kt similarity index 81% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/service/RepositoryService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/service/RepositoryService.kt index a75b8cfa..a05c2e45 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/service/RepositoryService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/repository/service/RepositoryService.kt @@ -1,18 +1,18 @@ -package de.fraunhofer.iem.dataprovider.repository.service - -import de.fraunhofer.iem.dataprovider.gitlab.service.OpenCodeGitlabApi -import de.fraunhofer.iem.dataprovider.kpi.dto.RawValueKpiCreateDto -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryConsentDto -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryCreateDto -import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity -import de.fraunhofer.iem.dataprovider.repository.repository.RepositoryRepository -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.service.ToolService -import de.fraunhofer.iem.dataprovider.toolRun.dto.ToolRunDto -import de.fraunhofer.iem.dataprovider.toolRun.entity.LanguageEntity -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity -import de.fraunhofer.iem.dataprovider.toolRun.repository.ToolRunRepository +package de.fraunhofer.iem.app.repository.service + +import de.fraunhofer.iem.app.gitlab.service.OpenCodeGitlabApi +import de.fraunhofer.iem.app.kpi.dto.RawValueKpiCreateDto +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.dto.RepositoryConsentDto +import de.fraunhofer.iem.app.repository.dto.RepositoryCreateDto +import de.fraunhofer.iem.app.repository.entity.RepositoryEntity +import de.fraunhofer.iem.app.repository.repository.RepositoryRepository +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.service.ToolService +import de.fraunhofer.iem.app.toolRun.dto.ToolRunDto +import de.fraunhofer.iem.app.toolRun.entity.LanguageEntity +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity +import de.fraunhofer.iem.app.toolRun.repository.ToolRunRepository import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/controller/ToolController.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/controller/ToolController.kt similarity index 69% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/controller/ToolController.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/controller/ToolController.kt index e118cbe0..9ac5bec7 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/controller/ToolController.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/controller/ToolController.kt @@ -1,8 +1,8 @@ -package de.fraunhofer.iem.dataprovider.tool.controller +package de.fraunhofer.iem.app.tool.controller -import de.fraunhofer.iem.dataprovider.configuration.ApiPaths -import de.fraunhofer.iem.dataprovider.tool.dto.ToolDto -import de.fraunhofer.iem.dataprovider.tool.repository.ToolRepository +import de.fraunhofer.iem.app.configuration.ApiPaths +import de.fraunhofer.iem.app.tool.dto.ToolDto +import de.fraunhofer.iem.app.tool.repository.ToolRepository import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional import org.springframework.web.bind.annotation.GetMapping diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/CreateToolDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/CreateToolDto.kt similarity index 50% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/CreateToolDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/CreateToolDto.kt index 40869de8..4a25b71a 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/CreateToolDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/CreateToolDto.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.tool.dto +package de.fraunhofer.iem.app.tool.dto -import de.fraunhofer.iem.dataprovider.tool.entity.ToolEntity -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType +import de.fraunhofer.iem.app.tool.entity.ToolEntity +import de.fraunhofer.iem.app.tool.enumeration.ToolType data class CreateToolDto(val name: String, val type: ToolType) { fun asDbObject(): ToolEntity { diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/FindingDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/FindingDto.kt new file mode 100644 index 00000000..f0abe51d --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/FindingDto.kt @@ -0,0 +1,3 @@ +package de.fraunhofer.iem.app.tool.dto + +data class FindingDto(val message: String) diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/ToolDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/ToolDto.kt new file mode 100644 index 00000000..c941656a --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/dto/ToolDto.kt @@ -0,0 +1,11 @@ +package de.fraunhofer.iem.app.tool.dto + +import de.fraunhofer.iem.app.tool.enumeration.ToolType + +data class ToolDto( + val name: String, + val description: String, + val relevantKpis: List<String>, + val findings: MutableList<de.fraunhofer.iem.app.tool.dto.FindingDto> = mutableListOf(), + val toolType: ToolType +) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/entity/ToolEntity.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/entity/ToolEntity.kt similarity index 82% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/entity/ToolEntity.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/entity/ToolEntity.kt index a9af058a..9b6d90ca 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/entity/ToolEntity.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/entity/ToolEntity.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.tool.entity +package de.fraunhofer.iem.app.tool.entity -import de.fraunhofer.iem.dataprovider.tool.dto.ToolDto -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType +import de.fraunhofer.iem.app.tool.dto.ToolDto +import de.fraunhofer.iem.app.tool.enumeration.ToolType import jakarta.persistence.* import org.hibernate.Hibernate import java.util.* diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/enumeration/ToolType.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/enumeration/ToolType.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/enumeration/ToolType.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/enumeration/ToolType.kt index 32fd9533..e9cde5a2 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/enumeration/ToolType.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/enumeration/ToolType.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.tool.enumeration +package de.fraunhofer.iem.app.tool.enumeration -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind -import de.fraunhofer.iem.dataprovider.tool.dto.ToolDto +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.tool.dto.ToolDto enum class ToolType { ORT { diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/repository/ToolRepository.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/repository/ToolRepository.kt similarity index 77% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/repository/ToolRepository.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/repository/ToolRepository.kt index 1b0ae7a3..630a4330 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/repository/ToolRepository.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/repository/ToolRepository.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.tool.repository +package de.fraunhofer.iem.app.tool.repository -import de.fraunhofer.iem.dataprovider.tool.entity.ToolEntity +import de.fraunhofer.iem.app.tool.entity.ToolEntity import org.springframework.data.jpa.repository.JpaRepository import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/service/ToolService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/service/ToolService.kt similarity index 69% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/service/ToolService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/service/ToolService.kt index f719bd33..9423dc51 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/service/ToolService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tool/service/ToolService.kt @@ -1,11 +1,11 @@ -package de.fraunhofer.iem.dataprovider.tool.service +package de.fraunhofer.iem.app.tool.service -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.entity.ToolEntity -import de.fraunhofer.iem.dataprovider.tool.repository.ToolRepository -import de.fraunhofer.iem.dataprovider.tools.gitlab.service.RepositoryDetailsService -import de.fraunhofer.iem.dataprovider.tools.occmd.service.OccmdService -import de.fraunhofer.iem.dataprovider.tools.ort.service.OrtService +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.entity.ToolEntity +import de.fraunhofer.iem.app.tool.repository.ToolRepository +import de.fraunhofer.iem.app.tools.gitlab.service.RepositoryDetailsService +import de.fraunhofer.iem.app.tools.occmd.service.OccmdService +import de.fraunhofer.iem.app.tools.ort.service.OrtService import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/LanguageDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/LanguageDto.kt similarity index 56% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/LanguageDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/LanguageDto.kt index c51baf84..98541cdc 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/LanguageDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/LanguageDto.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.toolRun.dto +package de.fraunhofer.iem.app.toolRun.dto data class LanguageDto(val name: String, val percentage: Float) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/ToolRunDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/ToolRunDto.kt similarity index 84% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/ToolRunDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/ToolRunDto.kt index ef1e7b61..498a63e8 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/dto/ToolRunDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/dto/ToolRunDto.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.toolRun.dto +package de.fraunhofer.iem.app.toolRun.dto -import de.fraunhofer.iem.dataprovider.tool.dto.ToolDto -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity +import de.fraunhofer.iem.app.tool.dto.ToolDto +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity import java.util.* data class ToolRunDto( diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/LanguageEntity.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/LanguageEntity.kt similarity index 89% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/LanguageEntity.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/LanguageEntity.kt index d0146676..f4fc6bb6 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/LanguageEntity.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/LanguageEntity.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.toolRun.entity +package de.fraunhofer.iem.app.toolRun.entity import jakarta.persistence.* import java.util.* diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/ToolRunEntity.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/ToolRunEntity.kt similarity index 79% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/ToolRunEntity.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/ToolRunEntity.kt index 38fffeee..b5d23d5c 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/entity/ToolRunEntity.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/entity/ToolRunEntity.kt @@ -1,8 +1,7 @@ -package de.fraunhofer.iem.dataprovider.toolRun.entity +package de.fraunhofer.iem.app.toolRun.entity -import de.fraunhofer.iem.dataprovider.kpi.entity.KPIEntity -import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity -import de.fraunhofer.iem.dataprovider.tool.entity.ToolEntity +import de.fraunhofer.iem.app.repository.entity.RepositoryEntity +import de.fraunhofer.iem.app.tool.entity.ToolEntity import jakarta.persistence.* import org.hibernate.annotations.CurrentTimestamp import org.hibernate.annotations.UpdateTimestamp @@ -30,7 +29,7 @@ class ToolRunEntity( val toolEntities: MutableSet<ToolEntity> = mutableSetOf(), @OneToMany(cascade = [CascadeType.ALL], mappedBy = "toolRunEntity", orphanRemoval = true) - val kpiEntities: MutableSet<KPIEntity> = mutableSetOf(), + val kpiEntities: MutableSet<de.fraunhofer.iem.app.kpi.entity.KPIEntity> = mutableSetOf(), @OneToMany(cascade = [CascadeType.ALL], mappedBy = "toolRunEntity", orphanRemoval = true) val languageEntities: MutableSet<LanguageEntity> = mutableSetOf(), diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/repository/ToolRunRepository.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/repository/ToolRunRepository.kt similarity index 77% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/repository/ToolRunRepository.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/repository/ToolRunRepository.kt index 0f222226..cb2b5f88 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/repository/ToolRunRepository.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/repository/ToolRunRepository.kt @@ -1,6 +1,6 @@ -package de.fraunhofer.iem.dataprovider.toolRun.repository +package de.fraunhofer.iem.app.toolRun.repository -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity +import de.fraunhofer.iem.app.toolRun.entity.ToolRunEntity import org.springframework.data.jpa.repository.JpaRepository import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt similarity index 90% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt index 62ac29ce..3338ccac 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt @@ -1,13 +1,13 @@ -package de.fraunhofer.iem.dataprovider.toolRun.service - -import de.fraunhofer.iem.dataprovider.kpi.service.KPIService -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.repository.service.RepositoryService -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType -import de.fraunhofer.iem.dataprovider.toolRun.dto.ToolRunDto -import de.fraunhofer.iem.dataprovider.tools.gitlab.service.RepositoryDetailsService -import de.fraunhofer.iem.dataprovider.tools.occmd.service.OccmdService -import de.fraunhofer.iem.dataprovider.tools.ort.service.OrtService +package de.fraunhofer.iem.app.toolRun.service + +import de.fraunhofer.iem.app.kpi.service.KPIService +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.repository.service.RepositoryService +import de.fraunhofer.iem.app.tool.enumeration.ToolType +import de.fraunhofer.iem.app.toolRun.dto.ToolRunDto +import de.fraunhofer.iem.app.tools.gitlab.service.RepositoryDetailsService +import de.fraunhofer.iem.app.tools.occmd.service.OccmdService +import de.fraunhofer.iem.app.tools.ort.service.OrtService import kotlinx.coroutines.* import org.springframework.stereotype.Service diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/gitlab/service/RepositoryDetailsService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/gitlab/service/RepositoryDetailsService.kt similarity index 62% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/gitlab/service/RepositoryDetailsService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/gitlab/service/RepositoryDetailsService.kt index f65c3848..9abf37e2 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/gitlab/service/RepositoryDetailsService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/gitlab/service/RepositoryDetailsService.kt @@ -1,9 +1,9 @@ -package de.fraunhofer.iem.dataprovider.tools.gitlab.service +package de.fraunhofer.iem.app.tools.gitlab.service -import de.fraunhofer.iem.dataprovider.gitlab.service.OpenCodeGitlabApi -import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryDetailsDto -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType +import de.fraunhofer.iem.app.gitlab.service.OpenCodeGitlabApi +import de.fraunhofer.iem.app.repository.dto.RepositoryDetailsDto +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.enumeration.ToolType import org.springframework.stereotype.Service @Service diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/enumeration/Checks.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/enumeration/Checks.kt similarity index 87% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/enumeration/Checks.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/enumeration/Checks.kt index 736c0c2f..a4a73530 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/enumeration/Checks.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/enumeration/Checks.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.enumeration +package de.fraunhofer.iem.app.tools.occmd.enumeration enum class Checks(val checkName: String) { SastUsageBasic("SastUsageBasic"), diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/RawResultJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/RawResultJson.kt similarity index 88% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/RawResultJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/RawResultJson.kt index 22904aec..3390c050 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/RawResultJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/RawResultJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.json +package de.fraunhofer.iem.app.tools.occmd.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/SecretResultsJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/SecretResultsJson.kt similarity index 79% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/SecretResultsJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/SecretResultsJson.kt index c33911b7..511401a6 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/SecretResultsJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/SecretResultsJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.json +package de.fraunhofer.iem.app.tools.occmd.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretJson.kt similarity index 81% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretJson.kt index b22fe6b3..9f0f0653 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.json +package de.fraunhofer.iem.app.tools.occmd.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretResultJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretResultJson.kt similarity index 82% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretResultJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretResultJson.kt index c04304b5..4be78541 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/json/ToolSecretResultJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/json/ToolSecretResultJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.json +package de.fraunhofer.iem.app.tools.occmd.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/service/OccmdService.kt similarity index 91% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/service/OccmdService.kt index 13eb2ae6..f3bae5b1 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/occmd/service/OccmdService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/occmd/service/OccmdService.kt @@ -1,11 +1,11 @@ -package de.fraunhofer.iem.dataprovider.tools.occmd.service +package de.fraunhofer.iem.app.tools.occmd.service -import de.fraunhofer.iem.dataprovider.configuration.DirectoryPathsProperties -import de.fraunhofer.iem.dataprovider.configuration.OpenCodeGitlabApiProperties -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType -import de.fraunhofer.iem.dataprovider.tools.occmd.json.RawResultJson +import de.fraunhofer.iem.app.configuration.DirectoryPathsProperties +import de.fraunhofer.iem.app.configuration.OpenCodeGitlabApiProperties +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.enumeration.ToolType +import de.fraunhofer.iem.app.tools.occmd.json.RawResultJson import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/dto/VulnerabilityDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/dto/VulnerabilityDto.kt similarity index 66% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/dto/VulnerabilityDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/dto/VulnerabilityDto.kt index c26385a1..afde6721 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/dto/VulnerabilityDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/dto/VulnerabilityDto.kt @@ -1,3 +1,3 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.dto +package de.fraunhofer.iem.app.tools.ort.dto data class VulnerabilityDto(val cveIdentifier: String, val packageName: String, val severity: Double) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/DataJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/DataJson.kt similarity index 86% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/DataJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/DataJson.kt index 6f9cff0e..1a4d4557 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/DataJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/DataJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.json +package de.fraunhofer.iem.app.tools.ort.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/OrtJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/OrtJson.kt similarity index 58% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/OrtJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/OrtJson.kt index 50c0b61d..5a8a6835 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/OrtJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/OrtJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.json +package de.fraunhofer.iem.app.tools.ort.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -8,5 +8,5 @@ data class OrtJson( @SerialName("code") val code: Int, @SerialName("result") - val result: List<ResultJson> = mutableListOf() + val result: List<de.fraunhofer.iem.app.tools.ort.json.ResultJson> = mutableListOf() ) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ReferenceJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ReferenceJson.kt similarity index 84% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ReferenceJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ReferenceJson.kt index 51791704..b2287506 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ReferenceJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ReferenceJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.json +package de.fraunhofer.iem.app.tools.ort.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ResultJson.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ResultJson.kt similarity index 91% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ResultJson.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ResultJson.kt index b7f23463..bdd15231 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/json/ResultJson.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/json/ResultJson.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.json +package de.fraunhofer.iem.app.tools.ort.json import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtService.kt similarity index 76% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtService.kt index 08ffe3c9..9d94ae7f 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtService.kt @@ -1,14 +1,12 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.service +package de.fraunhofer.iem.app.tools.ort.service -import de.fraunhofer.iem.dataprovider.configuration.OpenCodeApiProperties -import de.fraunhofer.iem.dataprovider.logger.getLogger -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.dto.FindingDto -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType -import de.fraunhofer.iem.dataprovider.tools.ort.dto.VulnerabilityDto -import de.fraunhofer.iem.dataprovider.tools.ort.json.OrtJson -import de.fraunhofer.iem.dataprovider.tools.ort.json.ResultJson -import de.fraunhofer.iem.dataprovider.utilities.HttpClientWrapper +import de.fraunhofer.iem.app.configuration.OpenCodeApiProperties +import de.fraunhofer.iem.app.logger.getLogger +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.enumeration.ToolType +import de.fraunhofer.iem.app.tools.ort.dto.VulnerabilityDto +import de.fraunhofer.iem.app.tools.ort.json.ResultJson +import de.fraunhofer.iem.app.utilities.HttpClientWrapper import io.ktor.client.call.* import io.ktor.client.request.* import io.ktor.client.statement.* @@ -44,9 +42,9 @@ class OrtService( } } - suspend fun getFindings(rawResults: List<VulnerabilityDto>): List<FindingDto> { + suspend fun getFindings(rawResults: List<VulnerabilityDto>): List<de.fraunhofer.iem.app.tool.dto.FindingDto> { return rawResults.map { result -> - FindingDto( + de.fraunhofer.iem.app.tool.dto.FindingDto( "Vulnerability with CVE ${result.cveIdentifier} " + "found in package ${result.packageName} with severity ${result.severity}" ) @@ -62,7 +60,7 @@ class OrtService( logger.info("Query ORT API for repo with id $projectId") val response: HttpResponse = httpClient.get(getToolApiPath(projectId)) - val ortJson = response.body<OrtJson>() + val ortJson = response.body<de.fraunhofer.iem.app.tools.ort.json.OrtJson>() if (ortJson.code != HttpStatusCode.OK.value) { throw Exception("ORT API returned with code ${ortJson.code}") } diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserDetailsResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserDetailsResponseDto.kt similarity index 89% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserDetailsResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserDetailsResponseDto.kt index 5ad2b753..8c01791a 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserDetailsResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserDetailsResponseDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.user.dto +package de.fraunhofer.iem.app.user.dto import kotlinx.serialization.SerialName diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserResponseDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserResponseDto.kt similarity index 84% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserResponseDto.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserResponseDto.kt index 5e7f773d..304102a8 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/UserResponseDto.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/UserResponseDto.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.user.dto +package de.fraunhofer.iem.app.user.dto import kotlinx.serialization.SerialName diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/ValidateUserDto.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/ValidateUserDto.kt new file mode 100644 index 00000000..11d39759 --- /dev/null +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/dto/ValidateUserDto.kt @@ -0,0 +1,3 @@ +package de.fraunhofer.iem.app.user.dto + +data class ValidateUserDto(val b: String) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/service/UserService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/service/UserService.kt similarity index 85% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/user/service/UserService.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/service/UserService.kt index 981e0a83..613619c9 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/service/UserService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/user/service/UserService.kt @@ -1,8 +1,8 @@ -package de.fraunhofer.iem.dataprovider.user.service +package de.fraunhofer.iem.app.user.service -import de.fraunhofer.iem.dataprovider.configuration.OpenCodeApiProperties -import de.fraunhofer.iem.dataprovider.user.dto.UserResponseDto -import de.fraunhofer.iem.dataprovider.user.dto.ValidateUserDto +import de.fraunhofer.iem.app.configuration.OpenCodeApiProperties +import de.fraunhofer.iem.app.user.dto.UserResponseDto +import de.fraunhofer.iem.app.user.dto.ValidateUserDto import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.engine.cio.* diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/utilities/HttpClientWrapper.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/utilities/HttpClientWrapper.kt similarity index 93% rename from src/main/kotlin/de/fraunhofer/iem/dataprovider/utilities/HttpClientWrapper.kt rename to app/backend/src/main/kotlin/de/fraunhofer/iem/app/utilities/HttpClientWrapper.kt index 59f34447..1b778971 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/utilities/HttpClientWrapper.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/utilities/HttpClientWrapper.kt @@ -1,4 +1,4 @@ -package de.fraunhofer.iem.dataprovider.utilities +package de.fraunhofer.iem.app.utilities import io.ktor.client.* import io.ktor.client.engine.cio.* diff --git a/src/main/resources/application-dev.properties b/app/backend/src/main/resources/application-dev.properties similarity index 99% rename from src/main/resources/application-dev.properties rename to app/backend/src/main/resources/application-dev.properties index c2571ead..19cce4b6 100644 --- a/src/main/resources/application-dev.properties +++ b/app/backend/src/main/resources/application-dev.properties @@ -10,7 +10,6 @@ opencode.api.base-path=https://sl.dev.o4oe.de/api/v1/project/ opencode.api.ort=/cve-result opencode.api.auth=https://sl.dev.o4oe.de/api/ opencode.api.auth-api-key=${AUTH_API_KEY} - # API key to access this server's API # The api key is needed for all routes. # the admin password is needed for the repo changed route. diff --git a/src/main/resources/application-local.properties b/app/backend/src/main/resources/application-local.properties similarity index 100% rename from src/main/resources/application-local.properties rename to app/backend/src/main/resources/application-local.properties diff --git a/src/main/resources/application-prod.properties b/app/backend/src/main/resources/application-prod.properties similarity index 100% rename from src/main/resources/application-prod.properties rename to app/backend/src/main/resources/application-prod.properties diff --git a/src/main/resources/scripts/occmd.sh b/app/backend/src/main/resources/scripts/occmd.sh similarity index 100% rename from src/main/resources/scripts/occmd.sh rename to app/backend/src/main/resources/scripts/occmd.sh diff --git a/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt b/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt similarity index 100% rename from src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt rename to app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt diff --git a/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt b/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt similarity index 100% rename from src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt rename to app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt diff --git a/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json b/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json similarity index 100% rename from src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json rename to app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json diff --git a/src/test/resources/application.properties b/app/backend/src/test/resources/application.properties similarity index 100% rename from src/test/resources/application.properties rename to app/backend/src/test/resources/application.properties diff --git a/tools/db/Dockerfile b/app/backend/tools/db/Dockerfile similarity index 100% rename from tools/db/Dockerfile rename to app/backend/tools/db/Dockerfile diff --git a/tools/db/api.json b/app/backend/tools/db/api.json similarity index 100% rename from tools/db/api.json rename to app/backend/tools/db/api.json diff --git a/tools/db/docker-compose.yml b/app/backend/tools/db/docker-compose.yml similarity index 90% rename from tools/db/docker-compose.yml rename to app/backend/tools/db/docker-compose.yml index 743d19a9..9e6a4917 100644 --- a/tools/db/docker-compose.yml +++ b/app/backend/tools/db/docker-compose.yml @@ -14,7 +14,7 @@ services: - "8083:8080" command: start-single-node --insecure volumes: - - "database:/cockroach/cockroach-data" + - "${PWD}/cockroach-data/crdb:/cockroach/cockroach-data" healthcheck: # user / database is taken from env variables # cockroach creates at the end the database + user diff --git a/tools/db/json-server.json b/app/backend/tools/db/json-server.json similarity index 100% rename from tools/db/json-server.json rename to app/backend/tools/db/json-server.json diff --git a/tools/occmd/Dockerfile b/app/backend/tools/occmd/Dockerfile similarity index 100% rename from tools/occmd/Dockerfile rename to app/backend/tools/occmd/Dockerfile diff --git a/tools/occmd/occmdcfg.ini b/app/backend/tools/occmd/occmdcfg.ini similarity index 100% rename from tools/occmd/occmdcfg.ini rename to app/backend/tools/occmd/occmdcfg.ini diff --git a/app/settings.gradle.kts b/app/settings.gradle.kts new file mode 100644 index 00000000..c9c9fbf0 --- /dev/null +++ b/app/settings.gradle.kts @@ -0,0 +1,3 @@ +rootProject.name = "app" + +include("backend") diff --git a/build.gradle.kts b/build.gradle.kts index b3e62a58..0e427897 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,144 +1,9 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -val springVersion = "3.3.1" - -plugins { - id("org.springframework.boot") version "3.3.1" - id("io.spring.dependency-management") version "1.1.6" - id("org.jetbrains.kotlin.plugin.allopen") version "2.0.20-Beta2" -// id("io.gitlab.arturbosch.detekt").version("1.23.3") - kotlin("jvm") version "2.0.0" - kotlin("plugin.spring") version "2.0.20-Beta2" - kotlin("plugin.jpa") version "2.0.20-Beta2" - kotlin("plugin.serialization") version "2.0.0" -} - -allOpen { - annotation("javax.persistence.Entity") - annotation("javax.persistence.Embeddable") - annotation("javax.persistence.MappedSuperclass") - annotation("jakarta.persistence.Entity") - annotation("jakarta.persistence.Embeddable") - annotation("jakarta.persistence.MappedSuperclass") -} - -group = "de.fraunhofer.iem" -version = "0.0.2-SNAPSHOT" -java.sourceCompatibility = JavaVersion.VERSION_21 -configurations { - compileOnly { - extendsFrom(configurations.annotationProcessor.get()) - } -} +defaultTasks("run") repositories { mavenCentral() } -val coroutineVersion = "1.9.0-RC" -val ktorVersion = "2.3.12" -dependencies { -// detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3") - implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion") - implementation("org.springframework.boot:spring-boot-starter-validation:$springVersion") - implementation("org.springframework.boot:spring-boot-starter-security:$springVersion") - implementation("org.springframework.boot:spring-boot-starter-webflux:$springVersion") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.1") - implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive:$coroutineVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutineVersion") - implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:2.5.0") - implementation("org.gitlab4j:gitlab4j-api:6.0.0-rc.5") - implementation("org.eclipse.jgit:org.eclipse.jgit:6.10.0.202406032230-r") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") - implementation("org.springframework.boot:spring-boot-starter-actuator:$springVersion") - implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") - implementation("io.ktor:ktor-client-cio-jvm:$ktorVersion") - implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") - implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") - implementation("com.auth0:java-jwt:4.4.0") - developmentOnly("org.springframework.boot:spring-boot-devtools:$springVersion") - runtimeOnly("org.postgresql:postgresql:42.7.3") - testImplementation("org.springframework.boot:spring-boot-starter-test:$springVersion") { - exclude(module = "mockito-core") - exclude(group = "org.junit.vintage", module = "junit-vintage-engine") - } - testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3") - testImplementation("io.ktor:ktor-client-mock-jvm:$ktorVersion") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3") - testRuntimeOnly("com.h2database:h2:2.2.224") - testImplementation("com.ninja-squad:springmockk:4.0.2") - testImplementation("org.springframework.security:spring-security-test:6.1.5") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion") -} -// -//detekt { -// // Version of detekt that will be used. When unspecified the latest detekt -// // version found will be used. Override to stay on the same version. -// toolVersion = "1.23.1" -// -// // The directories where detekt looks for source files. -// // Defaults to `files("src/main/java", "src/test/java", "src/main/kotlin", "src/test/kotlin")`. -// source.setFrom("src/main/java", "src/main/kotlin") -// -// // Builds the AST in parallel. Rules are always executed in parallel. -// // Can lead to speedups in larger projects. `false` by default. -// parallel = false -// -// // Define the detekt configuration(s) you want to use. -// // Defaults to the default detekt configuration. -// config.setFrom("config/detekt.yml") -// -// // Applies the config files on top of detekt's default config file. `false` by default. -// buildUponDefaultConfig = true -// -// // Turns on all the rules. `false` by default. -// allRules = false -// -// // Specifying a baseline file. All findings stored in this file in subsequent runs of detekt. -// baseline = file("config/baseline.xml") -// -// // Disables all default detekt rulesets and will only run detekt with custom rules -// // defined in plugins passed in with `detektPlugins` configuration. `false` by default. -// disableDefaultRuleSets = false -// -// // Adds debug output during task execution. `false` by default. -// debug = false -// -// // If set to `true` the build does not fail when the -// // maxIssues count was reached. Defaults to `false`. -// ignoreFailures = false -// -// // Android: Don't create tasks for the specified build types (e.g. "release") -// ignoredBuildTypes = listOf("release") -// -// // Android: Don't create tasks for the specified build flavor (e.g. "production") -// ignoredFlavors = listOf("production") -// -// // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") -// ignoredVariants = listOf("productionRelease") -// -// // Specify the base path for file paths in the formatted reports. -// // If not set, all file paths reported will be absolute file path. -// basePath = projectDir.absolutePath -//} -// -//configurations.all { -// resolutionStrategy.eachDependency { -// if (requested.group == "org.jetbrains.kotlin") { -// useVersion("1.9.21") -// } -// } -//} - -tasks.withType<KotlinCompile> { - kotlinOptions { - freeCompilerArgs = listOf("-Xjsr305=strict") - jvmTarget = "21" - } -} - -tasks.withType<Test> { - useJUnitPlatform() +tasks.register("run") { + dependsOn(gradle.includedBuild("app").task(":app:run")) } diff --git a/kpi-calculator/core/build.gradle.kts b/kpi-calculator/core/build.gradle.kts new file mode 100644 index 00000000..92f04e9a --- /dev/null +++ b/kpi-calculator/core/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + kotlin("jvm") version "2.0.0" +} + +group = "de.fraunhofer.iem" +version = "0.0.2-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation(kotlin("test")) +} + +tasks.test { + useJUnitPlatform() +} +kotlin { + jvmToolchain(21) +} diff --git a/kpi-calculator/core/src/main/kotlin/Main.kt b/kpi-calculator/core/src/main/kotlin/Main.kt new file mode 100644 index 00000000..66492046 --- /dev/null +++ b/kpi-calculator/core/src/main/kotlin/Main.kt @@ -0,0 +1,5 @@ +package de.fraunhofer.iem + +fun sayHello() { + println("Hello World!") +} diff --git a/kpi-calculator/settings.gradle.kts b/kpi-calculator/settings.gradle.kts new file mode 100644 index 00000000..ffa8c861 --- /dev/null +++ b/kpi-calculator/settings.gradle.kts @@ -0,0 +1,3 @@ +rootProject.name = "kpi-calculator" + +include("core") \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index cc7c351d..1857f21e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,7 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} rootProject.name = "data-provider" + +includeBuild("kpi-calculator") +includeBuild("app") diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/MemberDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/MemberDto.kt deleted file mode 100644 index fbb6563f..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/gitlab/dto/MemberDto.kt +++ /dev/null @@ -1,6 +0,0 @@ -package de.fraunhofer.iem.dataprovider.gitlab.dto - -import de.fraunhofer.iem.dataprovider.gitlab.enumeration.AccessLevel - - -data class MemberDto(val id: Long, val name: String, val accessLevel: AccessLevel) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/RawValueKpiCreateDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/RawValueKpiCreateDto.kt deleted file mode 100644 index c227dd1c..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/dto/RawValueKpiCreateDto.kt +++ /dev/null @@ -1,18 +0,0 @@ -package de.fraunhofer.iem.dataprovider.kpi.dto - -import de.fraunhofer.iem.dataprovider.kpi.entity.KPIEntity -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind -import de.fraunhofer.iem.dataprovider.toolRun.entity.ToolRunEntity -import java.sql.Timestamp -import java.time.Instant - -data class RawValueKpiCreateDto(val kind: KpiKind, val score: Int) { - fun toDbObject(toolRun: ToolRunEntity): KPIEntity { - return KPIEntity( - kind = this.kind, - score = this.score, - createdAt = Timestamp.from(Instant.now()), - toolRunEntity = toolRun - ) - } -} diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RawValueKPICalculationStrategy.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RawValueKPICalculationStrategy.kt deleted file mode 100644 index 7a8e6629..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/RawValueKPICalculationStrategy.kt +++ /dev/null @@ -1,9 +0,0 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy - -import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto - -class RawValueKPICalculationStrategy(private val value: Int) : KPICalculationStrategy { - override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Pair<Int, List<KPIHierarchyEdgeDto>> { - return Pair(this.value, children) - } -} diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RawKpiDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RawKpiDto.kt deleted file mode 100644 index ca8adb6c..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/RawKpiDto.kt +++ /dev/null @@ -1,5 +0,0 @@ -package de.fraunhofer.iem.dataprovider.repository.dto - -import de.fraunhofer.iem.dataprovider.kpi.dto.KpiCalculationDto - -data class RawKpiDto(val rawKpis: List<KpiCalculationDto>) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ScoreCardResponseDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ScoreCardResponseDto.kt deleted file mode 100644 index f2f95a87..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ScoreCardResponseDto.kt +++ /dev/null @@ -1,8 +0,0 @@ -package de.fraunhofer.iem.dataprovider.repository.dto - -import de.fraunhofer.iem.dataprovider.kpi.dto.KPITreeResponseDto - -data class ScoreCardResponseDto( - val repository: RepositoryResponseDto, - val kpis: KPITreeResponseDto? -) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ToolRunResponseDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ToolRunResponseDto.kt deleted file mode 100644 index 7be525a1..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/repository/dto/ToolRunResponseDto.kt +++ /dev/null @@ -1,5 +0,0 @@ -package de.fraunhofer.iem.dataprovider.repository.dto - -import de.fraunhofer.iem.dataprovider.toolRun.dto.ToolRunDto - -data class ToolRunResponseDto(val isProjectMember: Boolean = false, val toolRun: ToolRunDto) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/FindingDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/FindingDto.kt deleted file mode 100644 index 409cb0ed..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/FindingDto.kt +++ /dev/null @@ -1,3 +0,0 @@ -package de.fraunhofer.iem.dataprovider.tool.dto - -data class FindingDto(val message: String) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/ToolDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/ToolDto.kt deleted file mode 100644 index 6409abf7..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/tool/dto/ToolDto.kt +++ /dev/null @@ -1,11 +0,0 @@ -package de.fraunhofer.iem.dataprovider.tool.dto - -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType - -data class ToolDto( - val name: String, - val description: String, - val relevantKpis: List<String>, - val findings: MutableList<FindingDto> = mutableListOf(), - val toolType: ToolType -) diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/ValidateUserDto.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/ValidateUserDto.kt deleted file mode 100644 index 1d3523f6..00000000 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/user/dto/ValidateUserDto.kt +++ /dev/null @@ -1,3 +0,0 @@ -package de.fraunhofer.iem.dataprovider.user.dto - -data class ValidateUserDto(val b: String) -- GitLab From 0947268fca814fa8011e386d0395fdf53f441141 Mon Sep 17 00:00:00 2001 From: Lucas Briese <lucas.briese@iem.fraunhofer.de> Date: Thu, 25 Jul 2024 16:22:15 +0200 Subject: [PATCH 2/9] build: compose include moved --- .env | 10 ++++++++++ docker-compose.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..6c10d6a4 --- /dev/null +++ b/.env @@ -0,0 +1,10 @@ +# exclude from git with: +# git update-index --skip-worktree .env +# revert: +# git update-index --no-skip-worktree .env +# +# e.g. oc000... from https://keycloak.opencode.de/auth/realms/osr/account/#/personal-info +SECRET_OC_GL_USER= +# https://gitlab.opencode.de/-/user_settings/personal_access_tokens +# with read_api, read_user, read_repository, read_registry +SECRET_OC_GL_APIKEY= diff --git a/docker-compose.yml b/docker-compose.yml index 77bb8258..7dc9d061 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ name: opencode include: - - path: ./tools/db/docker-compose.yml + - path: ./app/backend/tools/db/docker-compose.yml services: data-provider: -- GitLab From 5422869a612ad54f07b33f51abf479a28e87c279 Mon Sep 17 00:00:00 2001 From: Lucas Briese <lucas.briese@iem.fraunhofer.de> Date: Thu, 25 Jul 2024 16:44:19 +0200 Subject: [PATCH 3/9] build: db should use volume not bind mount --- app/backend/tools/db/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/backend/tools/db/docker-compose.yml b/app/backend/tools/db/docker-compose.yml index 9e6a4917..743d19a9 100644 --- a/app/backend/tools/db/docker-compose.yml +++ b/app/backend/tools/db/docker-compose.yml @@ -14,7 +14,7 @@ services: - "8083:8080" command: start-single-node --insecure volumes: - - "${PWD}/cockroach-data/crdb:/cockroach/cockroach-data" + - "database:/cockroach/cockroach-data" healthcheck: # user / database is taken from env variables # cockroach creates at the end the database + user -- GitLab From 19ec3d803d76697236923d46a28fdd1142b139dd Mon Sep 17 00:00:00 2001 From: Hutomo Saleh <hutomo.saleh@iem.fraunhofer.de> Date: Fri, 26 Jul 2024 08:09:14 +0200 Subject: [PATCH 4/9] build: register backend tasks --- build.gradle.kts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0e427897..733a529d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,5 +5,17 @@ repositories { } tasks.register("run") { - dependsOn(gradle.includedBuild("app").task(":app:run")) + dependsOn(gradle.includedBuild("app").task(":backend:bootRun")) +} +tasks.register("clean") { + dependsOn(gradle.includedBuild("app").task(":backend:clean")) +} +tasks.register("build") { + dependsOn(gradle.includedBuild("app").task(":backend:build")) +} +tasks.register("test") { + dependsOn(gradle.includedBuild("app").task(":backend:test")) +} +tasks.register("assemble") { + dependsOn(gradle.includedBuild("app").task(":backend:assemble")) } -- GitLab From feee41d29ca131764c112f6bcde1620cedbd6800 Mon Sep 17 00:00:00 2001 From: Hutomo Saleh <hutomo.saleh@iem.fraunhofer.de> Date: Fri, 26 Jul 2024 08:24:11 +0200 Subject: [PATCH 5/9] build: use gradle assemble, adapt entrypoint, use spring profile env --- Dockerfile | 12 ++++-------- docker-compose.yml | 9 ++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21504e4c..05437e90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,17 @@ FROM eclipse-temurin:21-jdk-noble AS build -ARG profile=prod -ENV profileEnv=$profile WORKDIR /app COPY . /app RUN set -eux; \ - ./gradlew clean build -Dspring.profiles.active=${profile} -x test; \ + ./gradlew assemble; \ + cp -r app/backend/build /app; \ mkdir -p build/dependency; \ - cd build/dependency; \ + cd build/dependency; \ jar -xf ../libs/*-SNAPSHOT.jar FROM eclipse-temurin:21-jdk-noble -ARG profile=prod -ENV profileEnv=$profile - # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 @@ -81,4 +77,4 @@ RUN set -eux; \ # Workaround until OCCMD tool is included into CI/CD USER $UID -ENTRYPOINT ["java","-cp","/app:/app/lib/*", "-Dspring.profiles.active=${profileEnv}", "de.fraunhofer.iem.dataprovider.DataProviderApplicationKt"] +ENTRYPOINT ["java","-cp","/app:/app/lib/*", "de.fraunhofer.iem.app.DataProviderApplicationKt"] diff --git a/docker-compose.yml b/docker-compose.yml index 7dc9d061..1dc7ba83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,15 +12,14 @@ services: image: data-provider build: context: . - args: - profile: dev environment: - OCCMD_PATH=/app/scripts/occmd.sh - OC_GL_USER=${SECRET_OC_GL_USER} - OC_GL_APIKEY=${SECRET_OC_GL_APIKEY} - XDG_CONFIG_HOME=/app/.config/ - GIT_CLONE_TARGET_DIRECTORY=/app/git/ - - USE_MANAGEMENT_PORT=false # Needs to define a SwaggerWelcomeCommon bean if true + - USE_MANAGEMENT_PORT=false + - MANAGEMENT_PORT=4001 - PROJECT_IDS=1448,2991,1317,560,2188,2155,2149,2235 # occmd-public, Covid19 fraud detection, Opendesk, Helm chart, e2e tests - CORS_ORIGIN=* # Must be without quotes i.e. allow everything: * | originally https://sec-kpi.opencode.de @@ -34,5 +33,9 @@ services: - ADMIN_PASSWORD=01234567890123456789 - ADMIN_USERNAME=012345678901234567890123456789 - API_KEY=012345678901234567890123456789 + + - SPRING_PROFILES_ACTIVE=local ports: - 4000:4000 + volumes: + - ./app/backend/src/main/resources/application-local.properties:/app/application-local.properties -- GitLab From 8d1eb53f46973083f75d9f56062ce05cfec0a984 Mon Sep 17 00:00:00 2001 From: Lucas Briese <lucas.briese@iem.fraunhofer.de> Date: Fri, 26 Jul 2024 09:14:49 +0200 Subject: [PATCH 6/9] doc: alternative .env exclusion --- .env | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.env b/.env index 6c10d6a4..18d58e45 100644 --- a/.env +++ b/.env @@ -3,6 +3,11 @@ # revert: # git update-index --no-skip-worktree .env # +# or as alternative: +# git update-index --assume-unchanged .env +# revert: +# git update-index --no-assume-unchanged .env +# # e.g. oc000... from https://keycloak.opencode.de/auth/realms/osr/account/#/personal-info SECRET_OC_GL_USER= # https://gitlab.opencode.de/-/user_settings/personal_access_tokens -- GitLab From 48f22763bb9ffa4ae62b855ceb48db0146e29e66 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Struewer <j.n.struewer@gmail.com> Date: Fri, 26 Jul 2024 10:49:53 +0200 Subject: [PATCH 7/9] build: fixed building error for tests in the structure by moving the test files to the appropriate location. --- .../AggregationKPICalculationStrategyTest.kt | 6 +++--- .../tools/ort/service/OrtServiceTest.kt | 14 +++++++------- .../tools/ort/service/ortExample.json | 0 3 files changed, 10 insertions(+), 10 deletions(-) rename app/backend/src/test/kotlin/de/fraunhofer/iem/{dataprovider => app}/kpi/strategy/AggregationKPICalculationStrategyTest.kt (94%) rename app/backend/src/test/kotlin/de/fraunhofer/iem/{dataprovider => app}/tools/ort/service/OrtServiceTest.kt (96%) rename app/backend/src/test/kotlin/de/fraunhofer/iem/{dataprovider => app}/tools/ort/service/ortExample.json (100%) diff --git a/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt b/app/backend/src/test/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategyTest.kt similarity index 94% rename from app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt rename to app/backend/src/test/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategyTest.kt index b6bad2d0..4a6eb3e3 100644 --- a/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/kpi/strategy/AggregationKPICalculationStrategyTest.kt +++ b/app/backend/src/test/kotlin/de/fraunhofer/iem/app/kpi/strategy/AggregationKPICalculationStrategyTest.kt @@ -1,7 +1,7 @@ -package de.fraunhofer.iem.dataprovider.kpi.strategy +package de.fraunhofer.iem.app.kpi.strategy -import de.fraunhofer.iem.dataprovider.kpi.dto.KpiCalculationDto -import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind +import de.fraunhofer.iem.app.kpi.dto.KpiCalculationDto +import de.fraunhofer.iem.app.kpi.enumeration.KpiKind import org.junit.jupiter.api.Test class AggregationKPICalculationStrategyTest { diff --git a/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt b/app/backend/src/test/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtServiceTest.kt similarity index 96% rename from app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt rename to app/backend/src/test/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtServiceTest.kt index 6b77f94e..d522e818 100644 --- a/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/OrtServiceTest.kt +++ b/app/backend/src/test/kotlin/de/fraunhofer/iem/app/tools/ort/service/OrtServiceTest.kt @@ -1,11 +1,11 @@ -package de.fraunhofer.iem.dataprovider.tools.ort.service +package de.fraunhofer.iem.app.tools.ort.service -import de.fraunhofer.iem.dataprovider.configuration.OpenCodeApiProperties -import de.fraunhofer.iem.dataprovider.tool.dto.CreateToolDto -import de.fraunhofer.iem.dataprovider.tool.entity.ToolEntity -import de.fraunhofer.iem.dataprovider.tool.enumeration.ToolType -import de.fraunhofer.iem.dataprovider.tool.service.ToolService -import de.fraunhofer.iem.dataprovider.utilities.HttpClientWrapper +import de.fraunhofer.iem.app.configuration.OpenCodeApiProperties +import de.fraunhofer.iem.app.tool.dto.CreateToolDto +import de.fraunhofer.iem.app.tool.entity.ToolEntity +import de.fraunhofer.iem.app.tool.enumeration.ToolType +import de.fraunhofer.iem.app.tool.service.ToolService +import de.fraunhofer.iem.app.utilities.HttpClientWrapper import io.ktor.client.* import io.ktor.client.engine.mock.* import io.ktor.client.plugins.contentnegotiation.* diff --git a/app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json b/app/backend/src/test/kotlin/de/fraunhofer/iem/app/tools/ort/service/ortExample.json similarity index 100% rename from app/backend/src/test/kotlin/de/fraunhofer/iem/dataprovider/tools/ort/service/ortExample.json rename to app/backend/src/test/kotlin/de/fraunhofer/iem/app/tools/ort/service/ortExample.json -- GitLab From 52739ea0b42772e59724f671d5ddb7622a52489f Mon Sep 17 00:00:00 2001 From: Jan-Niclas Struewer <j.n.struewer@gmail.com> Date: Fri, 26 Jul 2024 13:44:47 +0200 Subject: [PATCH 8/9] build: added subprojects for model and adapter code. --- app/backend/build.gradle.kts | 4 +++- .../de/fraunhofer/iem/app/StartUpHandler.kt | 2 -- kpi-calculator/adapter/build.gradle.kts | 22 +++++++++++++++++++ kpi-calculator/core/build.gradle.kts | 2 +- kpi-calculator/core/src/main/kotlin/Main.kt | 5 ----- kpi-calculator/model/build.gradle.kts | 21 ++++++++++++++++++ kpi-calculator/settings.gradle.kts | 4 +++- 7 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 kpi-calculator/adapter/build.gradle.kts delete mode 100644 kpi-calculator/core/src/main/kotlin/Main.kt create mode 100644 kpi-calculator/model/build.gradle.kts diff --git a/app/backend/build.gradle.kts b/app/backend/build.gradle.kts index b4a26875..9061c718 100644 --- a/app/backend/build.gradle.kts +++ b/app/backend/build.gradle.kts @@ -37,7 +37,9 @@ repositories { val coroutineVersion = "1.9.0-RC" val ktorVersion = "2.3.12" dependencies { - implementation("de.fraunhofer.iem:core:0.0.2-SNAPSHOT") + implementation("de.fraunhofer.iem.kpiCalculator:core:0.0.2-SNAPSHOT") + implementation("de.fraunhofer.iem.kpiCalculator:adapter:0.0.2-SNAPSHOT") + implementation("de.fraunhofer.iem.kpiCalculator:model:0.0.2-SNAPSHOT") implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion") implementation("org.springframework.boot:spring-boot-starter-validation:$springVersion") implementation("org.springframework.boot:spring-boot-starter-security:$springVersion") diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt index 6224dff2..bec2903c 100644 --- a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/StartUpHandler.kt @@ -6,7 +6,6 @@ import de.fraunhofer.iem.app.repository.dto.RepositoryConsentDto import de.fraunhofer.iem.app.repository.service.RepositoryService import de.fraunhofer.iem.app.tool.service.ToolService import de.fraunhofer.iem.app.toolRun.service.ToolRunService -import de.fraunhofer.iem.sayHello import kotlinx.coroutines.* import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener @@ -24,7 +23,6 @@ class StartUpHandler( @EventListener(ApplicationReadyEvent::class) suspend fun queryProjects() { - sayHello() withContext(Dispatchers.IO) { logger.info("Creating tools in db") toolService.createAllTools() diff --git a/kpi-calculator/adapter/build.gradle.kts b/kpi-calculator/adapter/build.gradle.kts new file mode 100644 index 00000000..5d6e8933 --- /dev/null +++ b/kpi-calculator/adapter/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + kotlin("jvm") version "2.0.0" +} + +group = "de.fraunhofer.iem.kpiCalculator" +version = "0.0.2-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + implementation("de.fraunhofer.iem.kpiCalculator:model:0.0.2-SNAPSHOT") + testImplementation(kotlin("test")) +} + +tasks.test { + useJUnitPlatform() +} +kotlin { + jvmToolchain(21) +} diff --git a/kpi-calculator/core/build.gradle.kts b/kpi-calculator/core/build.gradle.kts index 92f04e9a..c89e559b 100644 --- a/kpi-calculator/core/build.gradle.kts +++ b/kpi-calculator/core/build.gradle.kts @@ -2,7 +2,7 @@ plugins { kotlin("jvm") version "2.0.0" } -group = "de.fraunhofer.iem" +group = "de.fraunhofer.iem.kpiCalculator" version = "0.0.2-SNAPSHOT" repositories { diff --git a/kpi-calculator/core/src/main/kotlin/Main.kt b/kpi-calculator/core/src/main/kotlin/Main.kt deleted file mode 100644 index 66492046..00000000 --- a/kpi-calculator/core/src/main/kotlin/Main.kt +++ /dev/null @@ -1,5 +0,0 @@ -package de.fraunhofer.iem - -fun sayHello() { - println("Hello World!") -} diff --git a/kpi-calculator/model/build.gradle.kts b/kpi-calculator/model/build.gradle.kts new file mode 100644 index 00000000..c89e559b --- /dev/null +++ b/kpi-calculator/model/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + kotlin("jvm") version "2.0.0" +} + +group = "de.fraunhofer.iem.kpiCalculator" +version = "0.0.2-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation(kotlin("test")) +} + +tasks.test { + useJUnitPlatform() +} +kotlin { + jvmToolchain(21) +} diff --git a/kpi-calculator/settings.gradle.kts b/kpi-calculator/settings.gradle.kts index ffa8c861..61035eae 100644 --- a/kpi-calculator/settings.gradle.kts +++ b/kpi-calculator/settings.gradle.kts @@ -1,3 +1,5 @@ rootProject.name = "kpi-calculator" -include("core") \ No newline at end of file +include("core") +include("model") +include("adapter") -- GitLab From ed14dd8f554c91e67c65dda0a7f9d1fdce29c528 Mon Sep 17 00:00:00 2001 From: Lucas Briese <lucas.briese@iem.fraunhofer.de> Date: Fri, 26 Jul 2024 14:11:21 +0200 Subject: [PATCH 9/9] doc: added gradle tasks and added descriptions/groups --- .dockerignore | 4 ++-- README.md | 24 +++++++++++------------- build.gradle.kts | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7a12d08c..5c8a0329 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,8 +2,8 @@ app/backend/.env docker-compose.yml # from .gitignore -.gradle -build +**/.gradle +**/build .idea bin **/.env diff --git a/README.md b/README.md index f52c9b9e..a7ea171a 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,18 @@ ## Dev Setup -We have a recommended folder structure for developers, some scripts expecting it: - -``` -opencode -├── data-provider (this repo) -└── dashboard -``` - -1. [add ssh key for authentification and commit signing](https://gitlab.opencode.de/-/user_settings/ssh_keys) -2. install Docker & test if "docker compose" (v2) is working. [docker-compose is v1 which does currently work but is not recommended](https://docs.docker.com/compose/migrate/#docker-compose-vs-docker-compose) +1. We have a recommended folder structure for developers, some scripts expecting it: + ``` + opencode + ├── data-provider (this repo) + └── dashboard + ``` +2. We are using EditorConfig so check you plugin `.editorconfig` is used +3. [add ssh key for authentification and commit signing](https://gitlab.opencode.de/-/user_settings/ssh_keys) +4. install Docker & test if "docker compose" (v2) is working. [docker-compose is v1 which does currently work but is not recommended](https://docs.docker.com/compose/migrate/#docker-compose-vs-docker-compose) - its suggested to install an alias for compose `printf "\nalias compose='%s'\n" "docker compose" >> ~/.bash_aliases` reload with `source ~/.bash_aliases` -3. read and fill [.env](app/backend/.env) -4. exclude env from git index via `git update-index --skip-worktree .env` -5. `docker compose up` which starts opencode-db-1 and data-provider +5. fill and follow [.env](app/backend/.env) +6. check `./gradlew tasks` for opencode ## Dev Setup old diff --git a/build.gradle.kts b/build.gradle.kts index 733a529d..f1a06169 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,18 +4,51 @@ repositories { mavenCentral() } +tasks.register<Exec>("run-db") { + group = "OpenCoDE" + description = "Runs the database in background via docker" + commandLine("docker", "compose", "up", "-d", "db") +} + +tasks.register<Exec>("run-dashboard") { + group = "OpenCoDE" + description = "Runs the dashboard in background via docker." + workingDir("../dashboard") + commandLine("docker", "compose", "up", "-d", "dashboard") +} + tasks.register("run") { + group = "OpenCoDE" + description = "Runs the dataprovider against the database, you should be sure database is running." dependsOn(gradle.includedBuild("app").task(":backend:bootRun")) } + +tasks.register<Exec>("run-container") { + group = "OpenCoDE" + description = "Runs the dataprovider against the database in foreground." + commandLine("docker", "compose", "up") +} + tasks.register("clean") { + group = "OpenCoDE" + description = "Removes all builds." dependsOn(gradle.includedBuild("app").task(":backend:clean")) } + tasks.register("build") { + group = "OpenCoDE" + description = "Build the service" dependsOn(gradle.includedBuild("app").task(":backend:build")) } + tasks.register("test") { + group = "OpenCoDE" + description = "Runs tests." dependsOn(gradle.includedBuild("app").task(":backend:test")) } + tasks.register("assemble") { + group = "OpenCoDE" + description = "Assembles everything into a deployable format." dependsOn(gradle.includedBuild("app").task(":backend:assemble")) } -- GitLab