de.uka.ipd.consensus.impl
Class TopicImpl

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

public class TopicImpl
extends TM4JTopicWrapper
implements Topic

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 TopicImpl(OntologyManagerImpl omi, org.tm4j.topicmap.Topic tmTopic)
           
 
Method Summary
 void addAttribute(User setter, Attribute attr)
          Adds an attribute object to the attributeable element.
 Occurrence addOccurrence(User adder, String data, Topic type)
          Creates an occurrence for this topic with the given type and value (data).
 Rating addRating(User rater, double value)
          Adds a rating for the given user to this element.
 SuperSubclass addSuperclass(User adder, Topic cls)
          Adds a superclass to this topic.
 Synonym addSynonym(User adder, Topic topic)
          Adds another topic as a synonym to this topic (and vice versa).
 TypeInstance addType(User adder, Topic type)
          Adds a type to this topic.
 Collection getAssociations(User user)
          Returns a collection of Association objects in which this topic plays a role.
 Attribute getAttribute(User getter, String id)
          Returns the attribute of a given id.
 Collection getAttributes(User getter)
          Returns a collection of all Attribute objects of this element that the user may see.
 Collection getAttributes(User getter, Topic type)
          Returns a collection of all Attribute objects of the given type.
 double getAverageRatingValue()
          Returns the average value (the arithmetic mean) of all current ratings for this element.
 Collection getInstances(User user)
          Returns a collection of TypeInstance objects containing the instances of this type (class) topic.
 Occurrence getOccurrence(User user, String id)
          Queries an occurrence of this topic with the given id.
 Collection getOccurrences(Topic type)
          Returns a collection of all Occurrence objects of a certain type for this topic.
 Collection getOccurrences(User user)
          Returns a collection of all Occurrence objects for this topic.
 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.
 Collection getSubclasses(User user)
          Returns a collection of SuperSubclass objects containing the subclasses of this class topic.
 SuperSubclass getSuperclass(User user, String id)
          Queries a superclass of this topic with the given id.
 Collection getSuperclasses(User user)
          Returns a collection of SuperSubclass objects containing the superclasses of this class topic.
 Synonym getSynonym(User user, String id)
          Queries a synonym of this topic with the given id.
 Collection getSynonyms(User user)
          Returns a collection of all Synonym objects for this topic.
 TypeInstance getType(User user, String id)
          Queries a type with the given id of this instance topic.
 Collection getTypes(User user)
          Returns a collection of TypeInstance objects containing the types of this instance topic.
protected  boolean hasFlag(String flag)
           
 boolean isClassTopic()
          Checks if this topic is a class topic.
 boolean isOfType(Topic type)
          Checks if this concept is of the given type.
 boolean isSynonymous(Topic topic)
          Checks if the given topic is synonymous with this topic.
 void removeAttribute(User remover, Attribute attr)
          Removes the given attribute, if the object is an attribute of this element (otherwise, the call is ignored).
protected  void removeFlag(String flag)
           
 void removeOccurrence(User remover, Occurrence occ)
          Removes an occurrence from this topic.
 void removeSuperclass(User remover, Topic cls)
          Removes a superclass from this class topic.
 void removeSynonym(User remover, Topic topic)
          Removes a synonymous topic from this topic (and vice versa).
 void removeType(User remover, Topic type)
          Removes a type from this topic.
 void setClassTopic(boolean isclass)
          Controls the class flag, i.e. if the topic is a class or an instance topic.
protected  void setFlag(String flag)
           
 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

TopicImpl

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

getInstances

public Collection getInstances(User user)
Description copied from interface: Topic
Returns a collection of TypeInstance objects containing the instances of this type (class) topic.

Specified by:
getInstances in interface Topic
Parameters:
user - the user who wants to see the instances
Returns:
a possibly empty collection, never null
See Also:
TypeInstance, DynamicRightsManager.mayViewTopic(User, Topic), QueryEngine.getInstances(User, Topic), Topic.isClassTopic(), Topic.getSubclasses(User)

getTypes

public Collection getTypes(User user)
Description copied from interface: Topic
Returns a collection of TypeInstance objects containing the types of this instance topic.

Specified by:
getTypes in interface Topic
Parameters:
user - the user who wants to see the types
Returns:
a possibly empty collection, never null
See Also:
TypeInstance, DynamicRightsManager.mayViewTopic(User, Topic), QueryEngine.getTypes(User, Topic), Topic.getSuperclasses(User)

getType

public TypeInstance getType(User user,
                            String id)
Description copied from interface: Topic
Queries a type with the given id of this instance topic.

