de.uka.ipd.consensus.foundation.schema
Interface User

All Superinterfaces:
Commentatable, Comparable, Rateable, Serializable
All Known Implementing Classes:
UserImpl

public interface User
extends Rateable, Commentatable, Serializable, Comparable

This interface represents a user who is part of the ontology, but managed by the UserManager. The user must be available within the ontology to enable associations between him and other elements of the ontology. But the user's data need to be stored outside the ontology for security reasons.

Version:
2006-06-14
Author:
Thomas Much
See Also:
UserManager, OntologyManager

Method Summary
 void addRole(UserRole role)
          Adds a UserRole to this user's roles.
 double getAverageOwnRatingsValue()
          Returns the average value (the arithmetic mean) of all ratings that this user has given to other elements of the ontology.
 String getId()
          Returns the user's id that was computed automatically from the username when the user created his account.
 Collection getOwnRatings()
          Returns a collection of all current Rating objects that this user has given to other elements of the ontology.
 int getOwnRatingsCount()
          Returns the number of ratings that this user has given to other elements of the ontology.
 Collection getRoles()
          Returns a collection of UserRole objects that this user is in.
 double getScore()
          Returns this user's score.
 UserManager getUserManager()
          Returns the UserManager instance that manages this user account.
 String getUsername()
          Returns the username that the user has given himself when creating his user account.
 boolean isAdmin()
          Checks if the user is in the admin role.
 boolean isInRole(UserRole role)
          Checks if the user is in the given role.
 boolean isLoggedOn()
          Checks if the user is logged on.
 void removeRole(UserRole role)
          Removes a UserRole from this user's roles.
 void setScore(double score)
          Changes this user's score.
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Rateable
addRating, getAverageRatingValue, getRating, getRatings, getRatingsCount
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Commentatable
getComment, setComment
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getUsername

public String getUsername()
Returns the username that the user has given himself when creating his user account. This username must be unique within the user database.

Returns:
the username (never empty, never null)
See Also:
getId(), UserManager.createUser(String, String, Map), UserManager.getUserByUsername(String)

getId

public String getId()
Returns the user's id that was computed automatically from the username when the user created his account. The user id must be unique within all elements of the ontology.

Specified by:
getId in interface Rateable
Returns:
the user's id (never empty, never null)
See Also:
getUsername(), UserManager.createUser(String, String, Map), UserManager.getUserById(String)

getUserManager

public UserManager getUserManager()
Returns the UserManager instance that manages this user account.

Returns:
the UserManager, never null

isInRole

public boolean isInRole(UserRole role)
Checks if the user is in the given role.

Parameters:
role - the role to check
Returns:
true if the user is in the role, false otherwise
See Also:
UserManager.findRole(String)

getRoles

public Collection getRoles()
Returns a collection of UserRole objects that this user is in.

Returns:
a possibly empty collection, never null
See Also:
UserRole

addRole

public void addRole(UserRole role)
Adds a UserRole to this user's roles.

Parameters:
role - the UserRole to add
See Also:
UserManager.findRole(String)

removeRole

public void removeRole(UserRole role)
Removes a UserRole from this user's roles. If the user isn't in the role, this call is ignored.

Parameters:
role - the UserRole to remove
See Also:
UserManager.findRole(String)

isAdmin

public boolean isAdmin()
Checks if the user is in the admin role.

Returns:
true if the user is in the admin role, false otherwise

isLoggedOn

public boolean isLoggedOn()
Checks if the user is logged on.

Returns:
true if the user is logged on, false otherwise
See Also:
UserManager.login(String, String), UserManager.logout(User)

getScore

public double getScore()
Returns this user's score. The IncentiveManager or a ScoringListener may change the user's score for his actions (e.g. create or rate elements).

Returns:
the user's score
See Also:
setScore(double), IncentiveManager.getInitialUserScore(), ScoringListener

setScore

public void setScore(double score)
Changes this user's score. This method is usually called from a ScoringListener.

Parameters:
score - the new score (an absolute value, not a delta value!)
See Also:
getScore(), ScoringListener

getOwnRatings

public Collection getOwnRatings()
Returns a collection of all current Rating objects that this user has given to other elements of the ontology. This method exists just for convenience and delegates to a RatingManager method.

Returns:
a possibly empty collection, never null
See Also:
Rating, RatingManager.getUsersOwnRatings(User)

getOwnRatingsCount

public int getOwnRatingsCount()
Returns the number of ratings that this user has given to other elements of the ontology. Each element can have only one current rating by one user, i.e. historical ratings do not count.

Returns:
the number of ratings that this user has given to other elements of the ontology.

getAverageOwnRatingsValue

public double getAverageOwnRatingsValue()
Returns the average value (the arithmetic mean) of all ratings that this user has given to other elements of the ontology. Each element can have only one current rating by one user, i.e. historical ratings do not count.

Returns:
the arithmetic mean of all ratings that this user has given to other elements of the ontology