Fix typos and break stuff

This commit is contained in:
Elias Schriefer 2024-07-08 16:37:13 +02:00
parent b305a76c58
commit 5fa28f80c4
31 changed files with 262 additions and 358 deletions

View File

@ -5,9 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class DataDashApplication { public class DataDashApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DataDashApplication.class, args); SpringApplication.run(DataDashApplication.class, args);
} }
} }

View File

@ -21,72 +21,61 @@ import jakarta.persistence.ManyToOne;
@Entity @Entity
public class Dataset { public class Dataset {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private UUID id; private UUID id;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private Type type; private Type type;
private String title; private String title;
private String summary;
private String abst;
private String description; private String description;
private String author; private String author;
private String license;
private Date date; private Date date;
private float rating;
private float raiting;
private int votes; private int votes;
private int upvotes; private int upvotes;
private URL url; private URL url;
@ManyToOne
private Category category;
@Column(name = "terms_of_use") @Column(name = "terms_of_use")
private URL termsOfUse; private URL termsOfUse;
private String licence; private static final List<String> sortable = Arrays.asList(
"author", "title", "upvotes", "rating", "date"
);
private static final List<String> sortable = Arrays.asList("author", "title", "upvotes", "raiting", "date"); public Dataset(String title, String summary, String description, String author, URL url, Category category, Type type, String license) {
this.rating = 0;
@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;
this.votes = 0; this.votes = 0;
this.upvotes = 0; this.upvotes = 0;
setTitle(title); setTitle(title);
setAbst(abst); setSummary(summary);
setDescription(description); setDescription(description);
setAuthor(author); setAuthor(author);
setDate(LocalDate.now()); setDate(LocalDate.now());
setCategorie(categories); setCategory(category);
setType(type); setType(type);
setUrl(url); setUrl(url);
setLicence(licence); setLicense(license);
} }
public Dataset() { public Dataset() {}
}
public String getSummary() {
public String getAbst() { return summary;
return abst;
} }
public String getAuthor() { public String getAuthor() {
return author; return author;
} }
public Category getCategorie() { public Category getCategory() {
return categorie; return category;
} }
public LocalDate getDate() { public LocalDate getDate() {
@ -101,8 +90,8 @@ public class Dataset {
return id; return id;
} }
public float getRaiting() { public float getRating() {
return raiting; return rating;
} }
public String getTitle() { public String getTitle() {
@ -129,42 +118,42 @@ public class Dataset {
return termsOfUse; return termsOfUse;
} }
public String getLicence() { public String getLicense() {
return licence; return license;
} }
public static List<String> getSort() { public static List<String> getSort() {
return sortable; return sortable;
} }
public void setAbst(String abst) { public void setSummary(String summary) {
this.abst = abst.substring(0, Math.min(abst.length(), 100)); this.summary = summary.substring(0, Math.min(summary.length(), 100));
} }
public void setAuthor(String author) { public void setAuthor(String author) {
this.author = author; this.author = author;
} }
public void setCategorie(Category categories) { public void setCategory(Category category) {
this.categorie = categories; this.category = category;
} }
public void setDate(LocalDate localDate) { public void setDate(LocalDate localDate) {
this.date = Date.valueOf(localDate); this.date = Date.valueOf(localDate);
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public void setUrl(URL url) { public void setUrl(URL url) {
this.url = url; this.url = url;
} }
public void setTermsOfUse(URL termsOfUse) { public void setTermsOfUse(URL termsOfUse) {
this.termsOfUse = termsOfUse; this.termsOfUse = termsOfUse;
} }
public void setTitle(String title) { public void setTitle(String title) {
this.title = title.substring(0, Math.min(title.length(), 50)); this.title = title.substring(0, Math.min(title.length(), 50));
} }
@ -172,9 +161,9 @@ public class Dataset {
public void setType(Type type) { public void setType(Type type) {
this.type = type; this.type = type;
} }
public void vote(int stars) { public void vote(int stars) {
raiting = (raiting*votes + stars) / (++votes); rating = (rating * votes + stars) / (++votes);
} }
public void upvote() { public void upvote() {
@ -185,8 +174,7 @@ public class Dataset {
upvotes--; upvotes--;
} }
public void setLicence(String licence) { public void setLicense(String license) {
this.licence = licence; this.license = license;
} }
} }

View File

@ -25,10 +25,9 @@ public class DatasetController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<Dataset> getDatasetById(@PathVariable("id") UUID id) { public ResponseEntity<Dataset> getDatasetById(@PathVariable("id") UUID id) {
Dataset d = datasetService.getDatasetById(id); Dataset d = datasetService.getDatasetById(id);
if (d == null) { return d == null
return new ResponseEntity<>(HttpStatus.NOT_FOUND); ? new ResponseEntity<>(HttpStatus.NOT_FOUND)
} : new ResponseEntity<>(d, HttpStatus.OK);
return new ResponseEntity<>(d, HttpStatus.OK);
} }
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ -42,6 +41,7 @@ public class DatasetController {
if (datasetService.getDatasetById(id) == null) { if (datasetService.getDatasetById(id) == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
datasetService.deleteDataset(id); datasetService.deleteDataset(id);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@ -61,44 +61,52 @@ public class DatasetController {
if (datasetService.getDatasetById(id) == null) { if (datasetService.getDatasetById(id) == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
datasetService.downvoteDataset(id); datasetService.downvoteDataset(id);
return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK); return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK);
} }
@PutMapping("/id/{id}/stars") @PutMapping("/id/{id}/stars")
public ResponseEntity<Dataset> postMethodName(@PathVariable("id") UUID id, public ResponseEntity<Dataset> postMethodName(
@RequestParam("stars") int stars) { @PathVariable("id") UUID id,
@RequestParam("stars") int stars
) {
if (datasetService.getDatasetById(id) == null) { if (datasetService.getDatasetById(id) == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} } else if (!(stars >= 0 && stars < 6)) {
if (!(stars >= 0 && stars < 6)) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
} }
datasetService.voteDataset(id, stars); datasetService.voteDataset(id, stars);
return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK); return new ResponseEntity<>(datasetService.getDatasetById(id), HttpStatus.OK);
} }
@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,
@RequestParam(value = "page", required = false, defaultValue = "0") int page, @RequestParam(value = "page", required = false, defaultValue = "0") int page,
@RequestParam(value = "size", required = false, defaultValue = "20") int size, @RequestParam(value = "size", required = false, defaultValue = "20") int size,
@RequestParam(value = "sort", required = false, defaultValue = "upvotes") String sort, @RequestParam(value = "sort", required = false, defaultValue = "upvotes") String sort,
@RequestParam(value = "direction", required = false, defaultValue = "desc") String direction, @RequestParam(value = "direction", required = false, defaultValue = "desc") String direction,
@RequestParam(value = "category", required = false, defaultValue = "%") String category, @RequestParam(value = "category", required = false, defaultValue = "%") String category,
@RequestParam(value = "type", required = false, defaultValue = "%") String type) { @RequestParam(value = "type", required = false, defaultValue = "%") String type
) {
Pageable pageable = null; Pageable pageable = null;
if (!Dataset.getSort().contains(sort)) if (!Dataset.getSort().contains(sort)) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
try { try {
pageable = PageRequest.of(page, size, pageable = PageRequest.of(page, size, Sort.by(
Sort.by(Sort.Direction.fromString(direction), sort)); Sort.Direction.fromString(direction), sort)
);
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
} }
return new ResponseEntity<>(datasetService.searchByOptionalCriteria(search, category, type, pageable), return new ResponseEntity<>(
HttpStatus.OK); datasetService.searchByOptionalCriteria(search, category, type, pageable),
HttpStatus.OK
);
} }
}
}

View File

@ -14,10 +14,10 @@ import org.springframework.data.domain.Page;
@Service @Service
public class DatasetService { public class DatasetService {
private dataRepository datasetRepository; private DatasetRepository datasetRepository;
private CategoryRepository categoryRepository; private CategoryRepository categoryRepository;
DatasetService(dataRepository datasetRepository, CategoryRepository categoryRepository) { DatasetService(DatasetRepository datasetRepository, CategoryRepository categoryRepository) {
this.datasetRepository = datasetRepository; this.datasetRepository = datasetRepository;
this.categoryRepository = categoryRepository; this.categoryRepository = categoryRepository;
} }
@ -54,17 +54,18 @@ public class DatasetService {
datasetRepository.save(dataset); datasetRepository.save(dataset);
} }
Page<Dataset> searchByOptionalCriteria(String search, String categories, String type, Pageable pageable) { Page<Dataset> searchByOptionalCriteria(String search, String categoryID, String type, Pageable pageable) {
Category category = categories.equals("%") ? null Category category = categoryID.equals("%")
: categoryRepository.getCategoryById(UUID.fromString(categories)); ? null
: categoryRepository.getCategoryById(UUID.fromString(categoryID));
Type t = type.equals("%") ? null : Type.valueOf(type); Type t = type.equals("%") ? null : Type.valueOf(type);
if (category == null) { return category == null
return datasetRepository.searchByOptionalCriteria(Optional.ofNullable(search), Optional.ofNullable(t), ? datasetRepository.searchByOptionalCriteria(
pageable); Optional.ofNullable(search), Optional.ofNullable(t), pageable
} )
return datasetRepository.searchByOptionalCriteriaWithCategory(Optional.ofNullable(search), category, : datasetRepository.searchByOptionalCriteriaWithCategory(
Optional.ofNullable(t), pageable); Optional.ofNullable(search), category, Optional.ofNullable(t), pageable
);
} }
}
}

View File

@ -3,4 +3,4 @@ package de.uni_passau.fim.PADAS.group3.DataDash.Dataset;
public enum Type { public enum Type {
DATASET, DATASET,
API API
} }

View File

@ -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, UUID> {
Dataset getDatasetById(UUID id);
@SuppressWarnings("null")
Page<Dataset> 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<Dataset> findByOptionalCriteria(@Param("title") Optional<String> title,
@Param("description") Optional<String> description,
@Param("author") Optional<String> author,
@Param("abst") Optional<String> abst,
@Param("type") Optional<Type> type,
@Param("categorie") Optional<Category> categories,
@Param("raiting") Optional<Float> 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<Dataset> searchByOptionalCriteriaWithCategory(@Param("search") Optional<String> search,
@Param("categorie") Category categories,
@Param("type") Optional<Type> 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<Dataset> searchByOptionalCriteria(@Param("search") Optional<String> search,
@Param("type") Optional<Type> type,
Pageable pageable);
}

View File

@ -4,10 +4,8 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer { public class ServletInitializer extends SpringBootServletInitializer {
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DataDashApplication.class); return application.sources(DataDashApplication.class);
} }
} }

View File

@ -14,13 +14,11 @@ import jakarta.persistence.OneToMany;
@Entity @Entity
public class Category { public class Category {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private UUID id; private UUID id;
private String name; private String name;
@Lazy @Lazy
@OneToMany(mappedBy = "categorie") @OneToMany(mappedBy = "categorie")
private List<Dataset> datasets; private List<Dataset> datasets;

View File

@ -13,9 +13,6 @@ import org.springframework.web.bind.annotation.PathVariable;
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;
@RestController @RestController
@RequestMapping("/api/v1/categories") @RequestMapping("/api/v1/categories")
public class CategoryController { public class CategoryController {
@ -30,16 +27,14 @@ public class CategoryController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> fetchCategoryById(@PathVariable("id") UUID id) { public ResponseEntity<?> fetchCategoryById(@PathVariable("id") UUID id) {
CategoryDto category = categoryService.getCategoryById(id); CategoryDto category = categoryService.getCategoryById(id);
if(category == null) { return category == null
return new ResponseEntity<>(HttpStatus.NOT_FOUND); ? new ResponseEntity<>(HttpStatus.NOT_FOUND)
} :new ResponseEntity<>(category, HttpStatus.OK);
return new ResponseEntity<>(category, HttpStatus.OK);
} }
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@PostMapping @PostMapping
public Category createCategory(@RequestBody CategoryDto dto) { public Category createCategory(@RequestBody CategoryDto dto) {
return categoryService.addCategory(dto); return categoryService.addCategory(dto);
} }
} }

View File

@ -3,19 +3,16 @@ package de.uni_passau.fim.PADAS.group3.DataDash.category;
import java.util.UUID; import java.util.UUID;
public class CategoryDto { public class CategoryDto {
private String name; private String name;
private UUID id; private UUID id;
public CategoryDto() { public CategoryDto() {}
}
CategoryDto(String name, UUID id) { CategoryDto(String name, UUID id) {
this.name = name; this.name = name;
this.id = id; this.id = id;
} }
public String getName() { public String getName() {
return name; return name;
} }
@ -24,4 +21,3 @@ public class CategoryDto {
return id; return id;
} }
} }

View File

@ -1,10 +1,7 @@
package de.uni_passau.fim.PADAS.group3.DataDash.category; package de.uni_passau.fim.PADAS.group3.DataDash.category;
public class CategoryDtoMapper { public class CategoryDtoMapper {
public static CategoryDto toDto(Category category) { public static CategoryDto toDto(Category category) {
CategoryDto dto = new CategoryDto(category.getName(), category.getId()); return new CategoryDto(category.getName(), category.getId());
return dto;
} }
} }

View File

@ -8,13 +8,12 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface CategoryRepository extends JpaRepository<Category, UUID>{ public interface CategoryRepository extends JpaRepository<Category, UUID>{
Category getCategoryById(UUID id); Category getCategoryById(UUID id);
@SuppressWarnings("null") @SuppressWarnings("null")
List<Category> findAll(); List<Category> findAll();
List<Category> findByName(String name); List<Category> findByName(String name);
@SuppressWarnings("null") @SuppressWarnings("null")
Optional<Category> findById(UUID id); Optional<Category> findById(UUID id);
}
}

View File

@ -25,10 +25,6 @@ public class CategoryService {
CategoryDto getCategoryById(UUID id) { CategoryDto getCategoryById(UUID id) {
Category c = categoryRepository.getCategoryById(id); Category c = categoryRepository.getCategoryById(id);
if (c == null) { return c == null ? null : CategoryDtoMapper.toDto(c);
return null;
}
return CategoryDtoMapper.toDto(c);
} }
} }

