chore: Remove unused DatasetController endpoint and method

This commit is contained in:
Erik Foris 2024-07-05 19:31:19 +02:00
parent baa8349110
commit bf9b411c9b
2 changed files with 0 additions and 64 deletions

View File

@ -14,8 +14,6 @@ import java.util.UUID;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import de.uni_passau.fim.PADAS.group3.DataDash.category.Category;
@RestController
@RequestMapping("/api/v1/datasets")
@EnableSpringDataWebSupport
@ -79,24 +77,6 @@ public class DatasetController {
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")
public ResponseEntity<Page<Dataset>> search(
@RequestParam(value = "search", required = false, defaultValue = "%") String search,

View File

@ -23,10 +23,6 @@ public class DatasetService {
this.categoryRepository = categoryRepository;
}
public List<Dataset> getAllDatasets() {
return datasetRepository.findAll();
}
public Dataset getDatasetById(UUID id) {
return datasetRepository.getDatasetById(id);
}
@ -36,10 +32,6 @@ public class DatasetService {
return datasetRepository.save(dataset);
}
public void updateDatasetTitle(UUID id, String title) {
datasetRepository.getDatasetById(id).setTitle(title);
}
public void voteDataset(UUID id, int vote) {
Dataset dataset = datasetRepository.getDatasetById(id);
dataset.vote(vote);
@ -51,34 +43,6 @@ public class DatasetService {
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) {
Dataset dataset = datasetRepository.getDatasetById(id);
dataset.upvote();
@ -91,14 +55,6 @@ public class DatasetService {
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) {
Category category = categories.equals("%") ? null
: categoryRepository.getCategoryById(UUID.fromString(categories));