de.topicmapslab.majortom.inmemory.store
Class SignatureStore

java.lang.Object
  extended by de.topicmapslab.majortom.inmemory.store.SignatureStore
All Implemented Interfaces:
de.topicmapslab.majortom.model.event.ITopicMapListener

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

Author:
Sven Krosse

Field Summary
private static java.lang.String ASSOCIATION_SIGNATURE
           
private  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IConstruct>> constructs
           
private  java.security.MessageDigest digest
           
private static java.lang.String NAME_SIGNATURE
           
private static java.lang.String OCCURRENCE_SIGNATURE
           
private static java.lang.String ROLE_SIGNATURE
           
private  java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.String> signatures
           
private  InMemoryTopicMapStore topicMapStore
           
private static java.lang.String VARIANT_SIGNATURE
           
 
Constructor Summary
SignatureStore(InMemoryTopicMapStore topicMapStore)
           
 
Method Summary
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IAssociation association)
          Internal method to generate new association signature
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IAssociationRole role)
          Internal method to generate new role signature
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IName name)
          Internal method to generate new name signature
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IName parent, de.topicmapslab.majortom.model.core.IVariant variant)
          Internal method to generate new variant signature
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IOccurrence occurrence)
          Internal method to generate new occurrence signature
private  java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IVariant variant)
          Internal method to generate new variant signature
 InMemoryTopicMapStore getTopicMapStore()
           
private  void internalRemoveDuplicates(de.topicmapslab.majortom.model.core.IAssociation association, java.util.Set<de.topicmapslab.majortom.model.core.IConstruct> removed, de.topicmapslab.majortom.model.revision.IRevision revision)
          Internal method to remove duplicates from topic map store
private  void internalRemoveDuplicates(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.revision.IRevision revision)
          Internal method to remove duplicates in context to the topic
 void removeDuplicates(de.topicmapslab.majortom.model.revision.IRevision revision)
          Removes all duplicates of the topic map
 void removeDuplicates(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.revision.IRevision revision)
          Removes all duplicates in relation to the given topic.
private  void removeSignature(de.topicmapslab.majortom.model.core.IConstruct construct)
          Method to remove the signature
private  java.lang.String toHash(java.lang.String string)
          Utility method to generate a hash
 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)
          
private  void updateSignature(de.topicmapslab.majortom.model.core.IAssociation association)
          Internal method delicates to update association signature
private  void updateSignature(de.topicmapslab.majortom.model.core.IAssociationRole role)
          Internal method delicates to update the role signatue
private  void updateSignature(de.topicmapslab.majortom.model.core.IConstruct construct, java.lang.String signature)
          Internal method to update the signature for given id
private  void updateSignature(de.topicmapslab.majortom.model.core.IName name)
          Internal method delicates to update name signature
private  void updateSignature(de.topicmapslab.majortom.model.core.IOccurrence occurrence)
          Internal method delicates to update occurrence signature
private  void updateSignature(de.topicmapslab.majortom.model.core.IVariant variant)
          Internal method delicates to update variant signature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASSOCIATION_SIGNATURE

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

ROLE_SIGNATURE

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

OCCURRENCE_SIGNATURE

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

NAME_SIGNATURE

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

VARIANT_SIGNATURE

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

signatures

private java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.String> signatures

constructs

private java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IConstruct>> constructs

digest

private final java.security.MessageDigest digest

topicMapStore

private final InMemoryTopicMapStore topicMapStore
Constructor Detail

SignatureStore

public SignatureStore(InMemoryTopicMapStore topicMapStore)
Method Detail

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

removeSignature

private void removeSignature(de.topicmapslab.majortom.model.core.IConstruct construct)
Method to remove the signature

Parameters:
construct - the construct

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IConstruct construct,
                             java.lang.String signature)
Internal method to update the signature for given id

Parameters:
construct - the construct
signature - the signature

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IAssociation association)
Internal method delicates to update association signature

Parameters:
association - the association

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IAssociationRole role)
Internal method delicates to update the role signatue

Parameters:
role - the role

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IName name)
Internal method delicates to update name signature

Parameters:
name - the name

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IOccurrence occurrence)
Internal method delicates to update occurrence signature

Parameters:
occurrence - the occurrence

updateSignature

private void updateSignature(de.topicmapslab.majortom.model.core.IVariant variant)
Internal method delicates to update variant signature

Parameters:
variant - the variant

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IAssociation association)
Internal method to generate new association signature

Parameters:
association - the association
Returns:
the generated signature

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IAssociationRole role)
Internal method to generate new role signature

Parameters:
role - the role
Returns:
the generated signature

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IName name)
Internal method to generate new name signature

Parameters:
name - the name
Returns:
the generated signature

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IOccurrence occurrence)
Internal method to generate new occurrence signature

Parameters:
occurrence - the occurrence
Returns:
the generated signature

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IName parent,
                                           de.topicmapslab.majortom.model.core.IVariant variant)
Internal method to generate new variant signature

Parameters:
parent - the name used as parent
variant - the variant
Returns:
the generated signature

generateSignature

private java.lang.String generateSignature(de.topicmapslab.majortom.model.core.IVariant variant)
Internal method to generate new variant signature

Parameters:
variant - the variant
Returns:
the generated signature

getTopicMapStore

public InMemoryTopicMapStore getTopicMapStore()
Returns:
the topicMapStore

internalRemoveDuplicates

private void internalRemoveDuplicates(de.topicmapslab.majortom.model.core.ITopic topic,
                                      de.topicmapslab.majortom.model.revision.IRevision revision)
Internal method to remove duplicates in context to the topic

Parameters:
topic - the topic
revision - the revision to store changes

internalRemoveDuplicates

private void internalRemoveDuplicates(de.topicmapslab.majortom.model.core.IAssociation association,
                                      java.util.Set<de.topicmapslab.majortom.model.core.IConstruct> removed,
                                      de.topicmapslab.majortom.model.revision.IRevision revision)
Internal method to remove duplicates from topic map store

Parameters:
association - the association
removed - the removed constructs
revision - the revision to store the changes

removeDuplicates

public void removeDuplicates(de.topicmapslab.majortom.model.revision.IRevision revision)
Removes all duplicates of the topic map

Parameters:
revision - the revision to store changes

removeDuplicates

public void removeDuplicates(de.topicmapslab.majortom.model.core.ITopic topic,
                             de.topicmapslab.majortom.model.revision.IRevision revision)
Removes all duplicates in relation to the given topic. In other words, all duplicate names, occurrences and played associations will be removed.

Parameters:
topic - the topic
revision - the revision to store changes

toHash

private java.lang.String toHash(java.lang.String string)
Utility method to generate a hash

Parameters:
string - the string
Returns:
the byte array as hash