View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.domain.repository;
24  
25  import java.io.File;
26  import java.util.List;
27  
28  /**
29   * Interface that describe useful function to manage the database
30   * 
31   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
32   */
33  public interface IDatabaseHelper {
34  
35      /**
36       * Drop the Normalize_text function in postgres
37       */
38      public void dropNormalize_textFunction();
39      
40      /**
41       * Determines if the normalize_text function is created in postgres
42       * 
43       * @return true if the call to that function does not throw exception and
44       *         return a the correct result
45       */
46      public boolean isNormalize_textFunctionCreated();
47  
48      /**
49       * create a postgres function in postgres to remove accent, lower cased, trim, and
50       * remove unwanted char (, . ; ")
51       */
52      public void createNormalize_textFunction();
53  
54      /**
55       * @param file
56       *            the file to execute, it will be read as an UTF-8 file
57       * @param continueOnError
58       *            if an error occured, the process will go on if this value is
59       *            true, if not it will throw an exception
60       * @throws Exception
61       *             in case of error during execution, or if the file is null or
62       *             does not exist
63       * @return A list of String with errorMessage
64       */
65      public List<String> execute(final File file, boolean continueOnError) throws Exception;
66  
67      /**
68       * Generate the sql file to create all the Gisgraphy tables
69       * 
70       * @param outputFile
71       *            The File that we want to write the SQL
72       */
73      public void generateSqlCreationSchemaFile(File outputFile);
74  
75      /**
76       * Generate the sql file to drop all the Gisgraphy tables
77       * 
78       * @param outputFile
79       *            The File that we want to write the SQL
80       */
81      public void generateSQLDropSchemaFile(File outputFile);
82  
83      /**
84       * Generate the SQL file to create all the Gisgraphy tables that have to be
85       * reset to rerun the import, the user and role tables won't be deleted
86       * 
87       * @param outputFile
88       *            The File that we want to write the SQL
89       */
90      public void generateSQLCreationSchemaFileToRerunImport(File outputFile);
91  
92      /**
93       * Generate the SQL file to drop all the Gisgraphy tables that have to be
94       * reset to rerun the import, the user and role tables won't be deleted
95       * 
96       * @param outputFile
97       *            The File that we want to write the SQL
98       */
99      public void generateSqlDropSchemaFileToRerunImport(File outputFile);
100 
101 }