Specified by:
getType in interface Topic
Parameters:
user - the user who wants to see the type
id - the queried id
Returns:
a TypeInstance object containing the type or null if there's no type with the given id
See Also:
DynamicRightsManager.mayViewTopic(User, Topic), Topic.getSuperclass(User, String)

addType

public TypeInstance addType(User adder,
                            Topic type)
                     throws OntologyManagerException,
                            DynamicRightsManagerException
Description copied from interface: Topic
Adds a type to this topic. If the implementation supports classes, the type must be a class topic.

Specified by:
addType in interface Topic
Parameters:
adder - the user who wants to add the type
type - the type topic to be added (must not be null)
Returns:
a TypeInstance object containing the type topic
Throws:
OntologyManagerException - if the type could not be added
DynamicRightsManagerException - if the user is not allowed to add a type
See Also:
Topic.isClassTopic(), DynamicRightsManager.mayAddType(User, Topic), Topic.addSuperclass(User, Topic)

removeType

public void removeType(User remover,
                       Topic type)
                throws OntologyManagerException,
                       DynamicRightsManagerException
Description copied from interface: Topic
Removes a type from this topic. If the given type is no type of this topic, this call has no effect.

Specified by:
removeType in interface Topic
Parameters:
remover - the user who wants to remove the type
type - the type to be removed
Throws:
DynamicRightsManagerException - if the user is not allowed to remove the type
OntologyManagerException - if the type could not be removed
See Also:
TypeInstance, DynamicRightsManager.mayRemoveType(User, TypeInstance), Topic.removeSuperclass(User, Topic)

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

getAssociations

public Collection getAssociations(User user)
Description copied from interface: Topic
Returns a collection of Association objects in which this topic plays a role.

