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

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

public class ScopeCache
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.IScope> associationScopes
          storage map of association-scope relation
private  de.topicmapslab.majortom.model.core.IScope emptyScope
          empty scope
private  java.util.Set<java.lang.String> modifiedScopeables
           
private  java.util.Map<de.topicmapslab.majortom.model.core.IName,de.topicmapslab.majortom.model.core.IScope> nameScopes
          storage map of name-scope relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IOccurrence,de.topicmapslab.majortom.model.core.IScope> occurrenceScopes
          storage map of occurrence-scope relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> scopedAssociations
          storage map of scope-association relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IName>> scopedNames
          storage map of scope-name relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> scopedOccurrences
          storage map of scope-occurrence relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> scopedVariants
          storage map of scope-variant relation
private  java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> scopes
          storage map of scope-themes mapping
private  TransactionTopicMapStore topicMapStore
           
private  java.util.Map<de.topicmapslab.majortom.model.core.IVariant,de.topicmapslab.majortom.model.core.IScope> variantScopes
          storage map of variant-scope relation
 
Constructor Summary
ScopeCache(TransactionTopicMapStore topicMapStore)
          constructor
 
Method Summary
 void close()
          Remove all items from the internal store.
protected  boolean containsScopeable(de.topicmapslab.majortom.model.core.IScopable scopable)
          Method checks if the given object is stored by the current data store.
 java.util.Set<de.topicmapslab.majortom.model.core.IScope> getAssociationScopes()
          
 de.topicmapslab.majortom.model.core.IScope getEmptyScope()
          Returns the empty scope object.
 java.util.Set<de.topicmapslab.majortom.model.core.IScope> getNameScopes()
          
 java.util.Set<de.topicmapslab.majortom.model.core.IScope> getOccurrenceScopes()
          
 de.topicmapslab.majortom.model.core.IScope getScope(java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IAssociation scoped)
          
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IName scoped)
          
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IOccurrence scoped)
          
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IScopable scoped)
          Returns the scope of the scoped construct
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.ITopic... themes)
          
 de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IVariant scoped)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IScopable> getScoped(de.topicmapslab.majortom.model.core.IScope scope)
          Returns all scoped items of the given scope.
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getScopedAssociations(de.topicmapslab.majortom.model.core.IScope scope)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getScopedNames(de.topicmapslab.majortom.model.core.IScope scope)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getScopedOccurrences(de.topicmapslab.majortom.model.core.IScope scope)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getScopedVariants(de.topicmapslab.majortom.model.core.IScope scope)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IScope> getScopes(de.topicmapslab.majortom.model.core.ITopic theme)
          
 ModifableTopicMapStoreImpl getTopicMapStore()
           
 TransactionTopicMapStore getTransactionStore()
           
 java.util.Set<de.topicmapslab.majortom.model.core.IScope> getVariantScopes()
          
private
<T extends de.topicmapslab.majortom.model.core.IScopable>
java.util.Set<T>
internalGetScoped(de.topicmapslab.majortom.model.core.IScope scope, java.lang.Class<? extends T> clazz)
          Returns all scoped items of the given scope and given type.
private  void internalSetScope(de.topicmapslab.majortom.model.core.IScopable scoped, de.topicmapslab.majortom.model.core.IScope s)
          Store the relation between the given scoped item and the scope.
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.IScope removeScope(de.topicmapslab.majortom.model.core.IAssociation scoped)
          
 de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IName scoped)
          
 de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IOccurrence scoped)
          
 de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IScopable scoped)
          Remove the relation between the scoped construct and the stored scope.
 de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IVariant scoped)
          
 java.util.Set<de.topicmapslab.majortom.model.core.IScopable> removeScopes(de.topicmapslab.majortom.model.core.ITopic theme)
          Removing the theme and all dependent scopes and scoped objects.
 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 setScope(de.topicmapslab.majortom.model.core.IAssociation scoped_, de.topicmapslab.majortom.model.core.IScope s)
          
 void setScope(de.topicmapslab.majortom.model.core.IName scoped_, de.topicmapslab.majortom.model.core.IScope s)
          
 void setScope(de.topicmapslab.majortom.model.core.IOccurrence scoped_, de.topicmapslab.majortom.model.core.IScope s)
          
 void setScope(de.topicmapslab.majortom.model.core.IScopable scoped, de.topicmapslab.majortom.model.core.IScope s)
          Store the relation between the given scoped item and the scope.
 void setScope(de.topicmapslab.majortom.model.core.IVariant scoped_, de.topicmapslab.majortom.model.core.IScope s)
          
 boolean usedAsTheme(de.topicmapslab.majortom.model.core.ITopic theme)
          Method checks if the given topic is used as theme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifiedScopeables

private java.util.Set<java.lang.String> modifiedScopeables

topicMapStore

private final TransactionTopicMapStore topicMapStore

scopes

private java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> scopes
storage map of scope-themes mapping


scopedNames

private java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IName>> scopedNames
storage map of scope-name relation


scopedOccurrences

private java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> scopedOccurrences
storage map of scope-occurrence relation


scopedVariants

private java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> scopedVariants
storage map of scope-variant relation


scopedAssociations

private java.util.Map<de.topicmapslab.majortom.model.core.IScope,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> scopedAssociations
storage map of scope-association relation


nameScopes

private java.util.Map<de.topicmapslab.majortom.model.core.IName,de.topicmapslab.majortom.model.core.IScope> nameScopes
storage map of name-scope relation


occurrenceScopes

private java.util.Map<de.topicmapslab.majortom.model.core.IOccurrence,de.topicmapslab.majortom.model.core.IScope> occurrenceScopes
storage map of occurrence-scope relation


variantScopes

private java.util.Map<de.topicmapslab.majortom.model.core.IVariant,de.topicmapslab.majortom.model.core.IScope> variantScopes
storage map of variant-scope relation


associationScopes

private java.util.Map<de.topicmapslab.majortom.model.core.IAssociation,de.topicmapslab.majortom.model.core.IScope> associationScopes
storage map of association-scope relation


emptyScope

private de.topicmapslab.majortom.model.core.IScope emptyScope
empty scope

Constructor Detail

ScopeCache

public ScopeCache(TransactionTopicMapStore topicMapStore)
constructor

Parameters:
store - the topic map store
Method Detail

close

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

Specified by:
close in interface IDataStore

getAssociationScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScope> getAssociationScopes()


getNameScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScope> getNameScopes()


getOccurrenceScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScope> getOccurrenceScopes()


getVariantScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScope> getVariantScopes()


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.ITopic... themes)


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IScopable scoped)
Returns the scope of the scoped construct

Parameters:
scoped - the scoped construct
Returns:
the scope and never null

getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IAssociation scoped)


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IName scoped)


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IOccurrence scoped)


getScope

public de.topicmapslab.majortom.model.core.IScope getScope(de.topicmapslab.majortom.model.core.IVariant scoped)


internalGetScoped

private <T extends de.topicmapslab.majortom.model.core.IScopable> java.util.Set<T> internalGetScoped(de.topicmapslab.majortom.model.core.IScope scope,
                                                                                                     java.lang.Class<? extends T> clazz)
Returns all scoped items of the given scope and given type.

Parameters:
scope - the scope
Returns:
the scoped construct

getScoped

public java.util.Set<de.topicmapslab.majortom.model.core.IScopable> getScoped(de.topicmapslab.majortom.model.core.IScope scope)
Returns all scoped items of the given scope.

Parameters:
scope - the scope
Returns:
the scoped construct

getScopedAssociations

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getScopedAssociations(de.topicmapslab.majortom.model.core.IScope scope)


getScopedNames

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getScopedNames(de.topicmapslab.majortom.model.core.IScope scope)


getScopedOccurrences

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getScopedOccurrences(de.topicmapslab.majortom.model.core.IScope scope)


getScopedVariants

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getScopedVariants(de.topicmapslab.majortom.model.core.IScope scope)


getScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScope> getScopes(de.topicmapslab.majortom.model.core.ITopic theme)


setScope

public void setScope(de.topicmapslab.majortom.model.core.IScopable scoped,
                     de.topicmapslab.majortom.model.core.IScope s)
Store the relation between the given scoped item and the scope.

Parameters:
scoped - the scoped construct
s - the scope

setScope

public void setScope(de.topicmapslab.majortom.model.core.IAssociation scoped_,
                     de.topicmapslab.majortom.model.core.IScope s)


setScope

public void setScope(de.topicmapslab.majortom.model.core.IName scoped_,
                     de.topicmapslab.majortom.model.core.IScope s)


setScope

public void setScope(de.topicmapslab.majortom.model.core.IOccurrence scoped_,
                     de.topicmapslab.majortom.model.core.IScope s)


setScope

public void setScope(de.topicmapslab.majortom.model.core.IVariant scoped_,
                     de.topicmapslab.majortom.model.core.IScope s)


internalSetScope

private final void internalSetScope(de.topicmapslab.majortom.model.core.IScopable scoped,
                                    de.topicmapslab.majortom.model.core.IScope s)
Store the relation between the given scoped item and the scope.

Parameters:
scoped - the scoped construct
s - the scope

removeScope

public de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IScopable scoped)
Remove the relation between the scoped construct and the stored scope.

Parameters:
scoped - the scoped construct
Returns:
the old scope

removeScope

public de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IAssociation scoped)


removeScope

public de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IName scoped)


removeScope

public de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IOccurrence scoped)


removeScope

public de.topicmapslab.majortom.model.core.IScope removeScope(de.topicmapslab.majortom.model.core.IVariant scoped)


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.

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

containsScopeable

protected final boolean containsScopeable(de.topicmapslab.majortom.model.core.IScopable scopable)
Method checks if the given object is stored by the current data store.

Parameters:
scopable - the object to check
Returns:
true if the data store contains a scope relation for the given object, false otherwise.

usedAsTheme

public boolean usedAsTheme(de.topicmapslab.majortom.model.core.ITopic theme)
Method checks if the given topic is used as theme.

Parameters:
theme - the theme
Returns:
true if the topic is used as theme, false otherwise.

getEmptyScope

public de.topicmapslab.majortom.model.core.IScope getEmptyScope()
Returns the empty scope object.

Returns:
the empty scope object

removeScopes

public java.util.Set<de.topicmapslab.majortom.model.core.IScopable> removeScopes(de.topicmapslab.majortom.model.core.ITopic theme)
Removing the theme and all dependent scopes and scoped objects.

Parameters:
theme - the theme
Returns:
the removed scoped objects