de.topicmapslab.majortom.database.transaction
Class TransactionMergeUtils

java.lang.Object
  extended by de.topicmapslab.majortom.database.transaction.TransactionMergeUtils

public class TransactionMergeUtils
extends java.lang.Object

Utility class for merging process.

Author:
Sven Krosse

Constructor Summary
TransactionMergeUtils()
           
 
Method Summary
private static boolean checkTmdmAssociation(TransactionTopicMapStore store, org.tmapi.core.Association association, de.topicmapslab.majortom.model.core.ITopicMap topicMap, org.tmapi.core.TopicMap other)
          Method checks if the given association is a TMDM type-instance or supertype-subtype association
static java.util.Map<de.topicmapslab.majortom.model.core.ITopic,de.topicmapslab.majortom.model.core.IName> detectMergeByNameCandidate(TransactionTopicMapStore 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(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other, de.topicmapslab.majortom.model.revision.IRevision revision)
          Merging the given topics without creating duplicates.
static void doMergeReifiable(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.IReifiable reifiable, de.topicmapslab.majortom.model.core.IReifiable other, de.topicmapslab.majortom.model.revision.IRevision revision)
          Handling reification after merging the given constructs.
static void doMergeTopicMaps(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.ITopicMap topicMap, org.tmapi.core.TopicMap other)
          Merging all information items of the second topic map into the first topic map, without duplicates
static de.topicmapslab.majortom.model.core.IScope getCorrespondingScope(TransactionTopicMapStore store, java.util.Set<org.tmapi.core.Topic> themes)
          Returns the IScope object representing all the given themes in the given topic map store.
static de.topicmapslab.majortom.model.core.IAssociation getDuplette(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.IAssociation association)
          Returning the duplicated association with the same type, roles and scope than the given one.
static de.topicmapslab.majortom.model.core.IVariant getDuplette(TransactionTopicMapStore 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)
          Returning the duplicated variant with the given parent, value, datatype and scope.
static de.topicmapslab.majortom.model.core.IAssociation getDuplette(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic other, de.topicmapslab.majortom.model.core.IAssociation association)
          Returning the duplicated association with the same type, roles and scope than the given one.
static de.topicmapslab.majortom.model.core.IName getDuplette(TransactionTopicMapStore 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)
          Returning the duplicated name with the given type, parent, value and scope.
static de.topicmapslab.majortom.model.core.IOccurrence getDuplette(TransactionTopicMapStore 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)
          Returning the duplicated occurrence with the given type, parent, value, datatype and scope.
static de.topicmapslab.majortom.model.core.ITopic getDuplette(TransactionTopicMapStore store, org.tmapi.core.Topic topic)
          Returns the topic of the given store which is equal to the given one.
static void removeDuplicates(TransactionTopicMapStore store, de.topicmapslab.majortom.model.core.ITopicMap topicMap)
          Method removes all duplicates from the given topic map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionMergeUtils

public TransactionMergeUtils()
Method Detail

detectMergeByNameCandidate

public static java.util.Map<de.topicmapslab.majortom.model.core.ITopic,de.topicmapslab.majortom.model.core.IName> detectMergeByNameCandidate(TransactionTopicMapStore 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(TransactionTopicMapStore store,
                                                                     org.tmapi.core.Topic topic)
                                                              throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Returns the topic of the given store which is equal to the given one.

Parameters:
store - the store
topic - a topic of another store
Returns:
the duplicated topic or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

getDuplette

public static de.topicmapslab.majortom.model.core.IName getDuplette(TransactionTopicMapStore 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
Returning the duplicated name with the given type, parent, value and scope.

Parameters:
store - the store
topic - the parent
type - the type
value - the value
themes - the 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(TransactionTopicMapStore 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
Returning the duplicated variant with the given parent, value, datatype and scope.

Parameters:
store - the store
name - the parent
value - the value
locator - the datatype
themes - the 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(TransactionTopicMapStore 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
Returning the duplicated occurrence with the given type, parent, value, datatype and scope.

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

getDuplette

public static de.topicmapslab.majortom.model.core.IAssociation getDuplette(TransactionTopicMapStore 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
Returning the duplicated association with the same type, roles and scope than the given one. All roles played by the source topic can be played by the target topic without changing the equality of associations.

Parameters:
store - the store
topic - the target topic
other - the source topic
association - the association
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(TransactionTopicMapStore store,
                                                                           de.topicmapslab.majortom.model.core.IAssociation association)
                                                                    throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Returning the duplicated association with the same type, roles and scope than the given one.

Parameters:
store - the store
association - the association
Returns:
the duplicated association or null
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

doMerge

public static void doMerge(TransactionTopicMapStore 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
Merging the given topics without creating duplicates.

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

doMergeReifiable

public static void doMergeReifiable(TransactionTopicMapStore 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
Handling reification after merging the given constructs. If both are reified, the reifier topics are merged. Otherwise the existing reifier are moved to the target construct.

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

doMergeTopicMaps

public static void doMergeTopicMaps(TransactionTopicMapStore store,
                                    de.topicmapslab.majortom.model.core.ITopicMap topicMap,
                                    org.tmapi.core.TopicMap other)
                             throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Merging all information items of the second topic map into the first topic map, without duplicates

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

getCorrespondingScope

public static de.topicmapslab.majortom.model.core.IScope getCorrespondingScope(TransactionTopicMapStore store,
                                                                               java.util.Set<org.tmapi.core.Topic> themes)
Returns the IScope object representing all the given themes in the given topic map store.

Parameters:
store - the store.
themes - the themes
Returns:
the scope object and never null

checkTmdmAssociation

private static boolean checkTmdmAssociation(TransactionTopicMapStore 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 given association is a TMDM type-instance or supertype-subtype association

Parameters:
store - the store
association - the association to check
topicMap - the topic map
other - the other topic map
Returns:
true if the associations is a TMDM type-instance or supertype-subtype association, false otherwise.
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails

removeDuplicates

public static void removeDuplicates(TransactionTopicMapStore 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 itself
Throws:
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if operation fails