From 658692f66e7980ec7247329440aecbe27b0e62f1 Mon Sep 17 00:00:00 2001 From: ppel Date: Tue, 18 Jun 2024 09:53:43 +0200 Subject: [PATCH] 434618 - Added count for datasets (federated catalog) --- .../controller/CountElementsApiController.java | 3 ++- .../sql/index/schema/BaseSqlDialectStatements.java | 3 +++ .../sql/index/schema/CountElementsStatements.java | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/extensions/count-elements-api/src/main/java/org/upm/inesdata/countelements/controller/CountElementsApiController.java b/extensions/count-elements-api/src/main/java/org/upm/inesdata/countelements/controller/CountElementsApiController.java index cd68ae8..5c3e4b6 100644 --- a/extensions/count-elements-api/src/main/java/org/upm/inesdata/countelements/controller/CountElementsApiController.java +++ b/extensions/count-elements-api/src/main/java/org/upm/inesdata/countelements/controller/CountElementsApiController.java @@ -30,7 +30,8 @@ public long countElements(@QueryParam("type") String entityType) { if (!Objects.equals(entityType, "asset") && !Objects.equals(entityType, "policyDefinition") && !Objects.equals(entityType, "contractDefinition") && !Objects.equals(entityType, "contractAgreement") - && !Objects.equals(entityType, "transferProcess")) { + && !Objects.equals(entityType, "transferProcess") + && !Objects.equals(entityType, "federatedCatalog")) { throw new BadRequestException("Entity type provided is not valid"); } diff --git a/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/BaseSqlDialectStatements.java b/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/BaseSqlDialectStatements.java index d83e2df..cedb579 100644 --- a/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/BaseSqlDialectStatements.java +++ b/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/BaseSqlDialectStatements.java @@ -34,6 +34,9 @@ public String getCount(String entityType) { case "transferProcess": tableName = getTransferProcessTable(); break; + case "federatedCatalog": + tableName = getDatasetTable(); + break; } return format("SELECT COUNT(*) FROM %s", tableName); diff --git a/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/CountElementsStatements.java b/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/CountElementsStatements.java index 3372676..3bec855 100644 --- a/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/CountElementsStatements.java +++ b/extensions/count-elements-sql/src/main/java/org/upm/inesdata/countelements/sql/index/schema/CountElementsStatements.java @@ -38,12 +38,19 @@ default String getContractDefinitionTable() { } /** - * The vocabulary table name. + * The transfer process table name. */ default String getTransferProcessTable() { return "edc_transfer_process"; } + /** + * The dataset table name. + */ + default String getDatasetTable() { + return "edc_dataset"; + } + /** * SELECT COUNT clause. */