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

All Superinterfaces:
Commentatable, Comparable, Concept, Createable, Rateable, Serializable, Versionable
All Known Implementing Classes:
AssociationImpl

public interface Association
extends Concept, Serializable, Comparable

This interface manages associations between topics which are separated into roles.

Version:
2006-06-14
Author:
Thomas Much
See Also:
Topic, AssociationRole, OntologyManager.createAssociation(User, String, String, Topic)

Method Summary
 AssociationRole addAssociationRole(User adder, Topic type)
          Creates an association role of the given type if the role does not exist yet.
 void addTopic(User adder, Topic topic, Topic roleType)
          Adds a topic to this association as a player of the given role.
 AssociationRole getAssociationRole(Topic type)
          Returns the AssociationRole of a certain type.
 Collection getAssociationRoles(User getter)
          Returns a collection of all AssociationRole objects used by this association.
 Collection getTopics(User getter, Topic roleType)
          Returns a collection of Topic player objects of the given role.
 Topic getType()
          Returns the type of the association.
 boolean hasTopic(Topic topic, Topic roleType)
          Queries if the topic is player of the given role in this association.
 boolean hasTopic(User user, Topic topic)
          Queries if the topic is player of any role (that the user is allowed to see) in this association.
 void removeAssociationRole(User remover, Topic type)
          Removes the association role of the given type.
 void removeTopic(User remover, Topic topic, Topic roleType)
          Removes a topic from the given role if it is player of the role.
 void setType(User setter, Topic type)
          Sets the type of the association.
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Concept
getId, getName, isOfType, 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.Rateable
addRating, getAverageRatingValue, getRating, getRatings, getRatingsCount
 
Methods inherited from interface de.uka.ipd.consensus.foundation.schema.Createable
getCreator
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getType

public Topic getType()
Returns the type of the association.

Returns:
the associations's type or null if the association does not have a type

setType

public void setType(User setter,
                    Topic type)
             throws OntologyManagerException,
                    DynamicRightsManagerException
Sets the type of the association. If the implementation supports classes, the type must be a class topic.

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(), DynamicRightsManager.mayChangeAssociation(User, Association)

getAssociationRoles

public Collection getAssociationRoles(User getter)
Returns a collection of all AssociationRole objects used by this association. This includes the typeless role if this association contains a typeless player topic.

Parameters:
getter - the user who wants to see the roles
Returns:
a possibly empty collection, never null
See Also:
AssociationRole, DynamicRightsManager.mayViewTopic(User, Topic)

getAssociationRole

public AssociationRole getAssociationRole(Topic type)
Returns the AssociationRole of a certain type.

Parameters:
type - the type topic of the desired role, null for the typeless role
Returns:
the role object of the given type or null if this association does not contain a player topic of the type

addAssociationRole

public AssociationRole addAssociationRole(User adder,
                                          Topic type)
                                   throws OntologyManagerException,
                                          DynamicRightsManagerException
Creates an association role of the given type if the role does not exist yet. The newly created or the already existing role is returned.

Parameters:
adder - the user who wants to add the role
type - the type topic of the role to be created, including null for the typeless role
Returns:
the role of the given type, never null
Throws:
OntologyManagerException - if the role could not be created
DynamicRightsManagerException - if the user is not allowed to add the role
See Also:
DynamicRightsManager.mayChangeAssociation(User, Association)

removeAssociationRole

public void removeAssociationRole(User remover,
                                  Topic type)
                           throws OntologyManagerException,
                                  DynamicRightsManagerException
Removes the association role of the given type. Its player topics are no longer part of this association afterwards (unless they are player of another role in this association).

Parameters:
remover - the user who wants to remove the role
type - the type of the role to be removed, including null for the typeless role
Throws:
OntologyManagerException - if the role could not be removed
DynamicRightsManagerException - if the user is not allowed to remove the role
See Also:
DynamicRightsManager.mayChangeAssociation(User, Association)

addTopic

public void addTopic(User adder,
                     Topic topic,
                     Topic roleType)
              throws OntologyManagerException,
                     DynamicRightsManagerException
Adds a topic to this association as a player of the given role. The AssociationRole is created if it does not exist yet. This is just a convenience method and simply delegates to AssociationRole.addTopic()!

Parameters:
adder - the user who wants to add the topic
topic - the topic to be added to this association
roleType - the player role of the topic, including null for the typeless role
Throws:
OntologyManagerException - if the topic could not be added
DynamicRightsManagerException - if the user is not allowed to add the topic
See Also:
AssociationRole.addTopic(User, Topic), DynamicRightsManager.mayChangeAssociation(User, Association)

removeTopic

public void removeTopic(User remover,
                        Topic topic,
                        Topic roleType)
                 throws OntologyManagerException,
                        DynamicRightsManagerException
Removes a topic from the given role if it is player of the role. If the topic is no player of the role of the role does not exist, the call is ignored. This is just a convenience method and simply delegates to AssociationRole.removeTopic()!

Parameters:
remover - the user who wants to remove the topic
topic - the topic to be removed
roleType - the role that the topic to be removed plays, including null for the typeless role
Throws:
OntologyManagerException - if the topic could not be removed
DynamicRightsManagerException - if the user is not allowed to remove the topic
See Also:
AssociationRole.removeTopic(User, Topic), DynamicRightsManager.mayChangeAssociation(User, Association)

hasTopic

public boolean hasTopic(Topic topic,
                        Topic roleType)
Queries if the topic is player of the given role in this association. This is just a convenience method and simply delegates to AssociationRole.hasTopic()!

Parameters:
topic - the queried topic
roleType - the role that this topic must play, including null for the typeless role
Returns:
true if the topic is player of the given role in this association, false otherwise
See Also:
AssociationRole.hasTopic(Topic)

hasTopic

public boolean hasTopic(User user,
                        Topic topic)
Queries if the topic is player of any role (that the user is allowed to see) in this association.

Parameters:
user - the user who does the query
topic - the queried topic
Returns:
true if the topic is player of any role in this association, false otherwise
See Also:
DynamicRightsManager.mayViewTopic(User, Topic), AssociationRole.hasTopic(Topic)

getTopics

public Collection getTopics(User getter,
                            Topic roleType)
Returns a collection of Topic player objects of the given role. This is just a convenience method and simply delegates to AssociationRole.getTopics()!

Parameters:
getter - the user who wants to see the topics
roleType - the role type, ncluding null for the typeless role
Returns:
a possibly empty collection, never null
See Also:
DynamicRightsManager.mayViewTopic(User, Topic), AssociationRole.getTopics(User)