org.mmbase.applications.xmlimporter
Class Consultant

java.lang.Object
  extended by org.mmbase.applications.xmlimporter.Consultant

public class Consultant
extends Object

A Consultant object serves as the intermediary for communication between the thread that processes a transaction on one hand, and threads that handle interaction with the user on the other hand, to resolve ambiguity when more than one similar object is found to merge an object with. The processing thread should call:

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

Field Summary
static int IMPORT_EXCEPTION
          When transaction time out.
static int IMPORT_FINISHED
          When import finished.
static int IMPORT_RUNNING
          When import running.
static int IMPORT_STARTING
          When import finished.
static int IMPORT_TIMED_OUT
          When transaction time out.
 
Constructor Summary
Consultant()
          Creates new Consultant
 
Method Summary
 void consultUser(TmpObject originalObject, List<TmpObject> mergeResults)
          Consult the user for a mergeresult choice.
 boolean duplicatesFound()
          Returns true if in a transaction duplicates are found.
 boolean duplicatesResolved()
          Returns true if the user has chosen a mergeresult.
 int getChoice()
          Returns the index of the mergeresult the user has chosen.
 int getImportStatus()
          Returns true if import has finished.
 List<TmpObject> getMergeResults()
          Returns the a list of merge results.
 TmpObject getOriginalObject()
          Returns the original object.
 void init()
          init all fields
 boolean interactive()
          Returns true if user has chosen interactive import mode.
static void logDebug(String source, String message)
          Add to log using debug.
static void logError(String source, String message)
          Add to log using error.
static void logInfo(String source, String message)
          Add to log using info.
static void logTrace(String source, String message)
          Add to log using trace.
 void setChoice(int choice)
          Sets the index of the mergeresult the user has chosen.
 void setDuplicatesFound(boolean duplicatesFound)
          sets the user chosen import mode true if interactive false otherwise
 void setImportStatus(int importStatus)
          Sets the import status.
 void setInteractive(boolean interactive)
          Sets the user chosen import mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPORT_STARTING

public static final int IMPORT_STARTING
When import finished.

See Also:
Constant Field Values

IMPORT_RUNNING

public static final int IMPORT_RUNNING
When import running.

See Also:
Constant Field Values

IMPORT_FINISHED

public static final int IMPORT_FINISHED
When import finished.

See Also:
Constant Field Values

IMPORT_TIMED_OUT

public static final int IMPORT_TIMED_OUT
When transaction time out.

See Also:
Constant Field Values

IMPORT_EXCEPTION

public static final int IMPORT_EXCEPTION
When transaction time out.

See Also:
Constant Field Values
Constructor Detail

Consultant

public Consultant()
Creates new Consultant

Method Detail

init

public void init()
init all fields


consultUser

public void consultUser(TmpObject originalObject,
                        List<TmpObject> mergeResults)
Consult the user for a mergeresult choice. After a call to this method, call duplicatesResolved() to examine if duplicates are resolved. If not the thread was interrupted.

Parameters:
originalObject - The original object.
mergeResults - The merge results to choose from.

setDuplicatesFound

public void setDuplicatesFound(boolean duplicatesFound)
sets the user chosen import mode true if interactive false otherwise

Parameters:
duplicatesFound - Set true if duplicates are found. False otherwise.

duplicatesFound

public boolean duplicatesFound()
Returns true if in a transaction duplicates are found.

Returns:
True if duplicates are found. False otherwise.

duplicatesResolved

public boolean duplicatesResolved()
Returns true if the user has chosen a mergeresult.

Returns:
True if duplicates are resolved. False otherwise.

getChoice

public int getChoice()
Returns the index of the mergeresult the user has chosen. Call this method after method duplicatesResolved() returns true and before the next call to method consultUser(). Nou ok tis goed.

Returns:
The index of the mergeresult the user has chosen.

setChoice

public void setChoice(int choice)
Sets the index of the mergeresult the user has chosen. Call this method after method duplicatesResolved() returns true and before the next call to method consultUser(). Nou ok tis goed.

Parameters:
choice - Sets the index of the mergeresult the user has chosen.

getOriginalObject

public TmpObject getOriginalObject()
Returns the original object. The consultant object holds an original object and a list of merge results.

Returns:
The original object.

getMergeResults

public List<TmpObject> getMergeResults()
Returns the a list of merge results. The consultant object holds an original object and a list of merge results.

Returns:
The list of merge results.

setImportStatus

public void setImportStatus(int importStatus)
Sets the import status. Import status can be: See public static final int class variables.

Parameters:
importStatus - Set to a known import status. See public static final int class variables.

getImportStatus

public int getImportStatus()
Returns true if import has finished. False otherwise.

Returns:
The actual import status.

setInteractive

public void setInteractive(boolean interactive)
Sets the user chosen import mode. True if interactive. False otherwise.

Parameters:
interactive - Set to true if user has chosen interactive importmode. Set false otherwise.

interactive

public boolean interactive()
Returns true if user has chosen interactive import mode. False otherwise.

Returns:
True if import mode is interactive. False otherwise.

logInfo

public static void logInfo(String source,
                           String message)
Add to log using info. Can be used from a jsp.

Parameters:
source - Name of the message source.
message - Text to add to log.

logError

public static void logError(String source,
                            String message)
Add to log using error. Can be used from a jsp.

Parameters:
source - Name of the message source.
message - Text to add to log.

logDebug

public static void logDebug(String source,
                            String message)
Add to log using debug. Can be used from a jsp.

Parameters:
source - Name of the message source.
message - Text to add to log.

logTrace

public static void logTrace(String source,
                            String message)
Add to log using trace. Can be used from a jsp.

Parameters:
source - Name of the message source.
message - Text to add to log.


MMBase 2.0-SNAPSHOT - null