|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gisgraphy.importer.AbstractSimpleImporterProcessor
public abstract class AbstractSimpleImporterProcessor
Base class for all geonames processor. it provides session management and the ability to process one or more CSV file
| Field Summary | |
|---|---|
protected String |
COMMENT_START
Lines starting with this prefix are considered as comments |
protected File |
currentFile
The current processed file |
protected ImporterConfig |
importerConfig
|
protected 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 String |
statusMessage
|
protected int |
totalReadLine
|
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager
The transaction manager |
protected org.springframework.transaction.support.DefaultTransactionDefinition |
txDefinition
|
protected org.springframework.transaction.TransactionStatus |
txStatus
|
| Constructor Summary | |
|---|---|
AbstractSimpleImporterProcessor()
Default constructor |
|
| Method Summary | |
|---|---|
protected void |
checkNumberOfColumn(String[] fields)
Utility method which throw an exception if the number of fields is not the one expected (retrieved by getNumberOfColumns()) |
protected void |
commit()
|
protected int |
countLines(File[] files)
|
protected int |
decrementReadedFileLine(int decrement)
|
protected static String |
dumpFields(String[] fields)
|
protected abstract void |
flushAndClear()
Should flush and clear all the Daos that are used by the processor. |
String |
getCurrentFileName()
|
protected abstract 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()
|
String |
getStatusMessage()
|
long |
getTotalReadLine()
The number of read line for all the processed file |
protected int |
incrementReadedFileLine(int increment)
|
protected static boolean |
isEmptyField(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()
|
protected boolean |
needCommit()
|
protected void |
onFileProcessed(File file)
|
void |
process()
Manage the transaction, flush Daos, and process all files to be processed |
protected abstract void |
processData(String line)
Process a read line of the geonames file, must be implemented by the concrete class |
protected void |
processError(Exception e)
|
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 void |
rollbackTransaction()
|
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 |
startTransaction()
|
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.importer.IImporterProcessor |
|---|
rollback |
| Field Detail |
|---|
protected int totalReadLine
protected int readFileLine
protected String statusMessage
protected ImporterStatus status
protected IInternationalisationService internationalisationService
protected ImporterConfig importerConfig
protected static final org.slf4j.Logger logger
protected String COMMENT_START
protected BufferedReader in
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected org.springframework.transaction.TransactionStatus txStatus
protected org.springframework.transaction.support.DefaultTransactionDefinition txDefinition
protected File currentFile
| Constructor Detail |
|---|
public AbstractSimpleImporterProcessor()
| 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 File[] getFiles()
ImporterHelperpublic String getCurrentFileName()
getCurrentFileName in interface IImporterProcessor
public int readLineAndProcessData()
throws ImporterException
ImporterException - if an error occurred
protected abstract void processData(String line)
throws ImporterException
line - the line to process
ImporterExceptionpublic void process()
process in interface IImporterProcessorprotected void processError(Exception e)
public boolean shouldBeSkipped()
shouldBeSkipped in interface IImporterProcessorprotected int incrementReadedFileLine(int increment)
protected int decrementReadedFileLine(int decrement)
protected void rollbackTransaction()
protected boolean needCommit()
protected void startTransaction()
protected void tearDown()
protected void onFileProcessed(File file)
protected void commit()
protected static boolean isEmptyField(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 String dumpFields(String[] fields)
fields - The array to process
protected void checkNumberOfColumn(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(File[] files)
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 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 | |||||||||