View File

@ -1,64 +1,65 @@
-- Insert sample data into category -- Insert sample data into category
INSERT INTO category (id, name) VALUES INSERT INTO category (id, name) VALUES
('123e4567-e89b-12d3-a456-426614174003', 'Business'), ('123e4567-e89b-12d3-a456-426614174003', 'Business'),
('123e4567-e89b-12d3-a456-426614174004', 'Education'), ('123e4567-e89b-12d3-a456-426614174004', 'Education'),
('123e4567-e89b-12d3-a456-426614174005', 'Sports'), ('123e4567-e89b-12d3-a456-426614174005', 'Sports'),
('123e4567-e89b-12d3-a456-426614174006', 'Entertainment'), ('123e4567-e89b-12d3-a456-426614174006', 'Entertainment'),
('123e4567-e89b-12d3-a456-426614174007', 'Art'), ('123e4567-e89b-12d3-a456-426614174007', 'Art'),
('123e4567-e89b-12d3-a456-426614174000', 'Science'), ('123e4567-e89b-12d3-a456-426614174000', 'Science'),
('123e4567-e89b-12d3-a456-426614174001', 'Technology'), ('123e4567-e89b-12d3-a456-426614174001', 'Technology'),
('123e4567-e89b-12d3-a456-426614174002', 'Health'); ('123e4567-e89b-12d3-a456-426614174002', 'Health');
-- Insert sample data into dataset -- 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 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-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-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-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-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-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-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-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-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-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-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-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-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'), ('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'), ('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'), ('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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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'); ('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 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 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-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-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-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-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-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-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-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-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-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'); ('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');

