Package org.databene.commons.file

Examples of org.databene.commons.file.FilePrintWriter


  public TableDetailsExporter(ReportContext context) {
    this.context = context;
  }
 
  public void exportTableChange(TableChange tableChange) throws IOException {
    FilePrintWriter out = null;
    try {
      DBTable oldTable = tableChange.getOldTable();
      DBTable newTable = tableChange.getNewTable();
      File htmlFile = tableFile(oldTable);
      FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
      File cssFile = context.reportFile("mad4db.css");
      out = HtmlReportUtil.createFile(htmlFile, "Modified Table " + oldTable.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(tableFile(newTable), out);
      out.println("<table width='90%'>");
     
      // database name
      out.println("  <tr>");
      out.println("    <td width='50%' align='center'><h2>" + oldTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
      out.println("    <td width='50%' align='center'><h2>" + newTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
      out.println("  </tr>");
     
      //columns
      out.println("  <tr>");
      out.println("    <td width='50%'>");
      exportColumns(oldTable, tableChange, out);
      out.println("    </td>");
      out.println("    <td width='50%'>");
      exportColumns(newTable, tableChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      //foreign keys
      out.println("  <tr>");
      out.println("    <td>");
      exportForeignKeys(oldTable, tableChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportForeignKeys(newTable, tableChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      //constraints
      out.println("  <tr>");
      out.println("    <td>");
      exportConstraints(oldTable, tableChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportConstraints(newTable, tableChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      // indexes
      out.println("  <tr>");
      out.println("    <td>");
      exportIndexes(oldTable, tableChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportIndexes(newTable, tableChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      // referrers
      out.println("  <tr>");
      out.println("    <td>");
      exportReferers(oldTable, tableChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportReferers(newTable, tableChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      out.println("</table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here


 
  public void exportTable(DBTable table, String info) throws IOException {
    File htmlFile = tableFile(table);
    FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
    File cssFile = context.reportFile("mad4db.css");
    FilePrintWriter out = null;
    try {
      out = HtmlReportUtil.createFile(htmlFile, info + " " + table.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(tableFile(table), out);
      exportColumns(table, null, out);
      exportForeignKeys(table, null, out);
View Full Code Here

  }

  public void report(SchemaChange schemaChange) {
    file = context.reportFile(FILE_NAME);
    File cssFile = context.reportFile("mad4db.css");
    FilePrintWriter out = null;
    try {
      out = HtmlReportUtil.createFile(file, "Packages", Encodings.UTF_8, cssFile);
      context.printNavBarFor(file, out);
      out.println("  <table width='100%'>");
      printChangedPackages(schemaChange, out);
      printDroppedAndCreatedPackages(schemaChange, out);
      printUnchangedPackages(schemaChange, out);
      out.println("  </table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here

  }

  public void report(SchemaChange schemaChange) {
    file = context.reportFile(FILE_NAME);
    File cssFile = context.reportFile("mad4db.css");
    FilePrintWriter out = null;
    try {
      out = HtmlReportUtil.createFile(file, "Triggers", Encodings.UTF_8, cssFile);
      context.printNavBarFor(file, out);
      out.println("  <table width='100%'>");
      printChangedTriggers(schemaChange, out);
      printDroppedAndCreatedTriggers(schemaChange, out);
      printUnchangedTriggers(schemaChange, out);
      out.println("  </table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here

  protected FilePrintWriter createFile(File file, ComparisonConfig config) throws IOException {
    File targetCss = context.reportFile("mad4db.css");
    IOUtil.copyFile("mad4db.css", targetCss.getCanonicalPath());
    String title = "Migration Analysis " + config.getEnvironment1() + " -> " + config.getEnvironment2();
    FilePrintWriter out = HtmlReportUtil.createFile(file, title, Encodings.UTF_8, targetCss);
    context.printNavBarFor(file, out);
    return out;
  }
View Full Code Here

  public TriggerDetailsExporter(ReportContext context) {
    this.context = context;
  }
 
  public void exportTriggerChange(TriggerChange triggerChange) throws IOException {
    FilePrintWriter out = null;
    try {
      DBTrigger oldTrigger = triggerChange.getOldTrigger();
      DBTrigger newTrigger = triggerChange.getNewTrigger();
      File htmlFile = triggerFile(oldTrigger);
      FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
      File cssFile = context.reportFile("mad4db.css");
      out = HtmlReportUtil.createFile(htmlFile, "Modified Trigger " + oldTrigger.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(triggerFile(newTrigger), out);
      out.println("<table width='90%'>");
     
      out.println("  <tr>");
      out.println("    <td width='50%'>");
      exportSimpleProperties(oldTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("    <td width='50%'>");
      exportSimpleProperties(newTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      // description
      out.println("  <tr>");
      out.println("    <td>");
      exportDescription(oldTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportDescription(newTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      // body
      out.println("  <tr>");
      out.println("    <td>");
      exportBody(oldTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportBody(newTrigger, triggerChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      out.println("</table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here

 
  public void exportTrigger(DBTrigger trigger, String info) throws IOException {
    File htmlFile = triggerFile(trigger);
    FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
    File cssFile = context.reportFile("mad4db.css");
    FilePrintWriter out = null;
    try {
      out = HtmlReportUtil.createFile(htmlFile, info + " " + trigger.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(triggerFile(trigger), out);
      exportSimpleProperties(trigger, null, out);
      exportDescription(trigger, null, out);
View Full Code Here

  }

  public void report(SchemaChange schemaChange) {
    file = context.reportFile(FILE_NAME);
    File cssFile = context.reportFile("mad4db.css");
    FilePrintWriter out = null;
    try {
      out = HtmlReportUtil.createFile(file, "Tables", Encodings.UTF_8, cssFile);
      context.printNavBarFor(file, out);
      out.println("  <table width='100%'>");
      printChangedTables(schemaChange, out);
      printDroppedAndCreatedTables(schemaChange, out);
      printUnchangedTables(schemaChange, out);
      out.println("  </table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here

  private HtmlReportUtil() { }
 
  public static FilePrintWriter createFile(File file, String title, String encoding, File css)
      throws UnsupportedEncodingException, FileNotFoundException {
    FilePrintWriter out = new FilePrintWriter(file, encoding);
    out.println(HTMLUtil.DOCTYPE_401);
    out.println("<html>");
    out.println("  <head>");
    out.println("    <title>" + title + "</title>");
    out.println("    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />");
    out.println("    <link href='" + FileUtil.relativePath(file, css) + "' media='all' rel='stylesheet' type='text/css' />");
    out.println("  </head>");
    out.println("  <body>");
    out.println("    <div class='page_header'>");
    out.println("      <h1>" + title + "</h1>");
    out.println("    </div>");
    return out;
  }
View Full Code Here

  public PackageDetailsExporter(ReportContext context) {
    this.context = context;
  }
 
  public void exportPackageChange(PackageChange packageChange) throws IOException {
    FilePrintWriter out = null;
    try {
      DBPackage oldPackage = packageChange.getOldPackage();
      DBPackage newPackage = packageChange.getNewPackage();
      File htmlFile = packageFile(oldPackage);
      FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
      File cssFile = context.reportFile("mad4db.css");
      out = HtmlReportUtil.createFile(htmlFile, "Modified Package " + oldPackage.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(packageFile(newPackage), out);
      out.println("<table width='90%'>");
     
      out.println("  <tr>");
      out.println("    <td width='50%'>");
      exportSimpleProperties(oldPackage, packageChange, out);
      out.println("    </td>");
      out.println("    <td width='50%'>");
      exportSimpleProperties(newPackage, packageChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      // description
      out.println("  <tr>");
      out.println("    <td>");
      exportProcedures(oldPackage, packageChange, out);
      out.println("    </td>");
      out.println("    <td>");
      exportProcedures(newPackage, packageChange, out);
      out.println("    </td>");
      out.println("  </tr>");
     
      out.println("</table>");
      out.println(context.footer());
      HtmlReportUtil.endHtmlFile(out);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtil.close(out);
View Full Code Here

TOP

Related Classes of org.databene.commons.file.FilePrintWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.