Merge branch '40-depricate-old-way-of-searching-datasets' into '22-integrate-api-and-frontend'
Resolve "depricate "Old" way of searching datasets" See merge request padas/24ss-5430-web-and-data-eng/gruppe-3/datadash!39
This commit is contained in:
commit
cd1e4c6b26
@ -14,8 +14,6 @@ import java.util.UUID;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import de.uni_passau.fim.PADAS.group3.DataDash.category.Category;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/datasets")
|
@RequestMapping("/api/v1/datasets")
|
||||||
@EnableSpringDataWebSupport
|
@EnableSpringDataWebSupport
|
||||||
@ -79,24 +77,6 @@ public class DatasetController {
|
|||||||
return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK);
|
return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public Page<Dataset> getDatasetsByDateAfter(@RequestParam(value = "author", required = false) String author,
|
|
||||||
@RequestParam(value = "title", required = false) String title,
|
|
||||||
@RequestParam(value = "description", required = false) String description,
|
|
||||||
@RequestParam(value = "abst", required = false) String abst,
|
|
||||||
@RequestParam(value = "type", required = false) Type type,
|
|
||||||
@RequestParam(value = "min-rating", required = false) Float rating,
|
|
||||||
@RequestParam(value = "page", required = false, defaultValue = "0") int page,
|
|
||||||
@RequestParam(value = "size", required = false, defaultValue = "20") int size,
|
|
||||||
@RequestParam(value = "sort", required = false, defaultValue = "upvotes") String sort,
|
|
||||||
@RequestParam(value = "direction", required = false, defaultValue = "desc") String direction,
|
|
||||||
@RequestParam(value = "category", required = false) Category category) {
|
|
||||||
Pageable pageable = PageRequest.of(page, size,
|
|
||||||
Sort.by(Sort.Direction.fromString(direction), sort));
|
|
||||||
return datasetService.getDatasetsByOptionalCriteria(title, description, author, abst, type, rating, category,
|
|
||||||
pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public ResponseEntity<Page<Dataset>> search(
|
public ResponseEntity<Page<Dataset>> search(
|
||||||
@RequestParam(value = "search", required = false, defaultValue = "%") String search,
|
@RequestParam(value = "search", required = false, defaultValue = "%") String search,
|
||||||
|
@ -23,10 +23,6 @@ public class DatasetService {
|
|||||||
this.categoryRepository = categoryRepository;
|
this.categoryRepository = categoryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Dataset> getAllDatasets() {
|
|
||||||
return datasetRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dataset getDatasetById(UUID id) {
|
public Dataset getDatasetById(UUID id) {
|
||||||
return datasetRepository.getDatasetById(id);
|
return datasetRepository.getDatasetById(id);
|
||||||
}
|
}
|
||||||
@ -36,10 +32,6 @@ public class DatasetService {
|
|||||||
return datasetRepository.save(dataset);
|
return datasetRepository.save(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDatasetTitle(UUID id, String title) {
|
|
||||||
datasetRepository.getDatasetById(id).setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void voteDataset(UUID id, int vote) {
|
public void voteDataset(UUID id, int vote) {
|
||||||
Dataset dataset = datasetRepository.getDatasetById(id);
|
Dataset dataset = datasetRepository.getDatasetById(id);
|
||||||
dataset.vote(vote);
|
dataset.vote(vote);
|
||||||
@ -51,34 +43,6 @@ public class DatasetService {
|
|||||||
datasetRepository.delete(dataset);
|
datasetRepository.delete(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByTitle(String title) {
|
|
||||||
return datasetRepository.findByTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByTitleLike(String title) {
|
|
||||||
return datasetRepository.findByTitleLike(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> findByDescriptionLike(String description) {
|
|
||||||
return datasetRepository.findByDescriptionLike(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByAuthorLike(String author) {
|
|
||||||
return datasetRepository.findByAuthorLike(author);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByType(Type type) {
|
|
||||||
return datasetRepository.findByType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByAbstLike(String abst) {
|
|
||||||
return datasetRepository.findByAbstLike(abst);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> getDatasetsByRaitingGreaterThan(float raiting) {
|
|
||||||
return datasetRepository.findByRaitingGreaterThan(raiting);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void upvoteDataset(UUID id) {
|
public void upvoteDataset(UUID id) {
|
||||||
Dataset dataset = datasetRepository.getDatasetById(id);
|
Dataset dataset = datasetRepository.getDatasetById(id);
|
||||||
dataset.upvote();
|
dataset.upvote();
|
||||||
@ -91,14 +55,6 @@ public class DatasetService {
|
|||||||
datasetRepository.save(dataset);
|
datasetRepository.save(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Dataset> getDatasetsByOptionalCriteria(String title, String description, String author, String abst,
|
|
||||||
Type type, Float raiting, Category category, Pageable pageable) {
|
|
||||||
return datasetRepository.findByOptionalCriteria(Optional.ofNullable(title), Optional.ofNullable(description),
|
|
||||||
Optional.ofNullable(author), Optional.ofNullable(abst), Optional.ofNullable(type),
|
|
||||||
Optional.ofNullable(category),
|
|
||||||
Optional.ofNullable(raiting), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Page<Dataset> searchByOptionalCriteria(String search, String categories, String type, Pageable pageable) {
|
public Page<Dataset> searchByOptionalCriteria(String search, String categories, String type, Pageable pageable) {
|
||||||
Category category = categories.equals("%") ? null
|
Category category = categories.equals("%") ? null
|
||||||
: categoryRepository.getCategoryById(UUID.fromString(categories));
|
: categoryRepository.getCategoryById(UUID.fromString(categories));
|
||||||
|
Loading…
Reference in New Issue
Block a user