|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gisgraphy.domain.geoloc.importer.AbstractGeonamesProcessor
public abstract class AbstractGeonamesProcessor
Base class for all geonames processor. it provides session management and the ability to process one or more CSV file
Field Summary | |
---|---|
protected java.lang.String |
COMMENT_START
Lines starting with this prefix are considered as comments |
protected java.io.File |
currentFile
The current processed file |
protected ImporterConfig |
importerConfig
|
protected java.io.BufferedReader |
in
The bufferReader for the current read Geonames file |
protected static org.slf4j.Logger |
logger
The logger |
protected int |
readFileLine
|
protected java.lang.String |
statusMessage
|
protected int |
totalReadLine
|
Constructor Summary | |
---|---|
AbstractGeonamesProcessor()
Default constructor |
Method Summary | |
---|---|
protected void |
checkNumberOfColumn(java.lang.String[] fields)
Utility method which throw an exception if the number of fields is not the one expected (retrieved by getNumberOfColumns() ) |
protected int |
countLines()
|
protected static java.lang.String |
dumpFields(java.lang.String[] fields)
|
protected abstract void |
flushAndClear()
Should flush and clear all the Daos that are used by the processor. |
java.lang.String |
getCurrentFileName()
|
protected abstract java.io.File[] |
getFiles()
|
protected int |
getMaxInsertsBeforeFlush()
|
protected abstract int |
getNumberOfColumns()
|
int |
getNumberOfLinesToProcess()
|
int |
getReadFileLine()
The number of read line for the current processed file |
ImporterStatus |
getStatus()
|
java.lang.String |
getStatusMessage()
|
int |
getTotalReadLine()
The number of read line for all the processed file |
protected static boolean |
isEmptyField(java.lang.String[] fields,
int position,
boolean required)
Check that the array is not null, and the fields of the specified position is not empty (after been trimed) |
protected boolean |
isEndOfDocument()
|
void |
process()
Manage the transaction, flush Daos, and process all files to be processed |
protected abstract void |
processData(java.lang.String line)
Process a read line of the geonames file, must be implemented by the concrete class |
int |
readLineAndProcessData()
Process the line if needed (is not a comment, should ignore first line, is end of document,...) |
protected void |
resetStatusFields()
|
protected abstract void |
setCommitFlushMode()
Will flush after every commit |
void |
setImporterConfig(ImporterConfig importerConfig)
|
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
|
protected void |
setup()
Template method that can be override. |
protected abstract boolean |
shouldIgnoreComments()
Whether the filter should ignore the comments (i.e. lines starting with #) |
protected abstract boolean |
shouldIgnoreFirstLine()
Template Method : Whether the processor should ignore the first line of the input |
protected void |
tearDown()
Template method that can be override. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.gisgraphy.domain.geoloc.importer.IGeonamesProcessor |
---|
rollback |
Field Detail |
---|
protected int totalReadLine
protected int readFileLine
protected java.lang.String statusMessage
protected ImporterConfig importerConfig
protected static final org.slf4j.Logger logger
protected java.lang.String COMMENT_START
protected java.io.BufferedReader in
protected java.io.File currentFile
Constructor Detail |
---|
public AbstractGeonamesProcessor()
Method Detail |
---|
protected abstract boolean shouldIgnoreFirstLine()
protected abstract void flushAndClear()
protected abstract void setCommitFlushMode()
flushAndClear()
protected abstract int getNumberOfColumns()
protected abstract boolean shouldIgnoreComments()
COMMENT_START
protected void setup()
protected abstract java.io.File[] getFiles()
ImporterHelper
public java.lang.String getCurrentFileName()
getCurrentFileName
in interface IGeonamesProcessor
public int readLineAndProcessData() throws GeonamesProcessorException
GeonamesProcessorException
- if an error occurredprotected abstract void processData(java.lang.String line) throws GeonamesProcessorException
line
- the line to process
GeonamesProcessorException
public void process()
process
in interface IGeonamesProcessor
protected void tearDown()
protected static boolean isEmptyField(java.lang.String[] fields, int position, boolean required)
fields
- The array to testposition
- the position of the field to test in the arrayrequired
- if an exception should be thrown if the field is empty
MissingRequiredFieldException
- if the fields is empty and required is trueprotected static java.lang.String dumpFields(java.lang.String[] fields)
fields
- The array to process
protected void checkNumberOfColumn(java.lang.String[] fields)
getNumberOfColumns()
)
fields
- The array to checkgetNumberOfColumns()
protected boolean isEndOfDocument()
public int getReadFileLine()
IGeonamesProcessor
getReadFileLine
in interface IGeonamesProcessor
IGeonamesProcessor.getTotalReadLine()
public int getTotalReadLine()
IGeonamesProcessor
getTotalReadLine
in interface IGeonamesProcessor
IGeonamesProcessor.getReadFileLine()
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
public void setImporterConfig(ImporterConfig importerConfig)
protected int countLines()
public int getNumberOfLinesToProcess()
getNumberOfLinesToProcess
in interface IGeonamesProcessor
public ImporterStatus getStatus()
getStatus
in interface IGeonamesProcessor
protected int getMaxInsertsBeforeFlush()
ImporterConfig.setMaxInsertsBeforeFlush(int)
protected void resetStatusFields()
public java.lang.String getStatusMessage()
getStatusMessage
in interface IGeonamesProcessor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |