Coverage Report - liquibase.snapshot.jvm.DB2DatabaseSnapshotGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
DB2DatabaseSnapshotGenerator
0%
0/13
0%
0/4
1.4
 
 1  
 package liquibase.snapshot.jvm;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.DB2Database;
 5  
 import liquibase.exception.DatabaseException;
 6  
 import liquibase.executor.ExecutorService;
 7  
 import liquibase.statement.core.RawSqlStatement;
 8  
 
 9  
 import java.util.List;
 10  
 import java.util.Map;
 11  
 
 12  0
 public class DB2DatabaseSnapshotGenerator extends JdbcDatabaseSnapshotGenerator {
 13  
     public boolean supports(Database database) {
 14  0
         return database instanceof DB2Database;
 15  
     }
 16  
 
 17  
     public int getPriority(Database database) {
 18  0
         return PRIORITY_DATABASE;
 19  
     }
 20  
 
 21  
     @Override
 22  
     protected String convertTableNameToDatabaseTableName(String tableName) {
 23  0
         return tableName.toUpperCase();
 24  
     }
 25  
 
 26  
     @Override
 27  
     protected String convertColumnNameToDatabaseTableName(String columnName) {
 28  0
         return columnName.toUpperCase();
 29  
     }
 30  
 
 31  
     @Override
 32  
     public boolean isColumnAutoIncrement(Database database, String schemaName, String tableName, String columnName)
 33  
             throws DatabaseException {
 34  0
         boolean autoIncrement = false;
 35  
 
 36  0
         List<Map> rs = ExecutorService
 37  
                 .getInstance()
 38  
                 .getExecutor(database)
 39  
                 .queryForList(
 40  
                         new RawSqlStatement("SELECT IDENTITY FROM SYSCAT.COLUMNS WHERE TABSCHEMA = '"
 41  
                                 + database.convertRequestedSchemaToSchema(schemaName) + "' AND TABNAME = '" + tableName
 42  
                                 + "' AND COLNAME = '" + columnName + "' AND HIDDEN != 'S'"));
 43  
 
 44  0
         for (Map row : rs) {
 45  0
             String identity = row.get("IDENTITY").toString();
 46  0
             if (identity.equalsIgnoreCase("Y")) {
 47  0
                 autoIncrement = true;
 48  
             }
 49  0
         }
 50  
 
 51  0
         return autoIncrement;
 52  
     }
 53  
 
 54  
 }