com.gisgraphy.domain.geoloc.importer
Class GeonamesAlternateNamesExtracter

java.lang.Object
  extended by com.gisgraphy.domain.geoloc.importer.AbstractImporterProcessor
      extended by com.gisgraphy.domain.geoloc.importer.GeonamesAlternateNamesExtracter
All Implemented Interfaces:
IImporterProcessor

public class GeonamesAlternateNamesExtracter
extends AbstractImporterProcessor

Extract the alternateNames into separate files : one for country, one for adm1 and one for adm2

Author:
David Masclet

Field Summary
protected  java.io.File adm1file
           
protected  java.io.OutputStreamWriter adm1fileOutputStreamWriter
           
protected  java.util.Map<java.lang.Long,java.lang.String> adm1Map
           
protected  java.io.File adm2file
           
protected  java.io.OutputStreamWriter adm2fileOutputStreamWriter
           
protected  java.util.Map<java.lang.Long,java.lang.String> adm2Map
           
protected  java.io.File countryFile
           
protected  java.io.OutputStreamWriter countryfileOutputStreamWriter
           
protected  java.util.Map<java.lang.Long,java.lang.String> countryMap
           
protected  java.io.File featuresFile
           
protected  java.io.OutputStreamWriter featuresfileOutputStreamWriter
           
 
Fields inherited from class com.gisgraphy.domain.geoloc.importer.AbstractImporterProcessor
COMMENT_START, currentFile, importerConfig, in, internationalisationService, logger, readFileLine, status, statusMessage, totalReadLine, transactionManager
 
Constructor Summary
GeonamesAlternateNamesExtracter()
          Default Constructor
 
Method Summary
protected  void flushAndClear()
          Should flush and clear all the Daos that are used by the processor.
protected  java.io.File[] getFiles()
           
protected  int getNumberOfColumns()
           
protected  void initFiles()
           
protected  boolean lineIsAnAlternateNameForAdm1(java.lang.Long featureId)
           
protected  boolean lineIsAnAlternateNameForCountry(java.lang.Long featureId)
           
protected  boolean lineIsAnAlternatNameForAdm2(java.lang.Long featureId)
           
protected  java.util.Map<java.lang.Long,java.lang.String> populateMapFromList(java.util.List<java.lang.Long> list)
           
protected  void processData(java.lang.String line)
          Process a read line of the geonames file, must be implemented by the concrete class
 java.util.List<NameValueDTO<java.lang.Integer>> rollback()
          /!
 void setAdmDao(IAdmDao admDao)
           
protected  void setCommitFlushMode()
          Will flush after every commit
 void setCountryDao(ICountryDao countryDao)
           
 void setup()
          Template method that can be override.
 boolean shouldBeSkipped()
           
