diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/User.java b/buisnesslogic/src/main/java/com/plannaplan/entities/User.java index 24e45bc..422ae1f 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/User.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/User.java @@ -32,6 +32,7 @@ public class User { private String token; private String refreshToken; private Timestamp tokenUsageDate; + private Integer ranking; public User() { } @@ -63,6 +64,21 @@ public class User { this.usosId = usosId; } + /** + * + * @param name name given to the user + * @param surname surname given to the user + * @param mail mail given to the user + * @param usosId id in the USOS system + * @param role user's role + * @param ranking ranking points <100;500>. It's calculated by + * gradesAvg*100*studiesYear + */ + public User(String name, String surname, String mail, String usosId, UserRoles role, Integer ranking) { + this(name, surname, mail, usosId, role); + this.ranking = ranking; + } + /** * usos id getter * @@ -189,6 +205,25 @@ public class User { return this.id; } + /** + * Ranking points are <100;500>. It's calculated by gradesAvg*100*studiesYear + * + * @return ranking points <100;500> + */ + public Integer getRanking() { + return ranking; + } + + /** + * Ranking points setter. Ranking points are <100;500>. It's calculated by + * gradesAvg*100*studiesYear + * + * @param ranking ranking points <100;500> + */ + public void setRanking(Integer ranking) { + this.ranking = ranking; + } + /** * updates user entity with data got by UsosApiService::getUserData * diff --git a/restservice/src/main/java/com/plannaplan/App.java b/restservice/src/main/java/com/plannaplan/App.java index d77366b..7f9885c 100755 --- a/restservice/src/main/java/com/plannaplan/App.java +++ b/restservice/src/main/java/com/plannaplan/App.java @@ -2,6 +2,7 @@ package com.plannaplan; import java.io.InputStream; import java.sql.Date; +import java.util.Random; import com.plannaplan.models.ConfigData; import com.plannaplan.models.TourData; @@ -30,7 +31,7 @@ public class App { private ConfiguratorService contrl; @Autowired - UserService userService; + private UserService userService; @Value("${plannaplan.dev}") private boolean isDev; @@ -52,8 +53,9 @@ public class App { System.out.println(Logo.getInitInfo(isDev)); if (this.isDev) { - InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); - ConfigData data = new ConfigData( + final Random generator = new Random(); + final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); + final ConfigData data = new ConfigData( new TourData(new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis() + 86400000)), new TourData(new Date(System.currentTimeMillis() + 86400000), @@ -65,6 +67,7 @@ public class App { newuser.setEmail("tommy@st.amu.edu.pl"); newuser.setName("Tomek"); newuser.setSurname("Atomek"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -72,6 +75,7 @@ public class App { newuser.setEmail("robercik@st.amu.edu.pl"); newuser.setName("Robert"); newuser.setSurname("GÅ‚owacki"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -79,6 +83,7 @@ public class App { newuser.setEmail("mewa@st.amu.edu.pl"); newuser.setName("Poznanska"); newuser.setSurname("Mewa"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -86,6 +91,7 @@ public class App { newuser.setEmail("tkul2@st.amu.edu.pl"); newuser.setName("Tomasz"); newuser.setSurname("Kula"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -93,6 +99,7 @@ public class App { newuser.setEmail("annana@st.amu.edu.pl"); newuser.setName("Anna"); newuser.setSurname("Na"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -100,6 +107,7 @@ public class App { newuser.setEmail("mnart@st.amu.edu.pl"); newuser.setName("Marta"); newuser.setSurname("Narta"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -107,6 +115,7 @@ public class App { newuser.setEmail("zmineniane@st.amu.edu.pl"); newuser.setName("Tutaj"); newuser.setSurname("Koncza"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -114,6 +123,7 @@ public class App { newuser.setEmail("mi@st.amu.edu.pl"); newuser.setName("Mi"); newuser.setSurname("Sie"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); @@ -121,11 +131,13 @@ public class App { newuser.setEmail("pms@st.amu.edu.pl"); newuser.setName("Pomysly"); newuser.setSurname("Sad"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("iamnull@st.amu.edu.pl"); + newuser.setRanking(generator.nextInt(400) + 100); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); }