From ad780fc695919333eeb18f67ad56019e413d2816 Mon Sep 17 00:00:00 2001 From: Moritz Staudinger <moritz.staudinger@tuwien.ac.at> Date: Tue, 25 May 2021 13:21:24 +0200 Subject: [PATCH] Changed return type to Table instead of queryResult --- .../main/java/at/tuwien/endpoints/TableEndpoint.java | 12 ++++++------ .../main/java/at/tuwien/service/TableService.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fda-table-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java b/fda-table-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java index 38fd548c5d..6a27cf395f 100644 --- a/fda-table-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java +++ b/fda-table-service/rest-service/src/main/java/at/tuwien/endpoints/TableEndpoint.java @@ -86,9 +86,9 @@ public class TableEndpoint { @ApiResponse(code = 409, message = "The container image is not supported."), }) public ResponseEntity<QueryResultDto> createViaCsv(@PathVariable("id") Long databaseId, @RequestPart("file") MultipartFile file, @RequestPart TableCSVInformation headers) { - final QueryResult queryResult = tableService.create(databaseId, file, headers); + final Table table = tableService.create(databaseId, file, headers); return ResponseEntity.status(HttpStatus.CREATED) - .body(queryResultMapper.queryResultToQueryResultDto(queryResult)); + .body(tableMapper.tableToTableDto(table)); } @PostMapping("/table/csv/local") @@ -101,10 +101,10 @@ public class TableEndpoint { @ApiResponse(code = 405, message = "The container is not running."), @ApiResponse(code = 409, message = "The container image is not supported."), }) - public ResponseEntity<QueryResultDto> createViaCsv(@PathVariable("id") Long databaseId, @RequestBody TableCSVInformation tableCSVInformation) throws IOException { - final QueryResult queryResult = tableService.create(databaseId, tableCSVInformation); + public ResponseEntity<TableDto> createViaCsv(@PathVariable("id") Long databaseId, @RequestBody TableCSVInformation tableCSVInformation) throws IOException { + final Table table = tableService.create(databaseId, tableCSVInformation); return ResponseEntity.status(HttpStatus.CREATED) - .body(queryResultMapper.queryResultToQueryResultDto(queryResult)); + .body(tableMapper.tableToTableDto(table)); } @@ -164,7 +164,7 @@ public class TableEndpoint { @ApiResponse(code = 200, message = "All tables are listed."), @ApiResponse(code = 401, message = "Not authorized to list all tables."), }) - public ResponseEntity<QueryResultDto> showData(@PathVariable("id") Long databaseId, @PathVariable("tableId") Long tableId) throws DatabaseNotFoundException, ImageNotSupportedException, TableNotFoundException { + public ResponseEntity<TableDto> showData(@PathVariable("id") Long databaseId, @PathVariable("tableId") Long tableId) throws DatabaseNotFoundException, ImageNotSupportedException, TableNotFoundException { final QueryResult queryResult = tableService.showData(databaseId, tableId); return ResponseEntity.ok(queryResultMapper.queryResultToQueryResultDto(queryResult)); } diff --git a/fda-table-service/services/src/main/java/at/tuwien/service/TableService.java b/fda-table-service/services/src/main/java/at/tuwien/service/TableService.java index 1977e7196c..063cc96862 100644 --- a/fda-table-service/services/src/main/java/at/tuwien/service/TableService.java +++ b/fda-table-service/services/src/main/java/at/tuwien/service/TableService.java @@ -215,7 +215,7 @@ public class TableService { return queryResult; } - public QueryResult create(Long databaseId, MultipartFile file, TableCSVInformation tableCSVInformation) { + public Table create(Long databaseId, MultipartFile file, TableCSVInformation tableCSVInformation) { try { String[] header = readHeader(file); for (String s : header) { @@ -244,7 +244,7 @@ public class TableService { tcd.setColumns(cdtos); Table table = create(databaseId, tcd); QueryResult insert = insert(databaseId, table.getId(), file); - return insert; + return table; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); @@ -252,7 +252,7 @@ public class TableService { return null; } - public QueryResult create(Long databaseId, TableCSVInformation tableCSVInformation) throws IOException { + public Table create(Long databaseId, TableCSVInformation tableCSVInformation) throws IOException { Path path = Paths.get("/tmp/" + tableCSVInformation.getFileLocation()); String contentType = "multipart/form-data"; byte[] content = null; -- GitLab