View Javadoc
1   package fr.ifremer.quadrige3.core.service;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 Core Shared
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  
28  
29  import org.nuiton.version.Version;
30  import org.springframework.transaction.annotation.Transactional;
31  
32  import java.io.File;
33  import java.io.IOException;
34  
35  /**
36   * <p>DatabaseSchemaService interface.</p>
37   *
38   */
39  @Transactional(readOnly = true)
40  public interface DatabaseSchemaService {
41  
42  	/**
43  	 * Return the version, stored in the database (e.g. in SYSTEM_VERSION table)
44  	 *
45  	 * @return a {@link org.nuiton.version.Version} object.
46  	 */
47  	Version getDbVersion();
48  
49  	/**
50  	 * Return the version of the applciation. This version comes from database updates (e.g. liquibase patch)
51  	 *
52  	 * @return the version, or null if not patch available
53  	 */
54  	Version getApplicationVersion();
55  
56  	/**
57  	 * <p>updateSchema.</p>
58  	 */
59  	@Transactional()
60  	void updateSchema();
61  	
62      /**
63       * Check if connection could be open.
64       * If a validation query has been set in configuration, test it
65       *
66       * @return if db is loaded
67       */
68      boolean isDbLoaded();
69      
70      /**
71       * Check if db files exists. If not a database file, return true
72       *
73       * @return if db files exists
74       */
75      boolean isDbExists();
76      
77      /**
78       * Report into a file the liquibase status of database
79       *
80       * @param outputFile a {@link java.io.File} object.
81       * @throws java.io.IOException if any.
82       */
83      void generateStatusReport(File outputFile) throws IOException;
84      
85      /**
86       * Generate a diff report, from Hibernate model to database
87       *
88       * @param outputFile a {@link java.io.File} object.
89       */
90      void generateDiffReport(File outputFile);
91      
92      /**
93       * Generate a diff changelog, from Hibernate model to database
94       *
95       * @param outputFile a {@link java.io.File} object.
96       */
97      void generateDiffChangeLog(File outputFile);
98      
99      /**
100      * <p>createSchemaToFile.</p>
101      *
102      * @param outputFile a {@link java.io.File} object.
103      * @param withDrop a boolean.
104      * @throws java.io.IOException if any.
105      */
106     void createSchemaToFile(File outputFile, boolean withDrop) throws IOException;
107 }