Merge branch '10-add-model-for-content' into 'main'
Resolve "Add model for content" Closes #10 See merge request padas/24ss-5430-web-and-data-eng/gruppe-3/datadash!4
This commit is contained in:
		@@ -0,0 +1,127 @@
 | 
				
			|||||||
 | 
					package de.uni_passau.fim.PADAS.group3.DataDash.model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Date;
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					import jakarta.persistence.Entity;
 | 
				
			||||||
 | 
					import jakarta.persistence.EnumType;
 | 
				
			||||||
 | 
					import jakarta.persistence.Enumerated;
 | 
				
			||||||
 | 
					import jakarta.persistence.GeneratedValue;
 | 
				
			||||||
 | 
					import jakarta.persistence.GenerationType;
 | 
				
			||||||
 | 
					import jakarta.persistence.Id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Entity
 | 
				
			||||||
 | 
					public class Dataset {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Id
 | 
				
			||||||
 | 
					    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
				
			||||||
 | 
					    private UUID id;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Enumerated(EnumType.STRING)
 | 
				
			||||||
 | 
					    private Type type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String abst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String description;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String author;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Date date;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private float raiting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int votes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String[] categories;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Dataset(String title, String abst, String description, String author, Date date, String[] categories, Type type) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.raiting = 0;
 | 
				
			||||||
 | 
					        this.votes = 0;
 | 
				
			||||||
 | 
					        setTitle(title);
 | 
				
			||||||
 | 
					        setAbst(abst);        
 | 
				
			||||||
 | 
					        setDescription(description);        
 | 
				
			||||||
 | 
					        setAuthor(author);
 | 
				
			||||||
 | 
					        setDate(date);        
 | 
				
			||||||
 | 
					        setCategories(categories);        
 | 
				
			||||||
 | 
					        setType(type);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Dataset() {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getAbst() {
 | 
				
			||||||
 | 
					        return abst;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getAuthor() {
 | 
				
			||||||
 | 
					        return author;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String[] getCategories() {
 | 
				
			||||||
 | 
					        return categories;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Date getDate() {
 | 
				
			||||||
 | 
					        return date;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getDescription() {
 | 
				
			||||||
 | 
					        return description;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public UUID getId() {
 | 
				
			||||||
 | 
					        return id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public float getRaiting() {
 | 
				
			||||||
 | 
					        return raiting;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getTitle() {
 | 
				
			||||||
 | 
					        return title;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Type getType() {
 | 
				
			||||||
 | 
					        return type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getVotes() {
 | 
				
			||||||
 | 
					        return votes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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 setCategories(String[] categories) {
 | 
				
			||||||
 | 
					        this.categories = categories;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void setDate(Date date) {
 | 
				
			||||||
 | 
					        this.date = date;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void setDescription(String description) {
 | 
				
			||||||
 | 
					        this.description = description;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					    public void setTitle(String title) {
 | 
				
			||||||
 | 
					        this.title = title.substring(0, Math.min(title.length(), 50));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setType(Type type) {
 | 
				
			||||||
 | 
					        this.type = type;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void vote(int stars) {
 | 
				
			||||||
 | 
					        raiting = (raiting*votes + stars) / (++votes);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					package de.uni_passau.fim.PADAS.group3.DataDash.model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public enum Type {
 | 
				
			||||||
 | 
					    DATASET,
 | 
				
			||||||
 | 
					    API
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					package de.uni_passau.fim.PADAS.group3.DataDash.model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					import java.sql.Date;
 | 
				
			||||||
 | 
					import org.springframework.data.jpa.repository.JpaRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface dataRepository extends JpaRepository<Dataset, UUID>{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<Dataset> findByTitle(String title);
 | 
				
			||||||
 | 
					    List<Dataset> findByTitleLike(String title);
 | 
				
			||||||
 | 
					    List<Dataset> findByAuthorLike(String author);
 | 
				
			||||||
 | 
					    List<Dataset> findByType(Type type);
 | 
				
			||||||
 | 
					    List<Dataset> findByAuthor(String author);
 | 
				
			||||||
 | 
					    List<Dataset> findByAbstLike(String abst);
 | 
				
			||||||
 | 
					    List<Dataset> findByDescriptionLike(String description);
 | 
				
			||||||
 | 
					    List<Dataset> findByCategories(String[] categories);
 | 
				
			||||||
 | 
					    List<Dataset> findByRaitingGreaterThan(float raiting);
 | 
				
			||||||
 | 
					    List<Dataset> findByVotesGreaterThan(int votes);
 | 
				
			||||||
 | 
					    List<Dataset> findByDateAfter(Date date);
 | 
				
			||||||
 | 
					    List<Dataset> findByDateBefore(Date date);
 | 
				
			||||||
 | 
					    List<Dataset> findByDateBetween(Date date1, Date date2);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user