de.topicmapslab.majortom.store
Class MergeUtils

java.lang.Object
  extended by de.topicmapslab.majortom.store.MergeUtils

public class MergeUtils
extends java.lang.Object

Utility class for merging process.

Author:
Sven Krosse

Constructor Summary
MergeUtils()
           
 
Method Summary
private static boolean checkTmdmAssociation(de.topicmapslab.majortom.model.store.ITopicMapStore store, org.tmapi.core.Association association, de.topicmapslab.majortom.model.core.ITopicMap topicMap, org.tmapi.core.TopicMap other)
          Method checks if the association is a TMDM association.
static NameMergeCandidate detectMergeByNameCandidate(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic nameType, java.lang.String value, java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          Method checks if there is a topic with the same name
static void doMerge(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other, de.topicmapslab.majortom.model.revision.IRevision revision)
          Method merge the given topics.
static void doMergeReifiable(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IReifiable reifiable, de.topicmapslab.majortom.model.core.IReifiable other, de.topicmapslab.majortom.model.revision.IRevision revision)
          Merge the reification of both reified constructs
static void doMergeTopicMaps(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopicMap topicMap, org.tmapi.core.TopicMap other)
          Merge the one topic map into the other
static de.topicmapslab.majortom.model.core.IScope getCorrespondingScope(de.topicmapslab.majortom.model.store.ITopicMapStore store, java.util.Set<org.tmapi.core.Topic> themes)
          Returns the corresponding scope containing all themes of the origin
static de.topicmapslab.majortom.model.core.IAssociation getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IAssociation association, java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> excluded)
          Method returns a duplicated association of the given one
static de.topicmapslab.majortom.model.core.IVariant getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IName name, java.lang.String value, de.topicmapslab.majortom.model.core.ILocator locator, java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          Method returns the duplicated variant of the given name with the scope, datatype and value
static de.topicmapslab.majortom.model.core.IAssociation getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other, de.topicmapslab.majortom.model.core.IAssociation association)
          Method return a duplicated association only differs in the given role players
static de.topicmapslab.majortom.model.core.IName getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic type, java.lang.String value, java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          Method returns the duplicated name of the given topic with the given type, scope and value
static de.topicmapslab.majortom.model.core.IOccurrence getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic type, java.lang.String value, de.topicmapslab.majortom.model.core.ILocator locator, java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          Method returns the duplicated occurrence of the given topic with the given type, scope, datatype and value
static de.topicmapslab.majortom.model.core.ITopic getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store, org.tmapi.core.Topic topic)
          Method try to find a topic with the same identity
static java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getDuplettes(de.topicmapslab.majortom.model.core.IAssociation association, de.topicmapslab.majortom.model.core.IAssociationRole role)
          Returns a set the duplicated role of the given association with the same type and player than the given one.
static java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getDuplettes(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IAssociation association)
          Method returns a set of duplicated association of the given one
static java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getDuplettes(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IName name, java.lang.String value, de.topicmapslab.majortom.model.core.ILocator locator, java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
          Method returns the duplicated variant of the given name with the scope, datatype and value
static java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getDuplettes2(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.IAssociation association)
           
static void removeDuplicates(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopicMap topicMap)
          Method removes all duplicates from the given topic map.
static void replaceAsTheme(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other)
          Method replace the one topic by the other topic as theme
static void replaceAsTypeOrSupertype(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other)
          Method replace each type or supertype relation of the one topic by the other topic
static void replaceIdentity(de.topicmapslab.majortom.model.store.ITopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other)
          Method mode the whole identity of the one topic to the other topic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergeUtils

public MergeUtils()
Method Detail

detectMergeByNameCandidate

public static NameMergeCandidate detectMergeByNameCandidate(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                            de.topicmapslab.majortom.model.core.ITopic topic,
                                                            de.topicmapslab.majortom.model.core.ITopic nameType,
                                                            java.lang.String value,
                                                            java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
Method checks if there is a topic with the same name

Parameters:
store - the in-memory store
topic - the topic, the name should added to
nameType - the type of the name
value - the name value
themes - a set of themes
Returns:
the merging candidate-name combination or null

getDuplette

public static de.topicmapslab.majortom.model.core.ITopic getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                     org.tmapi.core.Topic topic)
                                                              throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method try to find a topic with the same identity

Parameters:
store - the topic map store
topic - the topic with the identities
Returns:
the found topic or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException

getDuplette

public static de.topicmapslab.majortom.model.core.IName getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                    de.topicmapslab.majortom.model.core.ITopic topic,
                                                                    de.topicmapslab.majortom.model.core.ITopic type,
                                                                    java.lang.String value,
                                                                    java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
                                                             throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns the duplicated name of the given topic with the given type, scope and value

Parameters:
store - the store
topic - the topic
type - the type
value - the value
themes - the themes of scope
Returns:
the duplicated name or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplette

public static de.topicmapslab.majortom.model.core.IVariant getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                       de.topicmapslab.majortom.model.core.IName name,
                                                                       java.lang.String value,
                                                                       de.topicmapslab.majortom.model.core.ILocator locator,
                                                                       java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
                                                                throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns the duplicated variant of the given name with the scope, datatype and value

Parameters:
store - the store
topic - the topic
value - the value
locator - the locator of datatype
themes - the themes of scope
Returns:
the duplicated variant or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplette

public static de.topicmapslab.majortom.model.core.IOccurrence getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                          de.topicmapslab.majortom.model.core.ITopic topic,
                                                                          de.topicmapslab.majortom.model.core.ITopic type,
                                                                          java.lang.String value,
                                                                          de.topicmapslab.majortom.model.core.ILocator locator,
                                                                          java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
                                                                   throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns the duplicated occurrence of the given topic with the given type, scope, datatype and value

Parameters:
store - the store
topic - the topic
type - the type
value - the value
locator - the locator of datatype
themes - the themes of scope
Returns:
the duplicated occurrence or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplette

public static de.topicmapslab.majortom.model.core.IAssociation getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                           de.topicmapslab.majortom.model.core.ITopic topic,
                                                                           de.topicmapslab.majortom.model.core.ITopic other,
                                                                           de.topicmapslab.majortom.model.core.IAssociation association)
                                                                    throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method return a duplicated association only differs in the given role players

