fi.paatti.paattidatabaseutils.dbobjects
Class User

java.lang.Object
  extended by fi.paatti.paattidatabaseutils.dbobjects.User

public class User
extends Object

User object holds the username, ID, groups and roles of the user. It also has some methods to check if the user belongs to a certain group or has some role in those groups.

Author:
Lauri Satokangas, lauri.n.satokangas@student.jyu.fi
 

Constructor Summary
User(int userID)
          User constructor.
 
Method Summary
 void addUserGroup(UserGroup ugGroup)
          Adds a new user group to the user.
 ArrayList<UserGroup> getUserGroups()
          Returns the user's groups.
 int getUserID()
          Returns the value of userID.
 String getUsername()
          Returns the value of username.
 boolean hasRoleInAnyGroup(int roleID)
          Checks if the user has the given role in any of his/her groups.
 boolean hasRoleInUserGRoup(int roleID, int usergroupID)
          Checks if the user has the given role in the given group.
 boolean isInUserGroup(int usergroupID)
          Checks if the user belongs to a certain user group.
 void setUsername(String username)
          Sets the value of username.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User(int userID)
User constructor.

Parameters:
userID - The ID of the user.
Method Detail

getUsername

public String getUsername()
Returns the value of username.

Returns:
the value of username.

setUsername

public void setUsername(String username)
Sets the value of username.

Parameters:
username - new value of username.

getUserID

public int getUserID()
Returns the value of userID.

Returns:
the value of userID.

getUserGroups

public ArrayList<UserGroup> getUserGroups()
Returns the user's groups.

Returns:
The user's groups.

addUserGroup

public void addUserGroup(UserGroup ugGroup)
Adds a new user group to the user.

Parameters:
ugGroup - user group

isInUserGroup

public boolean isInUserGroup(int usergroupID)
Checks if the user belongs to a certain user group.

Parameters:
usergroupID - the user group's id.
Returns:
True if the user belongs to the given group, otherwise false.

hasRoleInUserGRoup

public boolean hasRoleInUserGRoup(int roleID,
                                  int usergroupID)
Checks if the user has the given role in the given group.

Parameters:
roleID - The ID of the user role.
usergroupID - The ID of the user group.
Returns:
True if the user has the given role in the given group, otherwise false.

hasRoleInAnyGroup

public boolean hasRoleInAnyGroup(int roleID)
Checks if the user has the given role in any of his/her groups.

Parameters:
roleID - The ID of the user role.
Returns:
True if the user has the given role in any of his/her groups, otherwise false.


Copyright © 2012. All Rights Reserved.