Coverage Report - liquibase.dbdoc.TableWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
TableWriter
0%
0/10
0%
0/2
1.25
 
 1  
 package liquibase.dbdoc;
 2  
 
 3  
 import liquibase.change.Change;
 4  
 import liquibase.database.Database;
 5  
 import liquibase.database.structure.Column;
 6  
 import liquibase.database.structure.Table;
 7  
 import liquibase.database.typeconversion.TypeConverterFactory;
 8  
 
 9  
 import java.io.File;
 10  
 import java.io.FileWriter;
 11  
 import java.io.IOException;
 12  
 import java.util.ArrayList;
 13  
 import java.util.Arrays;
 14  
 import java.util.List;
 15  
 
 16  
 public class TableWriter extends HTMLWriter {
 17  
 
 18  
     public TableWriter(File rootOutputDir, Database database) {
 19  0
         super(new File(rootOutputDir, "tables"), database);
 20  0
     }
 21  
 
 22  
     @Override
 23  
     protected String createTitle(Object object) {
 24  0
         return "Changes affecting table \"" + object.toString() + "\"";
 25  
     }
 26  
 
 27  
     @Override
 28  
     protected void writeCustomHTML(FileWriter fileWriter, Object object, List<Change> changes, Database database)
 29  
             throws IOException {
 30  0
         writeColumns(fileWriter, ((Table) object), database);
 31  0
     }
 32  
 
 33  
     private void writeColumns(FileWriter fileWriter, Table table, Database database) throws IOException {
 34  0
         List<List<String>> cells = new ArrayList<List<String>>();
 35  
 
 36  0
         for (Column column : table.getColumns()) {
 37  0
             cells.add(Arrays.asList(TypeConverterFactory.getInstance().findTypeConverter(database)
 38  
                     .convertToDatabaseTypeString(column, database),
 39  
                     "<A HREF=\"../columns/" + table.getName().toLowerCase() + "." + column.getName().toLowerCase()
 40  
                             + ".html" + "\">" + column.getName() + "</A>"));
 41  
             // todo: add foreign key info to columns?
 42  
         }
 43  
 
 44  0
         writeTable("Current Columns", cells, fileWriter);
 45  
 
 46  0
     }
 47  
 }