From a14343163494d328c4b1648ba2af1be69d6f612e Mon Sep 17 00:00:00 2001 From: Yoni Weisberg Date: Mon, 28 Oct 2024 16:38:19 +0200 Subject: [PATCH] applying spotless fixes --- .../impl/sql/AbstractSqlRegistryStorage.java | 10 +++------- .../storage/impl/sql/CommonSqlStatements.java | 19 ++++++++++++------- .../storage/impl/sql/MySQLSqlStatements.java | 6 ++++-- .../impl/sql/SQLServerSqlStatements.java | 7 ++++--- .../storage/impl/sql/SqlStatements.java | 3 ++- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java index 1d24657631..6aa0a57f01 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java @@ -1076,7 +1076,6 @@ public ArtifactSearchResultsDto searchArtifacts(Set filters, Order } orderByQuery.append(" ").append(orderDirection.name()); - // Query for the artifacts String artifactsQuerySql = sqlStatements.selectTableTemplate("a.*", "artifacts", "a", where.toString(), orderByQuery.toString()); @@ -2793,7 +2792,6 @@ public GroupSearchResultsDto searchGroups(Set filters, OrderBy ord List binders = new LinkedList<>(); String op; - StringBuilder where = new StringBuilder(); StringBuilder orderByQuery = new StringBuilder(); @@ -2858,14 +2856,13 @@ public GroupSearchResultsDto searchGroups(Set filters, OrderBy ord } orderByQuery.append(" ").append(orderDirection.name()); - // Query for the group - String groupsQuerySql = sqlStatements.selectTableTemplate("*", "groups", "g", - where.toString(), orderByQuery.toString()); + String groupsQuerySql = sqlStatements.selectTableTemplate("*", "groups", "g", where.toString(), + orderByQuery.toString()); Query groupsQuery = handle.createQuery(groupsQuerySql); // Query for the total row count String countQuerySql = sqlStatements.selectCountTableTemplate("g.groupId", "groups", "g", - where.toString()); + where.toString()); Query countQuery = handle.createQuery(countQuerySql); // Bind all query parameters @@ -3388,7 +3385,6 @@ public BranchSearchResultsDto getBranches(GA ga, int offset, int limit) { // Add order by to artifact query orderByQuery.append(" ORDER BY b.branchId ASC"); - // Query for the artifacts String branchesQuerySql = sqlStatements.selectTableTemplate("*", "branches", "b", where.toString(), orderByQuery.toString()); diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java index c03f1289b5..fbc791c6ef 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java @@ -669,7 +669,8 @@ public String insertContentReference() { */ @Override public String insertGroup() { - return "INSERT INTO " + groupsTable() + " (groupId, description, artifactsType, owner, createdOn, modifiedBy, modifiedOn, labels) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + return "INSERT INTO " + groupsTable() + + " (groupId, description, artifactsType, owner, createdOn, modifiedBy, modifiedOn, labels) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; } /** @@ -677,7 +678,8 @@ public String insertGroup() { */ @Override public String updateGroup() { - return "UPDATE " + groupsTable() + " SET description = ? , modifiedBy = ? , modifiedOn = ? , labels = ? WHERE groupId = ?"; + return "UPDATE " + groupsTable() + + " SET description = ? , modifiedBy = ? , modifiedOn = ? , labels = ? WHERE groupId = ?"; } /** @@ -818,7 +820,8 @@ public String importGlobalRule() { */ @Override public String importGroup() { - return "INSERT INTO " + groupsTable() + " (groupId, description, artifactsType, owner, createdOn, modifiedBy, modifiedOn, labels) " + return "INSERT INTO " + groupsTable() + + " (groupId, description, artifactsType, owner, createdOn, modifiedBy, modifiedOn, labels) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; } @@ -1212,16 +1215,18 @@ public String deleteOutboxEvent() { } @Override - public String selectCountTableTemplate(String countBy, String tableName, String alias, String whereClause) { + public String selectCountTableTemplate(String countBy, String tableName, String alias, + String whereClause) { return "SELECT COUNT(%s) FROM %s %s %s".formatted(countBy, tableName, alias, whereClause); } @Override - public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, String orderBy) { - return "SELECT %s FROM %s %s %s %s LIMIT ? OFFSET ?".formatted(columns, tableName, alias, whereClause, orderBy); + public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, + String orderBy) { + return "SELECT %s FROM %s %s %s %s LIMIT ? OFFSET ?".formatted(columns, tableName, alias, whereClause, + orderBy); } - protected String groupsTable() { return "groups"; } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/MySQLSqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/MySQLSqlStatements.java index 87170bbb6c..2ce9b9912e 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/MySQLSqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/MySQLSqlStatements.java @@ -70,12 +70,14 @@ INSERT INTO branches (groupId, artifactId, branchId, description, systemDefined, } @Override - public String selectCountTableTemplate(String countBy, String tableName, String alias, String whereClause) { + public String selectCountTableTemplate(String countBy, String tableName, String alias, + String whereClause) { return super.selectCountTableTemplate(countBy, "`" + tableName + "`", alias, whereClause); } @Override - public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, String orderBy) { + public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, + String orderBy) { return super.selectTableTemplate(columns, "`" + tableName + "`", alias, whereClause, orderBy); } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SQLServerSqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SQLServerSqlStatements.java index 4985233d67..27c22c0a75 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SQLServerSqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SQLServerSqlStatements.java @@ -126,9 +126,10 @@ public String selectBranchTipFilteredByState() { } @Override - public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, String orderBy) { - return "SELECT %s FROM %s %s %s %s OFFSET ? ROWS FETCH NEXT ? ROWS ONLY" - .formatted(columns, tableName, alias, whereClause, orderBy); + public String selectTableTemplate(String columns, String tableName, String alias, String whereClause, + String orderBy) { + return "SELECT %s FROM %s %s %s %s OFFSET ? ROWS FETCH NEXT ? ROWS ONLY".formatted(columns, tableName, + alias, whereClause, orderBy); } @Override diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java index c8faf84e96..f16cae7b84 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java @@ -654,5 +654,6 @@ public interface SqlStatements { String selectCountTableTemplate(String countBy, String tableName, String alias, String whereClause); - String selectTableTemplate(String columns, String tableName, String alias, String whereClause, String orderBy); + String selectTableTemplate(String columns, String tableName, String alias, String whereClause, + String orderBy); }