Class UserParentProvider

java.lang.Object
de.murmelmeister.murmelapi.user.parent.UserParentProvider
All Implemented Interfaces:
UserParent

public final class UserParentProvider extends Object implements UserParent
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addParent(int executorId, int userId, int parentId, long time)
    Adds a parent-child relationship for the specified user with an optional expiration time.
    void
    clearParent(int userId)
    Clears all parent-child relationships for the specified user.
    boolean
    existsParent(int userId, int parentId)
    Checks if a parent-child relationship exists between a user and a parent.
    getCreatedAt(int userId, int parentId)
    Retrieves the timestamp of when the parent-child relationship between a specified user and parent was created.
    int
    getCreatedBy(int userId, int parentId)
    Retrieves the ID of the user who created the parent-child relationship between the specified user and parent.
    getExpiredDate(int userId, int parentId)
    Retrieves the formatted expiration date of the relationship between the specified user and parent.
    long
    getExpiredTime(int userId, int parentId)
    Retrieves the expiration timestamp of the relationship between the specified user and parent.
    int
    getHighestPriority(Group group, int userId)
    Retrieves the highest priority value for a specific user within the given group.
    getModifiedAt(int userId, int parentId)
    Retrieves the timestamp indicating the last modification time of the relationship between the specified user and parent.
    int
    getModifiedBy(int userId, int parentId)
    Retrieves the ID of the user who last modified the relationship between the specified user and parent.
    getParentIds(int userId)
    Retrieves the list of parent IDs associated with the specified user.
    getParentNames(Group group, int userId)
    Retrieves the list of parent names associated with the specified user within the given group.
    boolean
    isExpired(int userId, int parentId)
    Checks if the relationship between a specified user and parent has expired.
    void
    Loads and processes the expired parent-child relationships for a given user.
    void
    removeParent(int userId, int parentId)
    Removes the parent-child relationship between a specified user and parent.
    setExpiredTime(int executorId, int userId, int parentId, long time)
    Sets the expiration time for the relationship between a specified user and parent.
    static void
    setup(Database database)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UserParentProvider

      public UserParentProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsParent

      public boolean existsParent(int userId, int parentId)
      Description copied from interface: UserParent
      Checks if a parent-child relationship exists between a user and a parent.
      Specified by:
      existsParent in interface UserParent
      Parameters:
      userId - The ID of the user whose parent relationship is to be verified
      parentId - The ID of the parent to be checked
      Returns:
      True if the user has the specified parent, false otherwise
    • addParent

      public void addParent(int executorId, int userId, int parentId, long time)
      Description copied from interface: UserParent
      Adds a parent-child relationship for the specified user with an optional expiration time.
      Specified by:
      addParent in interface UserParent
      Parameters:
      executorId - The ID of the user performing the log action.
      userId - The ID of the user for whom the parent relationship is being added.
      parentId - The ID of the parent to be associated with the user.
      time - The duration (in milliseconds) until this relationship expires. Use -1 for a relationship that does not expire.
    • removeParent

      public void removeParent(int userId, int parentId)
      Description copied from interface: UserParent
      Removes the parent-child relationship between a specified user and parent.
      Specified by:
      removeParent in interface UserParent
      Parameters:
      userId - The ID of the user whose parent relationship is being removed.
      parentId - The ID of the parent to be removed from the user.
    • clearParent

      public void clearParent(int userId)
      Description copied from interface: UserParent
      Clears all parent-child relationships for the specified user.
      Specified by:
      clearParent in interface UserParent
      Parameters:
      userId - The ID of the user whose parent relationships are being cleared.
    • getParentIds

      public List<Integer> getParentIds(int userId)
      Description copied from interface: UserParent
      Retrieves the list of parent IDs associated with the specified user.
      Specified by:
      getParentIds in interface UserParent
      Parameters:
      userId - The ID of the user whose parent IDs are to be fetched.
      Returns:
      A list of integers representing the parent IDs associated with the user.
    • getParentNames

      public List<String> getParentNames(Group group, int userId)
      Description copied from interface: UserParent
      Retrieves the list of parent names associated with the specified user within the given group.
      Specified by:
      getParentNames in interface UserParent
      Parameters:
      group - The group context in which the parent names are to be retrieved.
      userId - The ID of the user whose parent names are to be fetched.
      Returns:
      A list of strings representing the names of the parents associated with the specified user.
    • getHighestPriority

      public int getHighestPriority(Group group, int userId)
      Description copied from interface: UserParent
      Retrieves the highest priority value for a specific user within the given group.
      Specified by:
      getHighestPriority in interface UserParent
      Parameters:
      group - The group context to retrieve the priority for the user.
      userId - The ID of the user whose highest priority is being determined.
      Returns:
      The highest priority value associated with the user in the specified group.
    • getExpiredTime

      public long getExpiredTime(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the expiration timestamp of the relationship between the specified user and parent.
      Specified by:
      getExpiredTime in interface UserParent
      Parameters:
      userId - The ID of the user whose relationship expiration time is being retrieved.
      parentId - The ID of the parent involved in the relationship.
      Returns:
      The expiration timestamp of the relationship in milliseconds since the epoch. Returns -1 if the relationship does not expire.
    • getExpiredDate

      public String getExpiredDate(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the formatted expiration date of the relationship between the specified user and parent.
      Specified by:
      getExpiredDate in interface UserParent
      Parameters:
      userId - The ID of the user whose relationship expiration date is being retrieved.
      parentId - The ID of the parent involved in the relationship.
      Returns:
      A string representation of the expiration date of the relationship in a human-readable format.
    • setExpiredTime

      public String setExpiredTime(int executorId, int userId, int parentId, long time)
      Description copied from interface: UserParent
      Sets the expiration time for the relationship between a specified user and parent.
      Specified by:
      setExpiredTime in interface UserParent
      Parameters:
      executorId - The ID of the user performing the log action.
      userId - The ID of the user whose parent relationship is being updated.
      parentId - The ID of the parent associated with the user.
      time - The new expiration timestamp for the relationship in milliseconds since the epoch. Use -1 for a relationship that does not expire.
      Returns:
      A string message indicating the result of the operation.
    • isExpired

      public boolean isExpired(int userId, int parentId)
      Description copied from interface: UserParent
      Checks if the relationship between a specified user and parent has expired.
      Specified by:
      isExpired in interface UserParent
      Parameters:
      userId - The ID of the user whose parent relationship is being checked.
      parentId - The ID of the parent to check for expiration.
      Returns:
      True if the relationship has expired, false otherwise.
    • getCreatedBy

      public int getCreatedBy(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the ID of the user who created the parent-child relationship between the specified user and parent.
      Specified by:
      getCreatedBy in interface UserParent
      Parameters:
      userId - The ID of the user associated with the relationship.
      parentId - The ID of the parent associated with the relationship.
      Returns:
      The ID of the user who created the relationship.
    • getCreatedAt

      public Timestamp getCreatedAt(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the timestamp of when the parent-child relationship between a specified user and parent was created.
      Specified by:
      getCreatedAt in interface UserParent
      Parameters:
      userId - The ID of the user whose parent relationship creation timestamp is being retrieved.
      parentId - The ID of the parent involved in the relationship.
      Returns:
      The timestamp representing the creation time of the relationship.
    • getModifiedBy

      public int getModifiedBy(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the ID of the user who last modified the relationship between the specified user and parent.
      Specified by:
      getModifiedBy in interface UserParent
      Parameters:
      userId - The ID of the user associated with the relationship.
      parentId - The ID of the parent associated with the relationship.
      Returns:
      The ID of the user who last modified the relationship.
    • getModifiedAt

      public Timestamp getModifiedAt(int userId, int parentId)
      Description copied from interface: UserParent
      Retrieves the timestamp indicating the last modification time of the relationship between the specified user and parent.
      Specified by:
      getModifiedAt in interface UserParent
      Parameters:
      userId - The ID of the user whose relationship modification timestamp is being retrieved.
      parentId - The ID of the parent involved in the relationship.
      Returns:
      A Timestamp object representing the last modification time of the relationship between the user and parent.
    • loadExpired

      public void loadExpired(User user)
      Description copied from interface: UserParent
      Loads and processes the expired parent-child relationships for a given user.
      Specified by:
      loadExpired in interface UserParent
      Parameters:
      user - The user for whom expired relationships are to be loaded.