View File

@ -1,7 +1,23 @@
DROP TABLE IF EXISTS dataset; DROP TABLE IF EXISTS dataset;
DROP TABLE IF EXISTS category; DROP TABLE IF EXISTS category;
create table category (id uuid not null, name varchar(255), primary key (id)); 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)); create table dataset (
alter table if exists dataset add constraint FKq6qwq6u473f89h71s7rf97ruy foreign key (categorie_id) references category; 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;

View File

@ -130,14 +130,14 @@ form :has(#url) {
} }
} }
/* full description box */ /* description box */
#full-description-box { #description-box {
grid-column: 1 / -1; grid-column: 1 / -1;
align-items: start; align-items: start;
flex-direction: column; flex-direction: column;
} }
#full-description { #description {
height: 15rem; height: 15rem;
box-sizing: border-box; box-sizing: border-box;
} }

View File

@ -41,8 +41,8 @@
</span> </span>
<span> <span>
<label for="short-description">Short description</label> <label for="summary">Short description</label>
<input type="text" name="short-description" id="short-description" size="3" maxlength="100" required spellcheck="true"> <input type="text" name="summary" id="summary" size="3" maxlength="100" required spellcheck="true">
</span> </span>
<span> <span>
@ -73,9 +73,9 @@
</span> </span>
</span> </span>
<span id="full-description-box"> <span id="description-box">
<label for="full-description">Full description</label> <label for="description">Full description</label>
<textarea name="full-description" id="full-description" cols="3" spellcheck="true"></textarea> <textarea name="description" id="description" cols="3" spellcheck="true"></textarea>
</span> </span>
<span id="btn-bar"> <span id="btn-bar">
@ -86,4 +86,4 @@
</section> </section>
</main> </main>
</body> </body>
</html> </html>

View File

