diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplication.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplication.java index 496e751..ecc334d 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplication.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplication.java @@ -5,9 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DataDashApplication { - public static void main(String[] args) { SpringApplication.run(DataDashApplication.class, args); } - } diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Dataset.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Dataset.java index 36796e3..6afa2bc 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Dataset.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Dataset.java @@ -21,72 +21,61 @@ import jakarta.persistence.ManyToOne; @Entity public class Dataset { - @Id @GeneratedValue(strategy = GenerationType.AUTO) private UUID id; - + @Enumerated(EnumType.STRING) private Type type; private String title; - - private String abst; - + private String summary; private String description; - private String author; - + private String license; private Date date; - - private float raiting; - + private float rating; private int votes; - private int upvotes; - private URL url; + @ManyToOne + private Category category; + @Column(name = "terms_of_use") private URL termsOfUse; - private String licence; + private static final List sortable = Arrays.asList( + "author", "title", "upvotes", "rating", "date" + ); - private static final List sortable = Arrays.asList("author", "title", "upvotes", "raiting", "date"); - - @ManyToOne - private Category categorie; - - public Dataset(String title, String abst, String description, String author, URL url, Category categories, Type type, String licence) { - - this.raiting = 0; + public Dataset(String title, String summary, String description, String author, URL url, Category category, Type type, String license) { + this.rating = 0; this.votes = 0; this.upvotes = 0; setTitle(title); - setAbst(abst); - setDescription(description); + setSummary(summary); + setDescription(description); setAuthor(author); setDate(LocalDate.now()); - setCategorie(categories); + setCategory(category); setType(type); setUrl(url); - setLicence(licence); + setLicense(license); } - public Dataset() { - } + public Dataset() {} - - public String getAbst() { - return abst; + public String getSummary() { + return summary; } public String getAuthor() { return author; } - public Category getCategorie() { - return categorie; + public Category getCategory() { + return category; } public LocalDate getDate() { @@ -101,8 +90,8 @@ public class Dataset { return id; } - public float getRaiting() { - return raiting; + public float getRating() { + return rating; } public String getTitle() { @@ -129,42 +118,42 @@ public class Dataset { return termsOfUse; } - public String getLicence() { - return licence; + public String getLicense() { + return license; } public static List getSort() { return sortable; } - public void setAbst(String abst) { - this.abst = abst.substring(0, Math.min(abst.length(), 100)); + public void setSummary(String summary) { + this.summary = summary.substring(0, Math.min(summary.length(), 100)); } public void setAuthor(String author) { this.author = author; } - public void setCategorie(Category categories) { - this.categorie = categories; + public void setCategory(Category category) { + this.category = category; } - + public void setDate(LocalDate localDate) { this.date = Date.valueOf(localDate); } - + public void setDescription(String description) { this.description = description; } public void setUrl(URL url) { - this.url = url; + this.url = url; } - + public void setTermsOfUse(URL termsOfUse) { this.termsOfUse = termsOfUse; } - + public void setTitle(String title) { this.title = title.substring(0, Math.min(title.length(), 50)); } @@ -172,9 +161,9 @@ public class Dataset { public void setType(Type type) { this.type = type; } - + public void vote(int stars) { - raiting = (raiting*votes + stars) / (++votes); + rating = (rating * votes + stars) / (++votes); } public void upvote() { @@ -185,8 +174,7 @@ public class Dataset { upvotes--; } - public void setLicence(String licence) { - this.licence = licence; + public void setLicense(String license) { + this.license = license; } - } diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetController.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetController.java index d0a00ca..7a0c2cb 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetController.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetController.java @@ -25,10 +25,9 @@ public class DatasetController { @GetMapping("/id/{id}") public ResponseEntity getDatasetById(@PathVariable("id") UUID id) { Dataset d = datasetService.getDatasetById(id); - if (d == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - return new ResponseEntity<>(d, HttpStatus.OK); + return d == null + ? new ResponseEntity<>(HttpStatus.NOT_FOUND) + : new ResponseEntity<>(d, HttpStatus.OK); } @ResponseStatus(HttpStatus.CREATED) @@ -42,6 +41,7 @@ public class DatasetController { if (datasetService.getDatasetById(id) == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } + datasetService.deleteDataset(id); return new ResponseEntity<>(HttpStatus.OK); } @@ -61,44 +61,52 @@ public class DatasetController { if (datasetService.getDatasetById(id) == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } + datasetService.downvoteDataset(id); return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK); } @PutMapping("/id/{id}/stars") - public ResponseEntity postMethodName(@PathVariable("id") UUID id, - @RequestParam("stars") int stars) { + public ResponseEntity postMethodName( + @PathVariable("id") UUID id, + @RequestParam("stars") int stars + ) { if (datasetService.getDatasetById(id) == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - if (!(stars >= 0 && stars < 6)) { + } else if (!(stars >= 0 && stars < 6)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } + datasetService.voteDataset(id, stars); return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK); } @GetMapping("/search") public ResponseEntity> search( - @RequestParam(value = "search", required = false, defaultValue = "%") String search, - @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, defaultValue = "%") String category, - @RequestParam(value = "type", required = false, defaultValue = "%") String type) { + @RequestParam(value = "search", required = false, defaultValue = "%") String search, + @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, defaultValue = "%") String category, + @RequestParam(value = "type", required = false, defaultValue = "%") String type + ) { Pageable pageable = null; - if (!Dataset.getSort().contains(sort)) + if (!Dataset.getSort().contains(sort)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + try { - pageable = PageRequest.of(page, size, - Sort.by(Sort.Direction.fromString(direction), sort)); + pageable = PageRequest.of(page, size, Sort.by( + Sort.Direction.fromString(direction), sort) + ); } catch (Exception e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } - return new ResponseEntity<>(datasetService.searchByOptionalCriteria(search, category, type, pageable), - HttpStatus.OK); + return new ResponseEntity<>( + datasetService.searchByOptionalCriteria(search, category, type, pageable), + HttpStatus.OK + ); } - -} \ No newline at end of file +} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetRepository.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetRepository.java new file mode 100644 index 0000000..2e8557f --- /dev/null +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetRepository.java @@ -0,0 +1,68 @@ +package de.uni_passau.fim.PADAS.group3.DataDash.Dataset; + +import java.util.Optional; +import java.util.UUID; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import de.uni_passau.fim.PADAS.group3.DataDash.category.Category; + +public interface DatasetRepository extends JpaRepository { + Dataset getDatasetById(UUID id); + + @SuppressWarnings("null") + Page findAll(Pageable pageable); + + @Query(""" + SELECT d FROM Dataset d WHERE + (COALESCE(:title, '') = '' OR d.title LIKE :title) AND + (COALESCE(:description, '') = '' OR d.description LIKE :description) AND + (COALESCE(:author, '') = '' OR d.author LIKE :author) AND + (COALESCE(:summary, '') = '' OR d.summary LIKE :summary) AND + (:type IS NULL OR d.type = :type) AND + (:category IS NULL OR d.category = :category) AND + (:rating IS NULL OR d.rating > :rating) + """) + Page findByOptionalCriteria( + @Param("title") Optional title, + @Param("description") Optional description, + @Param("author") Optional author, + @Param("summary") Optional summary, + @Param("type") Optional type, + @Param("category") Optional categories, + @Param("rating") Optional rating, + Pageable pageable + ); + + @Query(""" + SELECT d FROM Dataset d WHERE + ((LOWER(d.title) LIKE LOWER(:search)) OR + (LOWER(d.description) LIKE LOWER(:search)) OR + (LOWER(d.author) LIKE LOWER(:search))) AND + (d.category = :category) AND + (:type IS NULL OR d.type = :type) + """) + Page searchByOptionalCriteriaWithCategory( + @Param("search") Optional search, + @Param("category") Category categories, + @Param("type") Optional type, + Pageable pageable + ); + + @Query(""" + SELECT d FROM Dataset d WHERE + ((LOWER(d.title) LIKE LOWER(:search)) OR + (LOWER(d.description) LIKE LOWER(:search)) OR + (LOWER(d.author) LIKE LOWER(:search))) AND + (:type IS NULL OR d.type = :type) + """) + Page searchByOptionalCriteria( + @Param("search") Optional search, + @Param("type") Optional type, + Pageable pageable + ); +} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetService.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetService.java index 757739e..290db8c 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetService.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetService.java @@ -14,10 +14,10 @@ import org.springframework.data.domain.Page; @Service public class DatasetService { - private dataRepository datasetRepository; + private DatasetRepository datasetRepository; private CategoryRepository categoryRepository; - DatasetService(dataRepository datasetRepository, CategoryRepository categoryRepository) { + DatasetService(DatasetRepository datasetRepository, CategoryRepository categoryRepository) { this.datasetRepository = datasetRepository; this.categoryRepository = categoryRepository; } @@ -54,17 +54,18 @@ public class DatasetService { datasetRepository.save(dataset); } - Page searchByOptionalCriteria(String search, String categories, String type, Pageable pageable) { - Category category = categories.equals("%") ? null - : categoryRepository.getCategoryById(UUID.fromString(categories)); + Page searchByOptionalCriteria(String search, String categoryID, String type, Pageable pageable) { + Category category = categoryID.equals("%") + ? null + : categoryRepository.getCategoryById(UUID.fromString(categoryID)); Type t = type.equals("%") ? null : Type.valueOf(type); - if (category == null) { - return datasetRepository.searchByOptionalCriteria(Optional.ofNullable(search), Optional.ofNullable(t), - pageable); - } - return datasetRepository.searchByOptionalCriteriaWithCategory(Optional.ofNullable(search), category, - Optional.ofNullable(t), pageable); + return category == null + ? datasetRepository.searchByOptionalCriteria( + Optional.ofNullable(search), Optional.ofNullable(t), pageable + ) + : datasetRepository.searchByOptionalCriteriaWithCategory( + Optional.ofNullable(search), category, Optional.ofNullable(t), pageable + ); } - -} \ No newline at end of file +} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Type.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Type.java index 9f2770d..8066901 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Type.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/Type.java @@ -3,4 +3,4 @@ package de.uni_passau.fim.PADAS.group3.DataDash.Dataset; public enum Type { DATASET, API -} \ No newline at end of file +} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/dataRepository.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/dataRepository.java deleted file mode 100644 index b983df2..0000000 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/dataRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.uni_passau.fim.PADAS.group3.DataDash.Dataset; - -import java.util.Optional; -import java.util.UUID; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import de.uni_passau.fim.PADAS.group3.DataDash.category.Category; - -public interface dataRepository extends JpaRepository { - - Dataset getDatasetById(UUID id); - - @SuppressWarnings("null") - Page findAll(Pageable pageable); - - @Query("SELECT d FROM Dataset d WHERE " + - "(COALESCE(:title, '') = '' OR d.title LIKE :title) AND " + - "(COALESCE(:description, '') = '' OR d.description LIKE :description) AND" + - "(COALESCE(:author, '') = '' OR d.author LIKE :author) AND" + - "(COALESCE(:abst, '') = '' OR d.abst LIKE :abst) AND" + - "(:type IS NULL OR d.type = :type) AND" + - "(:categorie IS NULL OR d.categorie = :categorie) AND" + - "(:raiting IS NULL OR d.raiting > :raiting)") - Page findByOptionalCriteria(@Param("title") Optional title, - @Param("description") Optional description, - @Param("author") Optional author, - @Param("abst") Optional abst, - @Param("type") Optional type, - @Param("categorie") Optional categories, - @Param("raiting") Optional raiting, - Pageable pageable); - - @Query("SELECT d FROM Dataset d WHERE " + - "((LOWER(d.title) LIKE LOWER(:search)) OR " + - "(LOWER(d.description) LIKE LOWER(:search)) OR " + - "(LOWER(d.author) LIKE LOWER(:search))) AND" + - "(d.categorie = :categorie) AND" + - "(:type IS NULL OR d.type = :type)") - Page searchByOptionalCriteriaWithCategory(@Param("search") Optional search, - @Param("categorie") Category categories, - @Param("type") Optional type, - Pageable pageable); - - @Query("SELECT d FROM Dataset d WHERE " + - "((LOWER(d.title) LIKE LOWER(:search)) OR " + - "(LOWER(d.description) LIKE LOWER(:search)) OR " + - "(LOWER(d.author) LIKE LOWER(:search))) AND" + - "(:type IS NULL OR d.type = :type)") - Page searchByOptionalCriteria(@Param("search") Optional search, - @Param("type") Optional type, - Pageable pageable); -} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/ServletInitializer.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/ServletInitializer.java index 87f8895..7cc3291 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/ServletInitializer.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/ServletInitializer.java @@ -4,10 +4,8 @@ import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; public class ServletInitializer extends SpringBootServletInitializer { - @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(DataDashApplication.class); } - } diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/Category.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/Category.java index a868283..1d62ed2 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/Category.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/Category.java @@ -14,13 +14,11 @@ import jakarta.persistence.OneToMany; @Entity public class Category { - @Id @GeneratedValue(strategy = GenerationType.AUTO) private UUID id; - private String name; - + @Lazy @OneToMany(mappedBy = "categorie") private List datasets; diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryController.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryController.java index f68be67..ab3eca9 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryController.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryController.java @@ -13,9 +13,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; - - - @RestController @RequestMapping("/api/v1/categories") public class CategoryController { @@ -30,16 +27,14 @@ public class CategoryController { @GetMapping("/id/{id}") public ResponseEntity fetchCategoryById(@PathVariable("id") UUID id) { CategoryDto category = categoryService.getCategoryById(id); - if(category == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - return new ResponseEntity<>(category, HttpStatus.OK); + return category == null + ? new ResponseEntity<>(HttpStatus.NOT_FOUND) + :new ResponseEntity<>(category, HttpStatus.OK); } + @ResponseStatus(HttpStatus.CREATED) @PostMapping public Category createCategory(@RequestBody CategoryDto dto) { return categoryService.addCategory(dto); - } - - + } } diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDto.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDto.java index 11644cc..eb29230 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDto.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDto.java @@ -3,19 +3,16 @@ package de.uni_passau.fim.PADAS.group3.DataDash.category; import java.util.UUID; public class CategoryDto { - private String name; private UUID id; - public CategoryDto() { - } + public CategoryDto() {} CategoryDto(String name, UUID id) { this.name = name; this.id = id; } - public String getName() { return name; } @@ -24,4 +21,3 @@ public class CategoryDto { return id; } } - diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDtoMapper.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDtoMapper.java index 683fdc8..2f4c38e 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDtoMapper.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryDtoMapper.java @@ -1,10 +1,7 @@ package de.uni_passau.fim.PADAS.group3.DataDash.category; public class CategoryDtoMapper { - public static CategoryDto toDto(Category category) { - CategoryDto dto = new CategoryDto(category.getName(), category.getId()); - return dto; + return new CategoryDto(category.getName(), category.getId()); } - } diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepository.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepository.java index 38e84c6..ee34bdf 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepository.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepository.java @@ -8,13 +8,12 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface CategoryRepository extends JpaRepository{ - Category getCategoryById(UUID id); @SuppressWarnings("null") List findAll(); List findByName(String name); + @SuppressWarnings("null") Optional findById(UUID id); - -} \ No newline at end of file +} diff --git a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryService.java b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryService.java index ced75f3..7ce5234 100644 --- a/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryService.java +++ b/src/main/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryService.java @@ -25,10 +25,6 @@ public class CategoryService { CategoryDto getCategoryById(UUID id) { Category c = categoryRepository.getCategoryById(id); - if (c == null) { - return null; - } - return CategoryDtoMapper.toDto(c); + return c == null ? null : CategoryDtoMapper.toDto(c); } - } diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 7fbfc2e..5316b3f 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,64 +1,65 @@ -- Insert sample data into category INSERT INTO category (id, name) VALUES -('123e4567-e89b-12d3-a456-426614174003', 'Business'), -('123e4567-e89b-12d3-a456-426614174004', 'Education'), -('123e4567-e89b-12d3-a456-426614174005', 'Sports'), -('123e4567-e89b-12d3-a456-426614174006', 'Entertainment'), -('123e4567-e89b-12d3-a456-426614174007', 'Art'), -('123e4567-e89b-12d3-a456-426614174000', 'Science'), -('123e4567-e89b-12d3-a456-426614174001', 'Technology'), -('123e4567-e89b-12d3-a456-426614174002', 'Health'); + ('123e4567-e89b-12d3-a456-426614174003', 'Business'), + ('123e4567-e89b-12d3-a456-426614174004', 'Education'), + ('123e4567-e89b-12d3-a456-426614174005', 'Sports'), + ('123e4567-e89b-12d3-a456-426614174006', 'Entertainment'), + ('123e4567-e89b-12d3-a456-426614174007', 'Art'), + ('123e4567-e89b-12d3-a456-426614174000', 'Science'), + ('123e4567-e89b-12d3-a456-426614174001', 'Technology'), + ('123e4567-e89b-12d3-a456-426614174002', 'Health'); -- Insert sample data into dataset -INSERT INTO dataset (date, raiting, upvotes, votes, categorie_id, id, abst, author, description, title, url, type, licence, terms_of_use) VALUES -('2023-01-01', 4.5, 100, 120, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174100', 'Abstract 1', 'Author 1', 'Description 1', 'Title 1', 'http://example.com/1', 'API', 'MIT', 'http://example.com'), -('2023-01-02', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174101', 'Abstract 2', 'Author 2', 'Description 2', 'Title 2', 'http://example.com/2', 'DATASET', 'MIT', 'http://example.com'), -('2023-01-03', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174102', 'Abstract 3', 'Author 3', 'Description 3', 'Title 3', 'http://example.com/3', 'API', 'MIT', 'http://example.com'), -('2023-01-04', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174103', 'Abstract 4', 'Author 4', 'Description 4', 'Title 4', 'http://example.com/4', 'DATASET', 'MIT', 'http://example.com'), -('2023-01-05', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174104', 'Abstract 5', 'Author 5', 'Description 5', 'Title 5', 'http://example.com/5', 'API', 'MIT', 'http://example.com'), -('2023-01-06', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174105', 'Abstract 6', 'Author 6', 'Description 6', 'Title 6', 'http://example.com/6', 'API', 'MIT', 'http://zip.com'), -('2023-01-07', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174106', 'Abstract 7', 'Author 7', 'Description 7', 'Title 7', 'http://example.com/7', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-08', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174107', 'Abstract 8', 'Author 8', 'Description 8', 'Title 8', 'http://example.com/8', 'API', 'MIT', 'http://zip.com'), -('2023-01-09', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174108', 'Abstract 9', 'Author 9', 'Description 9', 'Title 9', 'http://example.com/9', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-10', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174109', 'Abstract 10', 'Author 10', 'Description 10', 'Title 10', 'http://example.com/10', 'API', 'MIT', 'http://zip.com'), -('2023-11-11', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174110', 'Abstract 11', 'Author 11', 'Description 11', 'Title 11', 'http://example.com/11', 'DATASET', 'MIT', 'http://zip.com'), -('2023-09-12', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174111', 'Abstract 12', 'Author 12', 'Description 12', 'Title 12', 'http://example.com/12', 'API', 'MIT', 'http://zip.com'), -('2023-03-13', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174112', 'Abstract 13', 'Author 13', 'Description 13', 'Title 13', 'http://example.com/13', 'DATASET', 'MIT', 'http://zip.com'), -('2021-01-14', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174113', 'Abstract 14', 'Author 14', 'Description 14', 'Title 14', 'http://example.com/14', 'API', 'MIT', 'http://zip.com'), -('2024-01-15', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174114', 'Abstract 15', 'Author 15', 'Description 15', 'Title 15', 'http://example.com/15', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-16', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174115', 'Abstract 16', 'Author 16', 'Description 16', 'Title 16', 'http://example.com/16', 'API', 'MIT', 'http://zip.com'), -('2023-01-17', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174116', 'Abstract 17', 'Author 17', 'Description 17', 'Title 17', 'http://example.com/17', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-18', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174117', 'Abstract 18', 'Author 18', 'Description 18', 'Title 18', 'http://example.com/18', 'API', 'MIT', 'http://zip.com'), -('2023-01-19', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174118', 'Abstract 19', 'Author 19', 'Description 19', 'Title 19', 'http://example.com/19', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-20', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174119', 'Abstract 20', 'Author 20', 'Description 20', 'Title 20', 'http://example.com/20', 'API', 'MIT', 'http://zip.com'), -('2023-01-21', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174120', 'Abstract 21', 'Author 21', 'Description 21', 'Title 21', 'http://example.com/21', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-22', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174121', 'Abstract 22', 'Author 22', 'Description 22', 'Title 22', 'http://example.com/22', 'API', 'MIT', 'http://zip.com'), -('2023-01-23', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174122', 'Abstract 23', 'Author 23', 'Description 23', 'Title 23', 'http://example.com/23', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-24', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174123', 'Abstract 24', 'Author 24', 'Description 24', 'Title 24', 'http://example.com/24', 'API', 'MIT', 'http://zip.com'), -('2023-01-25', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174124', 'Abstract 25', 'Author 25', 'Description 25', 'Title 25', 'http://example.com/25', 'DATASET', 'MIT', 'http://zip.com'), -('2023-01-27', 4.3, 95, 115, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174126', 'Abstract 27', 'Author 27', 'Description 27', 'Title 27', 'http://example.com/27', 'DATASET', 'GPL', 'http://zip.com'), -('2023-01-28', 4.7, 160, 180, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174127', 'Abstract 28', 'Author 28', 'Description 28', 'Title 28', 'http://example.com/28', 'API', 'GPL', 'http://zip.com'), -('2023-01-29', 4.4, 110, 130, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174128', 'Abstract 29', 'Author 29', 'Description 29', 'Title 29', 'http://example.com/29', 'DATASET', 'GPL', 'http://zip.com'), -('2023-01-30', 4.8, 190, 210, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174129', 'Abstract 30', 'Author 30', 'Description 30', 'Title 30', 'http://example.com/30', 'API', 'GPL', 'http://zip.com'), -('2023-01-31', 4.5, 100, 120, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174130', 'Abstract 31', 'Author 31', 'Description 31', 'Title 31', 'http://example.com/31', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-01', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174131', 'Abstract 32', 'Author 32', 'Description 32', 'Title 32', 'http://example.com/32', 'API', 'GPL', 'http://zip.com'), -('2023-02-02', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174132', 'Abstract 33', 'Author 33', 'Description 33', 'Title 33', 'http://example.com/33', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-03', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174133', 'Abstract 34', 'Author 34', 'Description 34', 'Title 34', 'http://example.com/34', 'API', 'GPL', 'http://zip.com'), -('2023-02-04', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174134', 'Abstract 35', 'Author 35', 'Description 35', 'Title 35', 'http://example.com/35', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-05', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174135', 'Abstract 36', 'Author 36', 'Description 36', 'Title 36', 'http://example.com/36', 'API', 'GPL', 'http://zip.com'), -('2023-02-06', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174136', 'Abstract 37', 'Author 37', 'Description 37', 'Title 37', 'http://example.com/37', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-07', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174137', 'Abstract 38', 'Author 38', 'Description 38', 'Title 38', 'http://example.com/38', 'API', 'GPL', 'http://zip.com'), -('2023-02-08', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174138', 'Abstract 39', 'Author 39', 'Description 39', 'Title 39', 'http://example.com/39', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-09', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174139', 'Abstract 40', 'Author 40', 'Description 40', 'Title 40', 'http://example.com/40', 'API', 'GPL', 'http://zip.com'); +INSERT INTO dataset (date, rating, upvotes, votes, category_id, id, summary, author, description, title, url, type, license, terms_of_use) VALUES + ('2023-01-01', 4.5, 100, 120, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174100', 'Abstract 1', 'Author 1', 'Description 1', 'Title 1', 'http://example.com/1', 'API', 'MIT', 'http://example.com'), + ('2023-01-02', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174101', 'Abstract 2', 'Author 2', 'Description 2', 'Title 2', 'http://example.com/2', 'DATASET', 'MIT', 'http://example.com'), + ('2023-01-03', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174102', 'Abstract 3', 'Author 3', 'Description 3', 'Title 3', 'http://example.com/3', 'API', 'MIT', 'http://example.com'), + ('2023-01-04', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174103', 'Abstract 4', 'Author 4', 'Description 4', 'Title 4', 'http://example.com/4', 'DATASET', 'MIT', 'http://example.com'), + ('2023-01-05', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174104', 'Abstract 5', 'Author 5', 'Description 5', 'Title 5', 'http://example.com/5', 'API', 'MIT', 'http://example.com'), + ('2023-01-06', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174105', 'Abstract 6', 'Author 6', 'Description 6', 'Title 6', 'http://example.com/6', 'API', 'MIT', 'http://zip.com'), + ('2023-01-07', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174106', 'Abstract 7', 'Author 7', 'Description 7', 'Title 7', 'http://example.com/7', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-08', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174107', 'Abstract 8', 'Author 8', 'Description 8', 'Title 8', 'http://example.com/8', 'API', 'MIT', 'http://zip.com'), + ('2023-01-09', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174108', 'Abstract 9', 'Author 9', 'Description 9', 'Title 9', 'http://example.com/9', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-10', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174109', 'Abstract 10', 'Author 10', 'Description 10', 'Title 10', 'http://example.com/10', 'API', 'MIT', 'http://zip.com'), + ('2023-11-11', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174110', 'Abstract 11', 'Author 11', 'Description 11', 'Title 11', 'http://example.com/11', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-09-12', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174111', 'Abstract 12', 'Author 12', 'Description 12', 'Title 12', 'http://example.com/12', 'API', 'MIT', 'http://zip.com'), + ('2023-03-13', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174112', 'Abstract 13', 'Author 13', 'Description 13', 'Title 13', 'http://example.com/13', 'DATASET', 'MIT', 'http://zip.com'), + ('2021-01-14', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174113', 'Abstract 14', 'Author 14', 'Description 14', 'Title 14', 'http://example.com/14', 'API', 'MIT', 'http://zip.com'), + ('2024-01-15', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174114', 'Abstract 15', 'Author 15', 'Description 15', 'Title 15', 'http://example.com/15', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-16', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174115', 'Abstract 16', 'Author 16', 'Description 16', 'Title 16', 'http://example.com/16', 'API', 'MIT', 'http://zip.com'), + ('2023-01-17', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174116', 'Abstract 17', 'Author 17', 'Description 17', 'Title 17', 'http://example.com/17', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-18', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174117', 'Abstract 18', 'Author 18', 'Description 18', 'Title 18', 'http://example.com/18', 'API', 'MIT', 'http://zip.com'), + ('2023-01-19', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174118', 'Abstract 19', 'Author 19', 'Description 19', 'Title 19', 'http://example.com/19', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-20', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174119', 'Abstract 20', 'Author 20', 'Description 20', 'Title 20', 'http://example.com/20', 'API', 'MIT', 'http://zip.com'), + ('2023-01-21', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174120', 'Abstract 21', 'Author 21', 'Description 21', 'Title 21', 'http://example.com/21', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-22', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174121', 'Abstract 22', 'Author 22', 'Description 22', 'Title 22', 'http://example.com/22', 'API', 'MIT', 'http://zip.com'), + ('2023-01-23', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174122', 'Abstract 23', 'Author 23', 'Description 23', 'Title 23', 'http://example.com/23', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-24', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174123', 'Abstract 24', 'Author 24', 'Description 24', 'Title 24', 'http://example.com/24', 'API', 'MIT', 'http://zip.com'), + ('2023-01-25', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174124', 'Abstract 25', 'Author 25', 'Description 25', 'Title 25', 'http://example.com/25', 'DATASET', 'MIT', 'http://zip.com'), + ('2023-01-27', 4.3, 95, 115, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174126', 'Abstract 27', 'Author 27', 'Description 27', 'Title 27', 'http://example.com/27', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-01-28', 4.7, 160, 180, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174127', 'Abstract 28', 'Author 28', 'Description 28', 'Title 28', 'http://example.com/28', 'API', 'GPL', 'http://zip.com'), + ('2023-01-29', 4.4, 110, 130, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174128', 'Abstract 29', 'Author 29', 'Description 29', 'Title 29', 'http://example.com/29', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-01-30', 4.8, 190, 210, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174129', 'Abstract 30', 'Author 30', 'Description 30', 'Title 30', 'http://example.com/30', 'API', 'GPL', 'http://zip.com'), + ('2023-01-31', 4.5, 100, 120, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174130', 'Abstract 31', 'Author 31', 'Description 31', 'Title 31', 'http://example.com/31', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-01', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174131', 'Abstract 32', 'Author 32', 'Description 32', 'Title 32', 'http://example.com/32', 'API', 'GPL', 'http://zip.com'), + ('2023-02-02', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174132', 'Abstract 33', 'Author 33', 'Description 33', 'Title 33', 'http://example.com/33', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-03', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174133', 'Abstract 34', 'Author 34', 'Description 34', 'Title 34', 'http://example.com/34', 'API', 'GPL', 'http://zip.com'), + ('2023-02-04', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174134', 'Abstract 35', 'Author 35', 'Description 35', 'Title 35', 'http://example.com/35', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-05', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174135', 'Abstract 36', 'Author 36', 'Description 36', 'Title 36', 'http://example.com/36', 'API', 'GPL', 'http://zip.com'), + ('2023-02-06', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174136', 'Abstract 37', 'Author 37', 'Description 37', 'Title 37', 'http://example.com/37', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-07', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174137', 'Abstract 38', 'Author 38', 'Description 38', 'Title 38', 'http://example.com/38', 'API', 'GPL', 'http://zip.com'), + ('2023-02-08', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174138', 'Abstract 39', 'Author 39', 'Description 39', 'Title 39', 'http://example.com/39', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-09', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174139', 'Abstract 40', 'Author 40', 'Description 40', 'Title 40', 'http://example.com/40', 'API', 'GPL', 'http://zip.com'); + -- Insert more sample data into dataset -INSERT INTO dataset (date, raiting, upvotes, votes, categorie_id, id, abst, author, description, title, url, type, licence, terms_of_use) VALUES -('2023-02-10', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174140', 'Abstract 41', 'Author 41', 'Description 41', 'Title 41', 'http://example.com/41', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-11', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174141', 'Abstract 42', 'Author 42', 'Description 42', 'Title 42', 'http://example.com/42', 'API', 'GPL', 'http://zip.com'), -('2023-02-12', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174142', 'Abstract 43', 'Author 43', 'Description 43', 'Title 43', 'http://example.com/43', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-13', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174143', 'Abstract 44', 'Author 44', 'Description 44', 'Title 44', 'http://example.com/44', 'API', 'GPL', 'http://zip.com'), -('2023-02-14', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174144', 'Abstract 45', 'Author 45', 'Description 45', 'Title 45', 'http://example.com/45', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-15', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174145', 'Abstract 46', 'Author 46', 'Description 46', 'Title 46', 'http://example.com/46', 'API', 'GPL', 'http://zip.com'), -('2023-02-16', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174146', 'Abstract 47', 'Author 47', 'Description 47', 'Title 47', 'http://example.com/47', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-17', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174147', 'Abstract 48', 'Author 48', 'Description 48', 'Title 48', 'http://example.com/48', 'API', 'GPL', 'http://zip.com'), -('2023-02-18', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174148', 'Abstract 49', 'Author 49', 'Description 49', 'Title 49', 'http://example.com/49', 'DATASET', 'GPL', 'http://zip.com'), -('2023-02-19', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174149', 'Abstract 50', 'Author 50', 'Description 50', 'Title 50', 'http://example.com/50', 'API', 'GPL', 'http://zip.com'); \ No newline at end of file +INSERT INTO dataset (date, rating, upvotes, votes, category_id, id, summary, author, description, title, url, type, license, terms_of_use) VALUES + ('2023-02-10', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174140', 'Abstract 41', 'Author 41', 'Description 41', 'Title 41', 'http://example.com/41', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-11', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174141', 'Abstract 42', 'Author 42', 'Description 42', 'Title 42', 'http://example.com/42', 'API', 'GPL', 'http://zip.com'), + ('2023-02-12', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174002', '123e4567-e89b-12d3-a456-426614174142', 'Abstract 43', 'Author 43', 'Description 43', 'Title 43', 'http://example.com/43', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-13', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174003', '123e4567-e89b-12d3-a456-426614174143', 'Abstract 44', 'Author 44', 'Description 44', 'Title 44', 'http://example.com/44', 'API', 'GPL', 'http://zip.com'), + ('2023-02-14', 4.2, 80, 100, '123e4567-e89b-12d3-a456-426614174004', '123e4567-e89b-12d3-a456-426614174144', 'Abstract 45', 'Author 45', 'Description 45', 'Title 45', 'http://example.com/45', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-15', 4.6, 120, 140, '123e4567-e89b-12d3-a456-426614174005', '123e4567-e89b-12d3-a456-426614174145', 'Abstract 46', 'Author 46', 'Description 46', 'Title 46', 'http://example.com/46', 'API', 'GPL', 'http://zip.com'), + ('2023-02-16', 4.8, 180, 200, '123e4567-e89b-12d3-a456-426614174006', '123e4567-e89b-12d3-a456-426614174146', 'Abstract 47', 'Author 47', 'Description 47', 'Title 47', 'http://example.com/47', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-17', 4.3, 90, 110, '123e4567-e89b-12d3-a456-426614174007', '123e4567-e89b-12d3-a456-426614174147', 'Abstract 48', 'Author 48', 'Description 48', 'Title 48', 'http://example.com/48', 'API', 'GPL', 'http://zip.com'), + ('2023-02-18', 4.7, 150, 170, '123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174148', 'Abstract 49', 'Author 49', 'Description 49', 'Title 49', 'http://example.com/49', 'DATASET', 'GPL', 'http://zip.com'), + ('2023-02-19', 4.9, 200, 220, '123e4567-e89b-12d3-a456-426614174001', '123e4567-e89b-12d3-a456-426614174149', 'Abstract 50', 'Author 50', 'Description 50', 'Title 50', 'http://example.com/50', 'API', 'GPL', 'http://zip.com'); diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index d61125c..94f55ff 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -1,7 +1,23 @@ DROP TABLE IF EXISTS dataset; DROP TABLE IF EXISTS category; - create table category (id uuid not null, name varchar(255), primary key (id)); -create table dataset (date date, raiting float(24) not null, upvotes integer not null, votes integer not null, categorie_id uuid, id uuid not null, abst varchar(255), author varchar(255), description varchar(200000), title varchar(255), url varchar(2048), terms_of_use varchar(2048), type enum ('API','DATASET'), licence varchar(255), primary key (id)); -alter table if exists dataset add constraint FKq6qwq6u473f89h71s7rf97ruy foreign key (categorie_id) references category; +create table dataset ( + date date, + rating float(24) not null, + upvotes integer not null, + votes integer not null, + category_id uuid, + id uuid not null, + summary varchar(255), + author varchar(255), + description varchar(200000), + title varchar(255), + url varchar(2048), + terms_of_use varchar(2048), + type enum ('API','DATASET'), + license varchar(255), + primary key (id) +); + +alter table if exists dataset add constraint FKq6qwq6u473f89h71s7rf97ruy foreign key (category_id) references category; diff --git a/src/main/resources/static/add.css b/src/main/resources/static/add.css index 07fe2cb..8acdab5 100644 --- a/src/main/resources/static/add.css +++ b/src/main/resources/static/add.css @@ -130,14 +130,14 @@ form :has(#url) { } } -/* full description box */ -#full-description-box { +/* description box */ +#description-box { grid-column: 1 / -1; align-items: start; flex-direction: column; } -#full-description { +#description { height: 15rem; box-sizing: border-box; } diff --git a/src/main/resources/static/add.html b/src/main/resources/static/add.html index 65378d1..384177a 100644 --- a/src/main/resources/static/add.html +++ b/src/main/resources/static/add.html @@ -41,8 +41,8 @@ - - + + @@ -73,9 +73,9 @@ - - - + + + @@ -86,4 +86,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/static/add.js b/src/main/resources/static/add.js index 819e55e..7adfb86 100644 --- a/src/main/resources/static/add.js +++ b/src/main/resources/static/add.js @@ -5,14 +5,14 @@ const { title: titleEntry, author: authorEntry, ["is-dataset"]: isDatasetSwitch, - ["short-description"]: shortDescriptionEntry, + summary: summaryEntry, url: urlEntry, ["terms-of-use"]: termsOfUseEntry, license: licenseEntry, category: categorySpinner, ["new-category"]: newCategoryEntry, ["change-category-btn"]: changeCategoryBtn, - ["full-description"]: fullDescriptionEntry, + description: descriptionEntry, ["btn-add"]: addBtn, ["btn-cancel"]: cancelBtn, } = form.elements; @@ -26,12 +26,12 @@ const validationListener = () => { [ titleEntry, authorEntry, - shortDescriptionEntry, + summaryEntry, urlEntry, termsOfUseEntry, licenseEntry, newCategoryEntry, - fullDescriptionEntry, + descriptionEntry, ].forEach(input => input.addEventListener("input", validationListener)); // Category spinner @@ -126,14 +126,14 @@ form.addEventListener("submit", async e => { title: titleEntry.value, author: authorEntry.value, type: isDatasetSwitch.checked ? "API" : "DATASET", - abst: shortDescriptionEntry.value, + summary: summaryEntry.value, url: urlEntry.value, termsOfUse: termsOfUseEntry.value, - licence: licenseEntry.value, - categorie: { + license: licenseEntry.value, + category: { id: categoryID, }, - description: fullDescriptionEntry.value, + description: descriptionEntry.value, }; // Don't allow several requests to be sent at the same time diff --git a/src/main/resources/static/dataset.js b/src/main/resources/static/dataset.js index 87984cd..2bdfc47 100644 --- a/src/main/resources/static/dataset.js +++ b/src/main/resources/static/dataset.js @@ -3,11 +3,11 @@ import { DATASET_ENDPOINT, getBaseURL } from "./constants.js"; export default class Dataset { static #datasets = new Map(); - #shortDescription; + #summary; #author; #category; #date; - #fullDescription; + #description; #id; #rating; #title; @@ -23,14 +23,14 @@ export default class Dataset { return this.#datasets.get(id); } - constructor({ abst: shortDescription, author, categorie, date, description, id, raiting, title, type, upvotes, url, votes, licence: license, termsOfUse }) { - this.#shortDescription = shortDescription; + constructor({ summary, author, category, date, description, id, rating, title, type, upvotes, url, votes, license, termsOfUse }) { + this.#summary = summary; this.#author = author; - this.#category = categorie; + this.#category = category; this.#date = date; - this.#fullDescription = description; + this.#description = description; this.#id = id; - this.#rating = raiting; + this.#rating = rating; this.#title = title; this.#type = type; this.#upvotes = upvotes; @@ -43,8 +43,8 @@ export default class Dataset { } // Getters - get shortDescription() { - return this.#shortDescription; + get summary() { + return this.#summary; } get author() { @@ -59,8 +59,8 @@ export default class Dataset { return this.#date; } - get fullDescription() { - return this.#fullDescription; + get description() { + return this.#description; } get id() { @@ -130,7 +130,7 @@ export default class Dataset { } }) clone.querySelector(".dataset-title").innerText = this.#title; - clone.querySelector(".dataset-description").innerText = this.#shortDescription; + clone.querySelector(".dataset-description").innerText = this.#summary; clone.querySelector(".upvote-count").innerText = this.#upvotes; this.#elements.push(clone.children[0]); diff --git a/src/main/resources/static/details.css b/src/main/resources/static/details.css index 18f1083..738ed30 100644 --- a/src/main/resources/static/details.css +++ b/src/main/resources/static/details.css @@ -74,7 +74,7 @@ h1 { } } -#details summary, #url { +#details :has(#summary), #url { text-align: start; grid-column: 1 / 3; } @@ -146,13 +146,13 @@ a { gap: var(--gap-large); } -#full-description { +#description { text-wrap: balance; text-wrap: pretty; margin-top: 0; } -:is(#full-description, #not-found) br { +:is(#description, #not-found) br { margin-bottom: .5lh; } diff --git a/src/main/resources/static/details.html b/src/main/resources/static/details.html index 9d14c0b..ab00bc5 100644 --- a/src/main/resources/static/details.html +++ b/src/main/resources/static/details.html @@ -22,11 +22,11 @@

Title

- +
4 - Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis recusandae laborum odio corrupti voluptas quisquam dicta, quibusdam ipsum qui exercitationem. -
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis recusandae laborum odio corrupti voluptas quisquam dicta, quibusdam ipsum qui exercitationem. + https://example.com/dataset
- \ No newline at end of file + diff --git a/src/main/resources/static/details.js b/src/main/resources/static/details.js index 9a5cc97..9b775e6 100644 --- a/src/main/resources/static/details.js +++ b/src/main/resources/static/details.js @@ -6,13 +6,13 @@ const notFoundPage = document.getElementById("not-found"); const title = document.getElementById("title"); const rating = document.getElementById("rating"); const ratingText = document.getElementById("rating-text"); -const shortDescription = document.getElementById("short-description"); +const summary = document.getElementById("summary"); const url = document.getElementById("url"); const date = document.getElementById("date"); const category = document.getElementById("category"); const license = document.getElementById("license"); const termsOfUse = document.getElementById("terms-of-use"); -const fullDescription = document.getElementById("full-description"); +const description = document.getElementById("description"); const backButton = document.getElementById("back-btn"); const deleteButton = document.getElementById("delete-btn"); @@ -37,7 +37,7 @@ if (currentLocation.searchParams.has("id")) { title.dataset.type = dataset.type.toLowerCase(); rating.value = dataset.rating; ratingText.innerText = parseFloat(dataset.rating).toFixed(1); - shortDescription.innerText = dataset.shortDescription; + summary.innerText = dataset.summary; url.href = dataset.url; url.innerText = dataset.url; mainPage.querySelector(".upvote").replaceWith(upvoteComponent); @@ -53,7 +53,7 @@ if (currentLocation.searchParams.has("id")) { license.innerText = dataset.license; termsOfUse.href = dataset.termsOfUse; - fullDescription.innerText = dataset.fullDescription; + description.innerText = dataset.description; mainPage.classList.remove("skeleton"); } else { @@ -113,4 +113,4 @@ rating.addEventListener("click", async () => { rating.value = dataset.rating; } } -}) +}); diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 07cd93d..e963fc0 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -45,8 +45,8 @@ - - + + diff --git a/src/main/resources/static/main.js b/src/main/resources/static/main.js index de5083b..a48586d 100644 --- a/src/main/resources/static/main.js +++ b/src/main/resources/static/main.js @@ -16,8 +16,6 @@ const searchButton = document.getElementById("search-btn"); const searchBar = document.getElementById("search-entry"); const sortButton = document.getElementById("sort-btn"); const resetButton = document.getElementById("reset-tools-btn"); -const upvoteButtons = document.getElementsByClassName("upvote-btn"); -const downvoteButtons = document.getElementsByClassName("downvote-btn"); export const searchSection = document.getElementById("search"); const recentSection = document.getElementById("recents"); const mostLikedSection = document.getElementById("top"); @@ -27,22 +25,10 @@ export let searchBarTimeout; const searchDelay = 500; // Event listeners -addButton.addEventListener("click", () => { - navigateToAdd(); -}); - -filterButton.addEventListener("change", () => { - fetchQuery(createQuery(), true); -}); - -filterButton.addEventListener("click", () => { - fetchCategories(); -}) - -searchButton.addEventListener("click", () => { - fetchQuery(createQuery(), true); - -}); +addButton.addEventListener("click", () => location.assign("/add.html")); +filterButton.addEventListener("change", () => fetchQuery(createQuery(), true)); +filterButton.addEventListener("click", () => fetchCategories()); +searchButton.addEventListener("click", () => fetchQuery(createQuery(), true)); searchBar.addEventListener("input", () => { clearTimeout(searchBarTimeout); @@ -52,15 +38,13 @@ searchBar.addEventListener("input", () => { }, searchDelay); }); -searchBar.addEventListener('keypress', function (e) { +searchBar.addEventListener('keypress', e => { if (e.key === 'Enter') { fetchQuery(createQuery(), true); } }); -sortButton.addEventListener("change", () => { - fetchQuery(createQuery(), true); -}); +sortButton.addEventListener("change", () => fetchQuery(createQuery(), true)); resetButton.addEventListener("click", () => { searchBar.value = ""; @@ -70,10 +54,6 @@ resetButton.addEventListener("click", () => { }); // functions of the main page -function navigateToAdd() { - window.location.href = "/add.html"; //TODO: move to EventListener? -} - function getFilterQuery() { let filterString = filterButton.value.toUpperCase(); if (filterString === "NONE") { diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplicationTests.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplicationTests.java index 1da58ca..92ab2c2 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplicationTests.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/DataDashApplicationTests.java @@ -5,9 +5,6 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class DataDashApplicationTests { - @Test - void contextLoads() { - } - + void contextLoads() {} } diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DataRepositoryTests.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DataRepositoryTests.java index 3a8fa41..a887939 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DataRepositoryTests.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DataRepositoryTests.java @@ -13,9 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest public class DataRepositoryTests { - @Autowired - private dataRepository dataRepository; + private DatasetRepository dataRepository; @BeforeEach private void clearDatabase() { @@ -25,7 +24,7 @@ public class DataRepositoryTests { @Test public void testFindByOptionalCriteria() { // Prepare test data - Dataset dataset = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset); // Execute the method under test @@ -39,11 +38,11 @@ public class DataRepositoryTests { } @Test public void searchByOptionalCriteria() { - Dataset dataset1 = new Dataset("water", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset1 = new Dataset("water", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset1); - Dataset dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset); - dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT"); + dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset); Page result = dataRepository.searchByOptionalCriteria( @@ -54,11 +53,11 @@ public class DataRepositoryTests { } @Test public void searchByOptionalCriteriaMulti() { - Dataset dataset1 = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset1 = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset1); - Dataset dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset); - dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT"); + dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataRepository.save(dataset); Page result = dataRepository.searchByOptionalCriteria( @@ -69,7 +68,7 @@ public class DataRepositoryTests { @Test public void getDatasetById() { - Dataset dataset = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT"); dataset = dataRepository.save(dataset); Dataset result = dataRepository.getDatasetById(dataset.getId()); @@ -77,4 +76,4 @@ public class DataRepositoryTests { assertThat(result).isNotNull(); assertThat(result.getTitle()).isEqualTo("title"); } -} \ No newline at end of file +} diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetControllerTests.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetControllerTests.java index 87bb850..61d2a20 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetControllerTests.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetControllerTests.java @@ -30,7 +30,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(DatasetController.class) public class DatasetControllerTests { - @Autowired private MockMvc mockMvc; @@ -40,12 +39,12 @@ public class DatasetControllerTests { @Autowired private ObjectMapper objectMapper = new ObjectMapper(); - private Dataset d = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + private Dataset d = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); @Test void getDatasetById_whenExists() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); mockMvc.perform(get("/api/v1/datasets/id/" + id.toString())) @@ -74,7 +73,7 @@ public class DatasetControllerTests { @Test void deleteDataset_whenExists() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); mockMvc.perform(delete("/api/v1/datasets/id/" + id.toString())) @@ -93,7 +92,7 @@ public class DatasetControllerTests { @Test void upvote_whenExists() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); doAnswer(invocation -> { dataset.upvote(); // Directly modify the dataset @@ -121,7 +120,7 @@ public class DatasetControllerTests { @Test void downvote_whenExists() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); doAnswer(invocation -> { dataset.downvote(); // Directly modify the dataset @@ -149,7 +148,7 @@ public class DatasetControllerTests { @Test void postMethodName_whenExists() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); doAnswer(invocation -> { dataset.vote(3); // Directly modify the dataset @@ -162,7 +161,7 @@ public class DatasetControllerTests { .andExpect(status().isOk()) .andExpect(content().json(objectMapper.writeValueAsString(dataset))); - assertEquals(3, dataset.getRaiting()); // Assuming getVotes() method exists and initial votes are 0 + assertEquals(3, dataset.getRating()); // Assuming getVotes() method exists and initial votes are 0 } @Test @@ -177,7 +176,7 @@ public class DatasetControllerTests { @Test void postMethodName_whenInvalidStars() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); @@ -188,7 +187,7 @@ public class DatasetControllerTests { @Test void postMethodName_whenInvalidStars3() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); @@ -199,7 +198,7 @@ public class DatasetControllerTests { @Test void postMethodName_whenInvalidStars4() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); @@ -210,7 +209,7 @@ public class DatasetControllerTests { @Test void postMethodName_whenInvalidStars5() throws Exception { UUID id = UUID.randomUUID(); - Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT"); + Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT"); given(datasetService.getDatasetById(id)).willReturn(dataset); @@ -222,7 +221,7 @@ public class DatasetControllerTests { void searchDatasets_whenExists() throws Exception { String keyword = "title%"; List datasets = Arrays.asList( - new Dataset("Title 1", "abst", "data", "auth", null, null, Type.API, "MIT")); + new Dataset("Title 1", "summary", "data", "auth", null, null, Type.API, "MIT")); // new Dataset("Title 2", "abst", "data", "auth", null, null, Type.API, "MIT")); Page page = new PageImpl<>(datasets); @@ -293,5 +292,4 @@ public class DatasetControllerTests { mockMvc.perform(get("/api/v1/datasets/search?search=" + keyword + "&size=0")) .andExpect(status().isBadRequest()); } - -} \ No newline at end of file +} diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetServiceTest.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetServiceTest.java index 98e0ff4..2846b2e 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetServiceTest.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/Dataset/DatasetServiceTest.java @@ -25,7 +25,7 @@ import java.util.UUID; class DatasetServiceTest { @Mock - private dataRepository datasetRepository; + private DatasetRepository datasetRepository; @Mock private CategoryRepository categoryRepository; @@ -60,7 +60,7 @@ class DatasetServiceTest { datasetService.voteDataset(id, 5); verify(datasetRepository).save(dataset); assertEquals(1, dataset.getVotes()); - assertEquals(5, dataset.getRaiting()); + assertEquals(5, dataset.getRating()); } @Test @@ -120,4 +120,4 @@ class DatasetServiceTest { } // Additional tests for other methods can be added following the same pattern. -} \ No newline at end of file +} diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryControllerTest.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryControllerTest.java index d977563..bd570ab 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryControllerTest.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryControllerTest.java @@ -19,7 +19,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(CategoryController.class) public class CategoryControllerTest { - @Autowired private MockMvc mockMvc; @@ -38,8 +37,8 @@ public class CategoryControllerTest { given(categoryService.getAllCategories()).willReturn(Arrays.asList(category1, category2)); mockMvc.perform(get("/api/v1/categories")) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(Arrays.asList(category1, category2)))); + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(Arrays.asList(category1, category2)))); } @Test @@ -49,8 +48,8 @@ public class CategoryControllerTest { given(categoryService.getCategoryById(id)).willReturn(category); mockMvc.perform(get("/api/v1/categories/id/{id}", id)) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(category))); + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(category))); } @Test @@ -58,18 +57,18 @@ public class CategoryControllerTest { UUID id = UUID.randomUUID(); given(categoryService.getCategoryById(id)).willReturn(null); - mockMvc.perform(get("/api/v1/categories/id/{id}", id)) - .andExpect(status().isNotFound()); + mockMvc.perform(get("/api/v1/categories/id/{id}", id)).andExpect(status().isNotFound()); } @Test public void testCreateCategory() throws Exception { CategoryDto categoryDto = CategoryDtoMapper.toDto(category); mockMvc.perform(post("/api/v1/categories") - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(categoryDto))) - .andExpect(status().isCreated()); + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(categoryDto))) + .andExpect(status().isCreated()); + // Verify that the service method was called once verify(categoryService).addCategory(any(CategoryDto.class)); } -} \ No newline at end of file +} diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepositoryTests.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepositoryTests.java index 2330d6c..c6bae1a 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepositoryTests.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryRepositoryTests.java @@ -12,10 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest public class CategoryRepositoryTests { - @Autowired private CategoryRepository categoryRepository; - private Category savedCategory; @BeforeEach @@ -53,4 +51,4 @@ public class CategoryRepositoryTests { assertThat(foundCategory).isNotNull(); assertThat(foundCategory.getId()).isEqualTo(savedCategory.getId()); } -} \ No newline at end of file +} diff --git a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryServiceTest.java b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryServiceTest.java index a06d189..e2aee76 100644 --- a/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryServiceTest.java +++ b/src/test/java/de/uni_passau/fim/PADAS/group3/DataDash/category/CategoryServiceTest.java @@ -14,7 +14,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class CategoryServiceTest { - @Mock private CategoryRepository categoryRepository; @@ -65,4 +64,4 @@ public class CategoryServiceTest { assertNull(result); } -} \ No newline at end of file +}