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

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

public class TopicTypeCache
extends java.lang.Object
implements IDataStore

Author:
Sven Krosse

Field Summary
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> instances
          internal storage of the type-instance relations
private  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedInstances
           
private  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedSubtypes
           
private  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedSupertypes
           
private  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedTypes
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> subtypes
          internal storage of the type-subtypes relations
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> supertypes
          internal storage of the type-supertypes relations
private  TransactionTopicMapStore topicMapStore
          reference to the underlying topic map store
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> types
          internal storage of the instance-types relations
 
Constructor Summary
TopicTypeCache(TransactionTopicMapStore store)
           
 
Method Summary
 void addSupertype(de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.ITopic supertype)
          
 void addType(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ITopic type)
          
 void close()
          Remove all items from the internal store.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectInstances(de.topicmapslab.majortom.model.core.ITopic type)
          
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectInstancesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
          Return all direct-instances of the given topic type by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSubtypes(de.topicmapslab.majortom.model.core.ITopic type)
          
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSubtypesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
          Return all direct-subtypes of the given topic type by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSupertypes(de.topicmapslab.majortom.model.core.ITopic subtype)
          
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSupertypesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
          Return all direct-supertypes of the given topic type by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectTypes(de.topicmapslab.majortom.model.core.ITopic instance)
          
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectTypesByAssociation(de.topicmapslab.majortom.model.core.ITopic instance)
          Return all direct-types of the given topic type by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstances()
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstances(de.topicmapslab.majortom.model.core.ITopic type)
          Return all transitive instances of the given topic type.
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstancesByAssociation()
          Return all instances of the topic map by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes()
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes(de.topicmapslab.majortom.model.core.ITopic type)
          Return all sub types of the given topic type.
protected  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes(de.topicmapslab.majortom.model.core.ITopic type, java.util.Set<de.topicmapslab.majortom.model.core.ITopic> known)
          Return all sub types of the given topic type.
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypesByAssociation()
          Return all sub types of the topic map by using the internal topic map data model associations
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes()
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes(de.topicmapslab.majortom.model.core.ITopic type)
          Return all super types of the given topic type
protected  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes(de.topicmapslab.majortom.model.core.ITopic type, java.util.Set<de.topicmapslab.majortom.model.core.ITopic> known)
          Return all super types of the given topic type
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypesByAssociation()
          Return all supertypes of the topic map by using the internal topic map data model associations
protected  ModifableTopicMapStoreImpl getTopicMapStore()
          Returns the internal reference of the topic map store.
 TransactionTopicMapStore getTransactionStore()
           
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypes()
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypes(de.topicmapslab.majortom.model.core.ITopic instance)
          Return all transitive types of the given topic item.
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypesByAssociation()
          Return all types of the topic map by using the internal topic map data model associations
private  void internalAddSupertype(de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.ITopic supertype)
          Removing a super-type-sub-type-relation between the given types.
private  void internalAddType(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ITopic type)
          Internal method to add a type-instance-relation between the given topics.
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 removeSupertype(de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.ITopic supertype)
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> removeTopic(de.topicmapslab.majortom.model.core.ITopic topic)
          Removing the given topic from the internal store and all dependent relations.
 void removeType(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ITopic type)
          
 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.
private  void storeAkoRelation(de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.ITopic supertype)
          Store the old a-kind-of relation between the given topics
private  void storeIsaRelation(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ITopic type)
          Store the old is-instance-of relation between the given topics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

removedInstances

private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedInstances

removedTypes

private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedTypes

removedSupertypes

private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedSupertypes

removedSubtypes

private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> removedSubtypes

supertypes

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> supertypes
internal storage of the type-supertypes relations


instances

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> instances
internal storage of the type-instance relations


types

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> types
internal storage of the instance-types relations


subtypes

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> subtypes
internal storage of the type-subtypes relations


topicMapStore

private final TransactionTopicMapStore topicMapStore
reference to the underlying topic map store

Constructor Detail

TopicTypeCache

public TopicTypeCache(TransactionTopicMapStore store)
Parameters:
store -
Method Detail

close

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

Specified by:
close in interface IDataStore

addType

public void addType(de.topicmapslab.majortom.model.core.ITopic t,
                    de.topicmapslab.majortom.model.core.ITopic type)


internalAddType

private void internalAddType(de.topicmapslab.majortom.model.core.ITopic t,
                             de.topicmapslab.majortom.model.core.ITopic type)
Internal method to add a type-instance-relation between the given topics.

Parameters:
t - the topic item
type - the type

addSupertype

public void addSupertype(de.topicmapslab.majortom.model.core.ITopic type,
                         de.topicmapslab.majortom.model.core.ITopic supertype)


internalAddSupertype

private void internalAddSupertype(de.topicmapslab.majortom.model.core.ITopic type,
                                  de.topicmapslab.majortom.model.core.ITopic supertype)
Removing a super-type-sub-type-relation between the given types.

Parameters:
type - the topic type
supertype - the super type

removeType

public void removeType(de.topicmapslab.majortom.model.core.ITopic t,
                       de.topicmapslab.majortom.model.core.ITopic type)


storeIsaRelation

private void storeIsaRelation(de.topicmapslab.majortom.model.core.ITopic t,
                              de.topicmapslab.majortom.model.core.ITopic type)
Store the old is-instance-of relation between the given topics

Parameters:
t - the instance
type - the type

removeSupertype

public void removeSupertype(de.topicmapslab.majortom.model.core.ITopic type,
                            de.topicmapslab.majortom.model.core.ITopic supertype)


storeAkoRelation

private void storeAkoRelation(de.topicmapslab.majortom.model.core.ITopic type,
                              de.topicmapslab.majortom.model.core.ITopic supertype)
Store the old a-kind-of relation between the given topics

Parameters:
type - the type
supertype - the supertype

getTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypes()


getTypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypesByAssociation()
Return all types of the topic map by using the internal topic map data model associations

Returns:
the types

getTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTypes(de.topicmapslab.majortom.model.core.ITopic instance)
Return all transitive types of the given topic item.

Parameters:
instance - the topic item
Returns:
the types

getDirectTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectTypes(de.topicmapslab.majortom.model.core.ITopic instance)


getDirectTypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectTypesByAssociation(de.topicmapslab.majortom.model.core.ITopic instance)
Return all direct-types of the given topic type by using the internal topic map data model associations

Parameters:
type - the topic type
Returns:
the direct types

getInstances

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstances()


getInstancesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstancesByAssociation()
Return all instances of the topic map by using the internal topic map data model associations

Returns:
the instances

getInstances

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getInstances(de.topicmapslab.majortom.model.core.ITopic type)
Return all transitive instances of the given topic type.

Parameters:
type - the topic type
Returns:
the instances

getDirectInstances

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectInstances(de.topicmapslab.majortom.model.core.ITopic type)


getDirectInstancesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectInstancesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
Return all direct-instances of the given topic type by using the internal topic map data model associations

Parameters:
type - the topic type
Returns:
the direct instances

getSupertypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes()


getSupertypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypesByAssociation()
Return all supertypes of the topic map by using the internal topic map data model associations

Returns:
the supertypes

getSupertypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes(de.topicmapslab.majortom.model.core.ITopic type)
Return all super types of the given topic type

Parameters:
type - the topic type
Returns:
the super types

getSupertypes

protected java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSupertypes(de.topicmapslab.majortom.model.core.ITopic type,
                                                                                  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> known)
Return all super types of the given topic type

Parameters:
type - the topic type
known - a set containing all known type to enable cycle detection
Returns:
the super types

getDirectSupertypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSupertypes(de.topicmapslab.majortom.model.core.ITopic subtype)


getDirectSupertypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSupertypesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
Return all direct-supertypes of the given topic type by using the internal topic map data model associations

Parameters:
type - the topic type
Returns:
the direct supertypes

getSubtypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes()


getSubtypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypesByAssociation()
Return all sub types of the topic map by using the internal topic map data model associations

Returns:
the subtypes

getSubtypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes(de.topicmapslab.majortom.model.core.ITopic type)
Return all sub types of the given topic type.

Parameters:
type - the topic type
Returns:
the sub types

getSubtypes

protected java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getSubtypes(de.topicmapslab.majortom.model.core.ITopic type,
                                                                                java.util.Set<de.topicmapslab.majortom.model.core.ITopic> known)
Return all sub types of the given topic type.

Parameters:
type - the topic type
known - a set containing all known types, to enable cycle detection
Returns:
the sub types

getDirectSubtypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSubtypes(de.topicmapslab.majortom.model.core.ITopic type)


getDirectSubtypesByAssociation

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getDirectSubtypesByAssociation(de.topicmapslab.majortom.model.core.ITopic type)
Return all direct-subtypes of the given topic type by using the internal topic map data model associations

Parameters:
type - the topic type
Returns:
the direct subtypes

getTopicMapStore

protected ModifableTopicMapStoreImpl getTopicMapStore()
Returns the internal reference of the topic map store.

Returns:
the topic map store

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.

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

removeTopic

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> removeTopic(de.topicmapslab.majortom.model.core.ITopic topic)
Removing the given topic from the internal store and all dependent relations.

Parameters:
topic - the topic
Returns:
the removed dependent topics