parent
5fa28f80c4
commit
d13edead44
@ -5,7 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DataDashApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataDashApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,61 +21,72 @@ 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 summary;
|
||||
private String description;
|
||||
private String author;
|
||||
private String license;
|
||||
private Date date;
|
||||
private float rating;
|
||||
private int votes;
|
||||
private int upvotes;
|
||||
private URL url;
|
||||
|
||||
@ManyToOne
|
||||
private Category category;
|
||||
private String abst;
|
||||
|
||||
private String description;
|
||||
|
||||
private String author;
|
||||
|
||||
private Date date;
|
||||
|
||||
private float raiting;
|
||||
|
||||
private int votes;
|
||||
|
||||
private int upvotes;
|
||||
|
||||
private URL url;
|
||||
|
||||
@Column(name = "terms_of_use")
|
||||
private URL termsOfUse;
|
||||
|
||||
private static final List<String> sortable = Arrays.asList(
|
||||
"author", "title", "upvotes", "rating", "date"
|
||||
);
|
||||
private String licence;
|
||||
|
||||
public Dataset(String title, String summary, String description, String author, URL url, Category category, Type type, String license) {
|
||||
this.rating = 0;
|
||||
private static final List<String> 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;
|
||||
this.votes = 0;
|
||||
this.upvotes = 0;
|
||||
setTitle(title);
|
||||
setSummary(summary);
|
||||
setDescription(description);
|
||||
setAbst(abst);
|
||||
setDescription(description);
|
||||
setAuthor(author);
|
||||
setDate(LocalDate.now());
|
||||
setCategory(category);
|
||||
setCategorie(categories);
|
||||
setType(type);
|
||||
setUrl(url);
|
||||
setLicense(license);
|
||||
setLicence(licence);
|
||||
}
|
||||
|
||||
public Dataset() {}
|
||||
public Dataset() {
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
|
||||
public String getAbst() {
|
||||
return abst;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
public Category getCategorie() {
|
||||
return categorie;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
@ -90,8 +101,8 @@ public class Dataset {
|
||||
return id;
|
||||
}
|
||||
|
||||
public float getRating() {
|
||||
return rating;
|
||||
public float getRaiting() {
|
||||
return raiting;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@ -118,42 +129,42 @@ public class Dataset {
|
||||
return termsOfUse;
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return license;
|
||||
public String getLicence() {
|
||||
return licence;
|
||||
}
|
||||
|
||||
public static List<String> getSort() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary.substring(0, Math.min(summary.length(), 100));
|
||||
public void setAbst(String abst) {
|
||||
this.abst = abst.substring(0, Math.min(abst.length(), 100));
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
public void setCategorie(Category categories) {
|
||||
this.categorie = categories;
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
@ -161,9 +172,9 @@ public class Dataset {
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public void vote(int stars) {
|
||||
rating = (rating * votes + stars) / (++votes);
|
||||
raiting = (raiting*votes + stars) / (++votes);
|
||||
}
|
||||
|
||||
public void upvote() {
|
||||
@ -174,7 +185,8 @@ public class Dataset {
|
||||
upvotes--;
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
public void setLicence(String licence) {
|
||||
this.licence = licence;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,9 +25,10 @@ public class DatasetController {
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<Dataset> getDatasetById(@PathVariable("id") UUID id) {
|
||||
Dataset d = datasetService.getDatasetById(id);
|
||||
return d == null
|
||||
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
|
||||
: new ResponseEntity<>(d, HttpStatus.OK);
|
||||
if (d == null) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return new ResponseEntity<>(d, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@ -41,7 +42,6 @@ public class DatasetController {
|
||||
if (datasetService.getDatasetById(id) == null) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
datasetService.deleteDataset(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@ -61,52 +61,44 @@ 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<Dataset> postMethodName(
|
||||
@PathVariable("id") UUID id,
|
||||
@RequestParam("stars") int stars
|
||||
) {
|
||||
public ResponseEntity<Dataset> postMethodName(@PathVariable("id") UUID id,
|
||||
@RequestParam("stars") int stars) {
|
||||
if (datasetService.getDatasetById(id) == null) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
} else if (!(stars >= 0 && stars < 6)) {
|
||||
}
|
||||
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<Page<Dataset>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -14,10 +14,10 @@ import org.springframework.data.domain.Page;
|
||||
|
||||
@Service
|
||||
public class DatasetService {
|
||||
private DatasetRepository datasetRepository;
|
||||
private dataRepository datasetRepository;
|
||||
private CategoryRepository categoryRepository;
|
||||
|
||||
DatasetService(DatasetRepository datasetRepository, CategoryRepository categoryRepository) {
|
||||
DatasetService(dataRepository datasetRepository, CategoryRepository categoryRepository) {
|
||||
this.datasetRepository = datasetRepository;
|
||||
this.categoryRepository = categoryRepository;
|
||||
}
|
||||
@ -54,18 +54,17 @@ public class DatasetService {
|
||||
datasetRepository.save(dataset);
|
||||
}
|
||||
|
||||
Page<Dataset> searchByOptionalCriteria(String search, String categoryID, String type, Pageable pageable) {
|
||||
Category category = categoryID.equals("%")
|
||||
? null
|
||||
: categoryRepository.getCategoryById(UUID.fromString(categoryID));
|
||||
Page<Dataset> searchByOptionalCriteria(String search, String categories, String type, Pageable pageable) {
|
||||
Category category = categories.equals("%") ? null
|
||||
: categoryRepository.getCategoryById(UUID.fromString(categories));
|
||||
Type t = type.equals("%") ? null : Type.valueOf(type);
|
||||
|
||||
return category == null
|
||||
? datasetRepository.searchByOptionalCriteria(
|
||||
Optional.ofNullable(search), Optional.ofNullable(t), pageable
|
||||
)
|
||||
: datasetRepository.searchByOptionalCriteriaWithCategory(
|
||||
Optional.ofNullable(search), category, Optional.ofNullable(t), pageable
|
||||
);
|
||||
if (category == null) {
|
||||
return datasetRepository.searchByOptionalCriteria(Optional.ofNullable(search), Optional.ofNullable(t),
|
||||
pageable);
|
||||
}
|
||||
return datasetRepository.searchByOptionalCriteriaWithCategory(Optional.ofNullable(search), category,
|
||||
Optional.ofNullable(t), pageable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,4 @@ package de.uni_passau.fim.PADAS.group3.DataDash.Dataset;
|
||||
public enum Type {
|
||||
DATASET,
|
||||
API
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
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);
|
||||
}
|
@ -4,8 +4,10 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,11 +14,13 @@ 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<Dataset> datasets;
|
||||
|
@ -13,6 +13,9 @@ 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 {
|
||||
@ -27,14 +30,16 @@ public class CategoryController {
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> fetchCategoryById(@PathVariable("id") UUID id) {
|
||||
CategoryDto category = categoryService.getCategoryById(id);
|
||||
return category == null
|
||||
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
|
||||
:new ResponseEntity<>(category, HttpStatus.OK);
|
||||
if(category == null) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return new ResponseEntity<>(category, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@PostMapping
|
||||
public Category createCategory(@RequestBody CategoryDto dto) {
|
||||
return categoryService.addCategory(dto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,16 +3,19 @@ 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;
|
||||
}
|
||||
@ -21,3 +24,4 @@ public class CategoryDto {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
package de.uni_passau.fim.PADAS.group3.DataDash.category;
|
||||
|
||||
public class CategoryDtoMapper {
|
||||
|
||||
public static CategoryDto toDto(Category category) {
|
||||
return new CategoryDto(category.getName(), category.getId());
|
||||
CategoryDto dto = new CategoryDto(category.getName(), category.getId());
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,12 +8,13 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
|
||||
public interface CategoryRepository extends JpaRepository<Category, UUID>{
|
||||
|
||||
Category getCategoryById(UUID id);
|
||||
|
||||
@SuppressWarnings("null")
|
||||
List<Category> findAll();
|
||||
List<Category> findByName(String name);
|
||||
|
||||
@SuppressWarnings("null")
|
||||
Optional<Category> findById(UUID id);
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,10 @@ public class CategoryService {
|
||||
|
||||
CategoryDto getCategoryById(UUID id) {
|
||||
Category c = categoryRepository.getCategoryById(id);
|
||||
return c == null ? null : CategoryDtoMapper.toDto(c);
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
return CategoryDtoMapper.toDto(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,65 +1,64 @@
|
||||
-- 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, 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 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 more sample data into dataset
|
||||
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');
|
||||
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');
|
@ -1,23 +1,7 @@
|
||||
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,
|
||||
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;
|
||||
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;
|
||||
|
@ -130,14 +130,14 @@ form :has(#url) {
|
||||
}
|
||||
}
|
||||
|
||||
/* description box */
|
||||
#description-box {
|
||||
/* full description box */
|
||||
#full-description-box {
|
||||
grid-column: 1 / -1;
|
||||
align-items: start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#description {
|
||||
#full-description {
|
||||
height: 15rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
@ -41,8 +41,8 @@
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<label for="summary">Short description</label>
|
||||
<input type="text" name="summary" id="summary" size="3" maxlength="100" required spellcheck="true">
|
||||
<label for="short-description">Short description</label>
|
||||
<input type="text" name="short-description" id="short-description" size="3" maxlength="100" required spellcheck="true">
|
||||
</span>
|
||||
|
||||
<span>
|
||||
@ -73,9 +73,9 @@
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span id="description-box">
|
||||
<label for="description">Full description</label>
|
||||
<textarea name="description" id="description" cols="3" spellcheck="true"></textarea>
|
||||
<span id="full-description-box">
|
||||
<label for="full-description">Full description</label>
|
||||
<textarea name="full-description" id="full-description" cols="3" spellcheck="true"></textarea>
|
||||
</span>
|
||||
|
||||
<span id="btn-bar">
|
||||
@ -86,4 +86,4 @@
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -5,14 +5,14 @@ const {
|
||||
title: titleEntry,
|
||||
author: authorEntry,
|
||||
["is-dataset"]: isDatasetSwitch,
|
||||
summary: summaryEntry,
|
||||
["short-description"]: shortDescriptionEntry,
|
||||
url: urlEntry,
|
||||
["terms-of-use"]: termsOfUseEntry,
|
||||
license: licenseEntry,
|
||||
category: categorySpinner,
|
||||
["new-category"]: newCategoryEntry,
|
||||
["change-category-btn"]: changeCategoryBtn,
|
||||
description: descriptionEntry,
|
||||
["full-description"]: fullDescriptionEntry,
|
||||
["btn-add"]: addBtn,
|
||||
["btn-cancel"]: cancelBtn,
|
||||
} = form.elements;
|
||||
@ -26,12 +26,12 @@ const validationListener = () => {
|
||||
[
|
||||
titleEntry,
|
||||
authorEntry,
|
||||
summaryEntry,
|
||||
shortDescriptionEntry,
|
||||
urlEntry,
|
||||
termsOfUseEntry,
|
||||
licenseEntry,
|
||||
newCategoryEntry,
|
||||
descriptionEntry,
|
||||
fullDescriptionEntry,
|
||||
].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",
|
||||
summary: summaryEntry.value,
|
||||
abst: shortDescriptionEntry.value,
|
||||
url: urlEntry.value,
|
||||
termsOfUse: termsOfUseEntry.value,
|
||||
license: licenseEntry.value,
|
||||
category: {
|
||||
licence: licenseEntry.value,
|
||||
categorie: {
|
||||
id: categoryID,
|
||||
},
|
||||
description: descriptionEntry.value,
|
||||
description: fullDescriptionEntry.value,
|
||||
};
|
||||
|
||||
// Don't allow several requests to be sent at the same time
|
||||
|
@ -3,11 +3,11 @@ import { DATASET_ENDPOINT, getBaseURL } from "./constants.js";
|
||||
export default class Dataset {
|
||||
static #datasets = new Map();
|
||||
|
||||
#summary;
|
||||
#shortDescription;
|
||||
#author;
|
||||
#category;
|
||||
#date;
|
||||
#description;
|
||||
#fullDescription;
|
||||
#id;
|
||||
#rating;
|
||||
#title;
|
||||
@ -23,14 +23,14 @@ export default class Dataset {
|
||||
return this.#datasets.get(id);
|
||||
}
|
||||
|
||||
constructor({ summary, author, category, date, description, id, rating, title, type, upvotes, url, votes, license, termsOfUse }) {
|
||||
this.#summary = summary;
|
||||
constructor({ abst: shortDescription, author, categorie, date, description, id, raiting, title, type, upvotes, url, votes, licence: license, termsOfUse }) {
|
||||
this.#shortDescription = shortDescription;
|
||||
this.#author = author;
|
||||
this.#category = category;
|
||||
this.#category = categorie;
|
||||
this.#date = date;
|
||||
this.#description = description;
|
||||
this.#fullDescription = description;
|
||||
this.#id = id;
|
||||
this.#rating = rating;
|
||||
this.#rating = raiting;
|
||||
this.#title = title;
|
||||
this.#type = type;
|
||||
this.#upvotes = upvotes;
|
||||
@ -43,8 +43,8 @@ export default class Dataset {
|
||||
}
|
||||
|
||||
// Getters
|
||||
get summary() {
|
||||
return this.#summary;
|
||||
get shortDescription() {
|
||||
return this.#shortDescription;
|
||||
}
|
||||
|
||||
get author() {
|
||||
@ -59,8 +59,8 @@ export default class Dataset {
|
||||
return this.#date;
|
||||
}
|
||||
|
||||
get description() {
|
||||
return this.#description;
|
||||
get fullDescription() {
|
||||
return this.#fullDescription;
|
||||
}
|
||||
|
||||
get id() {
|
||||
@ -130,7 +130,7 @@ export default class Dataset {
|
||||
}
|
||||
})
|
||||
clone.querySelector(".dataset-title").innerText = this.#title;
|
||||
clone.querySelector(".dataset-description").innerText = this.#summary;
|
||||
clone.querySelector(".dataset-description").innerText = this.#shortDescription;
|
||||
clone.querySelector(".upvote-count").innerText = this.#upvotes;
|
||||
|
||||
this.#elements.push(clone.children[0]);
|
||||
|
@ -74,7 +74,7 @@ h1 {
|
||||
}
|
||||
}
|
||||
|
||||
#details :has(#summary), #url {
|
||||
#details summary, #url {
|
||||
text-align: start;
|
||||
grid-column: 1 / 3;
|
||||
}
|
||||
@ -146,13 +146,13 @@ a {
|
||||
gap: var(--gap-large);
|
||||
}
|
||||
|
||||
#description {
|
||||
#full-description {
|
||||
text-wrap: balance;
|
||||
text-wrap: pretty;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
:is(#description, #not-found) br {
|
||||
:is(#full-description, #not-found) br {
|
||||
margin-bottom: .5lh;
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@
|
||||
<main id="details" class="skeleton">
|
||||
<header data-id="dataset-id">
|
||||
<h1 id="title" data-type="api">Title</h1>
|
||||
<div>
|
||||
<summary>
|
||||
<span id="rating-text">4</span><meter id="rating" value="4" max="5"></meter>
|
||||
<span id="rating-input"></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>
|
||||
</div>
|
||||
<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>
|
||||
</summary>
|
||||
<a id="url">https://example.com/dataset</a>
|
||||
<aside class="upvote">
|
||||
<button disabled class="upvote-btn btn flat icon">Upvote</button>
|
||||
@ -43,7 +43,7 @@
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p id="description">Description<br>
|
||||
<p id="full-description">Full description<br>
|
||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae
|
||||
nihil saepe et numquam quo id voluptatum recusandae assumenda
|
||||
doloremque pariatur consequatur molestias delectus dolore
|
||||
@ -78,4 +78,4 @@
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -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 summary = document.getElementById("summary");
|
||||
const shortDescription = document.getElementById("short-description");
|
||||
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 description = document.getElementById("description");
|
||||
const fullDescription = document.getElementById("full-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);
|
||||
summary.innerText = dataset.summary;
|
||||
shortDescription.innerText = dataset.shortDescription;
|
||||
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;
|
||||
|
||||
description.innerText = dataset.description;
|
||||
fullDescription.innerText = dataset.fullDescription;
|
||||
|
||||
mainPage.classList.remove("skeleton");
|
||||
} else {
|
||||
@ -113,4 +113,4 @@ rating.addEventListener("click", async () => {
|
||||
rating.value = dataset.rating;
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -45,8 +45,8 @@
|
||||
<option>Author Z-A</option>
|
||||
<option>Title A-Z</option>
|
||||
<option>Title Z-A</option>
|
||||
<option>Rating ↑</option>
|
||||
<option>Rating ↓</option>
|
||||
<option>Raiting ↑</option>
|
||||
<option>Raiting ↓</option>
|
||||
<option>Upvotes ↑</option>
|
||||
<option>Upvotes ↓</option>
|
||||
</select>
|
||||
|
@ -16,6 +16,8 @@ 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");
|
||||
@ -25,10 +27,22 @@ export let searchBarTimeout;
|
||||
const searchDelay = 500;
|
||||
|
||||
// Event listeners
|
||||
addButton.addEventListener("click", () => location.assign("/add.html"));
|
||||
filterButton.addEventListener("change", () => fetchQuery(createQuery(), true));
|
||||
filterButton.addEventListener("click", () => fetchCategories());
|
||||
searchButton.addEventListener("click", () => fetchQuery(createQuery(), true));
|
||||
addButton.addEventListener("click", () => {
|
||||
navigateToAdd();
|
||||
});
|
||||
|
||||
filterButton.addEventListener("change", () => {
|
||||
fetchQuery(createQuery(), true);
|
||||
});
|
||||
|
||||
filterButton.addEventListener("click", () => {
|
||||
fetchCategories();
|
||||
})
|
||||
|
||||
searchButton.addEventListener("click", () => {
|
||||
fetchQuery(createQuery(), true);
|
||||
|
||||
});
|
||||
|
||||
searchBar.addEventListener("input", () => {
|
||||
clearTimeout(searchBarTimeout);
|
||||
@ -38,13 +52,15 @@ searchBar.addEventListener("input", () => {
|
||||
}, searchDelay);
|
||||
});
|
||||
|
||||
searchBar.addEventListener('keypress', e => {
|
||||
searchBar.addEventListener('keypress', function (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 = "";
|
||||
@ -54,6 +70,10 @@ 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") {
|
||||
|
@ -5,6 +5,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DataDashApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {}
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
public class DataRepositoryTests {
|
||||
|
||||
@Autowired
|
||||
private DatasetRepository dataRepository;
|
||||
private dataRepository dataRepository;
|
||||
|
||||
@BeforeEach
|
||||
private void clearDatabase() {
|
||||
@ -24,7 +25,7 @@ public class DataRepositoryTests {
|
||||
@Test
|
||||
public void testFindByOptionalCriteria() {
|
||||
// Prepare test data
|
||||
Dataset dataset = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset);
|
||||
|
||||
// Execute the method under test
|
||||
@ -38,11 +39,11 @@ public class DataRepositoryTests {
|
||||
}
|
||||
@Test
|
||||
public void searchByOptionalCriteria() {
|
||||
Dataset dataset1 = new Dataset("water", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset1 = new Dataset("water", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset1);
|
||||
Dataset dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset);
|
||||
dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset);
|
||||
|
||||
Page<Dataset> result = dataRepository.searchByOptionalCriteria(
|
||||
@ -53,11 +54,11 @@ public class DataRepositoryTests {
|
||||
}
|
||||
@Test
|
||||
public void searchByOptionalCriteriaMulti() {
|
||||
Dataset dataset1 = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset1 = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset1);
|
||||
Dataset dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset);
|
||||
dataset = new Dataset("title1", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataset = new Dataset("title1", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataRepository.save(dataset);
|
||||
|
||||
Page<Dataset> result = dataRepository.searchByOptionalCriteria(
|
||||
@ -68,7 +69,7 @@ public class DataRepositoryTests {
|
||||
|
||||
@Test
|
||||
public void getDatasetById() {
|
||||
Dataset dataset = new Dataset("title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
dataset = dataRepository.save(dataset);
|
||||
|
||||
Dataset result = dataRepository.getDatasetById(dataset.getId());
|
||||
@ -76,4 +77,4 @@ public class DataRepositoryTests {
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getTitle()).isEqualTo("title");
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@WebMvcTest(DatasetController.class)
|
||||
public class DatasetControllerTests {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@ -39,12 +40,12 @@ public class DatasetControllerTests {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private Dataset d = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
private Dataset d = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
@Test
|
||||
void getDatasetById_whenExists() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
mockMvc.perform(get("/api/v1/datasets/id/" + id.toString()))
|
||||
@ -73,7 +74,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void deleteDataset_whenExists() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
mockMvc.perform(delete("/api/v1/datasets/id/" + id.toString()))
|
||||
@ -92,7 +93,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void upvote_whenExists() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
doAnswer(invocation -> {
|
||||
dataset.upvote(); // Directly modify the dataset
|
||||
@ -120,7 +121,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void downvote_whenExists() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
doAnswer(invocation -> {
|
||||
dataset.downvote(); // Directly modify the dataset
|
||||
@ -148,7 +149,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void postMethodName_whenExists() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
doAnswer(invocation -> {
|
||||
dataset.vote(3); // Directly modify the dataset
|
||||
@ -161,7 +162,7 @@ public class DatasetControllerTests {
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().json(objectMapper.writeValueAsString(dataset)));
|
||||
|
||||
assertEquals(3, dataset.getRating()); // Assuming getVotes() method exists and initial votes are 0
|
||||
assertEquals(3, dataset.getRaiting()); // Assuming getVotes() method exists and initial votes are 0
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -176,7 +177,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void postMethodName_whenInvalidStars() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
@ -187,7 +188,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void postMethodName_whenInvalidStars3() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
@ -198,7 +199,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void postMethodName_whenInvalidStars4() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
@ -209,7 +210,7 @@ public class DatasetControllerTests {
|
||||
@Test
|
||||
void postMethodName_whenInvalidStars5() throws Exception {
|
||||
UUID id = UUID.randomUUID();
|
||||
Dataset dataset = new Dataset("Title", "summary", "desc", "auth", null, null, Type.API, "MIT");
|
||||
Dataset dataset = new Dataset("Title", "abst", "desc", "auth", null, null, Type.API, "MIT");
|
||||
|
||||
given(datasetService.getDatasetById(id)).willReturn(dataset);
|
||||
|
||||
@ -221,7 +222,7 @@ public class DatasetControllerTests {
|
||||
void searchDatasets_whenExists() throws Exception {
|
||||
String keyword = "title%";
|
||||
List<Dataset> datasets = Arrays.asList(
|
||||
new Dataset("Title 1", "summary", "data", "auth", null, null, Type.API, "MIT"));
|
||||
new Dataset("Title 1", "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);
|
||||
@ -292,4 +293,5 @@ public class DatasetControllerTests {
|
||||
mockMvc.perform(get("/api/v1/datasets/search?search=" + keyword + "&size=0"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
class DatasetServiceTest {
|
||||
|
||||
@Mock
|
||||
private DatasetRepository datasetRepository;
|
||||
private dataRepository 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.getRating());
|
||||
assertEquals(5, dataset.getRaiting());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -120,4 +120,4 @@ class DatasetServiceTest {
|
||||
}
|
||||
|
||||
// Additional tests for other methods can be added following the same pattern.
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@WebMvcTest(CategoryController.class)
|
||||
public class CategoryControllerTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@ -37,8 +38,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
|
||||
@ -48,8 +49,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
|
||||
@ -57,18 +58,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));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
public class CategoryRepositoryTests {
|
||||
|
||||
@Autowired
|
||||
private CategoryRepository categoryRepository;
|
||||
|
||||
private Category savedCategory;
|
||||
|
||||
@BeforeEach
|
||||
@ -51,4 +53,4 @@ public class CategoryRepositoryTests {
|
||||
assertThat(foundCategory).isNotNull();
|
||||
assertThat(foundCategory.getId()).isEqualTo(savedCategory.getId());
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
public class CategoryServiceTest {
|
||||
|
||||
@Mock
|
||||
private CategoryRepository categoryRepository;
|
||||
|
||||
@ -64,4 +65,4 @@ public class CategoryServiceTest {
|
||||
|
||||
assertNull(result);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user