Parameters:
store - the store
topic - the one player
other - the other player
association - the other association containing all information
Returns:
the duplicated association or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplette

public static de.topicmapslab.majortom.model.core.IAssociation getDuplette(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                           de.topicmapslab.majortom.model.core.IAssociation association,
                                                                           java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> excluded)
                                                                    throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns a duplicated association of the given one

Parameters:
store - the store
association - the association to check
excluded - a set of excluded associations
Returns:
the duplicated association or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

doMerge

public static void doMerge(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                           de.topicmapslab.majortom.model.core.ITopic topic,
                           de.topicmapslab.majortom.model.core.ITopic other,
                           de.topicmapslab.majortom.model.revision.IRevision revision)
                    throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method merge the given topics.

Parameters:
store - the store
topic - the one topic
other - the other topic
revision - the revision to store changes
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException

replaceIdentity

public static void replaceIdentity(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                   de.topicmapslab.majortom.model.core.ITopic topic,
                                   de.topicmapslab.majortom.model.core.ITopic other)
                            throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method mode the whole identity of the one topic to the other topic

Parameters:
store - the store
topic - the topic as target
other - the topic as source
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

replaceAsTypeOrSupertype

public static void replaceAsTypeOrSupertype(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                            de.topicmapslab.majortom.model.core.ITopic topic,
                                            de.topicmapslab.majortom.model.core.ITopic other)
                                     throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method replace each type or supertype relation of the one topic by the other topic

Parameters:
store - the store
topic - the topic as target
other - the topic as source
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

replaceAsTheme

public static void replaceAsTheme(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                  de.topicmapslab.majortom.model.core.ITopic topic,
                                  de.topicmapslab.majortom.model.core.ITopic other)
                           throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method replace the one topic by the other topic as theme

Parameters:
store - the store
topic - the topic as target
other - the topic as source
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

doMergeReifiable

public static void doMergeReifiable(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                    de.topicmapslab.majortom.model.core.IReifiable reifiable,
                                    de.topicmapslab.majortom.model.core.IReifiable other,
                                    de.topicmapslab.majortom.model.revision.IRevision revision)
                             throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Merge the reification of both reified constructs

Parameters:
store - the store
reifiable - the one reified construct
other - the other reified construct
revision - the revision to store
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

doMergeTopicMaps

public static void doMergeTopicMaps(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                    de.topicmapslab.majortom.model.core.ITopicMap topicMap,
                                    org.tmapi.core.TopicMap other)
                             throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Merge the one topic map into the other

Parameters:
store - the store
topicMap - the topic map as target
other - the topic map as source
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getCorrespondingScope

public static de.topicmapslab.majortom.model.core.IScope getCorrespondingScope(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                               java.util.Set<org.tmapi.core.Topic> themes)
Returns the corresponding scope containing all themes of the origin

Parameters:
store - the store
themes - the set of themes
Returns:
the scope object

checkTmdmAssociation

private static boolean checkTmdmAssociation(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                            org.tmapi.core.Association association,
                                            de.topicmapslab.majortom.model.core.ITopicMap topicMap,
                                            org.tmapi.core.TopicMap other)
                                     throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method checks if the association is a TMDM association. Such associations will not be copied into the new topic map to avoid duplicated entries.

Parameters:
store - the store
association - the association
topicMap - the topic map
other - the other topic map
Returns:
true if the association is an TMDM association, false otherwise.
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException

removeDuplicates

public static void removeDuplicates(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                    de.topicmapslab.majortom.model.core.ITopicMap topicMap)
                             throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method removes all duplicates from the given topic map.

Parameters:
store - the topic map store
topicMap - the topic map itselfs
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplettes

public static java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getDuplettes(de.topicmapslab.majortom.model.core.IAssociation association,
                                                                                               de.topicmapslab.majortom.model.core.IAssociationRole role)
Returns a set the duplicated role of the given association with the same type and player than the given one.

Parameters:
association - the association
role - the role
Returns:
a set of duplicated roles

getDuplettes2

public static java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getDuplettes2(de.topicmapslab.majortom.model.core.ITopic topic,
                                                                                            de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                                            de.topicmapslab.majortom.model.core.IAssociation association)
                                                                                     throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException

getDuplettes

public static java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getDuplettes(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                                           de.topicmapslab.majortom.model.core.IAssociation association)
                                                                                    throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns a set of duplicated association of the given one

Parameters:
store - the store
association - the association to check
Returns:
a set of duplicated associations
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplettes

public static java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getDuplettes(de.topicmapslab.majortom.model.store.ITopicMapStore store,
                                                                                       de.topicmapslab.majortom.model.core.IName name,
                                                                                       java.lang.String value,
                                                                                       de.topicmapslab.majortom.model.core.ILocator locator,
                                                                                       java.util.Collection<de.topicmapslab.majortom.model.core.ITopic> themes)
                                                                                throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Method returns the duplicated variant of the given name with the scope, datatype and value

Parameters:
store - the store
topic - the topic
value - the value
locator - the locator of datatype
themes - the themes of scope
Returns:
the duplicated variant or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails