From 9efe7fcd77ccdc32af81066b76402fb53457cde7 Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Tue, 9 Jul 2024 10:45:23 +0200 Subject: [PATCH] Inject table name for logs (fixes #96) --- .../autoconfigure/UiApiAutoConfiguration.java | 6 ++++-- .../no/bekk/dbscheduler/ui/model/TaskModel.java | 2 ++ .../no/bekk/dbscheduler/ui/service/LogLogic.java | 13 ++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/autoconfigure/UiApiAutoConfiguration.java b/db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/autoconfigure/UiApiAutoConfiguration.java index ff9f8ec..ecf6e41 100644 --- a/db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/autoconfigure/UiApiAutoConfiguration.java +++ b/db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/autoconfigure/UiApiAutoConfiguration.java @@ -76,12 +76,14 @@ LogLogic logLogic( DataSource dataSource, Caching caching, DbSchedulerCustomizer customizer, - DbSchedulerUiProperties properties) { + DbSchedulerUiProperties properties, + @Value("${db-scheduler-log.table-name:scheduled_execution_logs}") String logTableName) { return new LogLogic( dataSource, customizer.serializer().orElse(Serializer.DEFAULT_JAVA_SERIALIZER), caching, - properties.isTaskData()); + properties.isTaskData(), + logTableName); } @Bean diff --git a/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskModel.java b/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskModel.java index 4c669cb..e4ce270 100644 --- a/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskModel.java +++ b/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskModel.java @@ -17,10 +17,12 @@ import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter +@NoArgsConstructor @AllArgsConstructor public class TaskModel { diff --git a/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/service/LogLogic.java b/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/service/LogLogic.java index 1d05eaa..5caf831 100644 --- a/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/service/LogLogic.java +++ b/db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/service/LogLogic.java @@ -42,12 +42,19 @@ public class LogLogic { private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; private final Caching caching; private final LogModelRowMapper logModelRowMapper; - - public LogLogic(DataSource dataSource, Serializer serializer, Caching caching, boolean showData) { + private final String logTableName; + + public LogLogic( + DataSource dataSource, + Serializer serializer, + Caching caching, + boolean showData, + String logTableName) { this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); // currently we have no paging in the UI this.namedParameterJdbcTemplate.getJdbcTemplate().setMaxRows(DEFAULT_LIMIT); this.caching = caching; + this.logTableName = logTableName; this.logModelRowMapper = new LogModelRowMapper( showData, serializer == null ? Serializer.DEFAULT_JAVA_SERIALIZER : serializer); @@ -79,7 +86,7 @@ public LogPollResponse pollLogs(TaskDetailsRequestParams requestParams) { } public List getLogsDirectlyFromDB(TaskDetailsRequestParams requestParams) { - QueryBuilder queryBuilder = QueryBuilder.selectFromTable("scheduled_execution_logs"); + QueryBuilder queryBuilder = QueryBuilder.selectFromTable(logTableName); if (requestParams.getStartTime() != null) { queryBuilder.andCondition( new TimeCondition(