diff --git a/src/main/java/fr/lirmm/aren/model/User.java b/src/main/java/fr/lirmm/aren/model/User.java index e0312a7..f432622 100644 --- a/src/main/java/fr/lirmm/aren/model/User.java +++ b/src/main/java/fr/lirmm/aren/model/User.java @@ -137,15 +137,6 @@ public class User extends AbstractEntEntity implements Serializable { @SortNatural private SortedSet teams = new TreeSet<>(); - @JoinTable(name = "vm_teams_users", - joinColumns = { - @JoinColumn(name = "user_id", referencedColumnName = "id")}, - inverseJoinColumns = { - @JoinColumn(name = "team_id", referencedColumnName = "id")}) - @ManyToMany - @SortNatural - private SortedSet vmTeams = new TreeSet<>(); - @OneToMany(mappedBy = "owner") @SortNatural private SortedSet notifications = new TreeSet<>(); @@ -383,40 +374,6 @@ public class User extends AbstractEntEntity implements Serializable { team.getUsers().remove(this); } - /** - * - * @return - */ - public SortedSet getVmTeams() { - return vmTeams; - } - - /** - * - * @param vmTeams - */ - public void setVmTeams(SortedSet vmTeams) { - this.vmTeams = vmTeams; - } - - /** - * - * @param team - */ - public void addMember(VMTeam team) { - vmTeams.add(team); - team.getMembers().add(this); - } - - /** - * - * @param team - */ - public void removeMember(VMTeam team) { - vmTeams.remove(team); - team.getMembers().remove(this); - } - /** * * @return diff --git a/src/main/java/fr/lirmm/aren/model/vm/VMChoice.java b/src/main/java/fr/lirmm/aren/model/vm/VMChoice.java index 5f6e92e..7cd1486 100644 --- a/src/main/java/fr/lirmm/aren/model/vm/VMChoice.java +++ b/src/main/java/fr/lirmm/aren/model/vm/VMChoice.java @@ -1,6 +1,8 @@ package fr.lirmm.aren.model.vm; import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import fr.lirmm.aren.model.AbstractEntity; import org.hibernate.annotations.SortNatural; @@ -73,6 +75,10 @@ public class VMChoice extends AbstractEntity implements Serializable { @SortNatural private SortedSet votes = new TreeSet<>(); + @Transient + @JsonProperty + private int rank ; + /** * * @return @@ -297,6 +303,22 @@ public class VMChoice extends AbstractEntity implements Serializable { this.votes = votes; } + /** + * + * @return + */ + public int getRank() { + return rank; + } + + /** + * + * @param rank + */ + public void setRank(int rank) { + this.rank = rank; + } + public boolean isVoted(){ if(this.getRejected()!=0 || this.getInsufficient()!=0 || diff --git a/src/main/java/fr/lirmm/aren/model/vm/VMTeam.java b/src/main/java/fr/lirmm/aren/model/vm/VMTeam.java index 4a58ace..f09bca2 100644 --- a/src/main/java/fr/lirmm/aren/model/vm/VMTeam.java +++ b/src/main/java/fr/lirmm/aren/model/vm/VMTeam.java @@ -10,8 +10,6 @@ import org.hibernate.annotations.Where; import javax.persistence.*; import javax.validation.constraints.Size; import java.io.Serializable; -import java.util.SortedSet; -import java.util.TreeSet; /** * @author ANDRIAMBOLAHARIMIHANTA Havana on 11/07/2021 @@ -25,10 +23,6 @@ public class VMTeam extends AbstractEntity implements Serializable { @Column(name = "name") private String name; - @ManyToMany(mappedBy = "vmTeams") - @SortNatural - private SortedSet members = new TreeSet<>(); - /** * * @return @@ -44,38 +38,4 @@ public class VMTeam extends AbstractEntity implements Serializable { public void setName(String name) { this.name = name; } - - /** - * - * @return - */ - public SortedSet getMembers() { - return members; - } - - /** - * - * @param members - */ - public void setMembers(SortedSet members) { - this.members = members; - } - - /** - * - * @param user - */ - public void addUser(User user) { - this.members.add(user); - user.getVmTeams().add(this); - } - - /** - * - * @param user - */ - public void removeUser(User user) { - this.members.remove(user); - user.getVmTeams().remove(this); - } } \ No newline at end of file diff --git a/src/main/java/fr/lirmm/aren/model/vm/VMTheme.java b/src/main/java/fr/lirmm/aren/model/vm/VMTheme.java index e01973b..a303aa0 100644 --- a/src/main/java/fr/lirmm/aren/model/vm/VMTheme.java +++ b/src/main/java/fr/lirmm/aren/model/vm/VMTheme.java @@ -11,6 +11,7 @@ import javax.persistence.*; import javax.validation.constraints.Size; import java.io.Serializable; import java.time.ZonedDateTime; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; @@ -50,7 +51,7 @@ public class VMTheme extends AbstractEntity implements Serializable { private ZonedDateTime expiracyDate; @OneToMany(mappedBy = "themeId") - private Set choices = new LinkedHashSet<>(); + private Set choices = new HashSet<>(); /** * diff --git a/src/main/java/fr/lirmm/aren/service/vm/VMTeamService.java b/src/main/java/fr/lirmm/aren/service/vm/VMTeamService.java index 732a132..b6a983c 100644 --- a/src/main/java/fr/lirmm/aren/service/vm/VMTeamService.java +++ b/src/main/java/fr/lirmm/aren/service/vm/VMTeamService.java @@ -79,16 +79,4 @@ public class VMTeamService extends AbstractService { } return teams.get(0); } - - public void updateExternaleTables(VMTeam team) { - super.transactionBegin(); - team.getMembers().forEach(member->{ - System.out.println(team.getId()+" --- "+member.getId()); - getEntityManager().createNativeQuery("INSERT INTO vm_teams_users(vmteam_id,members_id) VALUES(?,?) ") - .setParameter(1, team.getId()) - .setParameter(2, member.getId()) - .executeUpdate(); - super.commit(); - }); - } } diff --git a/src/main/java/fr/lirmm/aren/ws/rest/VMTeamRESTFacade.java b/src/main/java/fr/lirmm/aren/ws/rest/VMTeamRESTFacade.java index 04af0ad..3c20152 100644 --- a/src/main/java/fr/lirmm/aren/ws/rest/VMTeamRESTFacade.java +++ b/src/main/java/fr/lirmm/aren/ws/rest/VMTeamRESTFacade.java @@ -46,12 +46,7 @@ public class VMTeamRESTFacade extends AbstractRESTFacade{ @Override @PermitAll public VMTeam create(VMTeam team){ - SortedSet members=team.getMembers() ; VMTeam teamRes= teamService.insert(team) ; - members.forEach(member->{ - teamRes.addUser(userService.getReference(member.getId())); - teamService.edit(teamRes); - }); return teamRes ; } diff --git a/src/main/java/fr/lirmm/aren/ws/rest/VMThemeRESTFacade.java b/src/main/java/fr/lirmm/aren/ws/rest/VMThemeRESTFacade.java index 57bbba6..3f84c24 100644 --- a/src/main/java/fr/lirmm/aren/ws/rest/VMThemeRESTFacade.java +++ b/src/main/java/fr/lirmm/aren/ws/rest/VMThemeRESTFacade.java @@ -119,16 +119,20 @@ public class VMThemeRESTFacade extends AbstractRESTFacade{ int index=0 ; for(ProposalResultInterface item : result.getProposalResults()){ - newChoices[item.getRank()-1]=(VMChoice) choices[index] ; + VMChoice vmChoice=(VMChoice) choices[index] ; + vmChoice.setRank(item.getRank()); + newChoices[item.getRank()-1]=vmChoice ; System.out.println(item.getRank()+" - "+newChoices[item.getRank()-1].getTitle()); index++ ; } } for(int i=0 ; i setChoices = new LinkedHashSet<>(); + HashSet setChoices = new HashSet<>(); System.out.println("Rang : ") ; for(int i=0 ; i