de.uka.ipd.consensus.impl
Class SQLRatingImpl

java.lang.Object
  extended byde.uka.ipd.consensus.impl.SQLRatingImpl
All Implemented Interfaces:
Commentatable, Comparable, Createable, Rating, Serializable, Versionable

public class SQLRatingImpl
extends Object
implements Rating

TODO

Version:
2006-06-14
Author:
Thomas Much
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface de.uka.ipd.consensus.foundation.schema.Rating
NEUTRAL, NO, YES
 
Constructor Summary
protected SQLRatingImpl(SQLRatingManagerImpl rmi, int id, String username, Rateable rateable, double value, String comment, long date, long rateddate)
           
protected SQLRatingImpl(SQLRatingManagerImpl rmi, int id, User creator, String username, double value, long date)
           
protected SQLRatingImpl(SQLRatingManagerImpl rmi, int id, User creator, String username, Rateable rateable, double value, String comment, long date, long rateddate)
           
protected SQLRatingImpl(SQLRatingManagerImpl rmi, int id, User creator, String username, Rateable rateable, double value, String comment, long date, long rateddate, boolean historical)
           
 
Method Summary
 int compareTo(Object obj)
           
 boolean equals(Object obj)
           
 String getComment()
          Returns the comment of the element.
 User getCreator()
          Returns the user that created this element.
 Collection getHistory()
          Returns a collection of Rating objects that contain all older values for this rating (i.e. the rating for this element from the creator of the rating).
protected  int getId()
           
protected  Rateable getInternalRateable()
           
 Rateable getRateable()
          Returns the rated element.
 Version getRatedVersion()
          Returns the version of the rated element.
protected  String getUsername()
           
 double getValue()
          Returns the rating's value from -1.0 to 1.0 (including both values).
 Version getVersion()
          Returns the version of the versionable element.
 int hashCode()
           
 boolean isHistorical()
          Checks if this rating is historic, i.e. if it contains older values than the element's current rating.
 void setComment(User setter, String comment)
          Changes the element's comment.
protected  void setHistorical(boolean historical)
           
protected  void setRateable(Rateable rateable)
           
 void setValue(double value)
          Changes the rating's value and adds the old values to the history.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLRatingImpl

protected SQLRatingImpl(SQLRatingManagerImpl rmi,
                        int id,
                        User creator,
                        String username,
                        double value,
                        long date)

SQLRatingImpl

protected SQLRatingImpl(SQLRatingManagerImpl rmi,
                        int id,
                        String username,
                        Rateable rateable,
                        double value,
                        String comment,
                        long date,
                        long rateddate)

SQLRatingImpl

protected SQLRatingImpl(SQLRatingManagerImpl rmi,
                        int id,
                        User creator,
                        String username,
                        Rateable rateable,
                        double value,
                        String comment,
                        long date,
                        long rateddate)

SQLRatingImpl

protected SQLRatingImpl(SQLRatingManagerImpl rmi,
                        int id,
                        User creator,
                        String username,
                        Rateable rateable,
                        double value,
                        String comment,
                        long date,
                        long rateddate,
                        boolean historical)
Method Detail

getId

protected int getId()

getUsername

protected String getUsername()

setRateable

protected void setRateable(Rateable rateable)

setHistorical

protected void setHistorical(boolean historical)

isHistorical

public boolean isHistorical()
Description copied from interface: Rating
Checks if this rating is historic, i.e. if it contains older values than the element's current rating. Historic ratings are read-only.

Specified by:
isHistorical in interface Rating
Returns:
true if this rating belongs to the rating history, false if it is a current rating
See Also:
Rating.getHistory(), Rating.setValue(double), Commentatable.setComment(User, String)

getRateable

public Rateable getRateable()
Description copied from interface: Rating
Returns the rated element. This can be only a concept (topic, association, attribute) or a user. However, if you want to retrieve an association wrapper like Synonym, SuperSubclass or TypeInstance (which are Rateable, too), use OntologyManager.checkInternalRateable() to convert the returned association into one of these wrappers.

Specified by:
getRateable in interface Rating
Returns:
the rated element
See Also:
OntologyManager.checkInternalRateable(Rateable)

getInternalRateable

protected Rateable getInternalRateable()

getCreator

public User getCreator()
Description copied from interface: Createable
Returns the user that created this element.

Specified by:
getCreator in interface Createable
Returns:
the User object

getValue

public double getValue()
Description copied from interface: Rating
Returns the rating's value from -1.0 to 1.0 (including both values).

Specified by:
getValue in interface Rating
Returns:
the rating's value
See Also:
Rating.setValue(double)

setValue

public void setValue(double value)
Description copied from interface: Rating
Changes the rating's value and adds the old values to the history. If this is a historic rating, changing its value has no effect.

Specified by:
setValue in interface Rating
Parameters:
value - the new value from -1.0 to 1.0 (including both values)
See Also:
Rating.getValue(), Rating.getHistory(), Rating.isHistorical()

getComment

public String getComment()
Description copied from interface: Commentatable
Returns the comment of the element.

Specified by:
getComment in interface Commentatable
Returns:
the comment (may be the empty string, but never null)

setComment

public void setComment(User setter,
                       String comment)
                throws OntologyManagerException,
                       DynamicRightsManagerException
Description copied from interface: Commentatable
Changes the element's comment.

Specified by:
setComment in interface Commentatable
Parameters:
setter - the user who wants to change the comment
comment - the new comment (null is treated as an empty string)
Throws:
DynamicRightsManagerException - if the user is not allowed to change the comment
OntologyManagerException - if the comment could not be changed
See Also:
DynamicRightsManager.mayChangeConceptComment(User, Concept), DynamicRightsManager.mayChangeUserComment(User, User)

getVersion

public Version getVersion()
Description copied from interface: Versionable
Returns the version of the versionable element.

Specified by:
getVersion in interface Versionable
Returns:
the Version object or null if no version information is available

getRatedVersion

public Version getRatedVersion()
Description copied from interface: Rating
Returns the version of the rated element. This is the element's version at the time when the rating was assigned to the element, not necessarily the element's current version.

Specified by:
getRatedVersion in interface Rating
Returns:
the version of the rated element, may be null if no version information is available

getHistory

public Collection getHistory()
Description copied from interface: Rating
Returns a collection of Rating objects that contain all older values for this rating (i.e. the rating for this element from the creator of the rating). If this rating is a historical rating itself or if the RatingManager does not support rating histories, an empty collection is returned.

Specified by:
getHistory in interface Rating
Returns:
a possibly empty collection, never null
See Also:
Rating.isHistorical()

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

toString

public String toString()