@PublicAPI public class Importer extends java.lang.Thread implements chemaxon.jchem.db.Transfer
Constructor and Description |
---|
Importer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Stops the importing progress.
|
ConnectionHandler |
getConnectionHandler()
Getter for property connectionHandler.
|
java.lang.String |
getConnections()
Deprecated.
since 2.2 replaced by
getFieldConnections() . |
java.util.List<java.lang.Integer> |
getDuplicateIDList()
Returns the IDs (cd_id column in database table) of duplicate structures.
|
int |
getDuplicates()
Returns the number of molecules that were not imported, because
they are duplicates.
|
int |
getEmptyStructures()
Returns the number of molecules that were not imported, because
they are empty strucures.
|
boolean |
getEmptyStructuresAllowed()
Gets whether empty structures are allowed.
|
java.lang.Throwable |
getErrorCause()
Retrieves Throwable caught in
run() method. |
java.lang.String |
getErrorMessage()
If error occurs this function returns the error message.
|
java.lang.String |
getFieldConnections()
Returns the specified table field - file field pairs.
|
java.util.List<java.lang.String> |
getFieldNameList()
Returns field names in an SDfile.
|
static java.util.List<java.lang.String> |
getFieldNameList(java.io.InputStream is,
int linesToCheck)
Returns field names in an SDfile.
|
java.util.List<java.lang.Integer> |
getImportedIDList()
Returns the IDs (cd_id column in database table) of imported structures.
|
int |
getImportedNumber()
Returns the number of imported molecules.
|
java.lang.Object |
getInput()
Gets the source object.
|
java.lang.String |
getNameFieldInDB() |
java.lang.String |
getNote()
Returns the note of the progresswriter.
|
long |
getProgress()
Gets the status of the importing progress.
|
ProgressWriter |
getProgressWriter()
Gets the ProgressWriter object used for monitoring.
|
int |
getRecordsToCheck()
Gets the number of records to check for file format.
|
boolean |
getSetChiralFlag()
Gets whether chiral flag is set on import.
|
int |
getSkip()
Gets the number of molecules to skip from the beginning ogf file.
|
int |
getStructCount()
Returns the current count of structures which were examined by the import process.
|
java.lang.String |
getTableName()
Gets the name of the table to import into.
|
int |
importMols()
Imports molecules.
|
void |
init()
Initialization, checking given number of lines for file format and fields.
|
boolean |
isDuplicateImportAllowed()
Gets whether duplicate structures are allowed.
|
boolean |
isFinished()
Checks whenver the import has been finished.
|
boolean |
isHaltOnError()
Gets if import should stop when an error occurs.
|
void |
run()
Starts execution as a thread.
|
void |
setConnectionHandler(ConnectionHandler conh)
Setter for property connectionHandler.
|
void |
setConnections(java.lang.String connections)
Deprecated.
since 2.2 replaced by
setFieldConnections(String) . |
void |
setDuplicateImportAllowed(boolean b)
Deprecated.
since JChem 5.4. This import option has been table option,
instead of this use
setDuplicateImportAllowed(int) method |
void |
setDuplicateImportAllowed(int duplicateFilteringOption)
Sets the duplicate filtering option on import.
|
void |
setEmptyStructuresAllowed(boolean b)
If set to
false does not import empty molecules. |
void |
setFieldConnections(java.lang.String connections)
Specifies which data fields correspond to which table fieds.
|
void |
setHaltOnError(boolean b)
Sets if import should stop when an error occurs.
|
void |
setInfoStream(java.io.PrintStream st)
Sets the stream where information about the import prorcess
will be written (e.g.
|
void |
setInput(java.io.File inputFile)
Sets the source object as a file.
|
void |
setInput(java.io.InputStream is)
Sets the source object as a stream.
|
void |
setInput(java.lang.String fileName)
Sets the source object as a file, specifying the name of the file.
|
void |
setNameFieldInDB(java.lang.String fieldName)
Set a DB field to contain the structure name.
|
void |
setOutputOptions(boolean printDuplicates,
boolean printNonDuplicates,
java.io.OutputStream os,
boolean doNotImport)
With this option one can print duplicate or non-duplicate molecules to
a stream.
|
void |
setProgressWriter(ProgressWriter pwriter)
Sets the
ProgressWriter
object to track the progress the actual importing. |
void |
setRecordsToCheck(int recordsToCheck)
Sets the number of records to check for file format.
|
void |
setSetChiralFlag(boolean setChiralFlag)
Sets if chiral flag should be set to
true during import. |
void |
setSkip(int skip)
Sets the number of molecules to skip from the beginning ogf file.
|
void |
setStoreDuplicates(boolean value)
Specifies whether the ID's of duplicate structures should be stored.
|
void |
setStoreImportedIDs(boolean value)
Specifies whether the ID's of imported structures should be stored.
|
void |
setTableName(java.lang.String tname)
Sets the name of the table to import into.
|
void |
skip(int offset)
Skips the given number of molecules.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public void setConnectionHandler(ConnectionHandler conh)
conh
- the connection handlerpublic ConnectionHandler getConnectionHandler()
public void setInput(java.io.File inputFile)
inputFile
- the source filepublic void setInput(java.io.InputStream is)
is
- the source streampublic void setInput(java.lang.String fileName)
fileName
- the source file namepublic java.lang.Object getInput()
File
or InputStream
.public void setTableName(java.lang.String tname)
tname
- the table namepublic java.lang.String getTableName()
@Deprecated public void setConnections(java.lang.String connections)
setFieldConnections(String)
.The fields are given in pair in the following format: "databaseField1=dataField1;databaseField2=dataField2"
null
, the fields are automatically connected by
equal names (default).connections
- the connection stringpublic void setFieldConnections(java.lang.String connections)
The fields are given in pair in the following format: "databaseField1=dataField1;databaseField2=dataField2"
null
, the fields are automatically connected by
equal names (default).connections
- the connection string@Deprecated public java.lang.String getConnections()
getFieldConnections()
.public java.lang.String getFieldConnections()
public void setRecordsToCheck(int recordsToCheck)
recordsToCheck
- the number of records to check for file formatpublic int getRecordsToCheck()
public void setProgressWriter(ProgressWriter pwriter)
ProgressWriter
object to track the progress the actual importing.
(Format checking and skipping not monitored by this object.)
null
if no
monitoring is necessary.pwriter
- the progress writerpublic ProgressWriter getProgressWriter()
public void setHaltOnError(boolean b)
b
- true
if halt on errorpublic boolean isHaltOnError()
true
if halt on error@Deprecated public void setDuplicateImportAllowed(boolean b)
setDuplicateImportAllowed(int)
methodfalse
does not import molecules
that already exist in the table with the same topology. This checking
may slow down the import progress.b
- new value for duplicateFilteringDatabaseProperties.setDuplicateFilteringOption(String, boolean)
,
StructureTableOptions.isDuplicateFiltering()
public void setDuplicateImportAllowed(int duplicateFilteringOption)
duplicateFilteringOption
- DUPLICATE_FILTERING_ON
does not
import molecules that already exist in the table with the same topology.
Forces switching ON duplicate filtering regardless of table setting.
This checking
may slow down the import progress. DUPLICATE_FILTERING_OFF
duplicates are allowed.
Forces switching OFF duplicate filtering regardless of table setting. DUPLICATE_FILTERING_TABLE_OPTION
the value of the table
option (StructureTableOptions.isDuplicateFiltering()
) controls the filtering of duplicates.UpdateHandler.DUPLICATE_FILTERING_ON
,
UpdateHandler.DUPLICATE_FILTERING_OFF
,
UpdateHandler.DUPLICATE_FILTERING_TABLE_OPTION
,
StructureTableOptions.isDuplicateFiltering()
public boolean isDuplicateImportAllowed()
java.lang.IllegalArgumentException
- if duplicate filtering option of the table cannot be determined.public void setEmptyStructuresAllowed(boolean b)
false
does not import empty molecules.b
- set to true if empty structures are allowedpublic boolean getEmptyStructuresAllowed()
public void setSetChiralFlag(boolean setChiralFlag)
true
during import.setChiralFlag
- if set to true
, chiral flag is
set to true
for imported molecules.
The default setting is false
.
since 2.3public boolean getSetChiralFlag()
public void setNameFieldInDB(java.lang.String fieldName)
fieldName
- the name of the column in the databasepublic java.lang.String getNameFieldInDB()
public boolean isFinished()
true
if importing has finished, else returns false
.public java.lang.String getErrorMessage()
public java.lang.Throwable getErrorCause()
run()
method.
WARNING This mechanism is expected to be revised in
the near future, use with extreme caution!null
public int getStructCount()
public int getImportedNumber()
public int getDuplicates()
public int getEmptyStructures()
public java.lang.String getNote()
public void setSkip(int skip)
skip
- the number of molecule to skippublic int getSkip()
public long getProgress()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setInfoStream(java.io.PrintStream st)
st
- the stream.
The default is null
(no info is written).public void setOutputOptions(boolean printDuplicates, boolean printNonDuplicates, java.io.OutputStream os, boolean doNotImport)
printDuplicates
- prints indexes of duplicate structuresprintNonDuplicates
- prints indexes of imported structuresos
- outputStream to write information, if null
stdout is used.doNotImport
- disables the real importing, just generates the index entry.public void setStoreDuplicates(boolean value)
value
- enable/disable storing of duplicatesgetDuplicateIDList()
public void setStoreImportedIDs(boolean value)
value
- enable/disable storing of idsgetImportedIDList()
public java.util.List<java.lang.Integer> getDuplicateIDList()
setStoreDuplicates(boolean)
public java.util.List<java.lang.Integer> getImportedIDList()
setStoreImportedIDs(boolean)
public int importMols() throws TransferException
TransferException
- if the settings are invalidpublic void cancel()
public void skip(int offset) throws TransferException
offset
- the number of molecules to be skippedTransferException
- if the settings are invalidpublic void init() throws TransferException
skip
or importMols
if necessary.TransferException
- if the settings are invalidpublic java.util.List<java.lang.String> getFieldNameList() throws TransferException, java.io.IOException
int
if initialization is necessary.TransferException
- in case of failurejava.io.IOException
- if an IOException occurspublic static java.util.List<java.lang.String> getFieldNameList(java.io.InputStream is, int linesToCheck) throws java.io.IOException, MRecordParseException
is
- inputStream to read fromlinesToCheck
- read ahead this many lines during field name identificationjava.io.IOException
- if the inputstream encounters a problemMRecordParseException
- if a record could not be read.