@ -5,14 +5,14 @@ const {
title: titleEntry, title: titleEntry,
author: authorEntry, author: authorEntry,
["is-dataset"]: isDatasetSwitch, ["is-dataset"]: isDatasetSwitch,
["short-description"]: shortDescriptionEntry, summary: summaryEntry,
url: urlEntry, url: urlEntry,
["terms-of-use"]: termsOfUseEntry, ["terms-of-use"]: termsOfUseEntry,
license: licenseEntry, license: licenseEntry,
category: categorySpinner, category: categorySpinner,
["new-category"]: newCategoryEntry, ["new-category"]: newCategoryEntry,
["change-category-btn"]: changeCategoryBtn, ["change-category-btn"]: changeCategoryBtn,
["full-description"]: fullDescriptionEntry, description: descriptionEntry,
["btn-add"]: addBtn, ["btn-add"]: addBtn,
["btn-cancel"]: cancelBtn, ["btn-cancel"]: cancelBtn,
} = form.elements; } = form.elements;
@ -26,12 +26,12 @@ const validationListener = () => {
[ [
titleEntry, titleEntry,
authorEntry, authorEntry,
shortDescriptionEntry, summaryEntry,
urlEntry, urlEntry,
termsOfUseEntry, termsOfUseEntry,
licenseEntry, licenseEntry,
newCategoryEntry, newCategoryEntry,
fullDescriptionEntry, descriptionEntry,
].forEach(input => input.addEventListener("input", validationListener)); ].forEach(input => input.addEventListener("input", validationListener));
// Category spinner // Category spinner
@ -126,14 +126,14 @@ form.addEventListener("submit", async e => {
title: titleEntry.value, title: titleEntry.value,
author: authorEntry.value, author: authorEntry.value,
type: isDatasetSwitch.checked ? "API" : "DATASET", type: isDatasetSwitch.checked ? "API" : "DATASET",
abst: shortDescriptionEntry.value, summary: summaryEntry.value,
url: urlEntry.value, url: urlEntry.value,
termsOfUse: termsOfUseEntry.value, termsOfUse: termsOfUseEntry.value,
licence: licenseEntry.value, license: licenseEntry.value,
categorie: { category: {
id: categoryID, id: categoryID,
}, },
description: fullDescriptionEntry.value, description: descriptionEntry.value,
}; };
// Don't allow several requests to be sent at the same time // Don't allow several requests to be sent at the same time

View File

@ -3,11 +3,11 @@ import { DATASET_ENDPOINT, getBaseURL } from "./constants.js";
export default class Dataset { export default class Dataset {
static #datasets = new Map(); static #datasets = new Map();
#shortDescription; #summary;
#author; #author;
#category; #category;
#date; #date;
#fullDescription; #description;
#id; #id;
#rating; #rating;
#title; #title;
@ -23,14 +23,14 @@ export default class Dataset {
return this.#datasets.get(id); return this.#datasets.get(id);
} }
constructor({ abst: shortDescription, author, categorie, date, description, id, raiting, title, type, upvotes, url, votes, licence: license, termsOfUse }) { constructor({ summary, author, category, date, description, id, rating, title, type, upvotes, url, votes, license, termsOfUse }) {
this.#shortDescription = shortDescription; this.#summary = summary;
this.#author = author; this.#author = author;
this.#category = categorie; this.#category = category;
this.#date = date; this.#date = date;
this.#fullDescription = description; this.#description = description;
this.#id = id; this.#id = id;
this.#rating = raiting; this.#rating = rating;
this.#title = title; this.#title = title;
this.#type = type; this.#type = type;
this.#upvotes = upvotes; this.#upvotes = upvotes;
@ -43,8 +43,8 @@ export default class Dataset {
} }
// Getters // Getters
get shortDescription() { get summary() {
return this.#shortDescription; return this.#summary;
} }
get author() { get author() {
@ -59,8 +59,8 @@ export default class Dataset {
return this.#date; return this.#date;
} }
get fullDescription() { get description() {
return this.#fullDescription; return this.#description;
} }
get id() { get id() {
@ -130,7 +130,7 @@ export default class Dataset {
} }
}) })
clone.querySelector(".dataset-title").innerText = this.#title; 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; clone.querySelector(".upvote-count").innerText = this.#upvotes;
this.#elements.push(clone.children[0]); this.#elements.push(clone.children[0]);

View File

@ -74,7 +74,7 @@ h1 {
} }
} }
#details summary, #url { #details :has(#summary), #url {
text-align: start; text-align: start;
grid-column: 1 / 3; grid-column: 1 / 3;
} }
@ -146,13 +146,13 @@ a {
gap: var(--gap-large); gap: var(--gap-large);
} }
#full-description { #description {
text-wrap: balance; text-wrap: balance;
text-wrap: pretty; text-wrap: pretty;
margin-top: 0; margin-top: 0;
} }
:is(#full-description, #not-found) br { :is(#description, #not-found) br {
margin-bottom: .5lh; margin-bottom: .5lh;
} }

View File

@ -22,11 +22,11 @@
<main id="details" class="skeleton"> <main id="details" class="skeleton">
<header data-id="dataset-id"> <header data-id="dataset-id">
<h1 id="title" data-type="api">Title</h1> <h1 id="title" data-type="api">Title</h1>
<summary> <div>
<span id="rating-text">4</span><meter id="rating" value="4" max="5"></meter> <span id="rating-text">4</span><meter id="rating" value="4" max="5"></meter>
<span id="rating-input"></span> <span id="rating-input"></span>
<span id="short-description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis recusandae laborum odio corrupti voluptas quisquam dicta, quibusdam ipsum qui exercitationem.</span> <span id="summary">Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis recusandae laborum odio corrupti voluptas quisquam dicta, quibusdam ipsum qui exercitationem.</span>
</summary> </div>
<a id="url">https://example.com/dataset</a> <a id="url">https://example.com/dataset</a>
<aside class="upvote"> <aside class="upvote">
<button disabled class="upvote-btn btn flat icon">Upvote</button> <button disabled class="upvote-btn btn flat icon">Upvote</button>
@ -43,7 +43,7 @@
</section> </section>
<section> <section>
<p id="full-description">Full description<br> <p id="description">Description<br>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae
nihil saepe et numquam quo id voluptatum recusandae assumenda nihil saepe et numquam quo id voluptatum recusandae assumenda
doloremque pariatur consequatur molestias delectus dolore doloremque pariatur consequatur molestias delectus dolore
@ -78,4 +78,4 @@
</p> </p>
</main> </main>
</body> </body>
</html> </html>

View File

