|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gisgraphy.domain.geoloc.importer.AbstractImporterProcessor
public abstract class AbstractImporterProcessor
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 IInternationalisationService |
internationalisationService
|
protected static org.slf4j.Logger |
logger
The logger |
protected int |
readFileLine
|
protected ImporterStatus |
status
|
protected java.lang.String |
statusMessage
|
protected int |
totalReadLine
|
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager
The transaction manager |
| Constructor Summary | |
|---|---|
AbstractImporterProcessor()
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()
|
long |
getNumberOfLinesToProcess()
|
long |
getReadFileLine()
The number of read line for the current processed file |
ImporterStatus |
getStatus()
|
java.lang.String |
getStatusMessage()
|
long |
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,...) |
void |
resetStatus()
Reset status fields, it should be done when the import has been canceled |
protected abstract void |
setCommitFlushMode()
Will flush after every commit |
void |
setImporterConfig(ImporterConfig importerConfig)
|
void |
setInternationalisationService(IInternationalisationService internationalisationService)
|
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
|
protected void |
setup()
Template method that can be override. |
boolean |
shouldBeSkipped()
|
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.IImporterProcessor |
|---|
rollback |
| Field Detail |
|---|
protected int totalReadLine
protected int readFileLine
protected java.lang.String statusMessage
protected ImporterStatus status
protected IInternationalisationService internationalisationService
protected ImporterConfig importerConfig
protected static final org.slf4j.Logger logger
protected java.lang.String COMMENT_START
protected java.io.BufferedReader in
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected java.io.File currentFile
| Constructor Detail |
|---|
public AbstractImporterProcessor()
| Method Detail |
|---|
protected abstract boolean shouldIgnoreFirstLine()
protected abstract void flushAndClear()
protected abstract void setCommitFlushMode()
flushAndClear()protected abstract int getNumberOfColumns()
protected abstract boolean shouldIgnoreComments()
COMMENT_STARTprotected void setup()
protected abstract java.io.File[] getFiles()
ImporterHelperpublic java.lang.String getCurrentFileName()
getCurrentFileName in interface IImporterProcessor
public int readLineAndProcessData()
throws ImporterException
ImporterException - if an error occurred
protected abstract void processData(java.lang.String line)
throws ImporterException
line - the line to process
ImporterExceptionpublic void process()
process in interface IImporterProcessorpublic boolean shouldBeSkipped()
shouldBeSkipped in interface IImporterProcessorprotected 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 long getReadFileLine()
IImporterProcessor
getReadFileLine in interface IImporterProcessorIImporterProcessor.getTotalReadLine()public long getTotalReadLine()
IImporterProcessor
getTotalReadLine in interface IImporterProcessorIImporterProcessor.getReadFileLine()public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
public void setImporterConfig(ImporterConfig importerConfig)
protected int countLines()
public long getNumberOfLinesToProcess()
getNumberOfLinesToProcess in interface IImporterProcessorpublic ImporterStatus getStatus()
getStatus in interface IImporterProcessorprotected int getMaxInsertsBeforeFlush()
ImporterConfig.setMaxInsertsBeforeFlush(int)public void resetStatus()
IImporterProcessor
resetStatus in interface IImporterProcessorpublic java.lang.String getStatusMessage()
getStatusMessage in interface IImporterProcessorpublic void setInternationalisationService(IInternationalisationService internationalisationService)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||