From 278166acaec3ecbd369bf0fcfbb19804475a301b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A5le=20Pedersen?= Date: Thu, 11 May 2023 17:23:29 +0200 Subject: [PATCH] Migration to Quarkus3 --- horreum-api/pom.xml | 5 + .../tools/horreum/api/ConditionConfig.java | 2 +- .../horreum/api/services/ActionService.java | 20 +-- .../horreum/api/services/AlertingService.java | 20 +-- .../horreum/api/services/BannerService.java | 12 +- .../horreum/api/services/ChangesService.java | 18 +-- .../horreum/api/services/ConfigService.java | 12 +- .../horreum/api/services/DatasetService.java | 20 +-- .../api/services/ExperimentService.java | 18 +-- .../horreum/api/services/LogService.java | 16 +- .../api/services/NotificationService.java | 14 +- .../horreum/api/services/ReportService.java | 20 +-- .../horreum/api/services/RunService.java | 22 +-- .../horreum/api/services/SchemaService.java | 22 +-- .../horreum/api/services/SqlService.java | 14 +- .../api/services/SubscriptionService.java | 16 +- .../horreum/api/services/TestService.java | 22 +-- .../horreum/api/services/UserService.java | 20 +-- horreum-backend/pom.xml | 8 +- .../horreum/action/ChangeToMarkdown.java | 2 +- .../action/ExperimentResultToMarkdown.java | 2 +- .../tools/horreum/action/GitHubClient.java | 6 +- .../action/GitHubIssueCommentAction.java | 2 +- .../action/GitHubIssueCreateAction.java | 6 +- .../horreum/action/GitHubPluginBase.java | 6 +- .../tools/horreum/action/HttpAction.java | 6 +- .../tools/horreum/bus/MessageBus.java | 130 +++++++++++----- .../horreum/converter/JavaTimeCustomizer.java | 2 +- .../converter/JsonPostgreSQLDialect.java | 14 +- .../tools/horreum/entity/ActionLogDAO.java | 4 +- .../tools/horreum/entity/BannerDAO.java | 8 +- .../horreum/entity/ExperimentComparison.java | 15 +- .../horreum/entity/ExperimentProfileDAO.java | 40 ++--- .../tools/horreum/entity/FingerprintDAO.java | 20 +-- .../tools/horreum/entity/PersistentLog.java | 10 +- .../tools/horreum/entity/SeqIdGenerator.java | 4 +- .../tools/horreum/entity/UserInfo.java | 18 +-- .../horreum/entity/ValidationErrorDAO.java | 13 +- .../horreum/entity/alerting/ChangeDAO.java | 18 +-- .../entity/alerting/ChangeDetectionDAO.java | 27 ++-- .../horreum/entity/alerting/DataPointDAO.java | 20 +-- .../entity/alerting/DatasetLogDAO.java | 14 +- .../entity/alerting/MissingDataRuleDAO.java | 28 ++-- .../alerting/MissingDataRuleResultDAO.java | 22 +-- .../alerting/NotificationSettingsDAO.java | 10 +- .../entity/alerting/RunExpectationDAO.java | 17 ++- .../entity/alerting/TransformationLogDAO.java | 12 +- .../horreum/entity/alerting/VariableDAO.java | 24 +-- .../horreum/entity/alerting/WatchDAO.java | 27 ++-- .../entity/converter/JsonConverter.java | 4 +- .../entity/converter/JsonUserType.java | 36 +++-- .../entity/converter/package-info.java | 2 +- .../tools/horreum/entity/data/ActionDAO.java | 11 +- .../horreum/entity/data/AllowedSiteDAO.java | 8 +- .../tools/horreum/entity/data/DataSetDAO.java | 37 ++--- .../tools/horreum/entity/data/Extractor.java | 6 +- .../tools/horreum/entity/data/LabelDAO.java | 29 ++-- .../horreum/entity/data/OwnedEntityBase.java | 9 +- .../entity/data/ProtectedBaseEntity.java | 2 +- .../tools/horreum/entity/data/RunDAO.java | 29 ++-- .../tools/horreum/entity/data/SchemaDAO.java | 25 ++-- .../tools/horreum/entity/data/TestDAO.java | 30 ++-- .../horreum/entity/data/TestTokenDAO.java | 19 ++- .../horreum/entity/data/TransformerDAO.java | 23 ++- .../horreum/entity/data/ViewComponentDAO.java | 26 ++-- .../tools/horreum/entity/data/ViewDAO.java | 25 ++-- .../entity/report/ReportCommentDAO.java | 16 +- .../entity/report/ReportComponentDAO.java | 24 +-- .../horreum/entity/report/ReportLogDAO.java | 6 +- .../entity/report/TableReportConfigDAO.java | 33 ++-- .../horreum/entity/report/TableReportDAO.java | 32 ++-- .../tools/horreum/hibernate/IntArrayType.java | 10 ++ .../horreum/hibernate/JsonBinaryType.java | 107 +++++++++++++ .../horreum/notification/EmailPlugin.java | 4 +- .../BaseTransactionRetryInterceptor.java | 16 +- .../ConstraintViolationExceptionMapper.java | 14 +- .../horreum/server/EncryptionManager.java | 4 +- .../tools/horreum/server/ErrorReporter.java | 4 +- .../server/HorreumAuthorizationFilter.java | 8 +- .../server/JWTBadRequestException.java | 4 +- .../tools/horreum/server/RoleManager.java | 10 +- .../horreum/server/RolesInterceptor.java | 16 +- .../tools/horreum/server/RouteFilter.java | 4 +- .../horreum/server/TokenInterceptor.java | 18 ++- .../tools/horreum/server/UserTeamsFilter.java | 12 +- .../tools/horreum/server/WithRoles.java | 4 +- .../tools/horreum/server/WithToken.java | 4 +- .../tools/horreum/svc/ActionServiceImpl.java | 28 ++-- .../horreum/svc/AlertingServiceImpl.java | 125 ++++++++-------- .../tools/horreum/svc/BannerServiceImpl.java | 10 +- .../tools/horreum/svc/ChangesServiceImpl.java | 18 +-- .../tools/horreum/svc/DatasetServiceImpl.java | 76 +++++----- .../tools/horreum/svc/EventAggregator.java | 8 +- .../horreum/svc/ExperimentServiceImpl.java | 48 +++--- .../tools/horreum/svc/LogServiceImpl.java | 14 +- .../horreum/svc/NotificationServiceImpl.java | 20 +-- .../tools/horreum/svc/ReportServiceImpl.java | 67 +++++---- .../io/hyperfoil/tools/horreum/svc/Roles.java | 2 +- .../tools/horreum/svc/RunServiceImpl.java | 141 +++++++++++------- .../tools/horreum/svc/SchemaServiceImpl.java | 71 +++++---- .../tools/horreum/svc/ServiceException.java | 8 +- .../tools/horreum/svc/SqlServiceImpl.java | 16 +- .../horreum/svc/SubscriptionServiceImpl.java | 16 +- .../tools/horreum/svc/TestServiceImpl.java | 28 ++-- .../tools/horreum/svc/TimeService.java | 2 +- .../tools/horreum/svc/UserServiceImpl.java | 24 +-- .../io/hyperfoil/tools/horreum/svc/Util.java | 24 +-- .../src/main/resources/application.properties | 2 +- .../src/main/resources/db/changeLog.xml | 29 +++- .../tools/horreum/bus/MessageBusTest.java | 8 +- .../tools/horreum/svc/ActionServiceTest.java | 2 +- .../horreum/svc/AlertingServiceTest.java | 8 +- .../tools/horreum/svc/BaseServiceTest.java | 22 +-- .../tools/horreum/svc/DatasetServiceTest.java | 10 +- .../horreum/svc/NotificationPluginTest.java | 4 +- .../tools/horreum/svc/RunServiceTest.java | 6 +- .../tools/horreum/svc/TestServiceTest.java | 7 +- .../tools/horreum/svc/TokenAuthTest.java | 2 +- .../tools/horreum/test/TestUtil.java | 4 +- .../io/hyperfoil/tools/HorreumClient.java | 2 +- .../hyperfoil/tools/RunServiceExtension.java | 6 +- .../auth/KeycloakClientRequestFilter.java | 8 +- .../tools/horreum/api/client/RunService.java | 20 +-- .../tools/horreum/it/HorreumClientIT.java | 2 +- infra/horreum-dev-services/deployment/pom.xml | 2 +- infra/horreum-dev-services/runtime/pom.xml | 2 +- infra/horreum-infra-common/pom.xml | 2 +- pom.xml | 7 +- webapp/src/alerts.tsx | 2 +- 129 files changed, 1349 insertions(+), 1053 deletions(-) create mode 100644 horreum-backend/src/main/java/io/hyperfoil/tools/horreum/hibernate/IntArrayType.java create mode 100644 horreum-backend/src/main/java/io/hyperfoil/tools/horreum/hibernate/JsonBinaryType.java diff --git a/horreum-api/pom.xml b/horreum-api/pom.xml index 205fe6937..6bd528f52 100644 --- a/horreum-api/pom.xml +++ b/horreum-api/pom.xml @@ -27,6 +27,11 @@ quarkus-rest-client-reactive true + + io.quarkus + quarkus-hibernate-validator + true + io.quarkus quarkus-smallrye-openapi diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/ConditionConfig.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/ConditionConfig.java index 632cb0208..1a5cb1907 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/ConditionConfig.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/ConditionConfig.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import org.eclipse.microprofile.openapi.annotations.media.Schema; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ActionService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ActionService.java index 6b4e23fa5..f7ba575a1 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ActionService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ActionService.java @@ -2,16 +2,16 @@ import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.Action; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/AlertingService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/AlertingService.java index fb380966e..f752cbcc3 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/AlertingService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/AlertingService.java @@ -4,16 +4,16 @@ import java.util.Collection; import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.ConditionConfig; import io.hyperfoil.tools.horreum.api.alerting.*; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/BannerService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/BannerService.java index 9a96b4743..4eef399f8 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/BannerService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/BannerService.java @@ -1,11 +1,11 @@ package io.hyperfoil.tools.horreum.api.services; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.data.Banner; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ChangesService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ChangesService.java index 0d2a5d686..37df9a603 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ChangesService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ChangesService.java @@ -4,15 +4,15 @@ import java.util.ArrayList; import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.OPTIONS; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.OPTIONS; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ConfigService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ConfigService.java index 241f55305..219ac149a 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ConfigService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ConfigService.java @@ -3,12 +3,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.quarkus.runtime.Startup; -import javax.annotation.security.PermitAll; -import javax.validation.constraints.NotNull; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.annotation.security.PermitAll; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; @Startup @PermitAll diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/DatasetService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/DatasetService.java index 31e692fe0..bc17a647a 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/DatasetService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/DatasetService.java @@ -2,16 +2,16 @@ import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.ValidationError; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ExperimentService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ExperimentService.java index 70bbb63d9..a992aa171 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ExperimentService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ExperimentService.java @@ -16,15 +16,15 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import java.io.IOException; import java.util.Collection; import java.util.List; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/LogService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/LogService.java index 4e93fed64..4e523b236 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/LogService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/LogService.java @@ -2,14 +2,14 @@ import java.util.List; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.data.ActionLog; import io.hyperfoil.tools.horreum.api.alerting.DatasetLog; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/NotificationService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/NotificationService.java index 7ebe90a8f..3e6530824 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/NotificationService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/NotificationService.java @@ -3,13 +3,13 @@ import java.util.Collection; import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.alerting.NotificationSettings; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ReportService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ReportService.java index dfbcae76a..c36b28342 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ReportService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/ReportService.java @@ -3,16 +3,16 @@ import java.time.Instant; import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.report.ReportComment; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/RunService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/RunService.java index 135fd3c0e..e2c5ea559 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/RunService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/RunService.java @@ -3,17 +3,17 @@ import java.util.List; import java.util.Map; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java index 10182682f..c76f5d8d9 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java @@ -4,17 +4,17 @@ import java.util.Collection; import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.Label; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SqlService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SqlService.java index 2a4cb2c7e..40954062a 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SqlService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SqlService.java @@ -1,12 +1,12 @@ package io.hyperfoil.tools.horreum.api.services; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SubscriptionService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SubscriptionService.java index 829331e99..1607a5a57 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SubscriptionService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SubscriptionService.java @@ -4,14 +4,14 @@ import java.util.Map; import java.util.Set; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.alerting.Watch; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java index fc9379319..de1c4b1be 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java @@ -3,17 +3,17 @@ import java.util.Collection; import java.util.List; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.*; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/UserService.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/UserService.java index 4985ea088..3deccc312 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/UserService.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/UserService.java @@ -4,16 +4,16 @@ import java.util.Map; import java.util.concurrent.CompletionStage; -import javax.validation.constraints.NotNull; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; diff --git a/horreum-backend/pom.xml b/horreum-backend/pom.xml index 5b8d90702..dc063159f 100644 --- a/horreum-backend/pom.xml +++ b/horreum-backend/pom.xml @@ -40,9 +40,9 @@ - com.vladmihalcea - hibernate-types-52 - 2.20.0 + io.hypersistence + hypersistence-utils-hibernate-62 + 3.5.1 com.networknt @@ -152,7 +152,7 @@ io.quarkus - quarkus-keycloak-admin-client + quarkus-keycloak-admin-client-reactive org.testcontainers diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ChangeToMarkdown.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ChangeToMarkdown.java index cf7799847..dc1d0adfd 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ChangeToMarkdown.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ChangeToMarkdown.java @@ -3,7 +3,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ExperimentResultToMarkdown.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ExperimentResultToMarkdown.java index fd452719c..c0f96bb0c 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ExperimentResultToMarkdown.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/ExperimentResultToMarkdown.java @@ -1,6 +1,6 @@ package io.hyperfoil.tools.horreum.action; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; import org.eclipse.microprofile.config.inject.ConfigProperty; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubClient.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubClient.java index 41b146be9..872906914 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubClient.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubClient.java @@ -1,8 +1,8 @@ package io.hyperfoil.tools.horreum.action; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import io.quarkus.runtime.Startup; import io.vertx.core.http.HttpVersion; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCommentAction.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCommentAction.java index 2a233c80f..703f527a6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCommentAction.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCommentAction.java @@ -5,7 +5,7 @@ import java.net.MalformedURLException; import java.net.URL; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCreateAction.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCreateAction.java index cce2da0bf..08e91cd38 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCreateAction.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubIssueCreateAction.java @@ -2,9 +2,9 @@ import static io.hyperfoil.tools.horreum.action.ActionUtil.replaceExpressions; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubPluginBase.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubPluginBase.java index 6825acd5a..2dbda27cd 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubPluginBase.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/GitHubPluginBase.java @@ -2,9 +2,9 @@ import java.util.concurrent.TimeUnit; -import javax.annotation.PostConstruct; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/HttpAction.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/HttpAction.java index 9946637f5..5e68a1756 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/HttpAction.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/action/HttpAction.java @@ -3,9 +3,9 @@ import java.net.MalformedURLException; import java.net.URL; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/bus/MessageBus.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/bus/MessageBus.java index a4a550fca..292d65b82 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/bus/MessageBus.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/bus/MessageBus.java @@ -8,17 +8,17 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.SystemException; -import javax.transaction.TransactionManager; -import javax.transaction.Transactional; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.RollbackException; +import jakarta.transaction.Status; +import jakarta.transaction.SystemException; +import jakarta.transaction.TransactionManager; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.data.Run; import io.hyperfoil.tools.horreum.entity.data.RunDAO; @@ -26,16 +26,16 @@ import io.hyperfoil.tools.horreum.mapper.RunMapper; import io.hyperfoil.tools.horreum.mapper.TestMapper; import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.hibernate.ScrollMode; import org.hibernate.ScrollableResults; import org.hibernate.query.NativeQuery; -import org.hibernate.type.IntegerType; -import org.hibernate.type.LongType; -import org.hibernate.type.TextType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.server.CloseMe; import io.hyperfoil.tools.horreum.server.ErrorReporter; @@ -105,11 +105,11 @@ public void publish(String channel, int testId, Object payload) { BigInteger id; if (componentFlag != null && componentFlag != 0) { try (CloseMe ignored = roleManager.withRoles(Collections.singleton(Roles.HORREUM_MESSAGEBUS))) { - id = (BigInteger) em.createNativeQuery("INSERT INTO messagebus (id, \"timestamp\", channel, testid, message, flags) VALUES (nextval('messagebus_seq'), NOW(), ?1, ?2, ?3, ?4) RETURNING id") + id = (BigInteger) em.createNativeQuery("INSERT INTO messagebus (id, \"timestamp\", channel, testid, message, flags) VALUES (nextval('messagebus_seq'), NOW(), ?1, ?2, ?3, ?4) RETURNING id", BigInteger.class) .unwrap(NativeQuery.class) .setParameter(1, channel) .setParameter(2, testId) - .setParameter(3, json, JsonNodeBinaryType.INSTANCE) + .setParameter(3, json, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .setParameter(4, componentFlag) .getSingleResult(); } @@ -248,36 +248,43 @@ void removeIndex(String channel, int index) { delayed = "{horreum.messagebus.retry.delay:30s}", concurrentExecution = Scheduled.ConcurrentExecution.SKIP) public void retryFailedMessages() { - Query query = em.createNativeQuery("SELECT channel, id, testid, flags, message FROM messagebus WHERE \"timestamp\" + make_interval(secs => ?1) <= now()") + + try(ScrollableResults results = (ScrollableResults) em.createNativeQuery("SELECT channel, id, testid, flags, message FROM messagebus WHERE \"timestamp\" + make_interval(secs => ?1) <= now()") .setParameter(1, retryAfter.toSeconds()) .unwrap(NativeQuery.class) - .addScalar("channel", TextType.INSTANCE) - .addScalar("id", LongType.INSTANCE) - .addScalar("testid", IntegerType.INSTANCE) - .addScalar("flags", IntegerType.INSTANCE) - .addScalar("message", JsonNodeBinaryType.INSTANCE); - try (ScrollableResults results = Util.scroll(query)) { + .addScalar("channel", StandardBasicTypes.TEXT) + .addScalar("id", StandardBasicTypes.LONG) + .addScalar("testid", StandardBasicTypes.INTEGER) + .addScalar("flags", StandardBasicTypes.INTEGER) + .addScalar("message", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .setTupleTransformer((tuples, aliases) -> { + ChannelMessage sm = new ChannelMessage(); + sm.setChannel((String) tuples[0]); + sm.setId((Long) tuples[1]); + sm.setTestid((Integer) tuples[2]); + sm.setFlags((Integer) tuples[3]); + sm.setMessage((JsonNode) tuples[4]); + return sm; + }) + .setReadOnly(true) + .setFetchSize(100) + .scroll(ScrollMode.FORWARD_ONLY)) { while (results.next()) { - Object[] row = results.get(); - String channel = (String) row[0]; - long id = (long) row[1]; - int testId = (int) row[2]; - int flags = (int) row[3]; - Class type = payloadClasses.get(channel); + ChannelMessage row = results.get(); + Class type = payloadClasses.get(row.getChannel()); // theoretically the type might not be set if the initial delay is too short // and components are not registered yet if (type != null) { - JsonNode json = (JsonNode) row[4]; - log.debugf("Retrying message %d (#%d) in channel %s (%s)", id, results.getRowNumber(), channel, type.getName()); + log.debugf("Retrying message %d (#%d) in channel %s (%s)", row.getId(), results.getRowNumber(), row.getChannel(), type.getName()); try { - Object payload = Util.OBJECT_MAPPER.treeToValue(json, type); - eventBus.publish(channel, new Message(id, testId, flags, payload)); + Object payload = Util.OBJECT_MAPPER.treeToValue(row.getMessage(), type); + eventBus.publish(row.getChannel(), new Message(row.getId(), row.getTestid(), row.getFlags(), payload)); } catch (JsonProcessingException e) { - String jsonStr = String.valueOf(json); + String jsonStr = String.valueOf(row.message); if (jsonStr.length() > 200) { jsonStr = jsonStr.substring(0, 200) + "..."; } - errorReporter.reportException(e, ERROR_SUBJECT, "Exception loading message to retry in bus channel %s, message %s%n%n", channel, jsonStr); + errorReporter.reportException(e, ERROR_SUBJECT, "Exception loading message to retry in bus channel %s, message %s%n%n", row.getChannel(), jsonStr); } } } @@ -340,4 +347,55 @@ public byte systemCodecID() { return -1; } } + + class ChannelMessage { + private String channel; + private Long id; + private Integer testid; + private Integer flags; + private JsonNode message; + + public ChannelMessage() { + } + + public String getChannel() { + return channel; + } + + public void setChannel(String channel) { + this.channel = channel; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getTestid() { + return testid; + } + + public void setTestid(Integer testid) { + this.testid = testid; + } + + public Integer getFlags() { + return flags; + } + + public void setFlags(Integer flags) { + this.flags = flags; + } + + public JsonNode getMessage() { + return message; + } + + public void setMessage(JsonNode message) { + this.message = message; + } + } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JavaTimeCustomizer.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JavaTimeCustomizer.java index eda35a380..bda0b35bf 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JavaTimeCustomizer.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JavaTimeCustomizer.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.quarkus.jackson.ObjectMapperCustomizer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Singleton public class JavaTimeCustomizer implements ObjectMapperCustomizer { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JsonPostgreSQLDialect.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JsonPostgreSQLDialect.java index 3fad1f5ce..1721e6bb4 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JsonPostgreSQLDialect.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/converter/JsonPostgreSQLDialect.java @@ -1,14 +1,22 @@ package io.hyperfoil.tools.horreum.converter; -import org.hibernate.dialect.PostgreSQL95Dialect; +import org.hibernate.dialect.PostgreSQLDialect; import java.sql.Types; -public class JsonPostgreSQLDialect extends PostgreSQL95Dialect { +public class JsonPostgreSQLDialect extends PostgreSQLDialect { public JsonPostgreSQLDialect(){ - registerColumnType(Types.JAVA_OBJECT,"jsonb"); + //stalep: PostgreSQLDialect now adds: new DdlTypeImpl(3001, "jsonb", this) as a dialect, not sure if we need this anymore + //registerColumnType(Types.JAVA_OBJECT,"jsonb"); + /* + super(); + this.registerColumnTypes( + Types.OTHER, JsonNodeBinaryType.class.getName() + ); + + */ } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java index 86cbfe2ea..fe79cde07 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java @@ -1,7 +1,7 @@ package io.hyperfoil.tools.horreum.entity; -import javax.persistence.Entity; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Entity; +import jakarta.validation.constraints.NotNull; @Entity(name = "ActionLog") public class ActionLogDAO extends PersistentLog { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/BannerDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/BannerDAO.java index babfeea8c..2698a1e16 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/BannerDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/BannerDAO.java @@ -2,10 +2,10 @@ import java.time.Instant; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; @Entity(name = "Banner") public class BannerDAO { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java index b490875ed..9704021c0 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java @@ -1,16 +1,17 @@ package io.hyperfoil.tools.horreum.entity; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.alerting.VariableDAO; +import org.hibernate.type.SqlTypes; @Embeddable public class ExperimentComparison { @@ -23,7 +24,7 @@ public class ExperimentComparison { public String model; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode config; public void setVariableId(Integer id) { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java index 82d8a1d1e..7c2b50ba1 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java @@ -2,31 +2,32 @@ import java.util.Collection; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ConstraintMode; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.data.TestDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.type.SqlTypes; @Entity(name = "ExperimentProfile") @Table(name = "experiment_profile") @@ -36,7 +37,6 @@ public class ExperimentProfileDAO extends PanacheEntityBase { name = "experimentProfileIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) @@ -51,14 +51,14 @@ public class ExperimentProfileDAO extends PanacheEntityBase { public TestDAO test; @Column(name = "selector_labels") - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode selectorLabels; @Column(name = "selector_filter") public String selectorFilter; @Column(name = "baseline_labels") - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode baselineLabels; @Column(name = "baseline_filter") @@ -71,7 +71,7 @@ public class ExperimentProfileDAO extends PanacheEntityBase { /* These labels are not used in Horreum but are added to the result event */ @Column(name = "extra_labels") - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode extraLabels; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/FingerprintDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/FingerprintDAO.java index c182648c0..2d742d030 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/FingerprintDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/FingerprintDAO.java @@ -1,20 +1,21 @@ package io.hyperfoil.tools.horreum.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.MapsId; -import javax.persistence.OneToOne; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.MapsId; +import jakarta.persistence.OneToOne; import org.hibernate.annotations.Immutable; -import org.hibernate.annotations.Type; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.annotations.Type; @Entity(name = "Fingerprint") @Immutable @@ -28,7 +29,8 @@ public class FingerprintDAO extends PanacheEntityBase { @JoinColumn(name = "dataset_id") public DataSetDAO dataset; - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @Type(JsonBinaryType.class) + @Column(columnDefinition = "jsonb") public JsonNode fingerprint; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java index fa9f1a698..e138ad4e3 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java @@ -2,11 +2,11 @@ import java.time.Instant; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.validation.constraints.NotNull; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/SeqIdGenerator.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/SeqIdGenerator.java index 852e0a2d3..88a22cf33 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/SeqIdGenerator.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/SeqIdGenerator.java @@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.function.Function; -import javax.persistence.Id; +import jakarta.persistence.Id; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; @@ -37,7 +37,7 @@ protected Function computeValue(Class type) { }; @Override - public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException { + public Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException { Function accessor = accessors.get(object.getClass()); if (accessor != null) { Serializable id = accessor.apply(object); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/UserInfo.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/UserInfo.java index bdcb38015..17c99e61f 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/UserInfo.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/UserInfo.java @@ -2,15 +2,15 @@ import java.util.Set; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.UniqueConstraint; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.UniqueConstraint; +import jakarta.validation.constraints.NotNull; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java index c43665334..bc5a84a02 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java @@ -1,15 +1,16 @@ package io.hyperfoil.tools.horreum.entity; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.data.SchemaDAO; +import org.hibernate.type.SqlTypes; @Embeddable public class ValidationErrorDAO { @@ -17,7 +18,7 @@ public class ValidationErrorDAO { public SchemaDAO schema; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode error; public void setSchema(int id) { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java index 54d2e59c6..1302f1cf5 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java @@ -2,15 +2,15 @@ import java.time.Instant; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java index 3aa534968..cce39c028 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java @@ -1,45 +1,44 @@ package io.hyperfoil.tools.horreum.entity.alerting; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.type.SqlTypes; @Entity(name = "ChangeDetection") @JsonIgnoreType public class ChangeDetectionDAO extends PanacheEntityBase { @Id @GenericGenerator( - name = "cdIdGenerator", + name = "changeDetectionIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cdIdGenerator") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "changeDetectionIdGenerator") public Integer id; @NotNull public String model; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode config; @ManyToOne(fetch = FetchType.LAZY) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java index dc5e16db1..585f17a11 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java @@ -2,16 +2,16 @@ import java.time.Instant; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java index f0e8ada85..9e6eae44f 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java @@ -1,12 +1,12 @@ package io.hyperfoil.tools.horreum.entity.alerting; -import javax.persistence.ConstraintMode; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; import io.hyperfoil.tools.horreum.entity.PersistentLog; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java index 8cf66f101..e3d61b08e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java @@ -3,27 +3,28 @@ import java.time.Instant; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.ConstraintMode; -import javax.persistence.Entity; -import javax.persistence.ForeignKey; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.Entity; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.node.ArrayNode; import io.hyperfoil.tools.horreum.entity.data.TestDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.type.SqlTypes; // If the test has no dataset matching the rule uploaded for more than this duration (in ms) // we send a notification about missing regular upload. If the value is non-positive @@ -36,7 +37,6 @@ public class MissingDataRuleDAO extends PanacheEntityBase { name = "mdrIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) @@ -49,7 +49,7 @@ public class MissingDataRuleDAO extends PanacheEntityBase { @JoinColumn(name = "test_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) public TestDAO test; - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public ArrayNode labels; public String condition; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleResultDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleResultDAO.java index e08901ad6..e61bd6aa7 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleResultDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleResultDAO.java @@ -4,15 +4,15 @@ import java.time.Instant; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.Immutable; @@ -73,11 +73,11 @@ public int datasetId() { } public static void deleteForDataset(int id) { - MissingDataRuleResultDAO.delete("dataset_id", id); + MissingDataRuleResultDAO.delete("pk.datasetId", id); } public static void deleteOlder(int ruleId, Instant timestamp) { - MissingDataRuleResultDAO.delete("rule_id = ?1 AND timestamp < ?2", ruleId, timestamp); + MissingDataRuleResultDAO.delete("pk.ruleId = ?1 AND timestamp < ?2", ruleId, timestamp); } @Override diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/NotificationSettingsDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/NotificationSettingsDAO.java index 1a250422f..4d5ce3cb1 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/NotificationSettingsDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/NotificationSettingsDAO.java @@ -1,10 +1,10 @@ package io.hyperfoil.tools.horreum.entity.alerting; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/RunExpectationDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/RunExpectationDAO.java index 6676734ed..0e8ff7910 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/RunExpectationDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/RunExpectationDAO.java @@ -2,14 +2,16 @@ import java.time.Instant; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; @Entity(name = "run_expectation") public class RunExpectationDAO extends PanacheEntityBase { @@ -21,7 +23,8 @@ public class RunExpectationDAO extends PanacheEntityBase { public int testId; @NotNull - @Column(columnDefinition = "timestamptz") + //@Column(columnDefinition = "timestamp") + @JdbcTypeCode(SqlTypes.TIMESTAMP) public Instant expectedBefore; public String expectedBy; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java index 2dd1bac4b..14736b8f6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java @@ -1,12 +1,12 @@ package io.hyperfoil.tools.horreum.entity.alerting; -import javax.persistence.ConstraintMode; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import io.hyperfoil.tools.horreum.entity.PersistentLog; import io.hyperfoil.tools.horreum.entity.data.RunDAO; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java index 8303cf9b1..e80e22226 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java @@ -2,27 +2,28 @@ import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonIgnoreType; import io.hyperfoil.tools.horreum.entity.data.LabelDAO; import io.hyperfoil.tools.horreum.entity.data.RunDAO; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.type.SqlTypes; /** * Variable emits a single value from the {@link RunDAO#data} @@ -38,7 +39,6 @@ public class VariableDAO extends PanacheEntityBase { name = "variableIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) @@ -59,7 +59,7 @@ public class VariableDAO extends PanacheEntityBase { public int order; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode labels; public String calculation; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java index 656c6c835..4e3718157 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java @@ -2,19 +2,19 @@ import java.util.List; -import javax.persistence.ConstraintMode; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; -import javax.validation.constraints.NotNull; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; @@ -37,7 +37,6 @@ public class WatchDAO extends PanacheEntityBase { name = "subscriptionIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonConverter.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonConverter.java index bf2594366..1300ba123 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonConverter.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonConverter.java @@ -1,7 +1,7 @@ package io.hyperfoil.tools.horreum.entity.converter; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java index 650599fda..0b2dc3c4e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java @@ -1,6 +1,7 @@ package io.hyperfoil.tools.horreum.entity.converter; import io.hyperfoil.tools.horreum.api.ApiUtil; +import io.quarkus.runtime.annotations.RegisterForReflection; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.usertype.UserType; @@ -14,10 +15,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -public class JsonUserType implements UserType { +@RegisterForReflection +public class JsonUserType implements UserType { + @Override - public int[] sqlTypes() { - return new int[]{Types.JAVA_OBJECT}; + public int getSqlType() { + return Types.JAVA_OBJECT; } @Override @@ -26,7 +29,7 @@ public Class returnedClass() { } @Override - public boolean equals(Object o1, Object o2) throws HibernateException { + public boolean equals(JsonNode o1, JsonNode o2) throws HibernateException { if (o1 == o2) { return true; } else if (o1 == null || o2 == null){ @@ -36,7 +39,7 @@ public boolean equals(Object o1, Object o2) throws HibernateException { } @Override - public int hashCode(Object o) throws HibernateException { + public int hashCode(JsonNode o) throws HibernateException { if(o == null){ return 0; } @@ -44,8 +47,8 @@ public int hashCode(Object o) throws HibernateException { } @Override - public Object nullSafeGet(ResultSet resultSet, String[] strings, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException, SQLException { - String content = resultSet.getString(strings[0]); + public JsonNode nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException { + String content = (String) resultSet.getObject(i); if (content == null) { return null; } @@ -57,7 +60,8 @@ public Object nullSafeGet(ResultSet resultSet, String[] strings, SharedSessionCo } @Override - public void nullSafeSet(PreparedStatement preparedStatement, Object o, int i, SharedSessionContractImplementor sharedSessionContractImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement preparedStatement, JsonNode o, int i, + SharedSessionContractImplementor sharedSessionContractImplementor) throws HibernateException, SQLException { if (o == null) { preparedStatement.setNull(i, Types.OTHER); return; @@ -70,11 +74,11 @@ public void nullSafeSet(PreparedStatement preparedStatement, Object o, int i, Sh } @Override - public Object deepCopy(Object o) throws HibernateException { - if (o instanceof JsonNode) { - return ((JsonNode) o).deepCopy(); - } - return null; + public JsonNode deepCopy(JsonNode o) throws HibernateException { + if(o != null) + return o.deepCopy(); + else + return null; } @Override @@ -83,7 +87,7 @@ public boolean isMutable() { } @Override - public Serializable disassemble(Object o) throws HibernateException { + public Serializable disassemble(JsonNode o) throws HibernateException { if(o == null){ return null; } @@ -91,7 +95,7 @@ public Serializable disassemble(Object o) throws HibernateException { } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public JsonNode assemble(Serializable cached, Object owner) throws HibernateException { if (cached instanceof String) { try { return ApiUtil.OBJECT_MAPPER.readTree((String) cached); @@ -103,7 +107,7 @@ public Object assemble(Serializable cached, Object owner) throws HibernateExcept } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public JsonNode replace(JsonNode original, JsonNode target, Object owner) throws HibernateException { return original; } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/package-info.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/package-info.java index b725775e3..3d783cee6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/package-info.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/package-info.java @@ -1,2 +1,2 @@ -@org.hibernate.annotations.TypeDef(name = "JsonUserType", typeClass = JsonUserType.class) +//@org.hibernate.annotations.TypeDef(name = "JsonUserType", typeClass = JsonUserType.class) package io.hyperfoil.tools.horreum.entity.converter; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java index 3857fc786..d8817f43c 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java @@ -2,17 +2,18 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import javax.persistence.*; -import javax.validation.constraints.NotNull; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import org.hibernate.type.SqlTypes; @Entity(name = "Action") public class ActionDAO extends PanacheEntityBase { @@ -37,12 +38,12 @@ public class ActionDAO extends PanacheEntityBase { public String type; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) @Column(name = "config") public JsonNode config; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) @Column(name = "secrets") public JsonNode secrets; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/AllowedSiteDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/AllowedSiteDAO.java index 83f6e06cc..da8dd8119 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/AllowedSiteDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/AllowedSiteDAO.java @@ -1,9 +1,9 @@ package io.hyperfoil.tools.horreum.entity.data; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java index 1181be3b8..170f8790d 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java @@ -5,29 +5,32 @@ import java.util.List; import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.SequenceGenerator; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.persistence.Basic; +import jakarta.persistence.CascadeType; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.SequenceGenerator; import com.fasterxml.jackson.annotation.JsonIgnoreType; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.query.NativeQuery; import com.fasterxml.jackson.databind.JsonNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; import io.smallrye.common.constraint.NotNull; +import org.hibernate.type.CustomType; +import org.hibernate.type.SqlTypes; +import org.hibernate.type.spi.TypeConfiguration; /** * Purpose of this object is to represent derived run data. @@ -64,7 +67,7 @@ public class DataSetDAO extends OwnedEntityBase { public Integer testid; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) @Basic(fetch = FetchType.LAZY) public JsonNode data; @@ -92,7 +95,7 @@ public String getFingerprint() { List fingerprintList = getEntityManager() .createNativeQuery("SELECT fingerprint FROM fingerprint WHERE dataset_id = ?") .setParameter(1, id).unwrap(NativeQuery.class) - .addScalar("fingerprint", JsonNodeBinaryType.INSTANCE) + .addScalar("fingerprint", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); if (fingerprintList.size() > 0) { return fingerprintList.stream().findFirst().get().toString(); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java index bf2ba88ac..eb7f9ca50 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java @@ -1,8 +1,8 @@ package io.hyperfoil.tools.horreum.entity.data; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.validation.constraints.NotNull; @Embeddable public class Extractor { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java index ac1ad0883..f50f51f70 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java @@ -4,27 +4,28 @@ import java.util.Collection; import java.util.Objects; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.type.SqlTypes; @Entity(name="label") public class LabelDAO extends OwnedEntityBase { @@ -81,7 +82,7 @@ public static class Value extends PanacheEntityBase implements Serializable { @Column(name = "label_id") public int labelId; - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode value; @Override diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java index 210d2003e..355f2a3f7 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java @@ -1,10 +1,13 @@ package io.hyperfoil.tools.horreum.entity.data; -import javax.persistence.MappedSuperclass; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import jakarta.validation.constraints.NotNull; import io.hyperfoil.tools.horreum.api.data.Access; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; @MappedSuperclass public class OwnedEntityBase extends PanacheEntityBase { @@ -13,6 +16,8 @@ public class OwnedEntityBase extends PanacheEntityBase { public String owner; @NotNull + @Column(columnDefinition = "INTEGER") + @JdbcTypeCode(SqlTypes.INTEGER) public Access access = Access.PUBLIC; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java index 916aca54b..ab3361bbc 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java @@ -1,6 +1,6 @@ package io.hyperfoil.tools.horreum.entity.data; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.MappedSuperclass; @MappedSuperclass public abstract class ProtectedBaseEntity extends OwnedEntityBase { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java index 2c104dd25..5c1007b4a 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java @@ -4,23 +4,24 @@ import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; -import javax.persistence.CascadeType; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.SequenceGenerator; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.SequenceGenerator; +import jakarta.validation.constraints.NotNull; import java.time.Instant; import java.util.Collection; import com.fasterxml.jackson.databind.JsonNode; +import org.hibernate.type.SqlTypes; @Entity(name = "run") @DynamicUpdate // We don't want to trigger schema analysis when trashing the run @@ -52,10 +53,10 @@ public class RunDAO extends ProtectedBaseEntity { public Integer testid; @NotNull - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode data; - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode metadata; @NotNull diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java index f9d44362b..deee9753f 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java @@ -6,22 +6,23 @@ import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedNativeQueries; -import javax.persistence.NamedNativeQuery; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedNativeQueries; +import jakarta.persistence.NamedNativeQuery; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.databind.JsonNode; +import org.hibernate.type.SqlTypes; @NamedNativeQueries({ @NamedNativeQuery( @@ -86,7 +87,7 @@ public class SchemaDAO extends ProtectedBaseEntity { public String description; - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode schema; public static class ValidationEvent { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java index a287f72a2..5777e1df4 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java @@ -6,26 +6,27 @@ import io.hyperfoil.tools.horreum.api.data.Access; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.OneToMany; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToMany; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Parameter; -import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; import com.fasterxml.jackson.databind.JsonNode; +import org.hibernate.type.SqlTypes; @Entity(name="test") @JsonIgnoreType @@ -59,20 +60,21 @@ public class TestDAO extends PanacheEntityBase { public String owner; @NotNull + @JdbcTypeCode(SqlTypes.INTEGER) public Access access = Access.PUBLIC; @OneToMany(mappedBy = "test", cascade = CascadeType.ALL, orphanRemoval = true) public Collection tokens; @Column(name = "timeline_labels") - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode timelineLabels; @Column(name = "timeline_function") public String timelineFunction; @Column(name = "fingerprint_labels") - @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") + @JdbcTypeCode( SqlTypes.JSON ) public JsonNode fingerprintLabels; @Column(name = "fingerprint_filter") diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java index ca4694391..bd2df1e5a 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java @@ -2,15 +2,15 @@ import java.util.function.Function; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; @@ -30,7 +30,6 @@ public class TestTokenDAO { name = "tokenIdGenerator", strategy = "io.hyperfoil.tools.horreum.entity.SeqIdGenerator", parameters = { - @Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SequenceStyleGenerator.DEF_SEQUENCE_NAME), @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "1"), } ) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java index 9ac3dcbb1..38de85762 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java @@ -4,17 +4,17 @@ import java.util.Collection; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.GenericGenerator; @@ -29,7 +29,6 @@ public class TransformerDAO extends OwnedEntityBase implements Comparable INT_ARRAY = new BasicTypeReference("int-array", int[].class, 666); + +} diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/hibernate/JsonBinaryType.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/hibernate/JsonBinaryType.java new file mode 100644 index 000000000..7685c45de --- /dev/null +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/hibernate/JsonBinaryType.java @@ -0,0 +1,107 @@ +package io.hyperfoil.tools.horreum.hibernate; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.type.SqlTypes; +import org.hibernate.usertype.UserType; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Objects; + +import static java.lang.String.format; + +public class JsonBinaryType implements UserType { + + private final ObjectMapper mapper = new ObjectMapper(); + + @Override + public int getSqlType() { + return SqlTypes.JSON; + } + + @Override + public Class returnedClass() { + return JsonNode.class; + } + + @Override + public boolean equals(JsonNode x, JsonNode y) { + return Objects.equals(x, y); + } + + @Override + public int hashCode(JsonNode x) { + return Objects.hashCode(x); + } + + @Override + public JsonNode nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) + throws SQLException { + final String json = rs.getString(position); + if (json == null) { + return null; + } + try { + return mapper.readTree(json.getBytes("UTF-8")); + } catch (final Exception ex) { + throw new RuntimeException("Failed to convert String to JSON: " + ex.getMessage(), ex); + } + } + + @Override + public void nullSafeSet(PreparedStatement ps, JsonNode value, int index, SharedSessionContractImplementor session) + throws SQLException { + if (value == null) { + ps.setNull(index, Types.OTHER); + return; + } + try { + ps.setObject(index, value.toString(), Types.OTHER); + } catch (final Exception ex) { + throw new RuntimeException(format("Failed to convert JSON to String: %s", ex.getMessage()), ex); + } + } + + @Override + public JsonNode deepCopy(JsonNode value) throws HibernateException { + if (value == null) { + return null; + } + return value.deepCopy(); + } + + @Override + public boolean isMutable() { + return true; + } + + @Override + public Serializable disassemble(JsonNode value) throws HibernateException { + return (Serializable) this.deepCopy(value); + } + + @Override + public JsonNode assemble(Serializable cached, Object owner) throws HibernateException { + try { + return mapper.readTree(cached.toString()); + } catch (JsonProcessingException ex) { + throw new RuntimeException(format("Failed to convert String to JSON: %s", ex.getMessage()), ex); + } + } + + @Override + public JsonNode replace(JsonNode original, JsonNode target, Object owner) throws HibernateException { + return original; + } + + public String getName() { + return "jsonb"; + } +} \ No newline at end of file diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/notification/EmailPlugin.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/notification/EmailPlugin.java index b3d71b1a6..f6337ac82 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/notification/EmailPlugin.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/notification/EmailPlugin.java @@ -7,8 +7,8 @@ import java.time.Instant; import java.util.Date; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/BaseTransactionRetryInterceptor.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/BaseTransactionRetryInterceptor.java index cc64f2430..59e9a4fb3 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/BaseTransactionRetryInterceptor.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/BaseTransactionRetryInterceptor.java @@ -3,14 +3,14 @@ import java.util.HashSet; import java.util.concurrent.ThreadLocalRandom; -import javax.annotation.Priority; -import javax.inject.Inject; -import javax.interceptor.AroundInvoke; -import javax.interceptor.Interceptor; -import javax.interceptor.InvocationContext; -import javax.transaction.Status; -import javax.transaction.TransactionManager; -import javax.transaction.Transactional; +import jakarta.annotation.Priority; +import jakarta.inject.Inject; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; +import jakarta.transaction.Status; +import jakarta.transaction.TransactionManager; +import jakarta.transaction.Transactional; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ConstraintViolationExceptionMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ConstraintViolationExceptionMapper.java index 02ccc60ca..471409208 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ConstraintViolationExceptionMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ConstraintViolationExceptionMapper.java @@ -1,12 +1,12 @@ package io.hyperfoil.tools.horreum.server; -import javax.json.Json; -import javax.json.JsonArrayBuilder; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; +import jakarta.json.Json; +import jakarta.json.JsonArrayBuilder; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/EncryptionManager.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/EncryptionManager.java index 039b359e9..f28185c74 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/EncryptionManager.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/EncryptionManager.java @@ -8,14 +8,14 @@ import java.security.spec.KeySpec; import java.util.Base64; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; import org.eclipse.microprofile.config.inject.ConfigProperty; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ErrorReporter.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ErrorReporter.java index ba35430ee..9883d79a8 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ErrorReporter.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/ErrorReporter.java @@ -6,8 +6,8 @@ import java.time.Duration; import java.util.Optional; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/HorreumAuthorizationFilter.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/HorreumAuthorizationFilter.java index fa2c8c612..0922d51c2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/HorreumAuthorizationFilter.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/HorreumAuthorizationFilter.java @@ -8,10 +8,10 @@ import java.util.Base64; import java.util.Locale; import java.util.Optional; -import javax.inject.Singleton; -import javax.ws.rs.Priorities; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; +import jakarta.inject.Singleton; +import jakarta.ws.rs.Priorities; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.Response; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.resteasy.reactive.server.ServerRequestFilter; import org.jboss.resteasy.reactive.server.spi.ResteasyReactiveContainerRequestContext; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/JWTBadRequestException.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/JWTBadRequestException.java index 35550cf7b..2ecf14a6e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/JWTBadRequestException.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/JWTBadRequestException.java @@ -1,7 +1,7 @@ package io.hyperfoil.tools.horreum.server; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.BadRequestException; +import jakarta.ws.rs.core.Response; public class JWTBadRequestException extends BadRequestException { public JWTBadRequestException() { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RoleManager.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RoleManager.java index 8e5e491c8..f655824f2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RoleManager.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RoleManager.java @@ -11,11 +11,11 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.Query; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RolesInterceptor.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RolesInterceptor.java index c3f8f95f9..c6d04bd0b 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RolesInterceptor.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RolesInterceptor.java @@ -5,14 +5,14 @@ import java.util.Collections; import java.util.function.Function; -import javax.annotation.Priority; -import javax.inject.Inject; -import javax.interceptor.AroundInvoke; -import javax.interceptor.Interceptor; -import javax.interceptor.InvocationContext; -import javax.persistence.EntityManager; -import javax.transaction.Status; -import javax.transaction.TransactionManager; +import jakarta.annotation.Priority; +import jakarta.inject.Inject; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; +import jakarta.persistence.EntityManager; +import jakarta.transaction.Status; +import jakarta.transaction.TransactionManager; import org.hibernate.Session; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RouteFilter.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RouteFilter.java index 5b46dcdb0..2e55b8425 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RouteFilter.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/RouteFilter.java @@ -1,7 +1,7 @@ package io.hyperfoil.tools.horreum.server; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.event.Observes; import java.util.regex.Pattern; import java.util.stream.Stream; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/TokenInterceptor.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/TokenInterceptor.java index bf60825de..d196e1269 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/TokenInterceptor.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/TokenInterceptor.java @@ -2,14 +2,14 @@ import java.util.List; -import javax.annotation.Priority; -import javax.inject.Inject; -import javax.interceptor.AroundInvoke; -import javax.interceptor.Interceptor; -import javax.interceptor.InvocationContext; -import javax.persistence.EntityManager; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.UriInfo; +import jakarta.annotation.Priority; +import jakarta.inject.Inject; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; +import jakarta.persistence.EntityManager; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.UriInfo; import io.hyperfoil.tools.horreum.svc.Util; import org.jboss.resteasy.reactive.server.spi.ServerRequestContext; @@ -20,6 +20,7 @@ public class TokenInterceptor { public final static String TOKEN_HEADER = "x-horreum-token"; + /* @Inject RoleManager roleManager; @@ -61,4 +62,5 @@ private boolean looksLikeJWT(String token) { } return dots == 2; } + */ } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/UserTeamsFilter.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/UserTeamsFilter.java index 3a082b7b8..eb71b6a52 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/UserTeamsFilter.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/UserTeamsFilter.java @@ -3,12 +3,12 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.Priorities; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Cookie; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import jakarta.ws.rs.Priorities; +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.core.Cookie; import org.jboss.logging.Logger; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithRoles.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithRoles.java index 833ca6192..76845333c 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithRoles.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithRoles.java @@ -7,8 +7,8 @@ import java.lang.annotation.Target; import java.util.function.Function; -import javax.enterprise.util.Nonbinding; -import javax.interceptor.InterceptorBinding; +import jakarta.enterprise.util.Nonbinding; +import jakarta.interceptor.InterceptorBinding; @Inherited @InterceptorBinding diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithToken.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithToken.java index 9b43b1f08..a55069d6a 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithToken.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/server/WithToken.java @@ -6,8 +6,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.enterprise.util.Nonbinding; -import javax.interceptor.InterceptorBinding; +import jakarta.enterprise.util.Nonbinding; +import jakarta.interceptor.InterceptorBinding; @Inherited @InterceptorBinding diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java index 2c2231be7..be3de3067 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java @@ -26,15 +26,15 @@ import org.jboss.logging.Logger; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.Transactional; -import javax.validation.constraints.NotNull; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.Transactional; +import jakarta.validation.constraints.NotNull; import java.security.GeneralSecurityException; import java.util.List; @@ -137,7 +137,7 @@ public void onNewTest(TestDAO test) { @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional public void onTestDelete(TestDAO test) { - ActionDAO.delete("test_id", test.id); + ActionDAO.delete("testId", test.id); } @WithRoles(extras = Roles.HORREUM_SYSTEM) @@ -192,7 +192,7 @@ public Action add(Action action){ return action; } - private JsonNode ensureNotNull(@NotNull JsonNode node) { + public JsonNode ensureNotNull(@NotNull JsonNode node) { return node == null || node.isNull() || node.isMissingNode() ? JsonNodeFactory.instance.objectNode() : node; } @@ -230,7 +230,7 @@ public List getActions(String event, int testId) { if (testId < 0) { return ActionDAO.find("event = ?1", event).list(); } else { - return ActionDAO.find("event = ?1 and (test_id = ?2 or test_id < 0)", event, testId).list(); + return ActionDAO.find("event = ?1 and (testId = ?2 or testId < 0)", event, testId).list(); } } @@ -239,7 +239,7 @@ public List getActions(String event, int testId) { @Override public List list(Integer limit, Integer page, String sort, SortDirection direction){ Sort.Direction sortDirection = direction == null ? null : Sort.Direction.valueOf(direction.name()); - PanacheQuery query = ActionDAO.find("test_id < 0", Sort.by(sort).direction(sortDirection)); + PanacheQuery query = ActionDAO.find("testId < 0", Sort.by(sort).direction(sortDirection)); if (limit != null && page != null) { query = query.page(Page.of(page, limit)); } @@ -290,7 +290,7 @@ public void onNewExperimentResult(ExperimentService.ExperimentResult result) { JsonNode exportTest(int testId) { ArrayNode actions = JsonNodeFactory.instance.arrayNode(); - for (ActionDAO action : ActionDAO.list("test_id", testId)) { + for (ActionDAO action : ActionDAO.list("testId", testId)) { ObjectNode node = Util.OBJECT_MAPPER.valueToTree(ActionMapper.from(action)); if (!action.secrets.isEmpty()) { try { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java index 2deab18cd..424b0a0d9 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java @@ -26,19 +26,21 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.PersistenceException; -import javax.persistence.Query; -import javax.transaction.TransactionManager; -import javax.transaction.Transactional; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; +import io.hyperfoil.tools.horreum.hibernate.IntArrayType; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import jakarta.transaction.TransactionManager; +import jakarta.transaction.Transactional; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; import io.hyperfoil.tools.horreum.api.ConditionConfig; import io.hyperfoil.tools.horreum.api.alerting.*; @@ -62,9 +64,9 @@ import org.hibernate.query.NativeQuery; import org.hibernate.transform.AliasToBeanResultTransformer; import org.hibernate.transform.Transformers; -import org.hibernate.type.InstantType; -import org.hibernate.type.IntegerType; -import org.hibernate.type.TextType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -72,8 +74,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.vladmihalcea.hibernate.type.array.IntArrayType; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.server.WithRoles; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -202,7 +202,7 @@ RelativeDifferenceChangeDetectionModel.NAME, new RelativeDifferenceChangeDetecti @Transactional public void onLabelsUpdated(DataSetDAO.LabelsUpdatedEvent event) { boolean sendNotifications; - DataPointDAO.delete("dataset_id", event.datasetId); + DataPointDAO.delete("dataset.id", event.datasetId); DataSetDAO dataset = DataSetDAO.findById(event.datasetId); if (dataset == null) { // The run is not committed yet? @@ -243,9 +243,9 @@ private void recalculateMissingDataRules(DataSetDAO dataset) { @SuppressWarnings("unchecked") List ruleValues = em.createNativeQuery(LOOKUP_RULE_LABEL_VALUES) .setParameter(1, dataset.id).setParameter(2, dataset.testid) .unwrap(NativeQuery.class) - .addScalar("rule_id", IntegerType.INSTANCE) - .addScalar("condition", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("rule_id", StandardBasicTypes.INTEGER) + .addScalar("condition", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); Util.evaluateMany(ruleValues, row -> (String) row[1], row -> (JsonNode) row[2], (row, result) -> { @@ -299,7 +299,8 @@ private boolean testFingerprint(DataSetDAO dataset, String filter) { @SuppressWarnings("unchecked") Optional result = em.createNativeQuery("SELECT fp.fingerprint FROM fingerprint fp WHERE dataset_id = ?1") .setParameter(1, dataset.id) - .unwrap(NativeQuery.class).addScalar("fingerprint", JsonNodeBinaryType.INSTANCE) + .unwrap(NativeQuery.class) + .addScalar("fingerprint", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultStream().findFirst(); JsonNode fingerprint; if (result.isPresent()) { @@ -325,9 +326,9 @@ private boolean testFingerprint(DataSetDAO dataset, String filter) { JsonNode exportTest(int testId) { ObjectNode config = JsonNodeFactory.instance.objectNode(); - List variables = VariableDAO.list("testid", testId); + List variables = VariableDAO.list("testId", testId); config.set("variables", Util.OBJECT_MAPPER.valueToTree(variables.stream().map(VariableMapper::from).collect(Collectors.toList()))); - List rules = MissingDataRuleDAO.list("test_id", testId); + List rules = MissingDataRuleDAO.list("test.id", testId); config.set("missingDataRules", Util.OBJECT_MAPPER.valueToTree(rules.stream().map(MissingDataRuleMapper::from).collect(Collectors.toList()))); return config; } @@ -400,12 +401,12 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R .setParameter(1, dataset.testid) .setParameter(2, dataset.id) .unwrap(NativeQuery.class) - .addScalar("variableId", IntegerType.INSTANCE) - .addScalar("name", TextType.INSTANCE) - .addScalar("group", TextType.INSTANCE) - .addScalar("calculation", TextType.INSTANCE) - .addScalar("numLabels", IntegerType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("variableId", StandardBasicTypes.INTEGER) + .addScalar("name", StandardBasicTypes.TEXT) + .addScalar("group", StandardBasicTypes.TEXT) + .addScalar("calculation", StandardBasicTypes.TEXT) + .addScalar("numLabels", StandardBasicTypes.INTEGER) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .setResultTransformer(new AliasToBeanResultTransformer(VariableData.class)) .getResultList(); if (debug) { @@ -417,8 +418,8 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R .setParameter(1, dataset.testid) .setParameter(2, dataset.id) .unwrap(NativeQuery.class) - .addScalar("timeline_function", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("timeline_function", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); Instant timestamp = dataset.start; if (!timestampList.isEmpty()) { @@ -572,14 +573,14 @@ void tryRunChangeDetection(VariableDAO variable, JsonNode fingerprint, boolean n private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, boolean notify, boolean expectExists) { UpTo valid = validUpTo.get(new VarAndFingerprint(variable.id, fingerprint)); - @SuppressWarnings("unchecked") Timestamp nextTimestamp = (Timestamp) em.createNativeQuery( + @SuppressWarnings("unchecked") Instant nextTimestamp = (Instant) em.createNativeQuery( "SELECT MIN(timestamp) FROM datapoint dp LEFT JOIN fingerprint fp ON dp.dataset_id = fp.dataset_id " + "WHERE dp.variable_id = ?1 AND (timestamp > ?2 OR (timestamp = ?2 AND ?3)) AND json_equals(fp.fingerprint, ?4)") .unwrap(NativeQuery.class) .setParameter(1, variable.id) - .setParameter(2, valid != null ? valid.timestamp : LONG_TIME_AGO, InstantType.INSTANCE) + .setParameter(2, valid != null ? valid.timestamp : LONG_TIME_AGO, StandardBasicTypes.INSTANT) .setParameter(3, valid == null || !valid.inclusive) - .setParameter(4, fingerprint, JsonNodeBinaryType.INSTANCE) + .setParameter(4, fingerprint, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultStream().filter(Objects::nonNull).findFirst().orElse(null); if (nextTimestamp == null) { log.debugf("No further datapoints for change detection"); @@ -594,9 +595,9 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool "AND json_equals(fp.fingerprint, ?4))") .unwrap(NativeQuery.class) .setParameter(1, variable.id) - .setParameter(2, valid.timestamp, InstantType.INSTANCE) + .setParameter(2, valid.timestamp, StandardBasicTypes.INSTANT) .setParameter(3, !valid.inclusive) - .setParameter(4, fingerprint, JsonNodeBinaryType.INSTANCE) + .setParameter(4, fingerprint, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .executeUpdate(); log.debugf("Deleted %d changes %s %s for variable %d, fingerprint %s", numDeleted, valid.inclusive ? ">" : ">=", valid.timestamp, variable.id, fingerprint); } @@ -610,7 +611,7 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool .setParameter(2, valid != null ? valid.timestamp : VERY_DISTANT_FUTURE) .setParameter(3, valid == null || valid.inclusive) .unwrap(org.hibernate.query.Query.class) - .setParameter(4, fingerprint, JsonNodeBinaryType.INSTANCE); + .setParameter(4, fingerprint, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())); ChangeDAO lastChange = changeQuery.setMaxResults(1).getResultStream().findFirst().orElse(null); Instant changeTimestamp = LONG_TIME_AGO; @@ -627,8 +628,9 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool "ORDER BY dp.timestamp DESC, dp.dataset.id DESC", DataPointDAO.class) .setParameter(1, variable) .setParameter(2, changeTimestamp) - .setParameter(3, nextTimestamp.toInstant()) - .unwrap(org.hibernate.query.Query.class).setParameter(4, fingerprint, JsonNodeBinaryType.INSTANCE) + .setParameter(3, nextTimestamp) + .unwrap(org.hibernate.query.Query.class) + .setParameter(4, fingerprint, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); // Last datapoint is already in the list if (dataPoints.isEmpty()) { @@ -658,7 +660,7 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool } } Util.doAfterCommit(tm, () -> { - validateUpTo(variable, fingerprint, nextTimestamp.toInstant()); + validateUpTo(variable, fingerprint, nextTimestamp); messageBus.executeForTest(variable.testId, () -> tryRunChangeDetection(variable, fingerprint, notify)); }); } @@ -693,7 +695,7 @@ private String reversedAndLimited(List list) { public List variables(Integer testId) { List variables; if (testId != null) { - variables = VariableDAO.list("testid", testId); + variables = VariableDAO.list("testId", testId); } else { variables = VariableDAO.listAll(); } @@ -715,7 +717,7 @@ public void updateVariables(int testId, List variablesDTO) { } try { List variables = variablesDTO.stream().map(VariableMapper::to).collect(Collectors.toList()); - List currentVariables = VariableDAO.list("testid", testId); + List currentVariables = VariableDAO.list("testId", testId); updateCollection(currentVariables, variables, v -> v.id, item -> { if (item.id != null && item.id <= 0) { item.id = null; @@ -747,8 +749,8 @@ public void updateVariables(int testId, List variablesDTO) { }, PanacheEntityBase::delete); current.persist(); }, current -> { - DataPointDAO.delete("variable_id", current.id); - ChangeDAO.delete("variable_id", current.id); + DataPointDAO.delete("variable.id", current.id); + ChangeDAO.delete("variable.id", current.id); current.delete(); }); @@ -841,7 +843,7 @@ public DashboardInfo dashboard(int testId, String fingerprint) { if (fingerprint == null) { fingerprint = ""; } - List variables = VariableDAO.list("testid", testId); + List variables = VariableDAO.list("testId", testId); return createChangesDashboard(testId, fingerprint, variables); } @@ -862,7 +864,7 @@ public List changes(int varId, String fingerprint) { List changes = em.createNativeQuery("SELECT change.* FROM change JOIN fingerprint fp ON change.dataset_id = fp.dataset_id " + "WHERE variable_id = ?1 AND json_equals(fp.fingerprint, ?2)", ChangeDAO.class) .setParameter(1, varId).unwrap(NativeQuery.class) - .setParameter(2, fp, JsonNodeBinaryType.INSTANCE) + .setParameter(2, fp, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); return changes.stream().map(ChangeMapper::from).collect(Collectors.toList()); } @@ -962,8 +964,8 @@ List getDatasetsForRecalculation(Integer testId, Long from, Long to) { .setParameter(3, to == null ? Long.MAX_VALUE : to); @SuppressWarnings("unchecked") List ids = query.getResultList(); - DataPointDAO.delete("dataset_id in ?1", ids); - ChangeDAO.delete("dataset_id in ?1 AND confirmed = false", ids); + DataPointDAO.delete("dataset.id in ?1", ids); + ChangeDAO.delete("dataset.id in ?1 AND confirmed = false", ids); if (ids.size() > 0) { // Due to RLS policies we cannot add a record to a dataset we don't own logCalculationMessage(testId, ids.get(0), PersistentLog.INFO, "Starting recalculation of %d runs.", ids.size()); @@ -1007,9 +1009,8 @@ public void checkMissingDataset() { int ruleId = (int) row[0]; int testId = (int) row[1]; String ruleName = (String) row[2]; - long maxStaleness = ((BigInteger) row[3]).longValue(); - Timestamp ts = (Timestamp) row[4]; - Instant timestamp = ts == null ? null : ts.toInstant(); + long maxStaleness = (long) row[3]; + Instant timestamp = (Instant) row[4]; if (timestamp == null || timestamp.isBefore(timeService.now().minusMillis(maxStaleness))) { if (ruleName == null) { ruleName = "rule #" + ruleId; @@ -1030,8 +1031,8 @@ public void checkMissingDataset() { public List findLastDatapoints(LastDatapointsParams params) { Query query = em.createNativeQuery(FIND_LAST_DATAPOINTS) .unwrap(NativeQuery.class) - .setParameter(1, Util.parseFingerprint(params.fingerprint), JsonNodeBinaryType.INSTANCE) - .setParameter(2, params.variables, IntArrayType.INSTANCE); + .setParameter(1, Util.parseFingerprint(params.fingerprint), new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .setParameter(2, params.variables, IntArrayType.INT_ARRAY); SqlServiceImpl.setResultTransformer(query, Transformers.aliasToBean(DatapointLastTimestamp.class)); //noinspection unchecked return query.getResultList(); @@ -1166,7 +1167,7 @@ void recalculateMissingDataRules(int testId, MissingDataRuleDAO rule) { em.createNativeQuery("SELECT id, start FROM dataset WHERE testid = ?1") .setParameter(1, testId).getResultList(); for (Object[] row : idsAndTimestamps) { - recalculateMissingDataRule((int) row[0], ((Timestamp) row[1]).toInstant(), rule); + recalculateMissingDataRule((int) row[0], (Instant) row[1], rule); } } @@ -1176,7 +1177,7 @@ void recalculateMissingDataRule(int datasetId, Instant timestamp, MissingDataRul JsonNode value = (JsonNode) em.createNativeQuery(LOOKUP_LABEL_VALUE_FOR_RULE) .setParameter(1, datasetId).setParameter(2, rule.id) .unwrap(NativeQuery.class) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getSingleResult(); boolean match = true; if (rule.condition != null && !rule.condition.isBlank()) { @@ -1220,12 +1221,12 @@ public void removeExpected(RunDAO run) { @Transactional void onDatasetDeleted(DataSetDAO.Info info) { log.debugf("Removing datasets and changes for dataset %d (%d/%d, test %d)", info.id, info.runId, info.ordinal, info.testId); - for (DataPointDAO dp : DataPointDAO.list("dataset_id", info.id)) { + for (DataPointDAO dp : DataPointDAO.list("dataset.id", info.id)) { messageBus.publish(DataPointDAO.EVENT_DELETED, info.testId, new DataPointDAO.Event(dp, info.testId, false)); dp.delete(); } - for (ChangeDAO c: ChangeDAO.list("dataset_id = ?1 AND confirmed = false", info.id)) { + for (ChangeDAO c: ChangeDAO.list("dataset.id = ?1 AND confirmed = false", info.id)) { c.delete(); } } @@ -1234,12 +1235,12 @@ void onDatasetDeleted(DataSetDAO.Info info) { @Transactional void onTestDeleted(TestDAO test) { // We need to delete in a loop to cascade this to ChangeDetection - List variables = VariableDAO.list("testid", test.id); + List variables = VariableDAO.list("testId", test.id); log.debugf("Deleting %d variables for test %s (%d)", variables.size(), test.name, test.id); for (var variable: variables) { variable.delete(); } - MissingDataRuleDAO.delete("test_id", test.id); + MissingDataRuleDAO.delete("test.id", test.id); em.flush(); } @@ -1247,7 +1248,7 @@ void onTestDeleted(TestDAO test) { @WithRoles(extras = Roles.HORREUM_SYSTEM) @Scheduled(every = "{horreum.alerting.expected.run.check}") public void checkExpectedRuns() { - for (RunExpectationDAO expectation : RunExpectationDAO.find("expectedbefore < ?1", timeService.now()).list()) { + for (RunExpectationDAO expectation : RunExpectationDAO.find("expectedBefore < ?1", timeService.now()).list()) { boolean sendNotifications = (Boolean) em.createNativeQuery("SELECT notificationsenabled FROM test WHERE id = ?") .setParameter(1, expectation.testId).getSingleResult(); if (sendNotifications) { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/BannerServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/BannerServiceImpl.java index e94ac1458..741ed0615 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/BannerServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/BannerServiceImpl.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.Optional; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.Transactional; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.data.Banner; import io.hyperfoil.tools.horreum.mapper.BannerMapper; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ChangesServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ChangesServiceImpl.java index 98d3d2359..737904fa6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ChangesServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ChangesServiceImpl.java @@ -3,13 +3,13 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.core.Response; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.ws.rs.HeaderParam; +import jakarta.ws.rs.core.Response; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; @@ -106,7 +106,7 @@ public List query(Query query) { sql.append("LEFT JOIN fingerprint fp ON fp.dataset_id = dp.dataset_id WHERE json_equals(fp.fingerprint, (?4)::::jsonb) "); } sql.append("ORDER BY timestamp ASC"); - javax.persistence.Query nativeQuery = em.createNativeQuery(sql.toString(), DataPointDAO.class) + jakarta.persistence.Query nativeQuery = em.createNativeQuery(sql.toString(), DataPointDAO.class) .setParameter(1, variableId) .setParameter(2, query.range.from) .setParameter(3, query.range.to); @@ -175,7 +175,7 @@ public List annotations(AnnotationsQuery query) { if (fingerprint != null) { sql.append("AND json_equals(fp.fingerprint, (?4)::::jsonb)"); } - javax.persistence.Query nativeQuery = em.createNativeQuery(sql.toString(), ChangeDAO.class) + jakarta.persistence.Query nativeQuery = em.createNativeQuery(sql.toString(), ChangeDAO.class) .setParameter(1, variableId) .setParameter(2, query.range.from) .setParameter(3, query.range.to); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java index 68738a457..935319ad7 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java @@ -6,15 +6,16 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.PersistenceException; -import javax.persistence.Query; -import javax.transaction.Transactional; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.DataSet; @@ -24,16 +25,15 @@ import org.hibernate.Hibernate; import org.hibernate.query.NativeQuery; import org.hibernate.transform.AliasToBeanResultTransformer; -import org.hibernate.type.IntegerType; -import org.hibernate.type.LongType; -import org.hibernate.type.TextType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.api.services.DatasetService; import io.hyperfoil.tools.horreum.api.services.QueryResult; @@ -184,7 +184,7 @@ public DatasetService.DatasetList listByTest(int testId, String filter, Integer Query query = em.createNativeQuery(sql.toString()) .setParameter(1, testId); if (jsonFilter != null) { - query.unwrap(NativeQuery.class).setParameter(2, jsonFilter, JsonNodeBinaryType.INSTANCE); + query.unwrap(NativeQuery.class).setParameter(2, jsonFilter, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())); } else { query.setParameter(2, null); } @@ -210,19 +210,19 @@ private void addViewIdCondition(StringBuilder sql, Integer viewId) { private void initTypes(Query query) { //noinspection deprecation query.unwrap(NativeQuery.class) - .addScalar("id", IntegerType.INSTANCE) - .addScalar("runId", IntegerType.INSTANCE) - .addScalar("ordinal", IntegerType.INSTANCE) - .addScalar("testId", IntegerType.INSTANCE) - .addScalar("testname", TextType.INSTANCE) - .addScalar("description", TextType.INSTANCE) - .addScalar("start", LongType.INSTANCE) - .addScalar("stop", LongType.INSTANCE) - .addScalar("owner", TextType.INSTANCE) - .addScalar("access", IntegerType.INSTANCE) - .addScalar("view", JsonNodeBinaryType.INSTANCE) - .addScalar("schemas", JsonNodeBinaryType.INSTANCE) - .addScalar("validationErrors", JsonNodeBinaryType.INSTANCE) + .addScalar("id", StandardBasicTypes.INTEGER) + .addScalar("runId", StandardBasicTypes.INTEGER) + .addScalar("ordinal", StandardBasicTypes.INTEGER) + .addScalar("testId", StandardBasicTypes.INTEGER) + .addScalar("testname", StandardBasicTypes.TEXT) + .addScalar("description", StandardBasicTypes.TEXT) + .addScalar("start", StandardBasicTypes.LONG) + .addScalar("stop", StandardBasicTypes.LONG) + .addScalar("owner", StandardBasicTypes.TEXT) + .addScalar("access", StandardBasicTypes.INTEGER) + .addScalar("view", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("schemas", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("validationErrors", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .setResultTransformer(DATASET_SUMMARY_TRANSFORMER); } @@ -296,12 +296,12 @@ public List labelValues(int datasetId) { Stream stream = em.createNativeQuery("SELECT label_id, label.name AS label_name, schema.id AS schema_id, schema.name AS schema_name, schema.uri, value FROM label_values " + "JOIN label ON label.id = label_id JOIN schema ON label.schema_id = schema.id WHERE dataset_id = ?1") .setParameter(1, datasetId).unwrap(NativeQuery.class) - .addScalar("label_id", IntegerType.INSTANCE) - .addScalar("label_name", TextType.INSTANCE) - .addScalar("schema_id", IntegerType.INSTANCE) - .addScalar("schema_name", TextType.INSTANCE) - .addScalar("uri", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("label_id", StandardBasicTypes.INTEGER) + .addScalar("label_name", StandardBasicTypes.TEXT) + .addScalar("schema_id", StandardBasicTypes.INTEGER) + .addScalar("schema_name", StandardBasicTypes.TEXT) + .addScalar("uri", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultStream(); return stream.map(row -> { LabelValue value = new LabelValue(); @@ -337,7 +337,7 @@ public LabelPreview previewLabel(int datasetId, Label label) { .setParameter(1, extractors) .setParameter(2, datasetId) .setParameter(3, label.schemaId) - .addScalar("value", JsonNodeBinaryType.INSTANCE).getSingleResult(); + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())).getSingleResult(); } catch (PersistenceException e) { preview.output = Util.explainCauses(e); return preview; @@ -408,10 +408,10 @@ void calculateLabels(int testId, int datasetId, int queryLabelId, boolean isReca .setParameter(1, datasetId) .setParameter(2, queryLabelId) .unwrap(NativeQuery.class) - .addScalar("label_id", IntegerType.INSTANCE) - .addScalar("name", TextType.INSTANCE) - .addScalar("function", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("label_id", StandardBasicTypes.INTEGER) + .addScalar("name", StandardBasicTypes.TEXT) + .addScalar("function", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); } catch (PersistenceException e) { logMessageInNewTx(datasetId, PersistentLog.ERROR, "Failed to extract data (JSONPath expression error?): " + Util.explainCauses(e)); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java index 674495581..73b29d111 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java @@ -3,10 +3,10 @@ import java.util.HashMap; import java.util.Map; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.bus.MessageBus; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java index f78ed5def..aeec12eda 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java @@ -10,16 +10,16 @@ import java.util.function.Function; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.transaction.Transactional; - -import com.fasterxml.jackson.databind.node.ArrayNode; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; + import com.fasterxml.jackson.databind.node.ObjectNode; import io.hyperfoil.tools.horreum.api.data.DataSet; import io.hyperfoil.tools.horreum.api.data.ExperimentComparison; @@ -33,13 +33,13 @@ import org.hibernate.Hibernate; import org.hibernate.query.NativeQuery; import org.hibernate.transform.Transformers; -import org.hibernate.type.IntegerType; -import org.hibernate.type.TextType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.api.ConditionConfig; import io.hyperfoil.tools.horreum.api.services.ExperimentService; @@ -151,7 +151,7 @@ public void onDatapointsCreated(DataPointDAO.DatasetProcessedEvent event) { @Transactional public void onTestDeleted(TestDAO test) { // we need to iterate in order to cascade the operation - for (var profile : ExperimentProfileDAO.list("test_id", test.id)) { + for (var profile : ExperimentProfileDAO.list("test.id", test.id)) { profile.delete(); } } @@ -178,9 +178,9 @@ private void runExperiments(DataSetDAO.Info info, Consumer res @SuppressWarnings("unchecked") List selectorRows = selectorQuery.setParameter(1, info.testId).setParameter(2, info.id) .unwrap(NativeQuery.class) - .addScalar("profile_id", IntegerType.INSTANCE) - .addScalar("selector_filter", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("profile_id", StandardBasicTypes.INTEGER) + .addScalar("selector_filter", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); List matchingProfile = new ArrayList<>(); @@ -216,10 +216,11 @@ private void runExperiments(DataSetDAO.Info info, Consumer res @SuppressWarnings("unchecked") List baselineRows = baselineQuery.setParameter(1, matchingProfile).setParameter(2, info.testId) .unwrap(NativeQuery.class) - .addScalar("profile_id", IntegerType.INSTANCE) - .addScalar("baseline_filter", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) - .addScalar("dataset_id", IntegerType.INSTANCE) + .addScalar("profile_id", StandardBasicTypes.INTEGER) + .addScalar("baseline_filter", StandardBasicTypes.TEXT) + .addScalar("value", StandardBasicTypes.TEXT) + //.addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("dataset_id", StandardBasicTypes.INTEGER) .getResultList(); Map> baselines = new HashMap<>(); @@ -283,7 +284,8 @@ private void runExperiments(DataSetDAO.Info info, Consumer res "LEFT JOIN label_values lv ON label.id = lv.label_id WHERE ep.id = ?1 AND lv.dataset_id = ?2") .setParameter(1, profile.id).setParameter(2, info.id) .unwrap(NativeQuery.class) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("value", StandardBasicTypes.TEXT) + //.addScalar("value", JsonNodeBinaryType.INSTANCE) .getSingleResult(); Hibernate.initialize(profile.test.name); resultConsumer.accept(new ExperimentResult(ExperimentProfileMapper.from(profile), @@ -294,7 +296,7 @@ private void runExperiments(DataSetDAO.Info info, Consumer res } JsonNode exportTest(int testId) { - List experimentProfiles = ExperimentProfileDAO.list("test_id", testId); + List experimentProfiles = ExperimentProfileDAO.list("test.id", testId); return Util.OBJECT_MAPPER.valueToTree(experimentProfiles.stream().map(ExperimentProfileMapper::from).collect(Collectors.toList())); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/LogServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/LogServiceImpl.java index 5c423028a..340e6d999 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/LogServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/LogServiceImpl.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.data.ActionLog; import io.hyperfoil.tools.horreum.api.alerting.DatasetLog; @@ -178,8 +178,8 @@ public void deleteActionLogs(int testId, Long from, Long to) { @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional public void onTestDelete(TestDAO test) { - DatasetLogDAO.delete("testid", test.id); - TransformationLogDAO.delete("testid", test.id); + DatasetLogDAO.delete("test.id", test.id); + TransformationLogDAO.delete("test.id", test.id); } @Scheduled(every = "{horreum.transformationlog.check}") diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/NotificationServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/NotificationServiceImpl.java index 4c989683d..a0fe94b80 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/NotificationServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/NotificationServiceImpl.java @@ -9,16 +9,16 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.SystemException; -import javax.transaction.TransactionManager; -import javax.transaction.Transactional; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.SystemException; +import jakarta.transaction.TransactionManager; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.alerting.NotificationSettings; import io.hyperfoil.tools.horreum.mapper.NotificationSettingsMapper; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java index c238ee549..b9f48d2db 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java @@ -14,14 +14,15 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.transaction.Transactional; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.report.ReportComment; import io.hyperfoil.tools.horreum.api.report.TableReportConfig; @@ -34,15 +35,15 @@ import org.graalvm.polyglot.Value; import org.hibernate.Hibernate; import org.hibernate.query.NativeQuery; -import org.hibernate.type.IntegerType; -import org.hibernate.type.TextType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.api.services.ReportService; import io.hyperfoil.tools.horreum.api.SortDirection; @@ -111,12 +112,12 @@ public AllTableReports getTableReports(String folder, Integer testId, String rol Util.addPaging(queryBuilder, limit, page, sort, direction); Query query = em.createNativeQuery(queryBuilder.toString()).unwrap(NativeQuery.class) - .addScalar("config_id", IntegerType.INSTANCE) - .addScalar("title", TextType.INSTANCE) - .addScalar("testname", TextType.INSTANCE) - .addScalar("testid", IntegerType.INSTANCE) - .addScalar("reports", JsonNodeBinaryType.INSTANCE) - .addScalar("total", IntegerType.INSTANCE); + .addScalar("config_id", StandardBasicTypes.INTEGER) + .addScalar("title", StandardBasicTypes.TEXT) + .addScalar("testname", StandardBasicTypes.TEXT) + .addScalar("testid", StandardBasicTypes.INTEGER) + .addScalar("reports", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("total", StandardBasicTypes.INTEGER); for (var entry : params.entrySet()) { query.setParameter(entry.getKey(), entry.getValue()); } @@ -373,8 +374,8 @@ private TableReportDAO createTableReport(TableReportConfigDAO config, Integer re log.debugf("Data per dataset: %s", datasetData); @SuppressWarnings("unchecked") - Map timestamps = ((Stream) timestampQuery.getResultStream()) - .collect(Collectors.toMap(row -> (Integer) row[0], row -> (Timestamp) row[1])); + Map timestamps = ((Stream) timestampQuery.getResultStream()) + .collect(Collectors.toMap(row -> (Integer) row[0], row -> (Instant) row[1])); // TODO: customizable time range List datasetIds = getFinalDatasetIds(timestamps, datasetData); List> values = config.components.stream() @@ -519,10 +520,10 @@ private String toText(JsonNode value) { return value == null ? "" : value.isTextual() ? value.asText() : value.toString(); } - private List getFinalDatasetIds(Map timestamps, Map datasetData) { + private List getFinalDatasetIds(Map timestamps, Map datasetData) { Map dataByCoords = new HashMap<>(); for (TableReportDAO.Data data : datasetData.values()) { - Timestamp dataTimestamp = timestamps.get(data.datasetId); + Instant dataTimestamp = timestamps.get(data.datasetId); if (dataTimestamp == null) { log.errorf("No timestamp for dataset %d", data.datasetId); continue; @@ -533,11 +534,11 @@ private List getFinalDatasetIds(Map timestamps, Map dataByCoords.put(coords, data); continue; } - Timestamp prevTimestamp = timestamps.get(prev.datasetId); + Instant prevTimestamp = timestamps.get(prev.datasetId); if (prevTimestamp == null) { log.errorf("No timestamp for prev dataset %d", prev.datasetId); dataByCoords.put(coords, data); - } else if (prevTimestamp.before(dataTimestamp)) { + } else if (prevTimestamp.isBefore(dataTimestamp)) { dataByCoords.put(coords, data); } } @@ -564,11 +565,11 @@ private List selectByTest(int testId, ArrayNode labels) { Query query = em.createNativeQuery(sql.toString()) .setParameter("testid", testId) .unwrap(NativeQuery.class) - .setParameter("labels", labels, JsonNodeBinaryType.INSTANCE) - .addScalar("id", IntegerType.INSTANCE) - .addScalar("runid", IntegerType.INSTANCE) - .addScalar("ordinal", IntegerType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE); + .setParameter("labels", labels, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("id", StandardBasicTypes.INTEGER) + .addScalar("runid", StandardBasicTypes.INTEGER) + .addScalar("ordinal", StandardBasicTypes.INTEGER) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())); //noinspection unchecked return query.getResultList(); } @@ -590,11 +591,11 @@ private List selectByDatasets(ArrayNode labels, List datasets Query query = em.createNativeQuery(sql.toString()) .setParameter("datasets", datasets) .unwrap(NativeQuery.class) - .setParameter("labels", labels, JsonNodeBinaryType.INSTANCE) - .addScalar("id", IntegerType.INSTANCE) - .addScalar("runid", IntegerType.INSTANCE) - .addScalar("ordinal", IntegerType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE); + .setParameter("labels", labels, new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("id", StandardBasicTypes.INTEGER) + .addScalar("runid", StandardBasicTypes.INTEGER) + .addScalar("ordinal", StandardBasicTypes.INTEGER) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())); //noinspection unchecked return (List) query.getResultList(); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Roles.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Roles.java index 333e3c8a6..0d0be71f7 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Roles.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Roles.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Set; -import javax.persistence.Query; +import jakarta.persistence.Query; import io.quarkus.security.identity.SecurityIdentity; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java index 0a2cf8a88..a9567dbf3 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java @@ -21,35 +21,34 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceException; -import javax.persistence.Query; -import javax.persistence.TransactionRequiredException; -import javax.transaction.InvalidTransactionException; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.Transactional; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import io.hypersistence.utils.hibernate.query.MapResultTransformer; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import jakarta.persistence.TransactionRequiredException; +import jakarta.transaction.InvalidTransactionException; +import jakarta.transaction.SystemException; +import jakarta.transaction.Transaction; +import jakarta.transaction.TransactionManager; +import jakarta.transaction.Transactional; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; -import com.vladmihalcea.hibernate.type.util.MapResultTransformer; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.Access; import io.hyperfoil.tools.horreum.api.data.Run; @@ -73,10 +72,9 @@ import org.hibernate.ScrollMode; import org.hibernate.ScrollableResults; import org.hibernate.query.NativeQuery; -import org.hibernate.type.BooleanType; -import org.hibernate.type.IntegerType; -import org.hibernate.type.TextType; -import org.hibernate.type.TimestampType; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import org.jboss.resteasy.reactive.multipart.FileUpload; @@ -146,7 +144,7 @@ void onTestDeleted(TestDAO test) { log.debugf("Trashing runs for test %s (%d)", test.name, test.id); ScrollableResults results = Util.scroll(em.createNativeQuery("SELECT id FROM run WHERE testid = ?1").setParameter(1, test.id)); while (results.next()) { - int id = (int) results.get(0); + int id = (int) results.get(); messageBus.executeForTest(test.id, () -> trashDueToTestDeleted(id)); } } @@ -188,9 +186,20 @@ void onNewOrUpdatedSchema(int schemaId) { } void findRunsWithUri(String uri, BiConsumer consumer) { - ScrollableResults results = Util.scroll(em.createNativeQuery(FIND_RUNS_WITH_URI).setParameter(1, uri)); + ScrollableResults results = + em.createNativeQuery(FIND_RUNS_WITH_URI).setParameter(1, uri) + .unwrap(NativeQuery.class) + .setTupleTransformer((tuple, aliases) -> { + RunFromUri r = new RunFromUri(); + r.id = (int) tuple[0]; + r.testId = (int) tuple[1]; + return r; + }) + .unwrap(NativeQuery.class).setReadOnly(true).setFetchSize(100) + .scroll(ScrollMode.FORWARD_ONLY); while (results.next()) { - consumer.accept((Integer) results.get(0), (Integer) results.get(1)); + RunFromUri r = results.get(); + consumer.accept( r.id, r.testId); } } @@ -726,20 +735,20 @@ public RunsSummary listAllRuns(String query, boolean matchAll, String roles, boo private void initTypes(Query query) { query.unwrap(NativeQuery.class) - .addScalar("id", IntegerType.INSTANCE) - .addScalar("start", TimestampType.INSTANCE) - .addScalar("stop", TimestampType.INSTANCE) - .addScalar("testid", IntegerType.INSTANCE) - .addScalar("owner", TextType.INSTANCE) - .addScalar("access", IntegerType.INSTANCE) - .addScalar("token", TextType.INSTANCE) - .addScalar("trashed", BooleanType.INSTANCE) - .addScalar("description", TextType.INSTANCE) - .addScalar("has_metadata", BooleanType.INSTANCE) - .addScalar("testname", TextType.INSTANCE) - .addScalar("schemas", JsonNodeBinaryType.INSTANCE) - .addScalar("datasets", JsonNodeBinaryType.INSTANCE) - .addScalar("validationErrors", JsonNodeBinaryType.INSTANCE); + .addScalar("id", StandardBasicTypes.INTEGER) + .addScalar("start", StandardBasicTypes.TIMESTAMP) + .addScalar("stop", StandardBasicTypes.TIMESTAMP) + .addScalar("testid", StandardBasicTypes.INTEGER) + .addScalar("owner", StandardBasicTypes.TEXT) + .addScalar("access", StandardBasicTypes.INTEGER) + .addScalar("token", StandardBasicTypes.TEXT) + .addScalar("trashed", StandardBasicTypes.BOOLEAN) + .addScalar("description", StandardBasicTypes.TEXT) + .addScalar("has_metadata", StandardBasicTypes.BOOLEAN) + .addScalar("testname", StandardBasicTypes.TEXT) + .addScalar("schemas", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("datasets", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) + .addScalar("validationErrors", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())); } private RunSummary createSummary(Object[] row) { @@ -968,16 +977,22 @@ public void recalculateAll(String fromStr, String toStr) { log.debugf("Deleted %d datasets for trashed runs between %s and %s", deleted, from, to); } - ScrollableResults results = em.createNativeQuery("SELECT id, testid FROM run WHERE start BETWEEN ?1 AND ?2 AND NOT trashed ORDER BY start") + ScrollableResults results = em.createNativeQuery("SELECT id, testid FROM run WHERE start BETWEEN ?1 AND ?2 AND NOT trashed ORDER BY start") .setParameter(1, from).setParameter(2, to) - .unwrap(NativeQuery.class).setReadOnly(true).setFetchSize(100) + .unwrap(NativeQuery.class) + .setTupleTransformer((tuples, aliases) -> { + Recalculate r = new Recalculate(); + r.runId = (int) tuples[0]; + r.testId = (int) tuples[1]; + return r; + }) + .setReadOnly(true).setFetchSize(100) .scroll(ScrollMode.FORWARD_ONLY); while (results.next()) { - int runId = (int) results.get(0); - int testId = (int) results.get(1); - log.debugf("Recalculate DataSets for run %d - forcing recalculation of all between %s and %s", runId, from, to); + Recalculate r = results.get(); + log.debugf("Recalculate DataSets for run %d - forcing recalculation of all between %s and %s", r.runId, from, to); // transform will add proper roles anyway - messageBus.executeForTest(testId, () -> datasetService.withRecalculationLock(() -> transform(runId, true))); + messageBus.executeForTest(r.testId, () -> datasetService.withRecalculationLock(() -> transform(r.runId, true))); } } @@ -1004,7 +1019,7 @@ int transform(int runId, boolean isRecalculation) { log.debugf("Transforming run ID %d, recalculation? %s", runId, Boolean.toString(isRecalculation)); // We need to make sure all old datasets are gone before creating new; otherwise we could // break the runid,ordinal uniqueness constraint - for (DataSetDAO old : DataSetDAO.list("runid", runId)) { + for (DataSetDAO old : DataSetDAO.list("run.id", runId)) { messageBus.publish(DataSetDAO.EVENT_DELETED, old.testid, old.getInfo()); old.delete(); } @@ -1022,11 +1037,11 @@ int transform(int runId, boolean isRecalculation) { List relevantSchemas = unchecked(em.createNamedQuery(QUERY_TRANSFORMER_TARGETS) .setParameter(1, run.id) .unwrap(NativeQuery.class) - .addScalar("type", IntegerType.INSTANCE) - .addScalar("key", TextType.INSTANCE) - .addScalar("transformer_id", IntegerType.INSTANCE) - .addScalar("uri", TextType.INSTANCE) - .addScalar("source", IntegerType.INSTANCE) + .addScalar("type", StandardBasicTypes.INTEGER) + .addScalar("key", StandardBasicTypes.TEXT) + .addScalar("transformer_id", StandardBasicTypes.INTEGER) + .addScalar("uri", StandardBasicTypes.TEXT) + .addScalar("source", StandardBasicTypes.INTEGER) .getResultList() ); int schemasAndTransformers = relevantSchemas.size(); @@ -1057,8 +1072,8 @@ int transform(int runId, boolean isRecalculation) { extractedData = unchecked(em.createNamedQuery(QUERY_1ST_LEVEL_BY_RUNID_TRANSFORMERID_SCHEMA_ID) .setParameter(1, run.id).setParameter(2, transformerId) .unwrap(NativeQuery.class) - .addScalar("name", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("name", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList()); } else { extractedData = unchecked(em.createNamedQuery(QUERY_2ND_LEVEL_BY_RUNID_TRANSFORMERID_SCHEMA_ID) @@ -1066,8 +1081,8 @@ int transform(int runId, boolean isRecalculation) { .setParameter(3, type == SchemaDAO.TYPE_2ND_LEVEL ? key : Integer.parseInt(key)) .setParameter(4, source) .unwrap(NativeQuery.class) - .addScalar("name", TextType.INSTANCE) - .addScalar("value", JsonNodeBinaryType.INSTANCE) + .addScalar("name", StandardBasicTypes.TEXT) + .addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList()); } } catch (PersistenceException e) { @@ -1267,4 +1282,14 @@ private void putIfAbsent(RunDAO run, String uri, ObjectNode node) { } } } + + class Recalculate { + private int runId; + private int testId; + } + + class RunFromUri { + private int id; + private int testId; + } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SchemaServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SchemaServiceImpl.java index ff3f46d1e..a895881b3 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SchemaServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SchemaServiceImpl.java @@ -1,5 +1,6 @@ package io.hyperfoil.tools.horreum.svc; +import com.networknt.schema.JsonMetaSchema; import io.hyperfoil.tools.horreum.api.data.*; import io.hyperfoil.tools.horreum.api.data.Extractor; import io.hyperfoil.tools.horreum.entity.data.*; @@ -19,14 +20,14 @@ import io.quarkus.security.identity.SecurityIdentity; import io.vertx.core.Vertx; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.Query; -import javax.transaction.Transactional; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; import java.io.ByteArrayInputStream; import java.net.URI; @@ -47,11 +48,11 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import org.hibernate.ScrollMode; import org.hibernate.ScrollableResults; import org.hibernate.query.NativeQuery; import org.hibernate.transform.AliasToBeanResultTransformer; -import org.hibernate.type.IntegerType; -import org.hibernate.type.TextType; +import org.hibernate.type.StandardBasicTypes; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -59,12 +60,12 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.networknt.schema.JsonMetaSchema; + import com.networknt.schema.JsonSchemaFactory; import com.networknt.schema.uri.URIFactory; import com.networknt.schema.uri.URIFetcher; import com.networknt.schema.uri.URLFactory; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; +//import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; @Startup public class SchemaServiceImpl implements SchemaService { @@ -340,11 +341,20 @@ void revalidateAll(int schemaId) { messageBus.executeForTest(testId, () -> validateRunData(runId, schemaFilter)) ); // Datasets might be re-created if URI is changing, so we might work on old, non-existent ones - ScrollableResults results = Util.scroll(em.createNativeQuery("SELECT id, testid FROM dataset WHERE ?1 IN (SELECT jsonb_array_elements(data)->>'$schema')").setParameter(1, schema.uri)); + ScrollableResults results = + em.createNativeQuery("SELECT id, testid FROM dataset WHERE ?1 IN (SELECT jsonb_array_elements(data)->>'$schema')").setParameter(1, schema.uri) + .unwrap(NativeQuery.class) + .setTupleTransformer((tuple, aliases) -> { + RecreateDataset r = new RecreateDataset(); + r.datasetId = (int) tuple[0]; + r.testId = (int) tuple[1]; + return r; + }) + .unwrap(NativeQuery.class).setReadOnly(true).setFetchSize(100) + .scroll(ScrollMode.FORWARD_ONLY); while (results.next()) { - int datasetId = (int) results.get(0); - int testId = (int) results.get(1); - messageBus.executeForTest(testId, () -> validateDatasetData(datasetId, schemaFilter)); + RecreateDataset r = results.get(); + messageBus.executeForTest(r.testId, () -> validateDatasetData(r.datasetId, schemaFilter)); } } @@ -419,12 +429,12 @@ public void delete(int id){ log.debugf("Deleting schema %s (%d), URI %s", schema.name, schema.id, schema.uri); em.createNativeQuery("DELETE FROM label_extractors WHERE label_id IN (SELECT id FROM label WHERE schema_id = ?1)") .setParameter(1, id).executeUpdate(); - LabelDAO.delete("schema_id", id); + LabelDAO.delete("schema.id", id); em.createNativeQuery("DELETE FROM transformer_extractors WHERE transformer_id IN (SELECT id FROM transformer WHERE schema_id = ?1)") .setParameter(1, id).executeUpdate(); em.createNativeQuery("DELETE FROM test_transformers WHERE transformer_id IN (SELECT id FROM transformer WHERE schema_id = ?1)") .setParameter(1, id).executeUpdate(); - TransformerDAO.delete("schema_id", id); + TransformerDAO.delete("schema.id", id); schema.delete(); } } @@ -464,14 +474,18 @@ public List findUsages(String label) { "filterlabels, categorylabels, serieslabels, scalelabels FROM tablereportconfig trc JOIN test ON test.id = trc.testid " + "WHERE json_contains(filterlabels, ?1) OR json_contains(categorylabels, ?1) OR json_contains(serieslabels, ?1) OR json_contains(scalelabels, ?1);") .setParameter(1, label).unwrap(NativeQuery.class) - .addScalar("testid", IntegerType.INSTANCE) - .addScalar("testname", TextType.INSTANCE) - .addScalar("configid", IntegerType.INSTANCE) - .addScalar("title", TextType.INSTANCE) - .addScalar("filterlabels", JsonNodeBinaryType.INSTANCE) - .addScalar("categorylabels", JsonNodeBinaryType.INSTANCE) - .addScalar("serieslabels", JsonNodeBinaryType.INSTANCE) - .addScalar("scalelabels", JsonNodeBinaryType.INSTANCE) + .addScalar("testid", StandardBasicTypes.INTEGER ) + .addScalar("testname", StandardBasicTypes.TEXT ) + .addScalar("configid", StandardBasicTypes.INTEGER) + .addScalar("title", StandardBasicTypes.TEXT) + //.addScalar("filterlabels", JsonNodeBinaryType.INSTANCE) + //.addScalar("categorylabels", JsonNodeBinaryType.INSTANCE) + //.addScalar("serieslabels", JsonNodeBinaryType.INSTANCE) + //.addScalar("scalelabels", JsonNodeBinaryType.INSTANCE) + .addScalar("filterlabels", StandardBasicTypes.TEXT) + .addScalar("categorylabels", StandardBasicTypes.TEXT) + .addScalar("serieslabels", StandardBasicTypes.TEXT) + .addScalar("scalelabels", StandardBasicTypes.TEXT) .getResultList()) { Object[] columns = (Object[]) row; StringBuilder where = new StringBuilder(); @@ -792,4 +806,9 @@ private void addPart(StringBuilder where, ArrayNode column, String label, String where.append(type); } } + + class RecreateDataset { + private int datasetId; + private int testId; + } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ServiceException.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ServiceException.java index d54b02482..c2bae22c2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ServiceException.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ServiceException.java @@ -1,9 +1,9 @@ package io.hyperfoil.tools.horreum.svc; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; public class ServiceException extends WebApplicationException { public static ServiceException badRequest(String message) { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SqlServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SqlServiceImpl.java index c42ef36b3..ec647234e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SqlServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SqlServiceImpl.java @@ -10,14 +10,14 @@ import io.vertx.mutiny.sqlclient.SqlConnection; import io.vertx.pgclient.PgConnection; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.annotation.security.PermitAll; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceException; -import javax.persistence.Query; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.annotation.security.PermitAll; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; import java.util.ArrayList; import java.util.Collections; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SubscriptionServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SubscriptionServiceImpl.java index d9c76ec4a..cec1caed4 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SubscriptionServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/SubscriptionServiceImpl.java @@ -10,12 +10,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.Transactional; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.Transactional; import io.hyperfoil.tools.horreum.api.alerting.Watch; import io.hyperfoil.tools.horreum.mapper.WatchMapper; @@ -206,7 +206,7 @@ public List removeUserOrTeam(int testId, String userOrTeam) { @Override public void update(int testId, Watch dto) { WatchDAO watch = WatchMapper.to(dto); - WatchDAO existing = WatchDAO.find("testid", testId).firstResult(); + WatchDAO existing = WatchDAO.find("test.id", testId).firstResult(); if (existing == null) { watch.id = null; watch.test = em.getReference(TestDAO.class, testId); @@ -249,7 +249,7 @@ private List currentWatches(WatchDAO watch) { @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional public void onTestDelete(TestDAO test) { - var subscriptions = WatchDAO.list("testid = ?1", test.id); + var subscriptions = WatchDAO.list("test.id = ?1", test.id); log.infof("Deleting %d subscriptions for test %s (%d)", subscriptions.size(), test.name, test.id); for (var subscription : subscriptions) { subscription.delete(); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TestServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TestServiceImpl.java index 11082348f..55ace9ab4 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TestServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TestServiceImpl.java @@ -3,6 +3,7 @@ import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.data.*; import io.hyperfoil.tools.horreum.entity.data.*; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; import io.hyperfoil.tools.horreum.mapper.ActionMapper; import io.hyperfoil.tools.horreum.mapper.TestMapper; import io.hyperfoil.tools.horreum.mapper.TestTokenMapper; @@ -17,15 +18,15 @@ import io.quarkus.panache.common.Sort; import io.quarkus.security.identity.SecurityIdentity; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceException; -import javax.persistence.Query; -import javax.transaction.Transactional; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; import java.security.GeneralSecurityException; import java.time.Instant; @@ -46,6 +47,8 @@ import org.hibernate.ScrollableResults; import org.hibernate.query.NativeQuery; import org.hibernate.transform.Transformers; +import org.hibernate.type.CustomType; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -53,7 +56,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; public class TestServiceImpl implements TestService { private static final Logger log = Logger.getLogger(TestServiceImpl.class); @@ -500,7 +502,7 @@ public List listFingerprints(int testId) { "SELECT DISTINCT fingerprint FROM fingerprint fp " + "JOIN dataset ON dataset.id = dataset_id WHERE dataset.testid = ?1") .setParameter(1, testId) - .unwrap(NativeQuery.class).addScalar("fingerprint", JsonNodeBinaryType.INSTANCE) + .unwrap(NativeQuery.class).addScalar("fingerprint", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); } @@ -511,7 +513,7 @@ public List listLabelValues(int testId, boolean filtering, boolean met return em.createNativeQuery(LABEL_VALUES_QUERY) .setParameter(1, testId).setParameter(2, filtering).setParameter(3, metrics) .unwrap(NativeQuery.class) - .addScalar("values", JsonNodeBinaryType.INSTANCE) + .addScalar("values", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); } @@ -562,7 +564,7 @@ public void recalculateDatasets(int testId) { .unwrap(NativeQuery.class).setReadOnly(true).setFetchSize(100) .scroll(ScrollMode.FORWARD_ONLY); while (results.next()) { - int runId = (int) results.get(0); + int runId = (int) results.get(); log.debugf("Recalculate DataSets for run %d - forcing recalculation for test %d (%s)", runId, testId, test.name); // transform will add proper roles anyway messageBus.executeForTest(testId, () -> datasetService.withRecalculationLock(() -> { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TimeService.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TimeService.java index f640dd639..9949c0c73 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TimeService.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/TimeService.java @@ -2,7 +2,7 @@ import java.time.Instant; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * {@link java.time.Instant#now()} cannot be mocked in JDK17 so we need to use a mockable service. diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/UserServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/UserServiceImpl.java index 6cd75ae34..806251f43 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/UserServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/UserServiceImpl.java @@ -14,18 +14,18 @@ import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.LockModeType; -import javax.persistence.PersistenceException; -import javax.transaction.Transactional; -import javax.ws.rs.ClientErrorException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.security.PermitAll; +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.persistence.LockModeType; +import jakarta.persistence.PersistenceException; +import jakarta.transaction.Transactional; +import jakarta.ws.rs.ClientErrorException; +import jakarta.ws.rs.NotFoundException; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; import org.eclipse.microprofile.config.ConfigProvider; import org.hibernate.exception.ConstraintViolationException; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Util.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Util.java index 772b0bc73..4a7d18ead 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Util.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/Util.java @@ -23,18 +23,18 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.OptimisticLockException; -import javax.persistence.Query; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.Synchronization; -import javax.transaction.SystemException; -import javax.transaction.TransactionManager; +import jakarta.persistence.EntityManager; +import jakarta.persistence.NoResultException; +import jakarta.persistence.OptimisticLockException; +import jakarta.persistence.Query; +import jakarta.transaction.HeuristicMixedException; +import jakarta.transaction.HeuristicRollbackException; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.RollbackException; +import jakarta.transaction.Status; +import jakarta.transaction.Synchronization; +import jakarta.transaction.SystemException; +import jakarta.transaction.TransactionManager; import io.hyperfoil.tools.horreum.api.SortDirection; import org.eclipse.microprofile.context.ThreadContext; diff --git a/horreum-backend/src/main/resources/application.properties b/horreum-backend/src/main/resources/application.properties index 341d3271c..1c0eb4bc9 100644 --- a/horreum-backend/src/main/resources/application.properties +++ b/horreum-backend/src/main/resources/application.properties @@ -29,7 +29,7 @@ quarkus.http.cors=true # Do not use for PROD - this needs to be more restrictive in PROD env quarkus.http.cors.origins=* -quarkus.hibernate-orm.dialect=io.hyperfoil.tools.horreum.converter.JsonPostgreSQLDialect +quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQLDialect # The database is initialized by Liquibase using db/changelog.xml - the application user # does not have privileges to drop or alter the tables. diff --git a/horreum-backend/src/main/resources/db/changeLog.xml b/horreum-backend/src/main/resources/db/changeLog.xml index c2f518674..a40b3dce2 100644 --- a/horreum-backend/src/main/resources/db/changeLog.xml +++ b/horreum-backend/src/main/resources/db/changeLog.xml @@ -4074,7 +4074,6 @@ ); - CREATE OR REPLACE FUNCTION before_variable_delete_func() RETURNS TRIGGER AS $$ @@ -4090,4 +4089,32 @@ CREATE TRIGGER before_variable_delete BEFORE DELETE ON variable FOR EACH ROW EXECUTE FUNCTION before_variable_delete_func(); + + + + + + + + + + + + + + + + + + + + + + + + + + GRANT ALL ON SEQUENCE ActionLog_SEQ, AllowedSite_SEQ, Banner_SEQ, Change_SEQ, DataPoint_SEQ, DatasetLog_SEQ, NotificationSettings_SEQ, ReportComment_SEQ, ReportComponent_SEQ, ReportLog_SEQ, Run_Expectation_SEQ, TableReport_SEQ, TableReportConfig_SEQ, TransformationLog_SEQ, changeDetectionIdGenerator, experimentProfileIdGenerator, mdrIdGenerator, subscriptionIdGenerator, tokenIdGenerator, transformerIdGenerator, variableIdGenerator, viewComponentIdGenerator, viewIdGenerator TO "${quarkus.datasource.username}"; + + diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/bus/MessageBusTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/bus/MessageBusTest.java index 4b4d3e036..27472474a 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/bus/MessageBusTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/bus/MessageBusTest.java @@ -10,9 +10,9 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.TransactionManager; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.TransactionManager; import io.quarkus.test.junit.TestProfile; import org.jboss.logging.Logger; @@ -122,7 +122,7 @@ public void testRetryManyWithExceptions() throws InterruptedException, TimeoutEx private void awaitMessageBus(int expectedMessages) { TestUtil.eventually(() -> expectedMessages == Util.withTx(tm, () -> { - long count = ((BigInteger) em.createNativeQuery("SELECT COUNT(*) FROM messagebus").getSingleResult()).longValue(); + long count = (long) em.createNativeQuery("SELECT COUNT(*) FROM messagebus").getSingleResult(); log.debugf("Message bus has %d messages, expected %d", count, expectedMessages); try { Thread.sleep(10); diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/ActionServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/ActionServiceTest.java index 74773a99e..5efe11ec5 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/ActionServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/ActionServiceTest.java @@ -50,7 +50,7 @@ public void testFailingHttp(TestInfo testInfo) { @org.junit.jupiter.api.Test public void testAddGlobalAction() { String responseType = addGlobalAction(TestDAO.EVENT_NEW, "https://attacker.com") - .then().statusCode(400).extract().header(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE); + .then().statusCode(400).extract().header(jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE); // constraint violations are mapped to 400 + JSON response, we want explicit error assertTrue(responseType.startsWith("text/plain")); // text/plain;charset=UTF-8 diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java index bfb1db16f..935e93c60 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java @@ -19,7 +19,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import javax.inject.Inject; +import jakarta.inject.Inject; import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.api.data.Extractor; @@ -443,14 +443,14 @@ public void testMissingRules(TestInfo info) throws InterruptedException { jsonRequest().delete("/api/alerting/missingdatarule/" + otherRuleId).then().statusCode(204); em.clear(); - assertEquals(0, MissingDataRuleResultDAO.find("rule_id", otherRuleId).count()); + assertEquals(0, MissingDataRuleResultDAO.find("pk.ruleId", otherRuleId).count()); } private void pollMissingDataRuleResultsByRule(int ruleId, int... datasetIds) throws InterruptedException { try (CloseMe h = roleManager.withRoles(SYSTEM_ROLES)) { for (int i = 0; i < 1000; ++i) { em.clear(); - List results = MissingDataRuleResultDAO.list("rule_id", ruleId); + List results = MissingDataRuleResultDAO.list("pk.ruleId", ruleId); if (results.size() == datasetIds.length && results.stream().mapToInt(MissingDataRuleResultDAO::datasetId) .allMatch(res -> IntStream.of(datasetIds).anyMatch(id -> id == res))) { return; @@ -467,7 +467,7 @@ private void pollMissingDataRuleResultsByDataset(int datasetId, long expectedRes // there's no event when the results are updated, we need to poll for (int i = 0; i < 1000; ++i) { em.clear(); - List results = MissingDataRuleResultDAO.list("dataset_id", datasetId); + List results = MissingDataRuleResultDAO.list("pk.datasetId", datasetId); if (expectedResults == results.size()) { return; } else { diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java index f13c54768..bd440e922 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java @@ -25,12 +25,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.transaction.Status; -import javax.transaction.TransactionManager; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.transaction.Status; +import jakarta.transaction.TransactionManager; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MediaType; import io.hyperfoil.tools.horreum.api.alerting.MissingDataRule; import io.hyperfoil.tools.horreum.api.data.*; @@ -39,6 +40,8 @@ import io.hyperfoil.tools.horreum.entity.data.*; import io.hyperfoil.tools.horreum.entity.data.ViewComponentDAO; import org.hibernate.query.NativeQuery; +import org.hibernate.type.CustomType; +import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -48,7 +51,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.action.GitHubIssueCommentAction; import io.hyperfoil.tools.horreum.action.HttpAction; @@ -459,7 +461,7 @@ protected T withExampleDataset(Test test, JsonNode data, Function> tableCon for (String table : tableContents.keySet()) { //noinspection unchecked List rows = em.createNativeQuery("SELECT to_jsonb(t) AS json FROM \"" + table + "\" t;") - .unwrap(NativeQuery.class).addScalar("json", JsonNodeBinaryType.INSTANCE).getResultList(); + .unwrap(NativeQuery.class).addScalar("json", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())).getResultList(); List expected = tableContents.get(table); assertEquals(expected.size(), rows.size()); @@ -669,7 +671,7 @@ protected HashMap> dumpDatabaseContents() { for (String table : tables) { //noinspection unchecked tableContents.put(table, em.createNativeQuery("SELECT to_jsonb(t) AS json FROM \"" + table + "\" t;") - .unwrap(NativeQuery.class).addScalar("json", JsonNodeBinaryType.INSTANCE).getResultList()); + .unwrap(NativeQuery.class).addScalar("json", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())).getResultList()); } } return null; diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java index 59b9c28ba..5856fce15 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import javax.inject.Inject; +import jakarta.inject.Inject; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -183,7 +183,7 @@ public void testDatasetLabelChanged() { BlockingQueue updateQueue = eventConsumerQueue(DataSetDAO.LabelsUpdatedEvent.class, DataSetDAO.EVENT_LABELS_UPDATED, e -> checkTestId(e.datasetId, test.id)); withExampleDataset(test, createABData(), ds -> { waitForUpdate(updateQueue, ds); - List values = LabelDAO.Value.find("dataset_id", ds.id).list(); + List values = LabelDAO.Value.find("datasetId", ds.id).list(); assertEquals(3, values.size()); assertEquals(24, values.stream().filter(v -> v.labelId == labelA).map(v -> v.value.numberValue()).findFirst().orElse(null)); assertEquals(43, values.stream().filter(v -> v.labelId == labelB).map(v -> v.value.numberValue()).findFirst().orElse(null)); @@ -197,7 +197,7 @@ public void testDatasetLabelChanged() { waitForUpdate(updateQueue, ds); // delete does not cause any update - values = LabelDAO.Value.find("dataset_id", ds.id).list(); + values = LabelDAO.Value.find("datasetId", ds.id).list(); assertEquals(2, values.size()); assertEquals(JsonNodeFactory.instance.arrayNode().add(24), values.stream().filter(v -> v.labelId == labelA).map(v -> v.value).findFirst().orElse(null)); assertEquals(84, values.stream().filter(v -> v.labelId == labelB).map(v -> v.value.numberValue()).findFirst().orElse(null)); @@ -213,7 +213,7 @@ private List withLabelValues(ArrayNode data) { BlockingQueue updateQueue = eventConsumerQueue(DataSetDAO.LabelsUpdatedEvent.class, DataSetDAO.EVENT_LABELS_UPDATED, e -> checkTestId(e.datasetId, test.id)); return withExampleDataset(test, data, ds -> { waitForUpdate(updateQueue, ds); - return LabelDAO.Value.find("dataset_id", ds.id).list().stream().map(LabelMapper::fromValue).collect(Collectors.toList()); + return LabelDAO.Value.find("datasetId", ds.id).list().stream().map(LabelMapper::fromValue).collect(Collectors.toList()); }); } @@ -395,7 +395,7 @@ public void testEverythingPrivate() throws InterruptedException { assertNotNull(event); try (CloseMe ignored = roleManager.withRoles(Arrays.asList(TESTER_ROLES))) { - List labels = LabelDAO.Value.find("dataset_id", event.datasetId).list(); + List labels = LabelDAO.Value.find("datasetId", event.datasetId).list(); assertEquals(1, labels.size()); } } diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java index 07839723f..d00bcd608 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java @@ -6,8 +6,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.api.alerting.Variable; diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/RunServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/RunServiceTest.java index 122c94c9d..c196bf787 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/RunServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/RunServiceTest.java @@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.StreamSupport; -import javax.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.HttpHeaders; import io.hyperfoil.tools.horreum.test.HorreumTestProfile; import io.hyperfoil.tools.horreum.api.data.*; @@ -423,14 +423,14 @@ public void testRecalculateDatasets() { List dsIds1 = recalculateDataset(ds.run.id); assertEquals(1, dsIds1.size()); try (CloseMe ignored = roleManager.withRoles(SYSTEM_ROLES)) { - List dataSets = DataSetDAO.find("runid", ds.run.id).list(); + List dataSets = DataSetDAO.find("run.id", ds.run.id).list(); assertEquals(1, dataSets.size()); assertEquals(dsIds1.get(0), dataSets.get(0).id); em.clear(); } List dsIds2 = recalculateDataset(ds.run.id); try (CloseMe ignored = roleManager.withRoles(SYSTEM_ROLES)) { - List dataSets = DataSetDAO.find("runid", ds.run.id).list(); + List dataSets = DataSetDAO.find("run.id", ds.run.id).list(); assertEquals(1, dataSets.size()); assertEquals(dsIds2.get(0), dataSets.get(0).id); } diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java index 23b93bf88..e13791b26 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TestServiceTest.java @@ -15,6 +15,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType; import io.hyperfoil.tools.horreum.test.HorreumTestProfile; import io.hyperfoil.tools.horreum.api.alerting.Watch; import io.hyperfoil.tools.horreum.api.data.*; @@ -23,11 +24,13 @@ import io.hyperfoil.tools.horreum.entity.alerting.*; import io.hyperfoil.tools.horreum.entity.data.*; import org.hibernate.query.NativeQuery; +import org.hibernate.type.CustomType; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.spi.TypeConfiguration; import org.junit.jupiter.api.TestInfo; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; import io.hyperfoil.tools.horreum.action.ExperimentResultToMarkdown; import io.hyperfoil.tools.horreum.api.services.ExperimentService; @@ -148,7 +151,7 @@ public void testUpdateView(TestInfo info) throws InterruptedException { @SuppressWarnings("unchecked") List list = em.createNativeQuery( "SELECT value FROM dataset_view WHERE dataset_id = ?1 AND view_id = ?2") .setParameter(1, event.dataset.id).setParameter(2, defaultView.id) - .unwrap(NativeQuery.class).addScalar("value", JsonNodeBinaryType.INSTANCE) + .unwrap(NativeQuery.class).addScalar("value", new CustomType<>(new JsonBinaryType(), new TypeConfiguration())) .getResultList(); return !list.isEmpty() && !list.get(0).isEmpty(); }); diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TokenAuthTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TokenAuthTest.java index 6fc79b980..2fc3a7ec6 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TokenAuthTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/TokenAuthTest.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; -import javax.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.HttpHeaders; import io.hyperfoil.tools.horreum.api.data.Access; import io.hyperfoil.tools.horreum.api.data.Test; diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/test/TestUtil.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/test/TestUtil.java index 44d06c984..ae01616f3 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/test/TestUtil.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/test/TestUtil.java @@ -7,8 +7,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; -import javax.persistence.EntityManager; -import javax.transaction.TransactionManager; +import jakarta.persistence.EntityManager; +import jakarta.transaction.TransactionManager; import org.jboss.logging.Logger; diff --git a/horreum-client/src/main/java/io/hyperfoil/tools/HorreumClient.java b/horreum-client/src/main/java/io/hyperfoil/tools/HorreumClient.java index 6867827da..21410f714 100644 --- a/horreum-client/src/main/java/io/hyperfoil/tools/HorreumClient.java +++ b/horreum-client/src/main/java/io/hyperfoil/tools/HorreumClient.java @@ -25,7 +25,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; -import javax.ws.rs.core.UriBuilder; +import jakarta.ws.rs.core.UriBuilder; import java.io.Closeable; import java.io.FileInputStream; diff --git a/horreum-client/src/main/java/io/hyperfoil/tools/RunServiceExtension.java b/horreum-client/src/main/java/io/hyperfoil/tools/RunServiceExtension.java index dce1faf9b..3356a2198 100644 --- a/horreum-client/src/main/java/io/hyperfoil/tools/RunServiceExtension.java +++ b/horreum-client/src/main/java/io/hyperfoil/tools/RunServiceExtension.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.stream.Stream; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.api.client.RunService; diff --git a/horreum-client/src/main/java/io/hyperfoil/tools/auth/KeycloakClientRequestFilter.java b/horreum-client/src/main/java/io/hyperfoil/tools/auth/KeycloakClientRequestFilter.java index 57fbc0450..0e77a88ff 100644 --- a/horreum-client/src/main/java/io/hyperfoil/tools/auth/KeycloakClientRequestFilter.java +++ b/horreum-client/src/main/java/io/hyperfoil/tools/auth/KeycloakClientRequestFilter.java @@ -9,10 +9,10 @@ import org.keycloak.admin.client.KeycloakBuilder; import javax.net.ssl.SSLContext; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientRequestFilter; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.client.ClientRequestContext; +import jakarta.ws.rs.client.ClientRequestFilter; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.Response; public class KeycloakClientRequestFilter implements ClientRequestFilter { diff --git a/horreum-client/src/main/java/io/hyperfoil/tools/horreum/api/client/RunService.java b/horreum-client/src/main/java/io/hyperfoil/tools/horreum/api/client/RunService.java index b8e2fa967..f8aeb352f 100644 --- a/horreum-client/src/main/java/io/hyperfoil/tools/horreum/api/client/RunService.java +++ b/horreum-client/src/main/java/io/hyperfoil/tools/horreum/api/client/RunService.java @@ -10,16 +10,16 @@ import io.hyperfoil.tools.horreum.api.services.RunService.RunSummary; import io.hyperfoil.tools.horreum.api.services.RunService.RunCount; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import java.util.List; import java.util.Map; diff --git a/horreum-integration-tests/src/test/java/io/hyperfoil/tools/horreum/it/HorreumClientIT.java b/horreum-integration-tests/src/test/java/io/hyperfoil/tools/horreum/it/HorreumClientIT.java index 4703bf787..7215a9f10 100644 --- a/horreum-integration-tests/src/test/java/io/hyperfoil/tools/horreum/it/HorreumClientIT.java +++ b/horreum-integration-tests/src/test/java/io/hyperfoil/tools/horreum/it/HorreumClientIT.java @@ -32,7 +32,7 @@ import io.quarkus.test.junit.callback.QuarkusTestMethodContext; import org.junit.jupiter.api.Assertions; -import javax.ws.rs.BadRequestException; +import jakarta.ws.rs.BadRequestException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; diff --git a/infra/horreum-dev-services/deployment/pom.xml b/infra/horreum-dev-services/deployment/pom.xml index 3368e7975..99d70d0a7 100644 --- a/infra/horreum-dev-services/deployment/pom.xml +++ b/infra/horreum-dev-services/deployment/pom.xml @@ -34,7 +34,7 @@ io.quarkus - quarkus-keycloak-admin-client-deployment + quarkus-keycloak-admin-client-reactive-deployment diff --git a/infra/horreum-dev-services/runtime/pom.xml b/infra/horreum-dev-services/runtime/pom.xml index 7d05e5366..600aff4ab 100644 --- a/infra/horreum-dev-services/runtime/pom.xml +++ b/infra/horreum-dev-services/runtime/pom.xml @@ -17,7 +17,7 @@ io.quarkus - quarkus-keycloak-admin-client + quarkus-keycloak-admin-client-reactive diff --git a/infra/horreum-infra-common/pom.xml b/infra/horreum-infra-common/pom.xml index f379873bf..84cee9c37 100644 --- a/infra/horreum-infra-common/pom.xml +++ b/infra/horreum-infra-common/pom.xml @@ -37,7 +37,7 @@ io.quarkus - quarkus-keycloak-admin-client + quarkus-keycloak-admin-client-reactive diff --git a/pom.xml b/pom.xml index f26b6c553..7e2652aef 100644 --- a/pom.xml +++ b/pom.xml @@ -74,14 +74,13 @@ UTF-8 UTF-8 - 3.6.1 22.3.0 - 2.16.9.Final - 1.2.9 + 3.2.3.Final + 2.0.3 3.0.0-M7 3.3.0 - 20.0.1 + 22.0.1 1.0.69 2.8.0 2.15.2 diff --git a/webapp/src/alerts.tsx b/webapp/src/alerts.tsx index 0a21e8f08..943ccb467 100644 --- a/webapp/src/alerts.tsx +++ b/webapp/src/alerts.tsx @@ -55,7 +55,7 @@ export const reducer = (state: Alert[] = [], action: AlertActions) => { } export const constraintValidationFormatter = (object: any) => (e: any) => { - if (e && e.error && e.error === "javax.validation.ConstraintViolationException") { + if (e && e.error && e.error === "jakarta.validation.ConstraintViolationException") { return ( <> Some constraints on {object} have failed: