From 35e8763015148b77f7bbf596c441c5afd969f536 Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Mon, 31 Mar 2025 19:26:52 +0000 Subject: [PATCH] Finished work --- .docs/changelog.md | 7 +- .../target/create-event-listener.jar | Bin 10141 -> 10141 bytes .../at/tuwien/endpoints/SubsetEndpoint.java | 4 +- .../at/tuwien/endpoints/ViewEndpoint.java | 11 +-- .../tuwien/endpoint/ViewEndpointUnitTest.java | 2 +- .../service/SubsetServiceIntegrationTest.java | 7 +- .../java/at/tuwien/mapper/MariaDbMapper.java | 52 +++++++++--- .../java/at/tuwien/service/SubsetService.java | 2 +- .../impl/SubsetServiceMariaDbImpl.java | 2 +- dbrepo-ui/components/subset/Builder.vue | 74 +++++++++++++----- dbrepo-ui/dto/index.ts | 3 +- dbrepo-ui/locales/en-US.json | 2 +- helm/dbrepo/files/create-event-listener.jar | Bin 10141 -> 10141 bytes .../api/database/query/DatasourceType.java | 25 ++++++ .../database/query/ExecuteStatementDto.java | 22 ------ .../core/api/database/query/ExportDto.java | 21 ----- .../core/api/database/query/SubsetDto.java | 8 +- .../tuwien/ifs/dbrepo/core/test/BaseTest.java | 15 ++-- 18 files changed, 157 insertions(+), 100 deletions(-) create mode 100644 lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/DatasourceType.java delete mode 100644 lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExecuteStatementDto.java delete mode 100644 lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExportDto.java diff --git a/.docs/changelog.md b/.docs/changelog.md index af778b5ec5..7dbd4f1bb7 100644 --- a/.docs/changelog.md +++ b/.docs/changelog.md @@ -6,13 +6,16 @@ author: Martin Weise #### Features -* Fixed a bug where validation of missing `Principal` object in Java services caused a 400 error instead of a 401 error - in [#512](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/512). * Refactored internal Java-based testing data that improves test consistency in [#510](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/510). * Added automated dashboard generation for all public databases where each view has an overview of its data and schema in [#460](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/460). +#### Fixes + +* Fixed a bug where validation of missing `Principal` object in Java services caused a 400 error instead of a 401 error + in [#512](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/512). + ## v1.7.3 (2025-03-17) [:simple-gitlab: GitLab Release](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tags/v1.7.3) diff --git a/dbrepo-auth-service/listeners/target/create-event-listener.jar b/dbrepo-auth-service/listeners/target/create-event-listener.jar index b06b36948412531f7600be5319d91696faf23810..c45fcf9fa8e58ddb816cd6f9afb13cfd470c001b 100644 GIT binary patch delta 227 zcmbR1Ki8ipz?+#xgn@yBgMp=XBhO++CYIXC8yQuZm}@8BVAKQgIGE%?lqQoJhzexV z22piPrXXr7lQ&2u6Z1I`b&0u$iKTXP0?S+`5dEKxhZ98e3e*aM6!$3322q+yQ$W;y zB?l12sB8+-YN2cg;#DZ?gQ%6tW+3XJvNed3Q*i}RsVdPRm4{S9K$L`P9!Ri5H4a3* VP;~-PI%>N?)JwHY5EY{C2>?3eJ|+MF delta 227 zcmbR1Ki8ipz?+#xgn@yBgCR6;BhO++rqH~}8yQtW)D1>G5XHeH527@g)Id}qlQxK| zV=@I%TbaB;6ch6~5Os;Uhbc5~a{|j;CJ_CfjfWFN^9s}of~0#CXM-qBr70k4zmfxp zVpIkjWT9*a;#DZ?gQ%6tW+3XJvNed3Q*i}RsVdPR>X1qZh>}pv15q8SaUkl2suPIP QQQHloUaDn+s1S8e0Ejn5=l}o! diff --git a/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/SubsetEndpoint.java b/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/SubsetEndpoint.java index 2a7add8ff4..28e7b2ca9c 100644 --- a/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/SubsetEndpoint.java +++ b/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/SubsetEndpoint.java @@ -254,8 +254,8 @@ public class SubsetEndpoint extends RestEndpoint { QueryStoreInsertException, TableMalformedException, PaginationException, QueryNotSupportedException, NotAllowedException, UserNotFoundException, MetadataServiceException, TableNotFoundException, ViewMalformedException, ViewNotFoundException, ImageNotFoundException, FormatNotAvailableException { - log.debug("endpoint create subset in database, databaseId={}, page={}, size={}, timestamp={}", databaseId, - page, size, timestamp); + log.debug("endpoint create subset in database, databaseId={}, page={}, size={}, timestamp={}, data.datasource_id={}", + databaseId, page, size, timestamp, data.getDatasourceId()); /* check */ endpointValidator.validateDataParams(page, size); endpointValidator.validateSubsetParams(data); diff --git a/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/ViewEndpoint.java b/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/ViewEndpoint.java index 245ca0ca26..73d88f0bef 100644 --- a/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/ViewEndpoint.java +++ b/dbrepo-data-service/rest-service/src/main/java/at/tuwien/endpoints/ViewEndpoint.java @@ -49,7 +49,6 @@ public class ViewEndpoint extends RestEndpoint { private final DSLContext context; private final ViewService viewService; private final CacheService cacheService; - private final TableService tableService; private final MariaDbMapper mariaDbMapper; private final SubsetService subsetService; private final StorageService storageService; @@ -58,13 +57,11 @@ public class ViewEndpoint extends RestEndpoint { @Autowired public ViewEndpoint(DSLContext context, ViewService viewService, CacheService cacheService, - TableService tableService, MariaDbMapper mariaDbMapper, SubsetService subsetService, - StorageService storageService, DatabaseService databaseService, - EndpointValidator endpointValidator) { + MariaDbMapper mariaDbMapper, SubsetService subsetService, StorageService storageService, + DatabaseService databaseService, EndpointValidator endpointValidator) { this.context = context; this.viewService = viewService; this.cacheService = cacheService; - this.tableService = tableService; this.mariaDbMapper = mariaDbMapper; this.subsetService = subsetService; this.storageService = storageService; @@ -139,7 +136,7 @@ public class ViewEndpoint extends RestEndpoint { mediaType = "application/json", schema = @Schema(implementation = ApiErrorDto.class))}), @ApiResponse(responseCode = "404", - description = "Failed to find database in metadata database", + description = "Failed to find database (or table or view) in metadata database", content = {@Content( mediaType = "application/json", schema = @Schema(implementation = ApiErrorDto.class))}), @@ -157,7 +154,7 @@ public class ViewEndpoint extends RestEndpoint { public ResponseEntity<ViewDto> create(@NotNull @PathVariable("databaseId") UUID databaseId, @Valid @RequestBody CreateViewDto data) throws DatabaseUnavailableException, DatabaseNotFoundException, RemoteUnavailableException, ViewMalformedException, MetadataServiceException, - TableNotFoundException, ImageNotFoundException, QueryMalformedException { + TableNotFoundException, ImageNotFoundException, QueryMalformedException, ViewNotFoundException { log.debug("endpoint create view, databaseId={}, data.name={}", databaseId, data.getName()); /* check */ endpointValidator.validateSubsetParams(data.getQuery()); diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/ViewEndpointUnitTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/ViewEndpointUnitTest.java index dfed71fbbb..b4215747e3 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/ViewEndpointUnitTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/ViewEndpointUnitTest.java @@ -63,7 +63,7 @@ public class ViewEndpointUnitTest extends BaseTest { @WithMockUser(username = USER_LOCAL_ADMIN_USERNAME, authorities = {"system"}) public void create_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, ViewMalformedException, SQLException, DatabaseUnavailableException, MetadataServiceException, TableNotFoundException, - ImageNotFoundException, QueryMalformedException { + ImageNotFoundException, QueryMalformedException, ViewNotFoundException { /* mock */ when(credentialService.getDatabase(DATABASE_1_ID, true)) diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SubsetServiceIntegrationTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SubsetServiceIntegrationTest.java index a3b0561bcc..f6bd02059b 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SubsetServiceIntegrationTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SubsetServiceIntegrationTest.java @@ -241,7 +241,7 @@ public class SubsetServiceIntegrationTest extends BaseTest { @Test public void create_succeeds() throws SQLException, QueryStoreInsertException, ViewMalformedException, - TableNotFoundException, QueryMalformedException, ImageNotFoundException { + TableNotFoundException, QueryMalformedException, ImageNotFoundException, ViewNotFoundException { /* test */ final UUID response = subsetService.create(DATABASE_1_PRIVILEGED_DTO, QUERY_1_SUBSET_DTO, QUERY_1_CREATED, USER_1_ID); @@ -252,9 +252,10 @@ public class SubsetServiceIntegrationTest extends BaseTest { @MethodSource("create_arguments") public void create_illegalQuery_succeeds(String name, String injection) throws TableNotFoundException, QueryStoreInsertException, ViewMalformedException, SQLException, QueryMalformedException, - ImageNotFoundException { + ImageNotFoundException, ViewNotFoundException { final SubsetDto request = SubsetDto.builder() - .tableId(TABLE_1_ID) + .datasourceId(TABLE_1_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<>(List.of(COLUMN_1_1_ID, COLUMN_1_2_ID, COLUMN_1_3_ID, COLUMN_1_4_ID, COLUMN_1_5_ID))) .filter(new LinkedList<>(List.of(FilterDto.builder() .type(FilterTypeDto.WHERE) diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/MariaDbMapper.java b/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/MariaDbMapper.java index 4861a7a1d7..7a0a094e16 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/MariaDbMapper.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/MariaDbMapper.java @@ -2,6 +2,7 @@ package at.tuwien.mapper; import at.ac.tuwien.ifs.dbrepo.core.api.container.image.OperatorDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.DatabaseDto; +import at.ac.tuwien.ifs.dbrepo.core.api.database.ViewDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.query.FilterDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.query.FilterTypeDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.query.OrderDto; @@ -13,13 +14,10 @@ import at.ac.tuwien.ifs.dbrepo.core.api.database.table.TupleUpdateDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.table.columns.ColumnDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.table.columns.ColumnTypeDto; import at.ac.tuwien.ifs.dbrepo.core.api.database.table.columns.CreateTableColumnDto; -import at.ac.tuwien.ifs.dbrepo.core.exception.ImageNotFoundException; -import at.ac.tuwien.ifs.dbrepo.core.exception.QueryMalformedException; -import at.ac.tuwien.ifs.dbrepo.core.exception.TableMalformedException; -import at.ac.tuwien.ifs.dbrepo.core.exception.TableNotFoundException; +import at.ac.tuwien.ifs.dbrepo.core.exception.*; import at.tuwien.utils.MariaDbUtil; -import org.jooq.Record; import org.jooq.*; +import org.jooq.Record; import org.jooq.conf.ParamType; import org.mapstruct.Mapper; import org.mapstruct.Named; @@ -895,15 +893,30 @@ public interface MariaDbMapper { } default String subsetDtoToRawQuery(DSLContext context, DatabaseDto database, SubsetDto data) - throws TableNotFoundException, ImageNotFoundException { - final TableDto table = tableIdToTableDto(database, data.getTableId()); - final List<Field<Object>> columns = table.getColumns() - .stream() - .filter(c -> data.getColumns().contains(c.getId())) - .map(c -> field(name(c.getInternalName()))) - .toList(); + throws TableNotFoundException, ImageNotFoundException, ViewNotFoundException { + final String datasourceName; + final List<Field<Object>> columns = switch (data.getDatasourceType()) { + case TABLE -> { + final TableDto table = tableIdToTableDto(database, data.getDatasourceId()); + datasourceName = table.getInternalName(); + yield table.getColumns() + .stream() + .filter(c -> data.getColumns().contains(c.getId())) + .map(c -> field(name(c.getInternalName()))) + .toList(); + } + case VIEW -> { + final ViewDto view = viewIdToViewDto(database, data.getDatasourceId()); + datasourceName = view.getInternalName(); + yield view.getColumns() + .stream() + .filter(c -> data.getColumns().contains(c.getId())) + .map(c -> field(name(c.getInternalName()))) + .toList(); + } + }; final SelectJoinStep<Record> query = context.select(columns) - .from(name(table.getInternalName())); + .from(name(datasourceName)); final SelectConditionStep<Record> where = subsetDtoToSelectConditions(query, database, data); final String sql; if (data.getOrder() == null) { @@ -972,4 +985,17 @@ public interface MariaDbMapper { return optional.get(); } + default ViewDto viewIdToViewDto(DatabaseDto database, UUID viewId) throws ViewNotFoundException { + final Optional<ViewDto> optional = database.getViews() + .stream() + .filter(v -> v.getId().equals(viewId)) + .findFirst(); + if (optional.isEmpty()) { + log.error("Failed to find view with id: {}", viewId); + log.trace("known view ids: {}", database.getViews().stream().map(ViewDto::getId).collect(Collectors.toList())); + throw new ViewNotFoundException("Failed to find view id: " + viewId); + } + return optional.get(); + } + } diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/service/SubsetService.java b/dbrepo-data-service/services/src/main/java/at/tuwien/service/SubsetService.java index 30f6c2604f..b57c2b3f10 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/service/SubsetService.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/service/SubsetService.java @@ -26,7 +26,7 @@ public interface SubsetService { * @throws SQLException The connection to the database could not be established. */ UUID create(DatabaseDto database, SubsetDto subset, Instant timestamp, UUID userId) - throws QueryStoreInsertException, SQLException, QueryMalformedException, TableNotFoundException, ImageNotFoundException, ViewMalformedException; + throws QueryStoreInsertException, SQLException, QueryMalformedException, TableNotFoundException, ImageNotFoundException, ViewMalformedException, ViewNotFoundException; /** * Counts the subset row count of a query of a given subset in the given database. diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/service/impl/SubsetServiceMariaDbImpl.java b/dbrepo-data-service/services/src/main/java/at/tuwien/service/impl/SubsetServiceMariaDbImpl.java index 7ace8e4a05..1b9757659f 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/service/impl/SubsetServiceMariaDbImpl.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/service/impl/SubsetServiceMariaDbImpl.java @@ -70,7 +70,7 @@ public class SubsetServiceMariaDbImpl extends DataConnector implements SubsetSer @Override public UUID create(DatabaseDto database, SubsetDto subset, Instant timestamp, UUID userId) throws QueryStoreInsertException, SQLException, QueryMalformedException, TableNotFoundException, - ImageNotFoundException, ViewMalformedException { + ImageNotFoundException, ViewMalformedException, ViewNotFoundException { final String statement = mariaDbMapper.subsetDtoToRawQuery(context, database, subset); return storeQuery(database, statement, timestamp, userId); } diff --git a/dbrepo-ui/components/subset/Builder.vue b/dbrepo-ui/components/subset/Builder.vue index 52fff4c4df..4e4fe21eec 100644 --- a/dbrepo-ui/components/subset/Builder.vue +++ b/dbrepo-ui/components/subset/Builder.vue @@ -91,9 +91,9 @@ <v-col lg="4"> <v-select - v-model="table" + v-model="datasource" :disabled="isExecuted" - :items="tables" + :items="datasources" item-title="name" return-object persistent-hint @@ -108,7 +108,7 @@ <v-select v-model="select" item-title="internal_name" - :disabled="!table || isExecuted" + :disabled="!datasource || isExecuted" :items="columns" :rules="[v => !!v || $t('validation.required')]" required @@ -375,7 +375,7 @@ export default { }, data () { return { - table: null, + datasource: null, views: [], columns: [], sorts: [], @@ -393,7 +393,8 @@ export default { resultId: null, errorKeyword: null, query: { - table_id: null, + datasource_id: null, + datasource_type: null, columns: [], filter: null }, @@ -424,11 +425,14 @@ export default { } return this.database.container.image.operators }, - tables () { + datasources () { if (!this.database) { return [] } - return this.database.tables + if (this.isView) { + return this.database.tables + } + return this.database.views }, database () { return this.cacheStore.getDatabase @@ -467,11 +471,12 @@ export default { return this.$config.public.database.unsupported.split(',') }, subset () { - if (!this.table || !this.select) { + if (!this.datasource || !this.select) { return null } return { - table_id: this.table.id, + datasource_id: this.datasource.id, + datasource_type: this.isView ? 'table' : 'view', columns: this.select.map(column => column.id), filter: this.clauses ? this.clauses.map(clause => { if (clause.type === 'or' || clause.type === 'and') { @@ -479,7 +484,7 @@ export default { type: clause.type } } - const filtered_column = this.table.columns.filter(column => column.internal_name === clause.params[0]) + const filtered_column = this.datasource.columns.filter(column => column.internal_name === clause.params[0]) const filtered_operator = this.database.container.image.operators.filter(operator => operator.value === clause.params[1]) if (!filtered_column || filtered_column.length === 0 || !filtered_operator || filtered_operator.length === 0) { return null @@ -514,16 +519,21 @@ export default { } }, watch: { - table () { + datasource () { this.select = [] - if (!this.table) { + if (!this.datasource) { + return + } + if (!this.isView) { + this.fetchViewColumns(this.datasource?.id) return } - this.fetchTableColumns(this.table?.id) + this.fetchTableColumns(this.datasource?.id) } }, mounted () { this.selectTable() + this.selectView() this.initViewVisibility() }, methods: { @@ -544,6 +554,23 @@ export default { toast.error(this.$t(code)) }) }, + fetchViewColumns (viewId) { + this.loadingColumns = true + const viewService = useViewService() + viewService.findOne(this.$route.params.database_id, viewId) + .then((view) => { + this.columns = view.columns + this.loadingColumns = false + }) + .catch(({code}) => { + this.loadingColumns = false + const toast = useToastInstance() + if (typeof code !== 'string') { + return + } + toast.error(this.$t(code)) + }) + }, initViewVisibility () { if (!this.database) { return @@ -564,13 +591,24 @@ export default { } const tid = this.$route.query.tid const selection = this.tables.filter(t => t.id === tid) - if (selection.length > 0) { - this.table = selection[0] - console.info('Preselect table with id', tid) - console.debug('preselected table', this.table) - } else { + if (selection.length === 0) { console.warn('Failed to find table with id', tid) + return + } + this.datasource = selection[0] + console.info('Preselect table with id', tid) + }, + selectView () { + if (this.$route.query.vid === undefined) { + return + } + const vid = this.$route.query.vid + const selection = this.views.filter(v => v.id === vid) + if (selection.length === 0) { + console.warn('Failed to find view with id', vid) } + this.datasource = selection[0] + console.info('Preselect view with id', vid) }, execute () { if (this.isView) { diff --git a/dbrepo-ui/dto/index.ts b/dbrepo-ui/dto/index.ts index 3c21ce5abe..e05e0fc4d4 100644 --- a/dbrepo-ui/dto/index.ts +++ b/dbrepo-ui/dto/index.ts @@ -614,7 +614,8 @@ interface OrderDto { } interface SubsetDto { - table_id: string; + datasource_id: string; + datasource_type: string; columns: string[]; filter: FilterDto[] | null; order: OrderDto[] | null; diff --git a/dbrepo-ui/locales/en-US.json b/dbrepo-ui/locales/en-US.json index ddbef88b97..242f48a5db 100644 --- a/dbrepo-ui/locales/en-US.json +++ b/dbrepo-ui/locales/en-US.json @@ -954,7 +954,7 @@ "hint": "Required" }, "table": { - "label": "Data Table", + "label": "Datasource", "hint": "Required" }, "columns": { diff --git a/helm/dbrepo/files/create-event-listener.jar b/helm/dbrepo/files/create-event-listener.jar index b06b36948412531f7600be5319d91696faf23810..c45fcf9fa8e58ddb816cd6f9afb13cfd470c001b 100644 GIT binary patch delta 227 zcmbR1Ki8ipz?+#xgn@yBgMp=XBhO++CYIXC8yQuZm}@8BVAKQgIGE%?lqQoJhzexV z22piPrXXr7lQ&2u6Z1I`b&0u$iKTXP0?S+`5dEKxhZ98e3e*aM6!$3322q+yQ$W;y zB?l12sB8+-YN2cg;#DZ?gQ%6tW+3XJvNed3Q*i}RsVdPRm4{S9K$L`P9!Ri5H4a3* VP;~-PI%>N?)JwHY5EY{C2>?3eJ|+MF delta 227 zcmbR1Ki8ipz?+#xgn@yBgCR6;BhO++rqH~}8yQtW)D1>G5XHeH527@g)Id}qlQxK| zV=@I%TbaB;6ch6~5Os;Uhbc5~a{|j;CJ_CfjfWFN^9s}of~0#CXM-qBr70k4zmfxp zVpIkjWT9*a;#DZ?gQ%6tW+3XJvNed3Q*i}RsVdPR>X1qZh>}pv15q8SaUkl2suPIP QQQHloUaDn+s1S8e0Ejn5=l}o! diff --git a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/DatasourceType.java b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/DatasourceType.java new file mode 100644 index 0000000000..a4f8a83d80 --- /dev/null +++ b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/DatasourceType.java @@ -0,0 +1,25 @@ +package at.ac.tuwien.ifs.dbrepo.core.api.database.query; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public enum DatasourceType { + + @JsonProperty("table") + TABLE("table"), + + @JsonProperty("view") + VIEW("view"); + + private final String name; + + DatasourceType(String name) { + this.name = name; + } + + @Override + public String toString() { + return this.name; + } +} diff --git a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExecuteStatementDto.java b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExecuteStatementDto.java deleted file mode 100644 index 6973486230..0000000000 --- a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExecuteStatementDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package at.ac.tuwien.ifs.dbrepo.core.api.database.query; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.NotBlank; -import lombok.extern.jackson.Jacksonized; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Jacksonized -@ToString -public class ExecuteStatementDto { - - @NotBlank - @Schema(example = "SELECT `id` FROM `air_quality`") - private String statement; - -} diff --git a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExportDto.java b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExportDto.java deleted file mode 100644 index 35f4fff473..0000000000 --- a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/ExportDto.java +++ /dev/null @@ -1,21 +0,0 @@ -package at.ac.tuwien.ifs.dbrepo.core.api.database.query; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.*; -import lombok.extern.jackson.Jacksonized; - -@Getter -@Setter -@Builder -@EqualsAndHashCode -@NoArgsConstructor -@AllArgsConstructor -@Jacksonized -@ToString -public class ExportDto { - - @NotBlank - @Schema(example = "/tmp/file.csv") - private String location; -} diff --git a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/SubsetDto.java b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/SubsetDto.java index 0b5975e05d..5fb53d0741 100644 --- a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/SubsetDto.java +++ b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/api/database/query/SubsetDto.java @@ -20,9 +20,13 @@ import java.util.UUID; public class SubsetDto { @NotNull - @JsonProperty("table_id") + @JsonProperty("datasource_id") @Schema(example = "f7df2a7d-4ade-4c78-97b0-7c744d0893c7") - private UUID tableId; + private UUID datasourceId; + + @NotNull + @JsonProperty("datasource_type") + private DatasourceType datasourceType; @NotNull @Schema(example = "[\"e891ba86-0258-41a6-a8d9-ff58bc10b618\"]") diff --git a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/test/BaseTest.java b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/test/BaseTest.java index d2f622fbd1..5209b40ce4 100644 --- a/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/test/BaseTest.java +++ b/lib/java/dbrepo-core/src/main/java/at/ac/tuwien/ifs/dbrepo/core/test/BaseTest.java @@ -2587,7 +2587,8 @@ public class BaseTest { .build(); public final SubsetDto QUERY_9_SUBSET_DTO = SubsetDto.builder() - .tableId(TABLE_9_ID) + .datasourceId(TABLE_9_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<>(List.of(COLUMN_9_2_ID, COLUMN_9_3_ID))) .filter(new LinkedList<>(List.of(FilterDto.builder() .columnId(COLUMN_9_1_ID) @@ -2895,7 +2896,8 @@ public class BaseTest { public final static Boolean QUERY_1_PERSISTED = true; public final SubsetDto QUERY_1_SUBSET_DTO = SubsetDto.builder() - .tableId(TABLE_1_ID) + .datasourceId(TABLE_1_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<UUID>(List.of(COLUMN_1_1_ID, COLUMN_1_2_ID, COLUMN_1_3_ID, COLUMN_1_4_ID, COLUMN_1_5_ID))) .order(new LinkedList<OrderDto>(List.of(OrderDto.builder() .columnId(COLUMN_1_1_ID) @@ -3022,7 +3024,8 @@ public class BaseTest { .build(); public final SubsetDto QUERY_5_SUBSET_DTO = SubsetDto.builder() - .tableId(TABLE_8_ID) + .datasourceId(TABLE_8_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<>(List.of(COLUMN_8_1_ID, COLUMN_8_2_ID))) .filter(new LinkedList<>(List.of(FilterDto.builder() .columnId(COLUMN_8_2_ID) @@ -4598,7 +4601,8 @@ public class BaseTest { public final static Boolean QUERY_8_PERSISTED = true; public final SubsetDto QUERY_8_SUBSET_DTO = SubsetDto.builder() - .tableId(TABLE_5_ID) + .datasourceId(TABLE_5_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<>(List.of(COLUMN_5_1_ID, COLUMN_5_2_ID))) .filter(new LinkedList<>(List.of(FilterDto.builder() .type(FilterTypeDto.WHERE) @@ -4845,7 +4849,8 @@ public class BaseTest { public final static UUID VIEW_COLUMN_1_3_ID = UUID.fromString("4f189a5f-c9ca-4518-9758-1a0730f6276b"); public final SubsetDto VIEW_1_SUBSET_DTO = SubsetDto.builder() - .tableId(TABLE_2_ID) + .datasourceId(TABLE_2_ID) + .datasourceType(DatasourceType.TABLE) .columns(new LinkedList<>(List.of(COLUMN_2_1_ID, COLUMN_2_2_ID, COLUMN_2_3_ID))) .build(); -- GitLab