de.topicmapslab.majortom.database.transaction.cache
Class AssociationCache

java.lang.Object
  extended by de.topicmapslab.majortom.database.transaction.cache.AssociationCache
All Implemented Interfaces:
IDataStore

public class AssociationCache
extends java.lang.Object
implements IDataStore

Author:
Sven Krosse

Field Summary
private  java.util.Map<de.topicmapslab.majortom.model.core.IAssociation,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> associations
          internal storage map of association-roles relations
private  java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> changedPlayers
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> playedRoles
          internal storage map of player-roles relations
private  java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> rolePlayers
          internal storage map of role-player relations
private  TransactionTopicMapStore topicMapStore
          reference to the underlying topic map store
 
Constructor Summary
AssociationCache(TransactionTopicMapStore topicMapStore)
           
 
Method Summary
 void addAssociation(de.topicmapslab.majortom.model.core.IAssociation association)
          Register a new association item.
 void addRole(de.topicmapslab.majortom.model.core.IAssociation association, de.topicmapslab.majortom.model.core.IAssociationRole role, de.topicmapslab.majortom.model.core.ITopic player)
          
 void close()
          Remove all items from the internal store.
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getAssociations()
          
 de.topicmapslab.majortom.model.core.ITopic getPlayer(org.tmapi.core.Role r)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(org.tmapi.core.Association association)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(de.topicmapslab.majortom.model.core.ITopic player)
          
 ModifableTopicMapStoreImpl getTopicMapStore()
           
 TransactionTopicMapStore getTransactionStore()
           
private  void internalAddRole(de.topicmapslab.majortom.model.core.IAssociation association, de.topicmapslab.majortom.model.core.IAssociationRole role, de.topicmapslab.majortom.model.core.ITopic player)
          Internal method to register a new association role item at the internal store.
private  de.topicmapslab.majortom.model.core.ITopic internalSetPlayer(de.topicmapslab.majortom.model.core.IAssociationRole r, de.topicmapslab.majortom.model.core.ITopic player)
          Internal method to modify the player of a specific role.
protected  boolean isRemovedConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
          Redirect method call to identity store and check if construct is marked as removed.
 void removeAssociation(de.topicmapslab.majortom.model.core.IAssociation association)
          
 void removeRole(de.topicmapslab.majortom.model.core.IAssociationRole role)
          
 void replace(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic replacement, de.topicmapslab.majortom.model.revision.IRevision revision)
          Replace each reference of the given topic by the given replacement.
 de.topicmapslab.majortom.model.core.ITopic setPlayer(de.topicmapslab.majortom.model.core.IAssociationRole r, de.topicmapslab.majortom.model.core.ITopic player)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

associations

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociation,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> associations
internal storage map of association-roles relations


rolePlayers

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> rolePlayers
internal storage map of role-player relations


playedRoles

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> playedRoles
internal storage map of player-roles relations


topicMapStore

private final TransactionTopicMapStore topicMapStore
reference to the underlying topic map store


changedPlayers

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> changedPlayers
Constructor Detail

AssociationCache

public AssociationCache(TransactionTopicMapStore topicMapStore)
Method Detail

getPlayer

public de.topicmapslab.majortom.model.core.ITopic getPlayer(org.tmapi.core.Role r)


addAssociation

public void addAssociation(de.topicmapslab.majortom.model.core.IAssociation association)
Register a new association item.

Parameters:
association - the association item

addRole

public void addRole(de.topicmapslab.majortom.model.core.IAssociation association,
                    de.topicmapslab.majortom.model.core.IAssociationRole role,
                    de.topicmapslab.majortom.model.core.ITopic player)


internalAddRole

private void internalAddRole(de.topicmapslab.majortom.model.core.IAssociation association,
                             de.topicmapslab.majortom.model.core.IAssociationRole role,
                             de.topicmapslab.majortom.model.core.ITopic player)
Internal method to register a new association role item at the internal store.

Parameters:
association - the parent association
role - the association role item
player - the role player

getAssociations

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getAssociations()


getRoles

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(org.tmapi.core.Association association)


getRoles

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(de.topicmapslab.majortom.model.core.ITopic player)


setPlayer

public de.topicmapslab.majortom.model.core.ITopic setPlayer(de.topicmapslab.majortom.model.core.IAssociationRole r,
                                                            de.topicmapslab.majortom.model.core.ITopic player)


internalSetPlayer

private de.topicmapslab.majortom.model.core.ITopic internalSetPlayer(de.topicmapslab.majortom.model.core.IAssociationRole r,
                                                                     de.topicmapslab.majortom.model.core.ITopic player)
Internal method to modify the player of a specific role.

Parameters:
r - the role
player - the new player
Returns:
the old player

removeRole

public void removeRole(de.topicmapslab.majortom.model.core.IAssociationRole role)


removeAssociation

public void removeAssociation(de.topicmapslab.majortom.model.core.IAssociation association)


replace

public void replace(de.topicmapslab.majortom.model.core.ITopic topic,
                    de.topicmapslab.majortom.model.core.ITopic replacement,
                    de.topicmapslab.majortom.model.revision.IRevision revision)
Replace each reference of the given topic by the given replacement.

Specified by:
replace in interface IDataStore
Parameters:
topic - the topic
replacement - the replacement
revision - the revision

close

public void close()
Remove all items from the internal store.

Specified by:
close in interface IDataStore

getTopicMapStore

public ModifableTopicMapStoreImpl getTopicMapStore()
Returns:
the topicMapStore

getTransactionStore

public TransactionTopicMapStore getTransactionStore()
Returns:
the topicMapStore

isRemovedConstruct

protected boolean isRemovedConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
Redirect method call to identity store and check if construct is marked as removed.

Parameters:
c - the construct
Returns:
true if the construct was marked as removed, false otherwise.