@ -6,13 +6,13 @@ const notFoundPage = document.getElementById("not-found");
const title = document.getElementById("title"); const title = document.getElementById("title");
const rating = document.getElementById("rating"); const rating = document.getElementById("rating");
const ratingText = document.getElementById("rating-text"); const ratingText = document.getElementById("rating-text");
const shortDescription = document.getElementById("short-description"); const summary = document.getElementById("summary");
const url = document.getElementById("url"); const url = document.getElementById("url");
const date = document.getElementById("date"); const date = document.getElementById("date");
const category = document.getElementById("category"); const category = document.getElementById("category");
const license = document.getElementById("license"); const license = document.getElementById("license");
const termsOfUse = document.getElementById("terms-of-use"); 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 backButton = document.getElementById("back-btn");
const deleteButton = document.getElementById("delete-btn"); const deleteButton = document.getElementById("delete-btn");
@ -37,7 +37,7 @@ if (currentLocation.searchParams.has("id")) {
title.dataset.type = dataset.type.toLowerCase(); title.dataset.type = dataset.type.toLowerCase();
rating.value = dataset.rating; rating.value = dataset.rating;
ratingText.innerText = parseFloat(dataset.rating).toFixed(1); ratingText.innerText = parseFloat(dataset.rating).toFixed(1);
shortDescription.innerText = dataset.shortDescription; summary.innerText = dataset.summary;
url.href = dataset.url; url.href = dataset.url;
url.innerText = dataset.url; url.innerText = dataset.url;
mainPage.querySelector(".upvote").replaceWith(upvoteComponent); mainPage.querySelector(".upvote").replaceWith(upvoteComponent);
@ -53,7 +53,7 @@ if (currentLocation.searchParams.has("id")) {
license.innerText = dataset.license; license.innerText = dataset.license;
termsOfUse.href = dataset.termsOfUse; termsOfUse.href = dataset.termsOfUse;
fullDescription.innerText = dataset.fullDescription; description.innerText = dataset.description;
mainPage.classList.remove("skeleton"); mainPage.classList.remove("skeleton");
} else { } else {
@ -113,4 +113,4 @@ rating.addEventListener("click", async () => {
rating.value = dataset.rating; rating.value = dataset.rating;
} }
} }
}) });

View File

@ -45,8 +45,8 @@
<option>Author Z-A</option> <option>Author Z-A</option>
<option>Title A-Z</option> <option>Title A-Z</option>
<option>Title Z-A</option> <option>Title Z-A</option>
<option>Raiting ↑</option> <option>Rating ↑</option>
<option>Raiting ↓</option> <option>Rating ↓</option>
<option>Upvotes ↑</option> <option>Upvotes ↑</option>
<option>Upvotes ↓</option> <option>Upvotes ↓</option>
</select> </select>

View File

@ -16,8 +16,6 @@ const searchButton = document.getElementById("search-btn");
const searchBar = document.getElementById("search-entry"); const searchBar = document.getElementById("search-entry");
const sortButton = document.getElementById("sort-btn"); const sortButton = document.getElementById("sort-btn");
const resetButton = document.getElementById("reset-tools-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"); export const searchSection = document.getElementById("search");
const recentSection = document.getElementById("recents"); const recentSection = document.getElementById("recents");
const mostLikedSection = document.getElementById("top"); const mostLikedSection = document.getElementById("top");
@ -27,22 +25,10 @@ export let searchBarTimeout;
const searchDelay = 500; const searchDelay = 500;
// Event listeners // Event listeners
addButton.addEventListener("click", () => { addButton.addEventListener("click", () => location.assign("/add.html"));
navigateToAdd(); filterButton.addEventListener("change", () => fetchQuery(createQuery(), true));
}); filterButton.addEventListener("click", () => fetchCategories());
searchButton.addEventListener("click", () => fetchQuery(createQuery(), true));
filterButton.addEventListener("change", () => {
fetchQuery(createQuery(), true);
});
filterButton.addEventListener("click", () => {
fetchCategories();
})
searchButton.addEventListener("click", () => {
fetchQuery(createQuery(), true);
});
searchBar.addEventListener("input", () => { searchBar.addEventListener("input", () => {
clearTimeout(searchBarTimeout); clearTimeout(searchBarTimeout);
@ -52,15 +38,13 @@ searchBar.addEventListener("input", () => {
}, searchDelay); }, searchDelay);
}); });
searchBar.addEventListener('keypress', function (e) { searchBar.addEventListener('keypress', e => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
fetchQuery(createQuery(), true); fetchQuery(createQuery(), true);
} }
}); });
sortButton.addEventListener("change", () => { sortButton.addEventListener("change", () => fetchQuery(createQuery(), true));
fetchQuery(createQuery(), true);
});
resetButton.addEventListener("click", () => { resetButton.addEventListener("click", () => {
searchBar.value = ""; searchBar.value = "";
@ -70,10 +54,6 @@ resetButton.addEventListener("click", () => {
}); });
// functions of the main page // functions of the main page
function navigateToAdd() {
window.location.href = "/add.html"; //TODO: move to EventListener?
}
function getFilterQuery() { function getFilterQuery() {
let filterString = filterButton.value.toUpperCase(); let filterString = filterButton.value.toUpperCase();
if (filterString === "NONE") { if (filterString === "NONE") {

View File

@ -5,9 +5,6 @@ import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
class DataDashApplicationTests { class DataDashApplicationTests {
@Test @Test
void contextLoads() { void contextLoads() {}
}
} }

View File

@ -13,9 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest
public class DataRepositoryTests { public class DataRepositoryTests {
@Autowired @Autowired
private dataRepository dataRepository; private DatasetRepository dataRepository;
@BeforeEach @BeforeEach
private void clearDatabase() { private void clearDatabase() {
@ -25,7 +24,7 @@ public class DataRepositoryTests {
@Test @Test
public void testFindByOptionalCriteria() { public void testFindByOptionalCriteria() {
// Prepare test data // 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); dataRepository.save(dataset);
// Execute the method under test // Execute the method under test
@ -39,11 +38,11 @@ public class DataRepositoryTests {
} }
@Test @Test
public void searchByOptionalCriteria() { 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); 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); 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); dataRepository.save(dataset);
Page<Dataset> result = dataRepository.searchByOptionalCriteria( Page<Dataset> result = dataRepository.searchByOptionalCriteria(
@ -54,11 +53,11 @@ public class DataRepositoryTests {
} }
@Test @Test
public void searchByOptionalCriteriaMulti() { 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); 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); 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); dataRepository.save(dataset);
Page<Dataset> result = dataRepository.searchByOptionalCriteria( Page<Dataset> result = dataRepository.searchByOptionalCriteria(
@ -69,7 +68,7 @@ public class DataRepositoryTests {
@Test @Test
public void getDatasetById() { 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 = dataRepository.save(dataset);
Dataset result = dataRepository.getDatasetById(dataset.getId()); Dataset result = dataRepository.getDatasetById(dataset.getId());
@ -77,4 +76,4 @@ public class DataRepositoryTests {
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.getTitle()).isEqualTo("title"); assertThat(result.getTitle()).isEqualTo("title");
} }
} }

View File

@ -30,7 +30,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@WebMvcTest(DatasetController.class) @WebMvcTest(DatasetController.class)
public class DatasetControllerTests { public class DatasetControllerTests {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;
@ -40,12 +39,12 @@ public class DatasetControllerTests {
@Autowired @Autowired
private ObjectMapper objectMapper = new ObjectMapper(); 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 @Test
void getDatasetById_whenExists() throws Exception { void getDatasetById_whenExists() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
mockMvc.perform(get("/api/v1/datasets/id/" + id.toString())) mockMvc.perform(get("/api/v1/datasets/id/" + id.toString()))
@ -74,7 +73,7 @@ public class DatasetControllerTests {
@Test @Test
void deleteDataset_whenExists() throws Exception { void deleteDataset_whenExists() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
mockMvc.perform(delete("/api/v1/datasets/id/" + id.toString())) mockMvc.perform(delete("/api/v1/datasets/id/" + id.toString()))
@ -93,7 +92,7 @@ public class DatasetControllerTests {
@Test @Test
void upvote_whenExists() throws Exception { void upvote_whenExists() throws Exception {
UUID id = UUID.randomUUID(); 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 -> { doAnswer(invocation -> {
dataset.upvote(); // Directly modify the dataset dataset.upvote(); // Directly modify the dataset
@ -121,7 +120,7 @@ public class DatasetControllerTests {
@Test @Test
void downvote_whenExists() throws Exception { void downvote_whenExists() throws Exception {
UUID id = UUID.randomUUID(); 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 -> { doAnswer(invocation -> {
dataset.downvote(); // Directly modify the dataset dataset.downvote(); // Directly modify the dataset
@ -149,7 +148,7 @@ public class DatasetControllerTests {
@Test @Test
void postMethodName_whenExists() throws Exception { void postMethodName_whenExists() throws Exception {
UUID id = UUID.randomUUID(); 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 -> { doAnswer(invocation -> {
dataset.vote(3); // Directly modify the dataset dataset.vote(3); // Directly modify the dataset
@ -162,7 +161,7 @@ public class DatasetControllerTests {
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().json(objectMapper.writeValueAsString(dataset))); .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 @Test
@ -177,7 +176,7 @@ public class DatasetControllerTests {
@Test @Test
void postMethodName_whenInvalidStars() throws Exception { void postMethodName_whenInvalidStars() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
@ -188,7 +187,7 @@ public class DatasetControllerTests {
@Test @Test
void postMethodName_whenInvalidStars3() throws Exception { void postMethodName_whenInvalidStars3() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
@ -199,7 +198,7 @@ public class DatasetControllerTests {
@Test @Test
void postMethodName_whenInvalidStars4() throws Exception { void postMethodName_whenInvalidStars4() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
@ -210,7 +209,7 @@ public class DatasetControllerTests {
@Test @Test
void postMethodName_whenInvalidStars5() throws Exception { void postMethodName_whenInvalidStars5() throws Exception {
UUID id = UUID.randomUUID(); 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); given(datasetService.getDatasetById(id)).willReturn(dataset);
@ -222,7 +221,7 @@ public class DatasetControllerTests {
void searchDatasets_whenExists() throws Exception { void searchDatasets_whenExists() throws Exception {
String keyword = "title%"; String keyword = "title%";
List<Dataset> datasets = Arrays.asList( List<Dataset> 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")); // new Dataset("Title 2", "abst", "data", "auth", null, null, Type.API, "MIT"));
Page<Dataset> page = new PageImpl<>(datasets); Page<Dataset> page = new PageImpl<>(datasets);
@ -293,5 +292,4 @@ public class DatasetControllerTests {
mockMvc.perform(get("/api/v1/datasets/search?search=" + keyword + "&size=0")) mockMvc.perform(get("/api/v1/datasets/search?search=" + keyword + "&size=0"))
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
}
}

View File

@ -25,7 +25,7 @@ import java.util.UUID;
class DatasetServiceTest { class DatasetServiceTest {
@Mock @Mock
private dataRepository datasetRepository; private DatasetRepository datasetRepository;
@Mock @Mock
private CategoryRepository categoryRepository; private CategoryRepository categoryRepository;
@ -60,7 +60,7 @@ class DatasetServiceTest {
datasetService.voteDataset(id, 5); datasetService.voteDataset(id, 5);
verify(datasetRepository).save(dataset); verify(datasetRepository).save(dataset);
assertEquals(1, dataset.getVotes()); assertEquals(1, dataset.getVotes());
assertEquals(5, dataset.getRaiting()); assertEquals(5, dataset.getRating());
} }
@Test @Test
@ -120,4 +120,4 @@ class DatasetServiceTest {
} }
// Additional tests for other methods can be added following the same pattern. // Additional tests for other methods can be added following the same pattern.
} }

View File

@ -19,7 +19,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@WebMvcTest(CategoryController.class) @WebMvcTest(CategoryController.class)
public class CategoryControllerTest { public class CategoryControllerTest {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;
@ -38,8 +37,8 @@ public class CategoryControllerTest {
given(categoryService.getAllCategories()).willReturn(Arrays.asList(category1, category2)); given(categoryService.getAllCategories()).willReturn(Arrays.asList(category1, category2));
mockMvc.perform(get("/api/v1/categories")) mockMvc.perform(get("/api/v1/categories"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().json(objectMapper.writeValueAsString(Arrays.asList(category1, category2)))); .andExpect(content().json(objectMapper.writeValueAsString(Arrays.asList(category1, category2))));
} }
@Test @Test
@ -49,8 +48,8 @@ public class CategoryControllerTest {
given(categoryService.getCategoryById(id)).willReturn(category); given(categoryService.getCategoryById(id)).willReturn(category);
mockMvc.perform(get("/api/v1/categories/id/{id}", id)) mockMvc.perform(get("/api/v1/categories/id/{id}", id))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().json(objectMapper.writeValueAsString(category))); .andExpect(content().json(objectMapper.writeValueAsString(category)));
} }
@Test @Test
@ -58,18 +57,18 @@ public class CategoryControllerTest {
UUID id = UUID.randomUUID(); UUID id = UUID.randomUUID();
given(categoryService.getCategoryById(id)).willReturn(null); given(categoryService.getCategoryById(id)).willReturn(null);
mockMvc.perform(get("/api/v1/categories/id/{id}", id)) mockMvc.perform(get("/api/v1/categories/id/{id}", id)).andExpect(status().isNotFound());
.andExpect(status().isNotFound());
} }
@Test @Test
public void testCreateCategory() throws Exception { public void testCreateCategory() throws Exception {
CategoryDto categoryDto = CategoryDtoMapper.toDto(category); CategoryDto categoryDto = CategoryDtoMapper.toDto(category);
mockMvc.perform(post("/api/v1/categories") mockMvc.perform(post("/api/v1/categories")
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(categoryDto))) .content(objectMapper.writeValueAsString(categoryDto)))
.andExpect(status().isCreated()); .andExpect(status().isCreated());
// Verify that the service method was called once // Verify that the service method was called once
verify(categoryService).addCategory(any(CategoryDto.class)); verify(categoryService).addCategory(any(CategoryDto.class));
} }
} }

View File

@ -12,10 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest
public class CategoryRepositoryTests { public class CategoryRepositoryTests {
@Autowired @Autowired
private CategoryRepository categoryRepository; private CategoryRepository categoryRepository;
private Category savedCategory; private Category savedCategory;
@BeforeEach @BeforeEach
@ -53,4 +51,4 @@ public class CategoryRepositoryTests {
assertThat(foundCategory).isNotNull(); assertThat(foundCategory).isNotNull();
assertThat(foundCategory.getId()).isEqualTo(savedCategory.getId()); assertThat(foundCategory.getId()).isEqualTo(savedCategory.getId());
} }
} }

View File

@ -14,7 +14,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
public class CategoryServiceTest { public class CategoryServiceTest {
@Mock @Mock
private CategoryRepository categoryRepository; private CategoryRepository categoryRepository;
@ -65,4 +64,4 @@ public class CategoryServiceTest {
assertNull(result); assertNull(result);
} }
} }