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 38fd548c5d7915cbaec31b2a5b6b80fa57923a93..6a27cf395f4d49e24a57efceb1b30ebc670d461f 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 1977e7196cea223bc27256ee7c17e2f07dee5a7d..063cc9686278c8610c8fe0214012d4d4c2812317 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;