From 287e8ea54009db9b1c2067965c16e70e547d1fdd Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Mon, 31 Mar 2025 15:41:43 +0200 Subject: [PATCH 1/2] Finished work Signed-off-by: Martin Weise <martin.weise@tuwien.ac.at> --- .../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 ++-- 17 files changed, 152 insertions(+), 98 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/dbrepo-auth-service/listeners/target/create-event-listener.jar b/dbrepo-auth-service/listeners/target/create-event-listener.jar index 5632a876e9fcc5546b307f7a795c6fbf2087d302..c45fcf9fa8e58ddb816cd6f9afb13cfd470c001b 100644 GIT binary patch delta 619 zcmbR1Ki6L<z?+#xgn@yBgMp>CK8o+`Pxp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0jVmDzt?@D<B1pEUfB1sYiKpBAc;__=O_ zNy72N=lfW)<!$Us79?DFVI%$R`-PV0_oQy`<^3%<zx#r-o#)Sb_HTive>QCu6XmU3 zKkL!e3kFMgKJU_Q&63`EaPO+<8$FF2o-5n-AK1u0>+s>qT$_ci<vM!~-IK{&ZngGV zr=I%r;<>2>)6OsVoTuuwG}3hSvk9RueN-3pf1elo_vxK{DHThXn=JenYcnNVSRCb} znkE*0;R8hk7Xt$a1H-$d$r~9}ncgN%zQL#mqBxl3L6jzw8q>R^$$?DTAgYeZ6hv)h z@&?H<F`olbmzaB)-X?8MV42GVqW`n;aDr%Ffm%V3;vU7>AWBnd3I{B<Cm&U^0*Nsy zn}Q6mP__e670UV`YNfInNbaGsHHeZ^aRpJSD$yXhLn<L4N<uXcM0Kdffv6X%P9RE0 QZ8u2eOSMc86{7A505}~K1poj5 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 fcc9d3cdec..503d58947b 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 5632a876e9fcc5546b307f7a795c6fbf2087d302..c45fcf9fa8e58ddb816cd6f9afb13cfd470c001b 100644 GIT binary patch delta 619 zcmbR1Ki6L<z?+#xgn@yBgMp>CK8o+`PxpyJO7*_QhZF?%rmOvLv}gDsC_FoQYx}i} zWp3H;9j>(*DoWls^6P!~#bYZkXI3+aecSl{<Fu&;RqT8(r6ZPWPoAVG-E#0wlf#J@ zZ)QxInsIPK_3EO#O{&Raa|JfLiA%<&R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5n-AK1u0>+s>qT$_ci<vM!~-IK{&ZngGV zr=I%r;<>2>)6OsVoTuuwG}3hSvk9RueN-3pf1elo_vxK{DHThXn=JenYcnNVSRCb} znkE*0;R8hk7Xt$a1H-$d$r~9}ncgN%zQL#mqBxl3L6jzw8q>R^$$?DTAgYeZ6hv)h z@&?H<F`olbmzaB)-X?8MV42GVqW`n;aDr%Ffm%V3;vU7>AWBnd3I{B<Cm&U^0*Nsy zn}Q6mP__e670UV`YNfInNbaGsHHeZ^aRpJSD$yXhLn<L4N<uXcM0Kdffv6X%P9RE0 QZ8u2eOSMc86{7A505}~K1poj5 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 From 246e675f25bf6977fc9695c56cd4fbef8a20bb6e Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Mon, 31 Mar 2025 15:44:58 +0200 Subject: [PATCH 2/2] Added changelog Signed-off-by: Martin Weise <martin.weise@tuwien.ac.at> --- .docs/changelog.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.docs/changelog.md b/.docs/changelog.md index 47439d975f..51cf52df20 100644 --- a/.docs/changelog.md +++ b/.docs/changelog.md @@ -6,11 +6,16 @@ author: Martin Weise #### Features -* 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). +#### Changes + +* Changed the API and UI to create subsets on both views and tables + in [#505](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/505). +* 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). + ## 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) -- GitLab