com.gisgraphy.importer

## Class OpenStreetMapCitiesSimpleImporter

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

- All Implemented Interfaces:
    IImporterProcessor

      public class OpenStreetMapCitiesSimpleImporter
      extends AbstractSimpleImporterProcessor

  Import the cities from an (pre-processed) openStreet map data file. The goal of this importer is to cross information between geonames and Openstreetmap. Geonames has no concept of city but of populated place (That can be a city, suburb or other) By cross the informations we can add shape and set a 'municipality' flag to identify city.
  Author:
    David Masclet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IAdmDao` | `admDao`
    `static Pattern` | `ALTERNATENAMES_EXTRACTION_PATTERN`
    `static String` | `ALTERNATENAMES_EXTRACTION_REGEXP`
    `protected ICityDao` | `cityDao`
    `protected CitySubdivisionDao` | `citySubdivisionDao`
    `protected com.gisgraphy.fulltext.IFullTextSearchEngine` | `fullTextSearchEngine`
    `protected IIdGenerator` | `idGenerator`
    `protected static org.slf4j.Logger` | `logger`
    `static com.gisgraphy.domain.valueobject.Output` | `MINIMUM_OUTPUT_STYLE`
    `protected IMunicipalityDetector` | `municipalityDetector`
    `static int` | `SCORE_LIMIT`
    `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
    `OpenStreetMapCitiesSimpleImporter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static String` | `dumpFields(String[] fields)`
    `protected void` | `flushAndClear()` Should flush and clear all the Daos that are used by the processor.
    `protected com.gisgraphy.fulltext.SolrResponseDto` | `getAdm(String name, String countryCode)`
    `protected File[]` | `getFiles()`
    `protected com.gisgraphy.fulltext.SolrResponseDto` | `getNearestCity(com.vividsolutions.jts.geom.Point location, String name, String countryCode, Class[] placetypes)`
    `protected int` | `getNumberOfColumns()`
    `protected void` | `populateZip(String zipAsString, GisFeature city)`
    `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` | `setAdmDao(IAdmDao admDao)`
    `void` | `setCityDao(ICityDao cityDao)`
    `void` | `setCitySubdivisionDao(CitySubdivisionDao citySubdivisionDao)`
    `protected void` | `setCommitFlushMode()` Will flush after every commit
    `void` | `setFullTextSearchEngine(com.gisgraphy.fulltext.IFullTextSearchEngine fullTextSearchEngine)`
    `void` | `setIdGenerator(IIdGenerator idGenerator)`
    `void` | `setMunicipalityDetector(IMunicipalityDetector municipalityDetector)`
    `void` | `setSolRSynchroniser(ISolRSynchroniser solRSynchroniser)`
    `protected 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.importer.AbstractSimpleImporterProcessor

      `checkNumberOfColumn, commit, countLines, decrementReadedFileLine, 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

    - #### SCORE_LIMIT

          public static final int SCORE_LIMIT

      See Also:
        Constant Field Values

    - #### logger

          protected static final org.slf4j.Logger logger

    - #### MINIMUM_OUTPUT_STYLE

          public static final com.gisgraphy.domain.valueobject.Output MINIMUM_OUTPUT_STYLE

    - #### 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

    - #### idGenerator

          protected IIdGenerator idGenerator

    - #### cityDao

          protected ICityDao cityDao

    - #### citySubdivisionDao

          protected CitySubdivisionDao citySubdivisionDao

    - #### admDao

          protected IAdmDao admDao

    - #### solRSynchroniser

          protected ISolRSynchroniser solRSynchroniser

    - #### fullTextSearchEngine

          protected com.gisgraphy.fulltext.IFullTextSearchEngine fullTextSearchEngine

    - #### municipalityDetector

          protected IMunicipalityDetector municipalityDetector

  - ### Constructor Detail

    - #### OpenStreetMapCitiesSimpleImporter

          public OpenStreetMapCitiesSimpleImporter()

  - ### 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`

    - #### dumpFields

          protected static String dumpFields(String[] fields)

      Parameters:
        `fields` - The array to process
      Returns:
        a string which represent a human readable string of the Array but without shape because it is useless in logs

    - #### populateZip

          protected void populateZip(String zipAsString,
                         GisFeature city)

    - #### getNearestCity

          protected com.gisgraphy.fulltext.SolrResponseDto getNearestCity(com.vividsolutions.jts.geom.Point location,
                                                              String name,
                                                              String countryCode,
                                                              Class[] placetypes)

    - #### getAdm

          protected com.gisgraphy.fulltext.SolrResponseDto getAdm(String name,
                                                      String countryCode)

    - #### 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`

    - #### setSolRSynchroniser

          public void setSolRSynchroniser(ISolRSynchroniser solRSynchroniser)

    - #### setIdGenerator

          public void setIdGenerator(IIdGenerator idGenerator)

    - #### setCityDao

          public void setCityDao(ICityDao cityDao)

    - #### setFullTextSearchEngine

          public void setFullTextSearchEngine(com.gisgraphy.fulltext.IFullTextSearchEngine fullTextSearchEngine)

    - #### setAdmDao

          public void setAdmDao(IAdmDao admDao)

    - #### setMunicipalityDetector

          public void setMunicipalityDetector(IMunicipalityDetector municipalityDetector)

    - #### setCitySubdivisionDao

          public void setCitySubdivisionDao(CitySubdivisionDao citySubdivisionDao)

Copyright © 2015. All rights reserved.