org.mmbase.applications.xmlimporter
Class SpecificObjectFinder

java.lang.Object
  extended by org.mmbase.applications.xmlimporter.SpecificObjectFinder
All Implemented Interfaces:
SimilarObjectFinder

public class SpecificObjectFinder
extends Object
implements SimilarObjectFinder

SpecificObjectFinder implements a SimilarObjectFinder in such a way that a search for an object similar to tmpObj1 always returns tmpObj2, and nothing for other objects, where tmpObj1 and tmpObj2 are provided by the user. An example of the useage is provided by the method mergePersistentObjects(), wich merges two objects in the persistent cloud (i.e. the database).

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

Constructor Summary
SpecificObjectFinder(TmpObject tmpObj1, TmpObject tmpObj2)
          Creates new SpecificObjectFinder.
 
Method Summary
 List<TmpObject> findSimilarObject(Transaction transaction, TmpObject tmpObj)
          Searches for similar object.
 void init(HashMap<String,String> params)
          Initialize this instance.
static void mergePersistentObjects(int mmbaseId1, int mmbaseId2, ObjectMerger merger)
          Merge two objects in the persistent cloud (the database).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecificObjectFinder

public SpecificObjectFinder(TmpObject tmpObj1,
                            TmpObject tmpObj2)
Creates new SpecificObjectFinder.

Parameters:
tmpObj1 - The only object for which a similar object will be returned.
tmpObj2 - The only object that will be returned as similar to tmpObj1.
Method Detail

init

public void init(HashMap<String,String> params)
Initialize this instance. This implementation does nothing.

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

findSimilarObject

public List<TmpObject> findSimilarObject(Transaction transaction,
                                         TmpObject tmpObj)
Searches for similar object. This implementation returns a list that contains tmpObj2 when the object to search for is tmpObj1, or an empty list when the object to search for is not tmpObj1.

Specified by:
findSimilarObject in interface SimilarObjectFinder
Parameters:
transaction - The transaction where the tmpObj belongs to.
tmpObj - The object to search for.
Returns:
List of the similar objects found.

mergePersistentObjects

public static void mergePersistentObjects(int mmbaseId1,
                                          int mmbaseId2,
                                          ObjectMerger merger)
                                   throws TransactionHandlerException
Merge two objects in the persistent cloud (the database).

Parameters:
mmbaseId1 - MMBase number of the first object. Afterward this object will be deleted.
mmbaseId2 - MMBase number of the second object. Afterward this object will hold the merged result.
merger - The merger to be used.
Throws:
TransactionHandlerException - If a failure occurred.


MMBase 2.0-SNAPSHOT - null