Skip to content
Snippets Groups Projects
Commit a68d2c09 authored by Moritz Staudinger's avatar Moritz Staudinger
Browse files

Changed return type to Table instead of queryResult

parent 549215fc
No related branches found
No related tags found
No related merge requests found
...@@ -86,9 +86,9 @@ public class TableEndpoint { ...@@ -86,9 +86,9 @@ public class TableEndpoint {
@ApiResponse(code = 409, message = "The container image is not supported."), @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) { 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) return ResponseEntity.status(HttpStatus.CREATED)
.body(queryResultMapper.queryResultToQueryResultDto(queryResult)); .body(tableMapper.tableToTableDto(table));
} }
@PostMapping("/table/csv/local") @PostMapping("/table/csv/local")
...@@ -101,10 +101,10 @@ public class TableEndpoint { ...@@ -101,10 +101,10 @@ public class TableEndpoint {
@ApiResponse(code = 405, message = "The container is not running."), @ApiResponse(code = 405, message = "The container is not running."),
@ApiResponse(code = 409, message = "The container image is not supported."), @ApiResponse(code = 409, message = "The container image is not supported."),
}) })
public ResponseEntity<QueryResultDto> createViaCsv(@PathVariable("id") Long databaseId, @RequestBody TableCSVInformation tableCSVInformation) throws IOException { public ResponseEntity<TableDto> createViaCsv(@PathVariable("id") Long databaseId, @RequestBody TableCSVInformation tableCSVInformation) throws IOException {
final QueryResult queryResult = tableService.create(databaseId, tableCSVInformation); final Table table = tableService.create(databaseId, tableCSVInformation);
return ResponseEntity.status(HttpStatus.CREATED) return ResponseEntity.status(HttpStatus.CREATED)
.body(queryResultMapper.queryResultToQueryResultDto(queryResult)); .body(tableMapper.tableToTableDto(table));
} }
...@@ -164,7 +164,7 @@ public class TableEndpoint { ...@@ -164,7 +164,7 @@ public class TableEndpoint {
@ApiResponse(code = 200, message = "All tables are listed."), @ApiResponse(code = 200, message = "All tables are listed."),
@ApiResponse(code = 401, message = "Not authorized to list all tables."), @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); final QueryResult queryResult = tableService.showData(databaseId, tableId);
return ResponseEntity.ok(queryResultMapper.queryResultToQueryResultDto(queryResult)); return ResponseEntity.ok(queryResultMapper.queryResultToQueryResultDto(queryResult));
} }
......
...@@ -215,7 +215,7 @@ public class TableService { ...@@ -215,7 +215,7 @@ public class TableService {
return queryResult; return queryResult;
} }
public QueryResult create(Long databaseId, MultipartFile file, TableCSVInformation tableCSVInformation) { public Table create(Long databaseId, MultipartFile file, TableCSVInformation tableCSVInformation) {
try { try {
String[] header = readHeader(file); String[] header = readHeader(file);
for (String s : header) { for (String s : header) {
...@@ -244,7 +244,7 @@ public class TableService { ...@@ -244,7 +244,7 @@ public class TableService {
tcd.setColumns(cdtos); tcd.setColumns(cdtos);
Table table = create(databaseId, tcd); Table table = create(databaseId, tcd);
QueryResult insert = insert(databaseId, table.getId(), file); QueryResult insert = insert(databaseId, table.getId(), file);
return insert; return table;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
...@@ -252,7 +252,7 @@ public class TableService { ...@@ -252,7 +252,7 @@ public class TableService {
return null; 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()); Path path = Paths.get("/tmp/" + tableCSVInformation.getFileLocation());
String contentType = "multipart/form-data"; String contentType = "multipart/form-data";
byte[] content = null; byte[] content = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment