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

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

public class TypedCache
extends java.lang.Object
implements IDataStore

Author:
Sven Krosse

Field Summary
private  java.util.Map<de.topicmapslab.majortom.model.core.IAssociation,de.topicmapslab.majortom.model.core.ITopic> associationTypes
          storage map of the association-type relation
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITypeable>> changedTypes
           
private  java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> modifiedConstructs
           
private  java.util.Map<de.topicmapslab.majortom.model.core.IName,de.topicmapslab.majortom.model.core.ITopic> nameTypes
          storage map of the name-type relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IOccurrence,de.topicmapslab.majortom.model.core.ITopic> occurrenceTypes
          storage map of the occurrence-type relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> roleTypes
          storage map of the role-type relation
private  TransactionTopicMapStore topicMapStore
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> typedAssociations
          storage map of the type-association relation
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> typedNames
          storage map of the type-name relation
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> typedOccurrences
          storage map of the type-occurrence relation
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> typedRoles
          storage map of the type-role relation
 
Constructor Summary
TypedCache(TransactionTopicMapStore topicMapStore)
          constructor
 
Method Summary
 void close()
          Remove all items from the internal store.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getAssociationTypes()
          Return a set containing all topic types used as type of an association item.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getCharacteristicTypes()
          Return a set containing all topic types used as type of a characteristics item.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getNameTypes()
          Return a set containing all topic types used as type of a name item.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getOccurrenceTypes()
          Return a set containing all topic types used as type of an occurrence item.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getRoleTypes()
          Return a set containing all topic types used as type of a role item.
protected  ModifableTopicMapStoreImpl getTopicMapStore()
          Returns the internal reference of the topic map store.
 TransactionTopicMapStore getTransactionStore()
           
 de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IAssociation typed)
          Return the type of the typed attribute
 de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IAssociationRole typed)
          Return the type of the typed attribute
 de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IName typed)
          Return the type of the typed attribute
 de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IOccurrence typed)
          Return the type of the typed attribute
 de.topicmapslab.majortom.model.core.ITopic getType(org.tmapi.core.Typed typed)
          Return the type of the typed attribute
 java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> getTyped(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed items of the given type.
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getTypedAssociations(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed items of the given type.
 java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getTypedCharacteristics(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed names items of the given type.
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getTypedNames(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed names items of the given type.
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getTypedOccurrences(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed names items of the given type.
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getTypedRoles(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the typed association role items of the given type.
protected  boolean isRemovedConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
          Redirect method call to identity store and check if construct is marked as removed.
 de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IAssociation typed)
          
 de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IAssociationRole typed)
          
 de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IName typed)
          
 de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IOccurrence typed)
          
 java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> removeType(de.topicmapslab.majortom.model.core.ITopic type)
          Removing the given topic as type of each stored typed.
 de.topicmapslab.majortom.model.core.ITopic removeType(org.tmapi.core.Typed typed)
          Remove the given type for the typed attribute
 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.
 void setType(de.topicmapslab.majortom.model.core.IAssociation typed, de.topicmapslab.majortom.model.core.ITopic t)
          Store the given type for the typed attribute
 void setType(de.topicmapslab.majortom.model.core.IAssociationRole typed, de.topicmapslab.majortom.model.core.ITopic t)
          Store the given type for the typed attribute
 void setType(de.topicmapslab.majortom.model.core.IName typed, de.topicmapslab.majortom.model.core.ITopic t)
          Store the given type for the typed attribute
 void setType(de.topicmapslab.majortom.model.core.IOccurrence typed, de.topicmapslab.majortom.model.core.ITopic t)
          Store the given type for the typed attribute
 void setType(org.tmapi.core.Typed typed, de.topicmapslab.majortom.model.core.ITopic t)
          Store the given type for the typed attribute
protected  void storeOldRelation(de.topicmapslab.majortom.model.core.ITypeable typed)
          Method checks if the type change of the given construct is the first type change in the transaction context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typedNames

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> typedNames
storage map of the type-name relation


nameTypes

private java.util.Map<de.topicmapslab.majortom.model.core.IName,de.topicmapslab.majortom.model.core.ITopic> nameTypes
storage map of the name-type relation


typedOccurrences

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> typedOccurrences
storage map of the type-occurrence relation


occurrenceTypes

private java.util.Map<de.topicmapslab.majortom.model.core.IOccurrence,de.topicmapslab.majortom.model.core.ITopic> occurrenceTypes
storage map of the occurrence-type relation


typedAssociations

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> typedAssociations
storage map of the type-association relation


associationTypes

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociation,de.topicmapslab.majortom.model.core.ITopic> associationTypes
storage map of the association-type relation


typedRoles

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> typedRoles
storage map of the type-role relation


roleTypes

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociationRole,de.topicmapslab.majortom.model.core.ITopic> roleTypes
storage map of the role-type relation


modifiedConstructs

private java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> modifiedConstructs

changedTypes

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ITypeable>> changedTypes

topicMapStore

private final TransactionTopicMapStore topicMapStore
Constructor Detail

TypedCache

public TypedCache(TransactionTopicMapStore topicMapStore)
constructor

Parameters:
topicMapStore - the transaction topic map store
Method Detail

getType

public de.topicmapslab.majortom.model.core.ITopic getType(org.tmapi.core.Typed typed)
Return the type of the typed attribute

Parameters:
typed - the typed item
Returns:
the type

getType

public de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IAssociation typed)
Return the type of the typed attribute

Parameters:
typed - the typed item
Returns:
the type

getType

public de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IAssociationRole typed)
Return the type of the typed attribute

Parameters:
typed - the typed item
Returns:
the type

getType

public de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IName typed)
Return the type of the typed attribute

Parameters:
typed - the typed item
Returns:
the type

getType

public de.topicmapslab.majortom.model.core.ITopic getType(de.topicmapslab.majortom.model.core.IOccurrence typed)
Return the type of the typed attribute

Parameters:
typed - the typed item
Returns:
the type

getTyped

public java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> getTyped(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed attributes

getTypedAssociations

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getTypedAssociations(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed attributes

getTypedRoles

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getTypedRoles(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed association role items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed association role items

getTypedCharacteristics

public java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getTypedCharacteristics(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed names items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed characteristics

getTypedNames

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getTypedNames(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed names items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed characteristics

getTypedOccurrences

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getTypedOccurrences(de.topicmapslab.majortom.model.core.ITopic t)
Returns the typed names items of the given type.

Parameters:
t - the type
Returns:
a set containing all typed characteristics

setType

public void setType(org.tmapi.core.Typed typed,
                    de.topicmapslab.majortom.model.core.ITopic t)
Store the given type for the typed attribute

Parameters:
typed - the typed item
t - the topic

setType

public void setType(de.topicmapslab.majortom.model.core.IAssociation typed,
                    de.topicmapslab.majortom.model.core.ITopic t)
Store the given type for the typed attribute

Parameters:
typed - the typed item
t - the topic

setType

public void setType(de.topicmapslab.majortom.model.core.IAssociationRole typed,
                    de.topicmapslab.majortom.model.core.ITopic t)
Store the given type for the typed attribute

Parameters:
typed - the typed item
t - the topic

setType

public void setType(de.topicmapslab.majortom.model.core.IName typed,
                    de.topicmapslab.majortom.model.core.ITopic t)
Store the given type for the typed attribute

Parameters:
typed - the typed item
t - the topic

setType

public void setType(de.topicmapslab.majortom.model.core.IOccurrence typed,
                    de.topicmapslab.majortom.model.core.ITopic t)
Store the given type for the typed attribute

Parameters:
typed - the typed item
t - the topic

removeType

public de.topicmapslab.majortom.model.core.ITopic removeType(org.tmapi.core.Typed typed)
Remove the given type for the typed attribute

Parameters:
typed - the typed item
Returns:
the removed type

removeType

public de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IAssociation typed)


removeType

public de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IAssociationRole typed)


removeType

public de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IName typed)


removeType

public de.topicmapslab.majortom.model.core.ITopic removeType(de.topicmapslab.majortom.model.core.IOccurrence typed)


getAssociationTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getAssociationTypes()
Return a set containing all topic types used as type of an association item.

Returns:
a set of all types

getRoleTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getRoleTypes()
Return a set containing all topic types used as type of a role item.

Returns:
a set of all types

getCharacteristicTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getCharacteristicTypes()
Return a set containing all topic types used as type of a characteristics item.

Returns:
a set of all types

getNameTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getNameTypes()
Return a set containing all topic types used as type of a name item.

Returns:
a set of all types

getOccurrenceTypes

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getOccurrenceTypes()
Return a set containing all topic types used as type of an occurrence item.

Returns:
a set of all types

close

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

Specified by:
close in interface IDataStore

storeOldRelation

protected void storeOldRelation(de.topicmapslab.majortom.model.core.ITypeable typed)
Method checks if the type change of the given construct is the first type change in the transaction context. If it is the first, the old relation stored to filter them later.

Parameters:
typed - the typed construct

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

removeType

public java.util.Set<de.topicmapslab.majortom.model.core.ITypeable> removeType(de.topicmapslab.majortom.model.core.ITopic type)
Removing the given topic as type of each stored typed. The typed objects will be removed too.

Parameters:
type - the type
Returns:
the removed typed items