org.mmbase.applications.xmlimporter
Class BasicMerger

java.lang.Object
  extended by org.mmbase.applications.xmlimporter.BasicMerger
All Implemented Interfaces:
ObjectMerger

public class BasicMerger
extends Object
implements ObjectMerger

This is a basic implementation of ObjectMerger. It applies these rules:

Since:
MMBase-1.5
Version:
$Id: BasicMerger.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Rob van Maris: Finalist IT Group

Constructor Summary
BasicMerger()
           
 
Method Summary
 boolean areDuplicates(TmpObject relation1, TmpObject relation2)
          Tests if two relations should be considered duplicates, indicating that one of them can be disposed of.
 void init(HashMap<String,String> params)
          Initialize this instance.
 boolean isAllowedToAdd(TmpObject tmpObj)
          Tests if this object should be added to the persistent cloud when not present already.
 void mergeField(TmpObject tmpObj1, TmpObject tmpObj2, String name)
          Merge a field.
 void mergeRelations(TmpObject tmpObj1, TmpObject tmpObj2, List<TmpObject> relations1, List<TmpObject> relations2)
          Merge relations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicMerger

public BasicMerger()
Method Detail

init

public void init(HashMap<String,String> params)
Initialize this instance. This implementation simply stores the initialization parameters.

Specified by:
init in interface ObjectMerger
Parameters:
params - The initialization parameters, provided as name/value pairs (both String).

mergeField

public void mergeField(TmpObject tmpObj1,
                       TmpObject tmpObj2,
                       String name)
Merge a field. This implementation leaves all fields unaffected.

Specified by:
mergeField in interface ObjectMerger
Parameters:
name - The name of the field. (Note: "number" and "owner" are not considered fields in this context, so this method will not be called with these values for name.)
tmpObj1 - The first object to be merged. This will hold the resulting merged object afterwards.
tmpObj2 - The second object. this object must be deleted afterwards.

mergeRelations

public void mergeRelations(TmpObject tmpObj1,
                           TmpObject tmpObj2,
                           List<TmpObject> relations1,
                           List<TmpObject> relations2)
Merge relations. This implementation moves all relations of the second object to the merged object.

Specified by:
mergeRelations in interface ObjectMerger
Parameters:
tmpObj1 - The first object to be merged. This will hold the resulting merged object afterwards.
tmpObj2 - The second object. this object must be deleted afterwards.
relations1 - List of all relations of the first object.
relations2 - List of all relations of the second object.

areDuplicates

public boolean areDuplicates(TmpObject relation1,
                             TmpObject relation2)
Tests if two relations should be considered duplicates, indicating that one of them can be disposed of. This test will only be called for pairs of relations that have already been verified to be of the same type, and have the same source, destination. This implementation always considers these pairs duplicates, it provides no additional tests.

Specified by:
areDuplicates in interface ObjectMerger
Parameters:
relation1 - The first relation.
relation2 - The second relation.
Returns:
true if these relations should be considered duplicates.

isAllowedToAdd

public boolean isAllowedToAdd(TmpObject tmpObj)
Tests if this object should be added to the persistent cloud when not present already. When this returns false, the object will be deleted from the transaction if no object is found to merge it with. This implementation allows all objects to be added when not present already.

Specified by:
isAllowedToAdd in interface ObjectMerger
Parameters:
tmpObj - The object.
Returns:
true If this object should be added, when not present already.


MMBase 2.0-SNAPSHOT - null