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

Removed limitation that the statement needed to have tables set - removed save...

Removed limitation that the statement needed to have tables set - removed save method, integrated it into execute


Former-commit-id: 7c45cb16
parent df33e92b
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,6 @@ public class QueryEndpoint { ...@@ -39,7 +39,6 @@ public class QueryEndpoint {
this.storeService = storeService; this.storeService = storeService;
} }
@Deprecated
@PutMapping @PutMapping
@Transactional @Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')") @PreAuthorize("hasRole('ROLE_RESEARCHER')")
...@@ -61,36 +60,12 @@ public class QueryEndpoint { ...@@ -61,36 +60,12 @@ public class QueryEndpoint {
log.error("Query is empty"); log.error("Query is empty");
throw new QueryMalformedException("Invalid query"); throw new QueryMalformedException("Invalid query");
} }
if (data.getTables().size() == 0) {
log.error("Table list is empty");
throw new QueryMalformedException("Invalid table");
}
log.debug("Data for execution: {}", data); log.debug("Data for execution: {}", data);
final QueryResultDto result = queryService.execute(id, databaseId, data, page, size); final QueryResultDto result = queryService.execute(id, databaseId, data, page, size);
return ResponseEntity.status(HttpStatus.ACCEPTED) return ResponseEntity.status(HttpStatus.ACCEPTED)
.body(result); .body(result);
} }
@PostMapping
@Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')")
@ApiOperation(value = "saves a query without execution")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Executed the query, Saved it and return the results"),
@ApiResponse(code = 404, message = "The database does not exist."),
@ApiResponse(code = 405, message = "The container is not running."),
@ApiResponse(code = 409, message = "The container image is not supported."),})
public ResponseEntity<QueryDto> save(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId,
@Valid @RequestBody SaveStatementDto data)
throws DatabaseNotFoundException, ImageNotSupportedException, QueryStoreException,
ContainerNotFoundException {
final Query query = storeService.insert(id, databaseId, null, data);
final QueryDto queryDto = queryMapper.queryToQueryDto(query);
return ResponseEntity.status(HttpStatus.ACCEPTED)
.body(queryDto);
}
@PutMapping("/{queryId}") @PutMapping("/{queryId}")
@Transactional @Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')") @PreAuthorize("hasRole('ROLE_RESEARCHER')")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment