org.mmbase.applications.xmlimporter
Class SpecificObjectFinder

java.lang.Object
  |
  +--org.mmbase.applications.xmlimporter.SpecificObjectFinder
All Implemented Interfaces:
SimilarObjectFinder

public class SpecificObjectFinder
extends java.lang.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,v 1.2 2002/02/27 16:54:26 pierre Exp $
Author:
Rob van Maris (Finalist IT Group)

Constructor Summary
SpecificObjectFinder(TmpObject tmpObj1, TmpObject tmpObj2)
          Creates new SpecificObjectFinder.
 
Method Summary
 java.util.List findSimilarObject(Transaction transaction, TmpObject tmpObj)
          Searches for similar object.
 void init(java.util.HashMap params)
          Initialize this instance.
static void mergePersistentObjects(int mmbaseId1, int mmbaseId2, ObjectMerger merger)
          Merge two objects in the persistent cloud, i.e.
 
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(java.util.HashMap params)
          throws TransactionHandlerException
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).
Throws:
TransactionHandlerException - if a failure occurred.

findSimilarObject

public java.util.List findSimilarObject(Transaction transaction,
                                        TmpObject tmpObj)
                                 throws TransactionHandlerException
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.
Throws:
TransactionHandlerException - If a failure occurred.

mergePersistentObjects

public static void mergePersistentObjects(int mmbaseId1,
                                          int mmbaseId2,
                                          ObjectMerger merger)
                                   throws TransactionHandlerException
Merge two objects in the persistent cloud, i.e. 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 build 1.6.5.20030923