Class UserService

java.lang.Object
com.plannaplan.services.UserService

@Service
public class UserService
extends java.lang.Object
Service of UserService which can get(By Email), login, save user.
  • Constructor Details

  • Method Details

    • checkForUser

      public User checkForUser​(java.lang.String email, java.lang.String usosId)
      checks if user exist and return him or creates new one with student role otherwise
      Parameters:
      email - user email in usos
      usosId - user id in usos
      Returns:
      user entity instace containing changes saved in database
    • checkForUser

      public User checkForUser​(java.lang.String email, java.lang.String usosId, UserRoles roleIfNotExist)
      checks if user exist and creates new one if doesn't
      Parameters:
      email - user email in usos
      usosId - user id in usos
      roleIfNotExist - role to be set in case user is not in database yet
      Returns:
      user entity instace containing changes saved in database
    • login

      public User login​(User authority) throws UserNotFoundException
      generates token for user and if user don't have name in database it will attemp to obtain these from usos api and saves changes in database
      Parameters:
      authority - user we want to login
      Returns:
      user with changed values after save in db
      Throws:
      UserNotFoundException - throwed if user doesn't exist
    • save

      public User save​(User user)
      sacves user to databse and return instatnce with id
      Parameters:
      user - to be saved
      Returns:
      instatnce with bd id
    • getUserByEmail

      public User getUserByEmail​(java.lang.String email) throws UserNotFoundException
      Parameters:
      email - of user to be find
      Returns:
      user with given mail
      Throws:
      UserNotFoundException - throwed if user doesn't exist
    • getByAuthority

      public java.util.Optional<User> getByAuthority​(java.lang.String authority)
      return user by given authority
      Parameters:
      authority - user usosId or email
      Returns:
      optional with user if found
    • getByToken

      public java.util.Optional<User> getByToken​(java.lang.String token)
    • searchForStudents

      public java.util.List<User> searchForStudents​(java.lang.String query)
      search for user with given query
      Parameters:
      query - string that will be matched to users name and surname
      Returns:
      list opf results
    • getById

      public java.util.Optional<User> getById​(java.lang.Long userId)
    • getAllStudents

      public java.util.List<User> getAllStudents()
    • getUserByRefreshToken

      public java.util.Optional<User> getUserByRefreshToken​(java.lang.String refreshToken)
    • adminExists

      public boolean adminExists()
    • saveAll

      public void saveAll​(java.util.List<User> users)
    • getStudentsSortedByRanking

      public java.util.List<User> getStudentsSortedByRanking()
      get students sorted by their ranking
      Returns:
      list of students
    • getAmmountOfUsersWithAssignedGroups

      public int getAmmountOfUsersWithAssignedGroups()
      Returns:
      ammount of how many users created an assignment
    • getAmmountOfUsersWithNoAssignedGroups

      public java.lang.Integer getAmmountOfUsersWithNoAssignedGroups()
      Returns:
      ammount of how many users haven't created an assignment yet
    • getAmmountOfUsersWithAcceptedSchedules

      public java.lang.Integer getAmmountOfUsersWithAcceptedSchedules()
      Returns:
      ammount of how many users have full schedule accepted
    • getAmmountOfUsersWithNoAcceptedSchedules

      public java.lang.Integer getAmmountOfUsersWithNoAcceptedSchedules()
      Returns:
      ammount of how many users have partly or none schedule accepted