Coverage Report - liquibase.snapshot.jvm.DerbyDatabaseSnapshotGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
DerbyDatabaseSnapshotGenerator
0%
0/15
0%
0/12
3.2
 
 1  
 package liquibase.snapshot.jvm;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.DerbyDatabase;
 5  
 import liquibase.exception.DatabaseException;
 6  
 
 7  
 import java.sql.ResultSet;
 8  
 import java.sql.SQLException;
 9  
 
 10  0
 public class DerbyDatabaseSnapshotGenerator extends JdbcDatabaseSnapshotGenerator {
 11  
     public boolean supports(Database database) {
 12  0
         return database instanceof DerbyDatabase;
 13  
     }
 14  
 
 15  
     public int getPriority(Database database) {
 16  0
         return PRIORITY_DATABASE;
 17  
     }
 18  
 
 19  
     @Override
 20  
     protected String convertTableNameToDatabaseTableName(String tableName) {
 21  0
         return tableName.toUpperCase();
 22  
     }
 23  
 
 24  
     @Override
 25  
     protected String convertColumnNameToDatabaseTableName(String columnName) {
 26  0
         return columnName.toUpperCase();
 27  
     }
 28  
 
 29  
     /**
 30  
      * Derby seems to have troubles
 31  
      */
 32  
     @Override
 33  
     public boolean hasIndex(String schemaName, String tableName, String indexName, Database database, String columnNames)
 34  
             throws DatabaseException {
 35  
         try {
 36  0
             ResultSet rs = getMetaData(database).getIndexInfo(database.convertRequestedSchemaToCatalog(schemaName),
 37  
                     database.convertRequestedSchemaToSchema(schemaName), "%", false, true);
 38  0
             while (rs.next()) {
 39  0
                 if (rs.getString("INDEX_NAME").equalsIgnoreCase(indexName)) {
 40  0
                     return true;
 41  
                 }
 42  0
                 if (tableName != null && columnNames != null) {
 43  0
                     if (tableName.equalsIgnoreCase(rs.getString("TABLE_NAME"))
 44  
                             && columnNames.replaceAll(" ", "").equalsIgnoreCase(
 45  
                                     rs.getString("COLUMN_NAME").replaceAll(" ", ""))) {
 46  0
                         return true;
 47  
                     }
 48  
                 }
 49  
             }
 50  0
             return false;
 51  0
         } catch (SQLException e) {
 52  0
             throw new DatabaseException(e);
 53  
         }
 54  
     }
 55  
 
 56  
 }