protected  boolean shouldIgnoreComments()
          Whether the filter should ignore the comments (i.e. lines starting with #)
protected  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 com.gisgraphy.domain.geoloc.importer.AbstractImporterProcessor
checkNumberOfColumn, countLines, dumpFields, getCurrentFileName, getMaxInsertsBeforeFlush, getNumberOfLinesToProcess, getReadFileLine, getStatus, getStatusMessage, getTotalReadLine, isEmptyField, isEndOfDocument, process, readLineAndProcessData, resetStatus, setImporterConfig, setInternationalisationService, setTransactionManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adm1file

protected java.io.File adm1file

adm2file

protected java.io.File adm2file

countryFile

protected java.io.File countryFile

featuresFile

protected java.io.File featuresFile

adm1fileOutputStreamWriter

protected java.io.OutputStreamWriter adm1fileOutputStreamWriter

adm2fileOutputStreamWriter

protected java.io.OutputStreamWriter adm2fileOutputStreamWriter

countryfileOutputStreamWriter

protected java.io.OutputStreamWriter countryfileOutputStreamWriter

featuresfileOutputStreamWriter

protected java.io.OutputStreamWriter featuresfileOutputStreamWriter

countryMap

protected java.util.Map<java.lang.Long,java.lang.String> countryMap

adm1Map

protected java.util.Map<java.lang.Long,java.lang.String> adm1Map

adm2Map

protected java.util.Map<java.lang.Long,java.lang.String> adm2Map
Constructor Detail

GeonamesAlternateNamesExtracter

public GeonamesAlternateNamesExtracter()
Default Constructor

Method Detail

processData

protected void processData(java.lang.String line)
Description copied from class: AbstractImporterProcessor
Process a read line of the geonames file, must be implemented by the concrete class

Specified by:
processData in class AbstractImporterProcessor
Parameters:
line - the line to process

lineIsAnAlternatNameForAdm2

protected boolean lineIsAnAlternatNameForAdm2(java.lang.Long featureId)

lineIsAnAlternateNameForAdm1

protected boolean lineIsAnAlternateNameForAdm1(java.lang.Long featureId)

lineIsAnAlternateNameForCountry

protected boolean lineIsAnAlternateNameForCountry(java.lang.Long featureId)

shouldBeSkipped

public boolean shouldBeSkipped()
Specified by:
shouldBeSkipped in interface IImporterProcessor
Overrides:
shouldBeSkipped in class AbstractImporterProcessor
Returns:
true if the processor should Not be executed

tearDown

protected void tearDown()
Description copied from class: AbstractImporterProcessor
Template method that can be override. This method is called after the end of the process. it is not called for each file processed. You should always call super.tearDown() when you overide this method

Overrides:
tearDown in class AbstractImporterProcessor

initFiles

protected void initFiles()

setup

public void setup()
Description copied from class: AbstractImporterProcessor
Template method that can be override. This method is called before the process start. it is not called for each file processed.

Overrides:
setup in class AbstractImporterProcessor

populateMapFromList

protected java.util.Map<java.lang.Long,java.lang.String> populateMapFromList(java.util.List<java.lang.Long> list)

shouldIgnoreFirstLine

protected boolean shouldIgnoreFirstLine()
Description copied from class: AbstractImporterProcessor
Template Method : Whether the processor should ignore the first line of the input

Specified by:
shouldIgnoreFirstLine in class AbstractImporterProcessor
Returns:
true if the processor should ignore first line

shouldIgnoreComments

protected boolean shouldIgnoreComments()
Description copied from class: AbstractImporterProcessor
Whether the filter should ignore the comments (i.e. lines starting with #)

Specified by:
shouldIgnoreComments in class AbstractImporterProcessor
See Also:
AbstractImporterProcessor.COMMENT_START

setCommitFlushMode

protected void setCommitFlushMode()
Description copied from class: AbstractImporterProcessor
Will flush after every commit

Specified by:
setCommitFlushMode in class AbstractImporterProcessor
See Also:
AbstractImporterProcessor.flushAndClear()

flushAndClear

protected void flushAndClear()
Description copied from class: AbstractImporterProcessor
Should flush and clear all the Daos that are used by the processor. This avoid memory leak

Specified by:
flushAndClear in class AbstractImporterProcessor

getNumberOfColumns

protected int getNumberOfColumns()
Specified by:
getNumberOfColumns in class AbstractImporterProcessor
Returns:
the number of fields the processed Geonames file should have

getFiles

protected java.io.File[] getFiles()
Specified by:
getFiles in class AbstractImporterProcessor
Returns:
The files to be process
See Also:
ImporterHelper

rollback

public java.util.List<NameValueDTO<java.lang.Integer>> rollback()
Description copied from interface: IImporterProcessor
/!\ USE THIS METHOD VERY CAREFULLY /!\ : If you call this function, all the imported data for the specified importer will be deleted

Returns:
a NameValueDTO with the name of the deleted object and the number of deleted Object. No entry will be return for Object that were 0 object will be deleted except if an error occurred during the deletion.

setAdmDao

public void setAdmDao(IAdmDao admDao)

setCountryDao

public void setCountryDao(ICountryDao countryDao)


Copyright © 2010. All Rights Reserved.