net.ontopia.topicmaps.utils
Class MergeUtils

java.lang.Object
  extended by net.ontopia.topicmaps.utils.MergeUtils

public class MergeUtils
extends java.lang.Object

PUBLIC: Utilities for merging topics and topic maps. This class provides static methods for testing whether topics should be merged, merging topics and for merging topic maps.


Constructor Summary
MergeUtils()
           
 
Method Summary
static TopicIF copyIdentifiers(TopicIF target, TopicIF source)
          INTERNAL: Copies all the identifiers from the source to the target topic.
static TopicIF copyIdentifiers(TopicIF target, TopicIF source, java.util.Map mergemap)
           
static TopicIF findTopic(TopicMapIF othertm, TopicIF topic)
          PUBLIC: Find a topic in the other topic map which would merge with the given topic if that were to be added to the same topic map.
static void mergeInto(AssociationIF target, AssociationIF source)
          PUBLIC: Merges the source association into the target association.
static void mergeInto(AssociationRoleIF target, AssociationRoleIF source)
          PUBLIC: Merges the source role into the target role.
static void mergeInto(OccurrenceIF target, OccurrenceIF source)
          PUBLIC: Merges the source occurrence into the target occurrence.
static void mergeInto(ReifiableIF target, ReifiableIF source)
          PUBLIC: Merges the source object into the target object.
static OccurrenceIF mergeInto(TopicIF target, OccurrenceIF source)
          PUBLIC: Merges the source occurrence into the target topic in another topic map.
static ReifiableIF mergeInto(TopicIF target, ReifiableIF source)
          PUBLIC: Merges the source object into a target topic in another topic map.
static void mergeInto(TopicIF target, TopicIF source)
          PUBLIC: Merges the characteristics of one topic into another topic.
static TopicNameIF mergeInto(TopicIF target, TopicNameIF source)
          PUBLIC: Merges the source topic name into the target topic in another topic map.
static AssociationIF mergeInto(TopicMapIF topicmap, AssociationIF source)
          PUBLIC: Merges the source association into the target topic map.
static TopicIF mergeInto(TopicMapIF targettm, TopicIF source)
          PUBLIC: Merges the source topic from into the target topic map, when the source topic is not already in the target topic map.
static TopicIF mergeInto(TopicMapIF targettm, TopicIF source, DeciderIF decider)
          PUBLIC: Merges the source topic from into the target topic map, when the source topic is not already in the target topic map.
static void mergeInto(TopicMapIF target, TopicMapIF source)
          PUBLIC: Merges one topic map into another topic map.
static void mergeInto(TopicNameIF target, TopicNameIF source)
          PUBLIC: Merges the source name into the target name.
static void mergeInto(VariantNameIF target, VariantNameIF source)
          PUBLIC: Merges the source variant into the target variant.
static boolean shouldMerge(TopicIF t1, TopicIF t2)
          PUBLIC: Tests whether two topics should be merged or not, according to XTM rules.
 
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

shouldMerge

public static boolean shouldMerge(TopicIF t1,
                                  TopicIF t2)
PUBLIC: Tests whether two topics should be merged or not, according to XTM rules.

Parameters:
t1 - topicIF; #1 topic to merge
t2 - topicIF; #2 topic to merge
Returns:
boolean; true if the topics should be merged, false otherwise.

mergeInto

public static void mergeInto(TopicIF target,
                             TopicIF source)
                      throws ConstraintViolationException
PUBLIC: Merges the characteristics of one topic into another topic. The source topic stripped of characteristics, all of which are moved to the target topic. Duplicate characteristics are suppressed. The topics must be in the same topic map, and the source topic is removed from the topic map.

Parameters:
source - topicIF; the source topic. This is empty after the operation and is removed from the topic map.
target - topicIF; the target topic. This gets new characteristics.
Throws:
throws - ConstraintViolationException if the two topics have different values for the 'subject' property, since if they do they cannot represent the same subject. If this exception is thrown both topics remain untouched.
ConstraintViolationException

mergeInto

public static void mergeInto(TopicNameIF target,
                             TopicNameIF source)
PUBLIC: Merges the source name into the target name. The two names must be in the same topic map, but need not have the same parent topic. It is assumed (but not verified) that the two names are actually equal.

Since:
5.1.0

mergeInto

public static void mergeInto(OccurrenceIF target,
                             OccurrenceIF source)
PUBLIC: Merges the source occurrence into the target occurrence. The two occurrences must be in the same topic map, but need not have the same parent topic. It is assumed (but not verified) that the two occurrences are actually equal.

Since:
5.1.0

mergeInto

public static void mergeInto(AssociationIF target,
                             AssociationIF source)
PUBLIC: Merges the source association into the target association. The two associations must be in the same topic map. If the two associations are not actually equal a ConstraintViolationException is thrown.

Since:
5.1.0

mergeInto

public static void mergeInto(AssociationRoleIF target,
                             AssociationRoleIF source)
PUBLIC: Merges the source role into the target role. The two roles must be in the same topic map, but need not have the same parent association. If the associations are not the same, they are merged, provided that they are equal; if they are not equal, a ConstraintViolationException is thrown. It is assumed (but not verified) that the two roles are actually equal.

Since:
5.1.0

mergeInto

public static void mergeInto(VariantNameIF target,
                             VariantNameIF source)
PUBLIC: Merges the source variant into the target variant. The two variants must be in the same topic map, but need not have the same parent name. It is assumed (but not verified) that the two variants are actually equal.

Since:
5.1.0

mergeInto

public static void mergeInto(ReifiableIF target,
                             ReifiableIF source)
PUBLIC: Merges the source object into the target object. The two objects must be in the same topic map, but need not have the same parent. It is assumed (but not verified) that the two objects are actually equal.

Since:
5.1.0

mergeInto

public static ReifiableIF mergeInto(TopicIF target,
                                    ReifiableIF source)
PUBLIC: Merges the source object into a target topic in another topic map. Makes no attempt to verify that the source topic represents the same subject as the target topic.

Since:
5.1.3

mergeInto

public static TopicNameIF mergeInto(TopicIF target,
                                    TopicNameIF source)
PUBLIC: Merges the source topic name into the target topic in another topic map. Makes no attempt to verify that the source topic represents the same subject as the target topic.

Returns:
The new topic name in the target topic map.
Since:
5.1.3

mergeInto

public static OccurrenceIF mergeInto(TopicIF target,
                                     OccurrenceIF source)
PUBLIC: Merges the source occurrence into the target topic in another topic map. Makes no attempt to verify that the source topic represents the same subject as the target topic.

Returns:
The new occurrence in the target topic map.
Since:
5.1.3

mergeInto

public static AssociationIF mergeInto(TopicMapIF topicmap,
                                      AssociationIF source)
PUBLIC: Merges the source association into the target topic map. Makes no attempt to verify that the source association is not already present.

Returns:
The new association in the target topic map.
Since:
5.1.3

mergeInto

public static TopicIF mergeInto(TopicMapIF targettm,
                                TopicIF source)
PUBLIC: Merges the source topic from into the target topic map, when the source topic is not already in the target topic map. All characteristics of the source topic are copied over, but topics referenced from the source topic are only included as identity stubs. The source topic is untouched.

Since:
2.0

mergeInto

public static TopicIF mergeInto(TopicMapIF targettm,
                                TopicIF source,
                                DeciderIF decider)
PUBLIC: Merges the source topic from into the target topic map, when the source topic is not already in the target topic map. All characteristics of the source topic that are approved by the decider are copied over, but topics referenced from the source topic are only included as identity stubs. The source topic is untouched.

Parameters:
decider - Used to decide which topic characteristics to copy. Is asked for each base name, occurrence, and association role.
Since:
2.0

copyIdentifiers

public static TopicIF copyIdentifiers(TopicIF target,
                                      TopicIF source)
INTERNAL: Copies all the identifiers from the source to the target topic. Note that this method might cause topics in the target topic map to merge. The source and target are assumed to come from different topic maps.


copyIdentifiers

public static TopicIF copyIdentifiers(TopicIF target,
                                      TopicIF source,
                                      java.util.Map mergemap)

mergeInto

public static void mergeInto(TopicMapIF target,
                             TopicMapIF source)
                      throws ConstraintViolationException
PUBLIC: Merges one topic map into another topic map. The source topic map is left untouched, while its contents are copied into the target topic map. The target topic map is updated accordingly, and no duplicate characteristics should be present after the merge.

Merges are done on the basis of subject locators, subject identifiers, item identifiers, and topic names (with scope).

Parameters:
source - topicIF; the source topic map. This is untouched after the operation.
target - topicIF; the target topic map. This gets new topics and topic characteristics.
Throws:
throws - ConstraintViolationException if two topics that are to be merged under XTM 1.0 rules have different values for the 'subject' property, since if they do they cannot represent the same subject.
ConstraintViolationException

findTopic

public static TopicIF findTopic(TopicMapIF othertm,
                                TopicIF topic)
PUBLIC: Find a topic in the other topic map which would merge with the given topic if that were to be added to the same topic map. Even if there are more topics which would merge only one is returned.

Parameters:
othertm - The topic map to find the corresponding topic in.
topic - A topic in a topic map other than othertm to look up in othertm.
Returns:
The corresponding topic.
Since:
5.1.3


Copyright © 2000-2012 Ontopia.