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

Changed return type to Table instead of queryResult

parent 434bb869
Branches
Tags
3 merge requests!23Sprint results,!18Merge Conflicts,!17UI sprint 2
......@@ -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));
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment