de.topicmapslab.majortom.cache
Class RevisionCache

java.lang.Object
  extended by de.topicmapslab.majortom.cache.RevisionCache
All Implemented Interfaces:
de.topicmapslab.majortom.model.event.ITopicMapListener

public class RevisionCache
extends java.lang.Object
implements de.topicmapslab.majortom.model.event.ITopicMapListener

Cache handling revisions

Author:
Sven Krosse

Nested Class Summary
(package private)  class RevisionCache.CacheEntry
           
 
Field Summary
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,RevisionCache.CacheEntry> associationDependents
           
private static java.lang.String CHANGESET
           
private  de.topicmapslab.majortom.model.revision.IRevision firstRevision
           
private static java.lang.String FUTURE
           
private  java.util.Calendar lastChange
           
private  de.topicmapslab.majortom.model.revision.IRevision lastRevision
           
private static java.lang.String METADATA
           
private static java.lang.String PAST
           
private  java.util.Map<de.topicmapslab.majortom.model.revision.IRevision,RevisionCache.CacheEntry> revisionDependents
           
private static java.lang.String REVISIONS
           
private  java.util.Map<java.lang.Long,de.topicmapslab.majortom.model.revision.IRevision> revisionsById
           
private  java.util.Map<java.util.Calendar,de.topicmapslab.majortom.model.revision.IRevision> revisionsByTimestamp
           
private  java.util.Map<java.lang.String,java.util.Calendar> tags
           
private static java.lang.String TIMESTAMP
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,RevisionCache.CacheEntry> topicDependent
           
private static java.lang.String TYPE
           
 
Constructor Summary
RevisionCache()
           
 
Method Summary
 void cacheAssociationChangeset(de.topicmapslab.majortom.model.core.ITopic associationType, de.topicmapslab.majortom.model.revision.Changeset changeset)
          Add the change set of the association type to internal cache
 void cacheAssociationRevisions(de.topicmapslab.majortom.model.core.ITopic associationType, java.util.List<de.topicmapslab.majortom.model.revision.IRevision> revisions)
          Add the revisions of the association type to internal cache
 void cacheChangeset(de.topicmapslab.majortom.model.revision.IRevision revision, de.topicmapslab.majortom.model.revision.Changeset changeset)
          Add the change set of the given revision to internal cache
 void cacheChangeset(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.revision.Changeset changeset)
          Add the change set of the topic to internal cache
 void cacheChangesetType(de.topicmapslab.majortom.model.revision.IRevision revision, de.topicmapslab.majortom.model.event.TopicMapEventType type)
          Add the change set type of the given revision to internal cache
private
<T,R> void
cachedEntry(java.util.Map<T,RevisionCache.CacheEntry> map, T key, java.lang.String field, R value)
          Internal method to access the stored values of the cache entry
 void cacheFirstRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
          Add the given revision as first revision to cache
 void cacheFutureRevision(de.topicmapslab.majortom.model.revision.IRevision revision, de.topicmapslab.majortom.model.revision.IRevision future)
          Add the future revision to internal cache
 void cacheLastModification(java.util.Calendar timestamp)
          Add time stamp representing the last change of the current topic map to internal cache
 void cacheLastModification(de.topicmapslab.majortom.model.core.ITopic topic, java.util.Calendar timestamp)
          Add the time stamp representing the last change of the given topic to internal cache
 void cacheLastRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
          Add the given revision as last revision to cache
 void cacheMetaData(de.topicmapslab.majortom.model.revision.IRevision revision, java.util.Map<java.lang.String,java.lang.String> metaData)
          Add the given meta data of the given revision to internal cache
 void cachePastRevision(de.topicmapslab.majortom.model.revision.IRevision revision, de.topicmapslab.majortom.model.revision.IRevision past)
          Add the previous revision of the given revision to internal cache
 void cacheRevision(java.util.Calendar timestamp, de.topicmapslab.majortom.model.revision.IRevision revision)
          Returns the revision of the given time stamp.
 void cacheRevision(long id, de.topicmapslab.majortom.model.revision.IRevision revision)
          Add the revision of the given id to internal cache.
 void cacheRevisions(de.topicmapslab.majortom.model.core.ITopic topic, java.util.List<de.topicmapslab.majortom.model.revision.IRevision> revisions)
          Add the revisions of the topic to internal cache
 void cacheRevisionTimestamp(de.topicmapslab.majortom.model.revision.IRevision revision, java.util.Calendar timestamp)
          Add the timestamp of the given revision to internal cache
 void clear()
          
 void clearMetaData(de.topicmapslab.majortom.model.revision.IRevision revision)
          Remove the cache meta-data information of the revision
 de.topicmapslab.majortom.model.revision.Changeset getAssociationChangeset(de.topicmapslab.majortom.model.core.ITopic associationType)
          Returns the changes set of all association items typed by the association type
 java.util.List<de.topicmapslab.majortom.model.revision.IRevision> getAssociationRevisions(de.topicmapslab.majortom.model.core.ITopic associationType)
          Returns all revisions of all association items typed by the association type
private
<T,R> R
getCachedEntry(java.util.Map<T,RevisionCache.CacheEntry> map, T key, java.lang.String field)
          Internal method to access the stored values of the cache entry
 de.topicmapslab.majortom.model.revision.Changeset getChangeset(de.topicmapslab.majortom.model.revision.IRevision revision)
          Returns the change set of the given revision
 de.topicmapslab.majortom.model.revision.Changeset getChangeset(de.topicmapslab.majortom.model.core.ITopic topic)
          Returns the changes set of the topic
 de.topicmapslab.majortom.model.event.TopicMapEventType getChangesetType(de.topicmapslab.majortom.model.revision.IRevision revision)
          Returns the change set type of the given revision
 de.topicmapslab.majortom.model.revision.IRevision getFirstRevision()
          Returns the first revision of the history
 de.topicmapslab.majortom.model.revision.IRevision getFutureRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
          Return the following revision of the given revision
 java.util.Calendar getLastModification()
          Returns a time stamp representing the last change of the current topic map
 java.util.Calendar getLastModification(de.topicmapslab.majortom.model.core.ITopic topic)
          Returns a time stamp representing the last change of the given topic
 de.topicmapslab.majortom.model.revision.IRevision getLastRevision()
          Returns the last revision of the history
 java.util.Map<java.lang.String,java.lang.String> getMetaData(de.topicmapslab.majortom.model.revision.IRevision revision)
          Returns all meta data sets of the given revision as copy.
 java.lang.String getMetaData(de.topicmapslab.majortom.model.revision.IRevision revision, java.lang.String key)
          Returns the value of the meta set of the given revision identified by the given key
 de.topicmapslab.majortom.model.revision.IRevision getPastRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
          Return the previous revision of the given revision
 de.topicmapslab.majortom.model.revision.IRevision getRevision(java.util.Calendar timestamp)
          Returns the revision of the given time stamp.
 de.topicmapslab.majortom.model.revision.IRevision getRevision(long id)
          Returns the revision of the given id.
 de.topicmapslab.majortom.model.revision.IRevision getRevision(java.lang.String tag)
          Returns the revision of the given tag.
 java.util.List<de.topicmapslab.majortom.model.revision.IRevision> getRevisions(de.topicmapslab.majortom.model.core.ITopic topic)
          Returns all revisions of the topic
 java.util.Calendar getRevisionTimestamp(de.topicmapslab.majortom.model.revision.IRevision revision)
          Return the time stamp representing the beginning of the given revision
 void topicMapChanged(java.lang.String id, de.topicmapslab.majortom.model.event.TopicMapEventType event, org.tmapi.core.Construct notifier, java.lang.Object newValue, java.lang.Object oldValue)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGESET

private static final java.lang.String CHANGESET
See Also:
Constant Field Values

REVISIONS

private static final java.lang.String REVISIONS
See Also:
Constant Field Values

TIMESTAMP

private static final java.lang.String TIMESTAMP
See Also:
Constant Field Values

PAST

private static final java.lang.String PAST
See Also:
Constant Field Values

FUTURE

private static final java.lang.String FUTURE
See Also:
Constant Field Values

METADATA

private static final java.lang.String METADATA
See Also:
Constant Field Values

TYPE

private static final java.lang.String TYPE
See Also:
Constant Field Values

topicDependent

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,RevisionCache.CacheEntry> topicDependent

associationDependents

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,RevisionCache.CacheEntry> associationDependents

revisionDependents

private java.util.Map<de.topicmapslab.majortom.model.revision.IRevision,RevisionCache.CacheEntry> revisionDependents

revisionsByTimestamp

private java.util.Map<java.util.Calendar,de.topicmapslab.majortom.model.revision.IRevision> revisionsByTimestamp

revisionsById

private java.util.Map<java.lang.Long,de.topicmapslab.majortom.model.revision.IRevision> revisionsById

tags

private java.util.Map<java.lang.String,java.util.Calendar> tags

lastChange

private java.util.Calendar lastChange

firstRevision

private de.topicmapslab.majortom.model.revision.IRevision firstRevision

lastRevision

private de.topicmapslab.majortom.model.revision.IRevision lastRevision
Constructor Detail

RevisionCache

public RevisionCache()
Method Detail

clear

public void clear()


getCachedEntry

private <T,R> R getCachedEntry(java.util.Map<T,RevisionCache.CacheEntry> map,
                               T key,
                               java.lang.String field)
Internal method to access the stored values of the cache entry

Type Parameters:
T - the key type
R - the return type
Parameters:
map - the map to extract the value requested
key - the key t extract the value requested
Returns:
the cache entry or null

getRevisionTimestamp

public java.util.Calendar getRevisionTimestamp(de.topicmapslab.majortom.model.revision.IRevision revision)
Return the time stamp representing the beginning of the given revision

Parameters:
revision - the revision
Returns:
the time stamp or null if the value was not cached before

getFutureRevision

public de.topicmapslab.majortom.model.revision.IRevision getFutureRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
Return the following revision of the given revision

Parameters:
revision - the revision
Returns:
the following revision or null if the value was not cached before

getPastRevision

public de.topicmapslab.majortom.model.revision.IRevision getPastRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
Return the previous revision of the given revision

Parameters:
revision - the revision
Returns:
the previous revision or null if the value was not cached before

getLastModification

public java.util.Calendar getLastModification()
Returns a time stamp representing the last change of the current topic map

Returns:
the lastChange

getLastModification

public java.util.Calendar getLastModification(de.topicmapslab.majortom.model.core.ITopic topic)
Returns a time stamp representing the last change of the given topic

Parameters:
topic - the topic
Returns:
the lastChange

getChangeset

public de.topicmapslab.majortom.model.revision.Changeset getChangeset(de.topicmapslab.majortom.model.revision.IRevision revision)
Returns the change set of the given revision

Parameters:
revision - the revision
Returns:
the change set

getChangesetType

public de.topicmapslab.majortom.model.event.TopicMapEventType getChangesetType(de.topicmapslab.majortom.model.revision.IRevision revision)
Returns the change set type of the given revision

Parameters:
revision - the revision
Returns:
the change set type

getFirstRevision

public de.topicmapslab.majortom.model.revision.IRevision getFirstRevision()
Returns the first revision of the history

Returns:
the first revision or null if history is empty

getLastRevision

public de.topicmapslab.majortom.model.revision.IRevision getLastRevision()
Returns the last revision of the history

Returns:
the last revision or null if history is empty

getRevision

public de.topicmapslab.majortom.model.revision.IRevision getRevision(java.util.Calendar timestamp)
Returns the revision of the given time stamp.

Parameters:
timestamp - the time stamp
Returns:
the revision

getRevision

public de.topicmapslab.majortom.model.revision.IRevision getRevision(java.lang.String tag)
Returns the revision of the given tag.

Parameters:
tag - the tag name
Returns:
the revision

getRevision

public de.topicmapslab.majortom.model.revision.IRevision getRevision(long id)
Returns the revision of the given id.

Parameters:
id - the id
Returns:
the revision

getRevisions

public java.util.List<de.topicmapslab.majortom.model.revision.IRevision> getRevisions(de.topicmapslab.majortom.model.core.ITopic topic)
Returns all revisions of the topic

Parameters:
topic - the topic
Returns:
the revisions

getChangeset

public de.topicmapslab.majortom.model.revision.Changeset getChangeset(de.topicmapslab.majortom.model.core.ITopic topic)
Returns the changes set of the topic

Parameters:
topic - the topic
Returns:
the changes set

getAssociationChangeset

public de.topicmapslab.majortom.model.revision.Changeset getAssociationChangeset(de.topicmapslab.majortom.model.core.ITopic associationType)
Returns the changes set of all association items typed by the association type

Parameters:
associationType - the association type
Returns:
the changes set

getAssociationRevisions

public java.util.List<de.topicmapslab.majortom.model.revision.IRevision> getAssociationRevisions(de.topicmapslab.majortom.model.core.ITopic associationType)
Returns all revisions of all association items typed by the association type

Parameters:
associationType - the association type
Returns:
the revisions

getMetaData

public java.lang.String getMetaData(de.topicmapslab.majortom.model.revision.IRevision revision,
                                    java.lang.String key)
Returns the value of the meta set of the given revision identified by the given key

Parameters:
revision - the revision
key - the key
Returns:
the value or null if the key is unknown

getMetaData

public java.util.Map<java.lang.String,java.lang.String> getMetaData(de.topicmapslab.majortom.model.revision.IRevision revision)
Returns all meta data sets of the given revision as copy.

Parameters:
revision - the revision
Returns:
the copy of all meta data sets

cachedEntry

private <T,R> void cachedEntry(java.util.Map<T,RevisionCache.CacheEntry> map,
                               T key,
                               java.lang.String field,
                               R value)
Internal method to access the stored values of the cache entry

Type Parameters:
T - the key type
R - the return type
Parameters:
map - the map to extract the value requested
key - the key t extract the value requested

cacheRevisionTimestamp

public void cacheRevisionTimestamp(de.topicmapslab.majortom.model.revision.IRevision revision,
                                   java.util.Calendar timestamp)
Add the timestamp of the given revision to internal cache

Parameters:
revision - the revision
timestamp - the timestamp to add

cacheFutureRevision

public void cacheFutureRevision(de.topicmapslab.majortom.model.revision.IRevision revision,
                                de.topicmapslab.majortom.model.revision.IRevision future)
Add the future revision to internal cache

Parameters:
revision - the revision
future - the revision after the given one

cachePastRevision

public void cachePastRevision(de.topicmapslab.majortom.model.revision.IRevision revision,
                              de.topicmapslab.majortom.model.revision.IRevision past)
Add the previous revision of the given revision to internal cache

Parameters:
revision - the revision
past - the revision before the given one

cacheMetaData

public void cacheMetaData(de.topicmapslab.majortom.model.revision.IRevision revision,
                          java.util.Map<java.lang.String,java.lang.String> metaData)
Add the given meta data of the given revision to internal cache

Parameters:
revision - the revision
metaData - the meta data

cacheLastModification

public void cacheLastModification(java.util.Calendar timestamp)
Add time stamp representing the last change of the current topic map to internal cache

Parameters:
timestamp - the timestamp

cacheLastModification

public void cacheLastModification(de.topicmapslab.majortom.model.core.ITopic topic,
                                  java.util.Calendar timestamp)
Add the time stamp representing the last change of the given topic to internal cache

Parameters:
topic - the topic
timestamp - the timestamp

cacheChangeset

public void cacheChangeset(de.topicmapslab.majortom.model.revision.IRevision revision,
                           de.topicmapslab.majortom.model.revision.Changeset changeset)
Add the change set of the given revision to internal cache

Parameters:
revision - the revision
changeset - the change set to add

cacheChangesetType

public void cacheChangesetType(de.topicmapslab.majortom.model.revision.IRevision revision,
                               de.topicmapslab.majortom.model.event.TopicMapEventType type)
Add the change set type of the given revision to internal cache

Parameters:
revision - the revision
type - the change set type

cacheFirstRevision

public void cacheFirstRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
Add the given revision as first revision to cache

Parameters:
revision - the revision

cacheLastRevision

public void cacheLastRevision(de.topicmapslab.majortom.model.revision.IRevision revision)
Add the given revision as last revision to cache

Parameters:
revision - the revision

cacheRevision

public void cacheRevision(java.util.Calendar timestamp,
                          de.topicmapslab.majortom.model.revision.IRevision revision)
Returns the revision of the given time stamp.

Parameters:
timestamp - the time stamp
revision - the revision

cacheRevision

public void cacheRevision(long id,
                          de.topicmapslab.majortom.model.revision.IRevision revision)
Add the revision of the given id to internal cache.

Parameters:
id - the id
revision - the revision

cacheRevisions

public void cacheRevisions(de.topicmapslab.majortom.model.core.ITopic topic,
                           java.util.List<de.topicmapslab.majortom.model.revision.IRevision> revisions)
Add the revisions of the topic to internal cache

Parameters:
topic - the topic
revisions - the revisions to add

cacheChangeset

public void cacheChangeset(de.topicmapslab.majortom.model.core.ITopic topic,
                           de.topicmapslab.majortom.model.revision.Changeset changeset)
Add the change set of the topic to internal cache

Parameters:
topic - the topic
changeset - the change set to add

cacheAssociationChangeset

public void cacheAssociationChangeset(de.topicmapslab.majortom.model.core.ITopic associationType,
                                      de.topicmapslab.majortom.model.revision.Changeset changeset)
Add the change set of the association type to internal cache

Parameters:
associationType - the association type
changeset - the change set to add

cacheAssociationRevisions

public void cacheAssociationRevisions(de.topicmapslab.majortom.model.core.ITopic associationType,
                                      java.util.List<de.topicmapslab.majortom.model.revision.IRevision> revisions)
Add the revisions of the association type to internal cache

Parameters:
associationType - the association type
revisions - the revisions to add

topicMapChanged

public void topicMapChanged(java.lang.String id,
                            de.topicmapslab.majortom.model.event.TopicMapEventType event,
                            org.tmapi.core.Construct notifier,
                            java.lang.Object newValue,
                            java.lang.Object oldValue)

Specified by:
topicMapChanged in interface de.topicmapslab.majortom.model.event.ITopicMapListener

clearMetaData

public void clearMetaData(de.topicmapslab.majortom.model.revision.IRevision revision)
Remove the cache meta-data information of the revision

Parameters:
revision - the revision