Specified by:
getAssociations in interface Topic
Parameters:
user - the user who wants to see the associations
Returns:
a possibly empty collection, never null
See Also:
Association, DynamicRightsManager.mayViewAssociation(User, Association), QueryEngine.getAssociations(User, 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

addAttribute

public void addAttribute(User setter,
                         Attribute attr)
                  throws OntologyManagerException,
                         DynamicRightsManagerException
Description copied from interface: Attributeable
Adds an attribute object to the attributeable element.

Specified by:
addAttribute in interface Attributeable
Parameters:
setter - the user who wants to add the attribute
attr - the Attribute object
Throws:
DynamicRightsManagerException - if the user is not allowed to add the attribute
OntologyManagerException - if the attribute could not be added
See Also:
OntologyManager.createAttribute(User, String, String, String, Topic), DynamicRightsManager.mayAddAttribute(User, Attribute, Attributeable)

removeAttribute

public void removeAttribute(User remover,
                            Attribute attr)
                     throws OntologyManagerException,
                            DynamicRightsManagerException
Description copied from interface: Attributeable
Removes the given attribute, if the object is an attribute of this element (otherwise, the call is ignored).

Specified by:
removeAttribute in interface Attributeable
Parameters:
remover - the user who wants to remove the attribute
attr - the Attribute object to be removed
Throws:
OntologyManagerException - if the attribute could not be removed
DynamicRightsManagerException - if the user is not allowed to remove the attribute
See Also:
DynamicRightsManager.mayRemoveAttribute(User, Attribute)

getAttribute

public Attribute getAttribute(User getter,
                              String id)
Description copied from interface: Attributeable
Returns the attribute of a given id.

Specified by:
getAttribute in interface Attributeable
Parameters:
getter - the user who wants to get the attribute
id - the id in question
Returns:
the attribute with the id or null if this element does not have an attribute with the id
See Also:
Concept.getId(), DynamicRightsManager.mayViewAttribute(User, Attribute)

getAttributes

public Collection getAttributes(User getter)
Description copied from interface: Attributeable
Returns a collection of all Attribute objects of this element that the user may see.

Specified by:
getAttributes in interface Attributeable
Parameters:
getter - the user who wants to see the attributes
Returns:
a possibly empty collection, never null
See Also:
Attribute, DynamicRightsManager.mayViewAttribute(User, Attribute), DynamicRightsManager.mayViewTopic(User, Topic)

getAttributes

public Collection getAttributes(User getter,
                                Topic type)
Description copied from interface: Attributeable
Returns a collection of all Attribute objects of the given type.

Specified by:
getAttributes in interface Attributeable
Parameters:
getter - the user who wants to see the attributes
type - type the type topic of the attributes, including null for the typeless attributes
Returns:
a possibly empty collection, never null
See Also:
Attribute, DynamicRightsManager.mayViewAttribute(User, Attribute)

getOccurrences

public Collection getOccurrences(User user)
Description copied from interface: Topic
Returns a collection of all Occurrence objects for this topic. The collection contains only occurrences whose type the user is allowed to see.

Specified by:
getOccurrences in interface Topic
Parameters:
user - the user who wants to see the occurrences.
Returns:
a possibly empty collection, never null
See Also:
Occurrence, DynamicRightsManager.mayViewTopic(User, Topic)

getOccurrences

public Collection getOccurrences(Topic type)
Description copied from interface: Topic
Returns a collection of all Occurrence objects of a certain type for this topic.

Specified by:
getOccurrences in interface Topic
Parameters:
type - the type of the occurrences
Returns:
a possibly empty collection, never null
See Also:
Occurrence

getOccurrence

public Occurrence getOccurrence(User user,
                                String id)
Description copied from interface: Topic
Queries an occurrence of this topic with the given id.

Specified by:
getOccurrence in interface Topic
Parameters:
user - the user who wants to see the occurrence
id - the queried id
Returns:
the occurrence or null if there's no occurrence with the given id for this topic
See Also:
Occurrence.getId(), DynamicRightsManager.mayViewTopic(User, Topic)

addOccurrence

public Occurrence addOccurrence(User adder,
                                String data,
                                Topic type)
                         throws OntologyManagerException,
                                DynamicRightsManagerException
Description copied from interface: Topic
Creates an occurrence for this topic with the given type and value (data). If the implementation supports classes, the type must be a class topic.

Specified by:
addOccurrence in interface Topic
Parameters:
adder - the user who wants to create the occurrence
data - the value of the occurrence (null is treated as the empty string)
type - the type of the occurrence, including null for a typeless occurrence
Returns:
the newly created Occurrence object
Throws:
DynamicRightsManagerException - if the user is not allowed to create occurrences
OntologyManagerException - if a new occurrence could not be created
See Also:
Topic.isClassTopic(), DynamicRightsManager.mayChangeOccurrence(User)

removeOccurrence

public void removeOccurrence(User remover,
                             Occurrence occ)
                      throws OntologyManagerException,
                             DynamicRightsManagerException
Description copied from interface: Topic
Removes an occurrence from this topic.

Specified by:
removeOccurrence in interface Topic
Parameters:
remover - the user who wants to remove the occurrence.
occ - the occurrence to be removed
Throws:
OntologyManagerException - if the occurrence could not be removed
DynamicRightsManagerException - if the user is not allowed to remove occurrences
See Also:
DynamicRightsManager.mayChangeOccurrence(User)

getSynonyms

public Collection getSynonyms(User user)
Description copied from interface: Topic
Returns a collection of all Synonym objects for this topic. The collection contains only synonymous topics the user is allowed to see.

Specified by:
getSynonyms in interface Topic
Parameters:
user - the user who wants to see the synonyms
Returns:
a possibly empty collection, never null
See Also:
Synonym, DynamicRightsManager.mayViewTopic(User, Topic)

getSynonym

public Synonym getSynonym(User user,
                          String id)
Description copied from interface: Topic
Queries a synonym of this topic with the given id.

Specified by:
getSynonym in interface Topic
Parameters:
user - the user who wants to see the synonym
id - the queried id
Returns:
a Synonym object containing the two synonymous topics or null if there's no synonym with the given id
See Also:
DynamicRightsManager.mayViewTopic(User, Topic)

isSynonymous

public boolean isSynonymous(Topic topic)
Description copied from interface: Topic
Checks if the given topic is synonymous with this topic.

Specified by:
isSynonymous in interface Topic
Parameters:
topic - the topic in question
Returns:
true if the two topics are synonymous, false otherwise

addSynonym

public Synonym addSynonym(User adder,
                          Topic topic)
                   throws OntologyManagerException,
                          DynamicRightsManagerException
Description copied from interface: Topic
Adds another topic as a synonym to this topic (and vice versa).

Specified by:
addSynonym in interface Topic
Parameters:
adder - the user who wants to add the synonym
topic - the synonymous topic to be added (not null, not this topic itself)
Returns:
a Synonym object containing the two synonymous topics
Throws:
DynamicRightsManagerException - if the user is not allowed to add synonyms
OntologyManagerException - if the synonymous topic could not be added
See Also:
DynamicRightsManager.mayAddSynonym(User, Topic)

removeSynonym

public void removeSynonym(User remover,
                          Topic topic)
                   throws OntologyManagerException,
                          DynamicRightsManagerException
Description copied from interface: Topic
Removes a synonymous topic from this topic (and vice versa).

Specified by:
removeSynonym in interface Topic
Parameters:
remover - the user who wants to remove the synonymous topic
topic - the synonymous topic to be removed
Throws:
DynamicRightsManagerException - if the user is not allowed to remove the synonymous topic
OntologyManagerException - if the synonymous topic could not be removed
See Also:
Synonym, DynamicRightsManager.mayRemoveSynonym(User, Synonym)

setFlag

protected void setFlag(String flag)
                throws OntologyManagerException
Throws:
OntologyManagerException

removeFlag

protected void removeFlag(String flag)
                   throws OntologyManagerException
Throws:
OntologyManagerException

hasFlag

protected boolean hasFlag(String flag)

setClassTopic

public void setClassTopic(boolean isclass)
                   throws OntologyManagerException
Description copied from interface: Topic

Controls the class flag, i.e. if the topic is a class or an instance topic.

You can use this method explicitely if the implementation is not configured to use classes, but usually you'll let the implementation decide which topics are classes by how the topics are created.

Specified by:
setClassTopic in interface Topic
Parameters:
isclass - true if the topic shall be a class topic, false if it shall be an instance topic
Throws:
OntologyManagerException - if the class flag could not be changed
See Also:
OntologyManager.createClassTopic(User, String, String, Topic), Topic.isClassTopic()

isClassTopic

public boolean isClassTopic()
Description copied from interface: Topic
Checks if this topic is a class topic.

Specified by:
isClassTopic in interface Topic
Returns:
true if this topic is a class topic, false otherwise
See Also:
Topic.setClassTopic(boolean)

getSuperclass

public SuperSubclass getSuperclass(User user,
                                   String id)
Description copied from interface: Topic
Queries a superclass of this topic with the given id. If this topic is not a class or if the implementation does not support classes at all, null is returned.

Specified by:
getSuperclass in interface Topic
Parameters:
user - the user who wants to see the superclass
id - the queried id
Returns:
a SuperSubclass object containing the superclass topic or null if there's no superclass with the given id
See Also:
DynamicRightsManager.mayViewTopic(User, Topic), Topic.isClassTopic(), Topic.getType(User, String)

getSuperclasses

public Collection getSuperclasses(User user)
Description copied from interface: Topic
Returns a collection of SuperSubclass objects containing the superclasses of this class topic. If this topic is not a class or if the implementation does not support classes at all, an empty collection is returned.

Specified by:
getSuperclasses in interface Topic
Parameters:
user - the user who wants to see the superclasses
Returns:
a possibly empty collection, never null
See Also:
SuperSubclass, DynamicRightsManager.mayViewTopic(User, Topic), QueryEngine.getSuperclasses(User, Topic), Topic.getTypes(User)

getSubclasses

public Collection getSubclasses(User user)
Description copied from interface: Topic
Returns a collection of SuperSubclass objects containing the subclasses of this class topic. If this topic is not a class or if the implementation does not support classes at all, an empty collection is returned.

Specified by:
getSubclasses in interface Topic
Parameters:
user - the user who wants to see the subclasses
Returns:
a possibly empty collection, never null
See Also:
SuperSubclass, DynamicRightsManager.mayViewTopic(User, Topic), QueryEngine.getSubclasses(User, Topic), Topic.getInstances(User)

addSuperclass

public SuperSubclass addSuperclass(User adder,
                                   Topic cls)
                            throws OntologyManagerException,
                                   DynamicRightsManagerException
Description copied from interface: Topic
Adds a superclass to this topic. Both topics must be class topics.

Specified by:
addSuperclass in interface Topic
Parameters:
adder - the user who wants to add the superclass
cls - the superclass topic to be added (must not be null)
Returns:
a SuperSubclass object containing the superclass topic
Throws:
OntologyManagerException - if the superclass could not be added
DynamicRightsManagerException - if the user is not allowed to add a superclass
See Also:
Topic.isClassTopic(), DynamicRightsManager.mayAddClass(User, Topic), Topic.addType(User, Topic)

removeSuperclass

public void removeSuperclass(User remover,
                             Topic cls)
                      throws OntologyManagerException,
                             DynamicRightsManagerException
Description copied from interface: Topic
Removes a superclass from this class topic.

Specified by:
removeSuperclass in interface Topic
Parameters:
remover - the user who wants to remove the superclass
cls - the superclass topic to be removed
Throws:
DynamicRightsManagerException - if the user is not allowed to remove the superclass
OntologyManagerException - if the superclass could not be removed
See Also:
Topic.isClassTopic(), DynamicRightsManager.mayRemoveClass(User, SuperSubclass), Topic.removeType(User, Topic)

toString

public String toString()