com.gisgraphy.domain.repository

## Class DatabaseHelper

- java.lang.Object
- - org.springframework.dao.support.DaoSupport
  - - org.springframework.orm.hibernate3.support.HibernateDaoSupport
    - - com.gisgraphy.domain.repository.DatabaseHelper

- All Implemented Interfaces:
    IDatabaseHelper, org.springframework.beans.factory.InitializingBean

      @Component
      public class DatabaseHelper
      extends org.springframework.orm.hibernate3.support.HibernateDaoSupport
      implements IDatabaseHelper

  Default implementation of `IDatabaseHelper`
  Author:
    David Masclet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static org.slf4j.Logger` | `logger`
    `static String` | `NORMALIZE_TEXT_FUNCTION_NAME`
    `static String` | `NORMALIZE_TEXT_POSTRES_FUNCTION_BODY`
    `static String[]` | `TABLES_NAME_THAT_MUST_BE_KEPT_WHEN_RESETING_IMPORT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DatabaseHelper()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createNormalize_textFunction()` create a postgres function in postgres to remove accent, lower cased, trim, and remove unwanted char (, . ; ")
    `void` | `dropNormalize_textFunction()` Drop the Normalize_text function in postgres
    `List<String>` | `execute(File file, boolean continueOnError)`
    `void` | `generateSqlCreationSchemaFile(File outputFile)` Generate the sql file to create all the Gisgraphy tables
    `void` | `generateSQLCreationSchemaFileToRerunImport(File outputFile)` Generate the SQL file to create all the Gisgraphy tables that have to be reset to rerun the import, the user and role tables won't be deleted
    `void` | `generateSQLDropSchemaFile(File outputFile)` Generate the sql file to drop all the Gisgraphy tables
    `void` | `generateSqlDropSchemaFileToRerunImport(File outputFile)` Generate the SQL file to drop all the Gisgraphy tables that have to be reset to rerun the import, the user and role tables won't be deleted
    `boolean` | `isNormalize_textFunctionCreated()` Determines if the normalize_text function is created in postgres

    - ### Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport

      `checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory`

    - ### Methods inherited from class org.springframework.dao.support.DaoSupport

      `afterPropertiesSet, initDao`

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

    - #### TABLES_NAME_THAT_MUST_BE_KEPT_WHEN_RESETING_IMPORT

          public static String[] TABLES_NAME_THAT_MUST_BE_KEPT_WHEN_RESETING_IMPORT

    - #### NORMALIZE_TEXT_FUNCTION_NAME

          public static final String NORMALIZE_TEXT_FUNCTION_NAME

      See Also:
        Constant Field Values

    - #### NORMALIZE_TEXT_POSTRES_FUNCTION_BODY

          public static final String NORMALIZE_TEXT_POSTRES_FUNCTION_BODY

  - ### Constructor Detail

    - #### DatabaseHelper

          public DatabaseHelper()

  - ### Method Detail

    - #### execute

          public List<String> execute(File file,
                             boolean continueOnError)
                               throws Exception

      Specified by:
        `execute` in interface `IDatabaseHelper`
      Parameters:
        `file` - the file to execute, it will be read as an UTF-8 file
        `continueOnError` - if an error occured, the process will go on if this value is true, if not it will throw an exception
      Returns:
        A list of String with errorMessage
      Throws:
        `Exception` - in case of error during execution, or if the file is null or does not exist

    - #### generateSqlCreationSchemaFile

          public void generateSqlCreationSchemaFile(File outputFile)

      Description copied from interface: `IDatabaseHelper`
      Generate the sql file to create all the Gisgraphy tables
      Specified by:
        `generateSqlCreationSchemaFile` in interface `IDatabaseHelper`
      Parameters:
        `outputFile` - The File that we want to write the SQL

    - #### generateSQLDropSchemaFile

          public void generateSQLDropSchemaFile(File outputFile)

      Description copied from interface: `IDatabaseHelper`
      Generate the sql file to drop all the Gisgraphy tables
      Specified by:
        `generateSQLDropSchemaFile` in interface `IDatabaseHelper`
      Parameters:
        `outputFile` - The File that we want to write the SQL

    - #### generateSQLCreationSchemaFileToRerunImport

          public void generateSQLCreationSchemaFileToRerunImport(File outputFile)

      Description copied from interface: `IDatabaseHelper`
      Generate the SQL file to create all the Gisgraphy tables that have to be reset to rerun the import, the user and role tables won't be deleted
      Specified by:
        `generateSQLCreationSchemaFileToRerunImport` in interface `IDatabaseHelper`
      Parameters:
        `outputFile` - The File that we want to write the SQL

    - #### generateSqlDropSchemaFileToRerunImport

          public void generateSqlDropSchemaFileToRerunImport(File outputFile)

      Description copied from interface: `IDatabaseHelper`
      Generate the SQL file to drop all the Gisgraphy tables that have to be reset to rerun the import, the user and role tables won't be deleted
      Specified by:
        `generateSqlDropSchemaFileToRerunImport` in interface `IDatabaseHelper`
      Parameters:
        `outputFile` - The File that we want to write the SQL

    - #### createNormalize_textFunction

          public void createNormalize_textFunction()

      Description copied from interface: `IDatabaseHelper`
      create a postgres function in postgres to remove accent, lower cased, trim, and remove unwanted char (, . ; ")
      Specified by:
        `createNormalize_textFunction` in interface `IDatabaseHelper`

    - #### isNormalize_textFunctionCreated

          public boolean isNormalize_textFunctionCreated()

      Description copied from interface: `IDatabaseHelper`
      Determines if the normalize_text function is created in postgres
      Specified by:
        `isNormalize_textFunctionCreated` in interface `IDatabaseHelper`
      Returns:
        true if the call to that function does not throw exception and return a the correct result

    - #### dropNormalize_textFunction

          public void dropNormalize_textFunction()

      Description copied from interface: `IDatabaseHelper`
      Drop the Normalize_text function in postgres
      Specified by:
        `dropNormalize_textFunction` in interface `IDatabaseHelper`

Copyright © 2015. All rights reserved.