Checkpoint - added many to many user group relations and test cerating users and groups to accept test
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
package com.plannaplan.entities;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import com.plannaplan.types.GroupType;
|
||||
@ -36,23 +40,36 @@ public class Groups {
|
||||
private Lecturer lecturer;
|
||||
private Integer zajCykId;
|
||||
private Integer grNr;
|
||||
@ManyToMany(mappedBy = "studentRegisteredGrups")
|
||||
private Set<User> registeredStudents;
|
||||
|
||||
public Set<User> getRegisteredStudents() {
|
||||
return this.registeredStudents;
|
||||
}
|
||||
|
||||
public void assignUser(User user) {
|
||||
if (this.registeredStudents == null) {
|
||||
this.registeredStudents = new HashSet<>();
|
||||
}
|
||||
this.registeredStudents.add(user);
|
||||
}
|
||||
|
||||
public Groups() {
|
||||
}
|
||||
|
||||
public Integer getGr_nr() {
|
||||
public Integer getGrNr() {
|
||||
return grNr;
|
||||
}
|
||||
|
||||
public void setGr_nr(Integer grNr) {
|
||||
public void setGrNr(Integer grNr) {
|
||||
this.grNr = grNr;
|
||||
}
|
||||
|
||||
public Integer getZaj_cyk_id() {
|
||||
public Integer getZajCykId() {
|
||||
return zajCykId;
|
||||
}
|
||||
|
||||
public void setZaj_cyk_id(Integer zajCykId) {
|
||||
public void setZajCykId(Integer zajCykId) {
|
||||
this.zajCykId = zajCykId;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,18 @@
|
||||
package com.plannaplan.entities;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
import com.plannaplan.models.UserApiResponse;
|
||||
import com.plannaplan.types.UserRoles;
|
||||
@ -33,6 +38,20 @@ public class User {
|
||||
private String refreshToken;
|
||||
private Timestamp tokenUsageDate;
|
||||
private Integer ranking;
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable
|
||||
private Set<Groups> studentRegisteredGrups;
|
||||
|
||||
public Set<Groups> getStudentRegisteredGrups() {
|
||||
return this.studentRegisteredGrups;
|
||||
}
|
||||
|
||||
public void claimGroup(Groups group) {
|
||||
if (this.studentRegisteredGrups == null) {
|
||||
this.studentRegisteredGrups = new HashSet<>();
|
||||
}
|
||||
this.studentRegisteredGrups.add(group);
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
Reference in New Issue
Block a user