de.uka.ipd.consensus.impl
Class AttributeImpl

java.lang.Object
  extended byde.uka.ipd.consensus.impl.TM4JObjectWrapper
      extended byde.uka.ipd.consensus.impl.TM4JTopicWrapper
          extended byde.uka.ipd.consensus.impl.AttributeImpl
All Implemented Interfaces:
Attribute, Commentatable, Comparable, Concept, Createable, Rateable, Serializable, Versionable

public class AttributeImpl
extends TM4JTopicWrapper
implements Attribute

TODO

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

Field Summary
 
Fields inherited from class de.uka.ipd.consensus.impl.TM4JObjectWrapper
EMPTY_SCOPE
 
Constructor Summary
protected AttributeImpl(OntologyManagerImpl omi, org.tm4j.topicmap.Topic tmTopic)
           
 
Method Summary
 Rating addRating(User rater, double value)
          Adds a rating for the given user to this element.
 Attributeable getAttributeable()
          Returns the element which this attribute belongs to.
 double getAverageRatingValue()
          Returns the average value (the arithmetic mean) of all current ratings for this element.
 Rating getRating(User user)
          Returns the rating of the given user for this element.
 Collection getRatings()
          Returns a collection of all current Rating objects (from different users) for this element.
 int getRatingsCount()
          Returns the number of ratings for this element.
 Topic getType()
          Returns the type of the attribute.
 String getValue()
          Returns the attribute's value.
protected  void initValue(String value)
           
 boolean isOfType(Topic type)
          Checks if this concept is of the given type.
 void setType(User setter, Topic type)
          Sets the type of the attribute.
 void setValue(User setter, String value)
          Changes the attribute's value.
 String toString()
           
 
Methods inherited from class de.uka.ipd.consensus.impl.TM4JTopicWrapper
compareTo, getComment, getCreator, getId, getName, getOccurrence, getVersion, getWrappedTopic, incVersion, setComment, setName
 
Methods inherited from class de.uka.ipd.consensus.impl.TM4JObjectWrapper
equals, getCache, getLoggingManager, getObjectId, getOccurrence, getOntologyManager, getWrappedObject, hashCode, putCache, wrap, wrap, wrap, wrap, wrap, wrap, wrap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Concept
getId, getName, setName
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Versionable
getVersion
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Commentatable
getComment, setComment
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Createable
getCreator
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

AttributeImpl

protected AttributeImpl(OntologyManagerImpl omi,
                        org.tm4j.topicmap.Topic tmTopic)
Method Detail

getValue

public String getValue()
Description copied from interface: Attribute
Returns the attribute's value.

Specified by:
getValue in interface Attribute
Returns:
the attribute's value (may be an empty string, but never null)

initValue

protected void initValue(String value)
                  throws Exception
Throws:
Exception

setValue

public void setValue(User setter,
                     String value)
              throws OntologyManagerException,
                     DynamicRightsManagerException
Description copied from interface: Attribute
Changes the attribute's value.

Specified by:
setValue in interface Attribute
Parameters:
setter - the user who wants to change the value
value - the new value (null is treated as an empty string)
Throws:
OntologyManagerException - if the value could not be changed
DynamicRightsManagerException - if the user is not allowed to change the value
See Also:
DynamicRightsManager.mayChangeAttributeValue(User, Attribute)

getType

public Topic getType()
Description copied from interface: Attribute
Returns the type of the attribute.

Specified by:
getType in interface Attribute
Returns:
the attribute's type or null if the attribute does not have a type

setType

public void setType(User setter,
                    Topic type)
             throws OntologyManagerException,
                    DynamicRightsManagerException
Description copied from interface: Attribute
Sets the type of the attribute. If the implementation supports classes, the type must be a class topic.

Specified by:
setType in interface Attribute
Parameters:
setter - the user who wants to set the type
type - the type topic (or null to remove the type)
Throws:
OntologyManagerException - if the type could not be set
DynamicRightsManagerException - if the user is not allowed to change the type
See Also:
Topic.isClassTopic()

isOfType

public boolean isOfType(Topic type)
Description copied from interface: Concept
Checks if this concept is of the given type.

Specified by:
isOfType in interface Concept
Parameters:
type - the type topic, including null for typeless concepts
Returns:
true if the concept is of the specified type, false otherwise

getAttributeable

public Attributeable getAttributeable()
Description copied from interface: Attribute
Returns the element which this attribute belongs to. With the current schema definition, this can only be a Topic object.

Specified by:
getAttributeable in interface Attribute
Returns:
the topic which this attribute belongs to
See Also:
Topic

addRating

public Rating addRating(User rater,
                        double value)
                 throws RatingManagerException,
                        DynamicRightsManagerException
Description copied from interface: Rateable
Adds a rating for the given user to this element. If the user has rated the element already, only the rating's value is changed. Otherwise, this method creates and adds a new rating using suitable RatingManager methods.

Specified by:
addRating in interface Rateable
Parameters:
rater - the user who wants to add or change the rating
value - the new value
Returns:
the newly created or the existing but changed rating
Throws:
DynamicRightsManagerException - if the user is not allowed to rate this element
RatingManagerException - if the rating could not be created/changed
See Also:
RatingManager, DynamicRightsManager.mayAddRating(Rating, Rateable)

getRatings

public Collection getRatings()
Description copied from interface: Rateable
Returns a collection of all current Rating objects (from different users) for this element. This method exists just for convenience and delegates to one of the getRatings() methods of RatingManager.

Specified by:
getRatings in interface Rateable
Returns:
a possibly empty collection, never null
See Also:
Rating, RatingManager

getAverageRatingValue

public double getAverageRatingValue()
Description copied from interface: Rateable
Returns the average value (the arithmetic mean) of all current ratings for this element.

Specified by:
getAverageRatingValue in interface Rateable
Returns:
the arithmetic mean of all ratings for this element

getRatingsCount

public int getRatingsCount()
Description copied from interface: Rateable
Returns the number of ratings for this element. Each user can have only one current rating for each element, i.e. historical ratings do not count.

Specified by:
getRatingsCount in interface Rateable
Returns:
the number of ratings for this element.

getRating

public Rating getRating(User user)
Description copied from interface: Rateable
Returns the rating of the given user for this element. This method exists just for convenience and delegates to one of the getRatings() methods of RatingManager.

Specified by:
getRating in interface Rateable
Parameters:
user - the user who's rating shall be returned
Returns:
the rating of the user or null if the user hasn't rated this element yet
See Also:
RatingManager

toString

public String toString()