org.mmbase.applications.xmlimporter
Class BasicMerger
java.lang.Object
|
+--org.mmbase.applications.xmlimporter.BasicMerger
- All Implemented Interfaces:
- ObjectMerger
- public class BasicMerger
- extends java.lang.Object
- implements ObjectMerger
This is a basic implementation of ObjectMerger.
It applies these rules:
- Leave the fields of the merging objects unaffected.
- Move the relations of both to the merged object.
- Relations are considered duplicates when of same type and
with same source and destination.
- Add objects to the persistent cloud that are not present already.
- Since:
- MMBase-1.5
- Version:
- $Id: BasicMerger.java,v 1.2 2002/02/27 16:54:24 pierre Exp $
- Author:
- Rob van Maris: Finalist IT Group
|
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(java.util.HashMap 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,
java.lang.String name)
Merge a field. |
void |
mergeRelations(TmpObject tmpObj1,
TmpObject tmpObj2,
java.util.List relations1,
java.util.List relations2)
Merge relations. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BasicMerger
public BasicMerger()
init
public void init(java.util.HashMap 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,
java.lang.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,
java.util.List relations1,
java.util.List 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 build 1.6.5.20030923