com.gisgraphy.importer

## Class OpenStreetMapSimpleImporter

- java.lang.Object
- - com.gisgraphy.importer.AbstractSimpleImporterProcessor
  - - com.gisgraphy.importer.OpenStreetMapSimpleImporter

- All Implemented Interfaces:
    IImporterProcessor

      public class OpenStreetMapSimpleImporter
      extends AbstractSimpleImporterProcessor

  Import the street from an (pre-processed) openStreet map data file .
  Author:
    David Masclet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Pattern` | `ALTERNATENAMES_EXTRACTION_PATTERN`
    `static String` | `ALTERNATENAMES_EXTRACTION_REGEXP`
    `protected ICityDao` | `cityDao`
    `static int` | `DISTANCE`
    `protected IIdGenerator` | `idGenerator`
    `protected static org.slf4j.Logger` | `logger`
    `protected IMunicipalityDetector` | `municipalityDetector`
    `protected IOpenStreetMapDao` | `openStreetMapDao`
    `protected ISolRSynchroniser` | `solRSynchroniser`

    - ### Fields inherited from class com.gisgraphy.importer.AbstractSimpleImporterProcessor

      `COMMENT_START, currentFile, importerConfig, in, internationalisationService, readFileLine, status, statusMessage, totalReadLine, transactionManager, txDefinition, txStatus`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OpenStreetMapSimpleImporter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkNumberOfColumn(String[] fields)` overidded because alternatenames can be null so number of fields can differ
    `protected void` | `flushAndClear()` Should flush and clear all the Daos that are used by the processor.
    `protected String` | `getDeeperAdmName(City city)`
    `protected File[]` | `getFiles()`
    `protected City` | `getNearestCity(com.vividsolutions.jts.geom.Point location, String countryCode, boolean filterMunicipality)`
    `protected int` | `getNumberOfColumns()`
    `protected String` | `pplxToPPL(String cityName)` tests if city is a paris district, if so it is probably a pplx that is newly considered as ppl http://forum.geonames.org/gforum/posts/list/2063.page
    `protected void` | `processData(String line)` Process a read line of the geonames file, must be implemented by the concrete class
    `List<NameValueDTO<Integer>>` | `rollback()` /!
    `void` | `setCityDao(ICityDao cityDao)`
    `protected void` | `setCommitFlushMode()` Will flush after every commit
    `void` | `setIdGenerator(IIdGenerator idGenerator)`
    `protected void` | `setIsInFields(OpenStreetMap street)`
    `void` | `setMunicipalityDetector(IMunicipalityDetector municipalityDetector)`
    `void` | `setOpenStreetMapDao(IOpenStreetMapDao openStreetMapDao)`
    `void` | `setSolRSynchroniser(ISolRSynchroniser solRSynchroniser)`
    `protected void` | `setup()` Template method that can be override.
    `boolean` | `shouldBeSkipped()`
    `protected boolean` | `shouldFillIsInField()`
    `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.importer.AbstractSimpleImporterProcessor

      `commit, countLines, decrementReadedFileLine, dumpFields, getCurrentFileName, getMaxInsertsBeforeFlush, getNumberOfLinesToProcess, getReadFileLine, getStatus, getStatusMessage, getTotalReadLine, incrementReadedFileLine, isEmptyField, isEndOfDocument, needCommit, onFileProcessed, process, processError, readLineAndProcessData, resetStatus, rollbackTransaction, setImporterConfig, setInternationalisationService, setTransactionManager, startTransaction`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected static final org.slf4j.Logger logger

    - #### DISTANCE

          public static final int DISTANCE

      See Also:
        Constant Field Values

    - #### idGenerator

          @Autowired
          protected IIdGenerator idGenerator

    - #### openStreetMapDao

          @Autowired
          protected IOpenStreetMapDao openStreetMapDao

    - #### solRSynchroniser

          @Autowired
          protected ISolRSynchroniser solRSynchroniser

    - #### municipalityDetector

          @Autowired
          protected IMunicipalityDetector municipalityDetector

    - #### cityDao

          @Autowired
          protected ICityDao cityDao

    - #### ALTERNATENAMES_EXTRACTION_REGEXP

          public static final String ALTERNATENAMES_EXTRACTION_REGEXP

      See Also:
        Constant Field Values

    - #### ALTERNATENAMES_EXTRACTION_PATTERN

          public static final Pattern ALTERNATENAMES_EXTRACTION_PATTERN

  - ### Constructor Detail

    - #### OpenStreetMapSimpleImporter

          public OpenStreetMapSimpleImporter()

  - ### Method Detail

    - #### flushAndClear

          protected void flushAndClear()

      Description copied from class: `AbstractSimpleImporterProcessor`
      Should flush and clear all the Daos that are used by the processor. This avoid memory leak
      Specified by:
        `flushAndClear` in class `AbstractSimpleImporterProcessor`

    - #### setup

          protected void setup()

      Description copied from class: `AbstractSimpleImporterProcessor`
      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 `AbstractSimpleImporterProcessor`

    - #### getFiles

          protected File[] getFiles()

      Specified by:
        `getFiles` in class `AbstractSimpleImporterProcessor`
      Returns:
        The files to be process
      See Also:
        `ImporterHelper`

    - #### getNumberOfColumns

          protected int getNumberOfColumns()

      Specified by:
        `getNumberOfColumns` in class `AbstractSimpleImporterProcessor`
      Returns:
        the number of fields the processed Geonames file should have

    - #### processData

          protected void processData(String line)
                              throws ImporterException

      Description copied from class: `AbstractSimpleImporterProcessor`
      Process a read line of the geonames file, must be implemented by the concrete class
      Specified by:
        `processData` in class `AbstractSimpleImporterProcessor`
      Parameters:
        `line` - the line to process
      Throws:
        `ImporterException`

    - #### setIsInFields

          protected void setIsInFields(OpenStreetMap street)

    - #### getDeeperAdmName

          protected String getDeeperAdmName(City city)

    - #### getNearestCity

          protected City getNearestCity(com.vividsolutions.jts.geom.Point location,
                            String countryCode,
                            boolean filterMunicipality)

    - #### pplxToPPL

          protected String pplxToPPL(String cityName)

      tests if city is a paris district, if so it is probably a pplx that is newly considered as ppl http://forum.geonames.org/gforum/posts/list/2063.page

    - #### shouldBeSkipped

          public boolean shouldBeSkipped()

      Specified by:
        `shouldBeSkipped` in interface `IImporterProcessor`
      Overrides:
        `shouldBeSkipped` in class `AbstractSimpleImporterProcessor`
      Returns:
        true if the processor should Not be executed

    - #### setCommitFlushMode

          protected void setCommitFlushMode()

      Description copied from class: `AbstractSimpleImporterProcessor`
      Will flush after every commit
      Specified by:
        `setCommitFlushMode` in class `AbstractSimpleImporterProcessor`
      See Also:
        `AbstractSimpleImporterProcessor.flushAndClear()`

    - #### shouldIgnoreComments

          protected boolean shouldIgnoreComments()

      Description copied from class: `AbstractSimpleImporterProcessor`
      Whether the filter should ignore the comments (i.e. lines starting with #)
      Specified by:
        `shouldIgnoreComments` in class `AbstractSimpleImporterProcessor`
      See Also:
        `AbstractSimpleImporterProcessor.COMMENT_START`

    - #### shouldIgnoreFirstLine

          protected boolean shouldIgnoreFirstLine()

      Description copied from class: `AbstractSimpleImporterProcessor`
      Template Method : Whether the processor should ignore the first line of the input
      Specified by:
        `shouldIgnoreFirstLine` in class `AbstractSimpleImporterProcessor`
      Returns:
        true if the processor should ignore first line

    - #### rollback

          public List<NameValueDTO<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.

    - #### tearDown

          protected void tearDown()

      Description copied from class: `AbstractSimpleImporterProcessor`
      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 `AbstractSimpleImporterProcessor`

    - #### checkNumberOfColumn

          protected void checkNumberOfColumn(String[] fields)

      overidded because alternatenames can be null so number of fields can differ
      Overrides:
        `checkNumberOfColumn` in class `AbstractSimpleImporterProcessor`
      Parameters:
        `fields` - The array to check
      See Also:
        `getNumberOfColumns()`

    - #### shouldFillIsInField

          protected boolean shouldFillIsInField()

    - #### setOpenStreetMapDao

          public void setOpenStreetMapDao(IOpenStreetMapDao openStreetMapDao)

    - #### setSolRSynchroniser

          public void setSolRSynchroniser(ISolRSynchroniser solRSynchroniser)

    - #### setIdGenerator

          public void setIdGenerator(IIdGenerator idGenerator)

    - #### setMunicipalityDetector

          public void setMunicipalityDetector(IMunicipalityDetector municipalityDetector)

    - #### setCityDao

          public void setCityDao(ICityDao cityDao)

Copyright © 2015. All rights reserved.