diff --git a/src/main/java/org/hbp/mip/model/App.java b/src/main/java/org/hbp/mip/model/App.java index 2c36deb26d8a25c6267aa917f79fe9f2794f431f..f52d8b8cb38073fdac16af8da43de36e2d12221e 100644 --- a/src/main/java/org/hbp/mip/model/App.java +++ b/src/main/java/org/hbp/mip/model/App.java @@ -8,6 +8,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.annotations.ApiModel; import javax.persistence.*; +import java.util.HashSet; +import java.util.Set; @Entity @Table(name = "`app`") @@ -39,6 +41,9 @@ public class App { private Integer ratingCount; + @OneToMany(mappedBy = "app", fetch = FetchType.EAGER) + private Set<Vote> votes = new HashSet<>(); + public App() { } @@ -132,4 +137,13 @@ public class App { public void setRatingCount(Integer ratingCount) { this.ratingCount = ratingCount; } + + + public Set<Vote> getVotes() { + return votes; + } + + public void setVotes(Set<Vote> votes) { + this.votes = votes; + } } diff --git a/src/main/java/org/hbp/mip/model/User.java b/src/main/java/org/hbp/mip/model/User.java index 3928f7bc8d7484b637ec1f42d069a80207e4d651..7713162c09ccd6f153a61ef4e3ad9d56dad844aa 100644 --- a/src/main/java/org/hbp/mip/model/User.java +++ b/src/main/java/org/hbp/mip/model/User.java @@ -9,8 +9,10 @@ import com.google.gson.annotations.Expose; import io.swagger.annotations.ApiModel; import javax.persistence.*; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -81,6 +83,9 @@ public class User { private Boolean agreeNDA = null; + @OneToMany(mappedBy = "user", fetch = FetchType.EAGER) + private Set<Vote> appsVotes = new HashSet<>(); + public User() { } @@ -324,4 +329,12 @@ public class User { this.agreeNDA = agreeNDA; } + + public Set<Vote> getAppsVotes() { + return appsVotes; + } + + public void setAppsVotes(Set<Vote> appsVotes) { + this.appsVotes = appsVotes; + } } diff --git a/src/main/java/org/hbp/mip/model/Vote.java b/src/main/java/org/hbp/mip/model/Vote.java new file mode 100644 index 0000000000000000000000000000000000000000..80069e31ce8b50f7190379682bbc386a73ca1380 --- /dev/null +++ b/src/main/java/org/hbp/mip/model/Vote.java @@ -0,0 +1,66 @@ +/** + * Created by mirco on 24.05.16. + */ + +package org.hbp.mip.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; + +import javax.persistence.*; + +@Entity +@Table(name = "`vote`") +@ApiModel +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Vote { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private User user; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private App app; + + private int value; + + + public Vote() { + } + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public App getApp() { + return app; + } + + public void setApp(App app) { + this.app = app; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index f6bf967ac5c5a89ffb4c3e6d089c15c29c82f96d..e769d47db76d641651c9a209b8a98bdd18142625 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -30,6 +30,7 @@ <mapping class="org.hbp.mip.model.Group"/> <mapping class="org.hbp.mip.model.Config"/> <mapping class="org.hbp.mip.model.App"/> + <mapping class="org.hbp.mip.model.Vote"/> </session-factory> </hibernate-configuration> diff --git a/src/test/db b/src/test/db index 4f109917a05e4b32be69702660177e3011e44092..2cf7c0b7921e69bfd7f3dfac78437a135b8aadbb 160000 --- a/src/test/db +++ b/src/test/db @@ -1 +1 @@ -Subproject commit 4f109917a05e4b32be69702660177e3011e44092 +Subproject commit 2cf7c0b7921e69bfd7f3dfac78437a135b8aadbb