com.ptc.windchill.upgrade.tool
Class ReportStyler

java.lang.Object
  extended bycom.ptc.windchill.upgrade.tool.ReportStyler

public class ReportStyler
extends Object


Nested Class Summary
static class ReportStyler.IndexEntry
          Inner public class IndexEntry is passed to ReportIndex for determining the tag for the index.xml file.
 
Field Summary
private  UpgradeContext context_
           
private  String CSR_REPORT_TAG
           
private  String CSR_XSL
           
private  String INDEX_XSL
           
private  String reportName_
           
private  String SQL_REPORT_TAG
           
private  String TXT_REPORT_TAG
           
private  String UPDATE_XSL
           
private  UpdateRunnerReport updateReport_
           
private  File updateReportHtmlFile_
           
private  File upgradeArchiveJarFile_
           
private  File upgradeDirectory_
           
private  File upgradePhaseReportDirectory_
           
private  File upgradeReportDirectory_
           
private  String XML_REPORT_TAG
           
 
Constructor Summary
ReportStyler()
          Used to copy general files to an archive jar file, but the jar copy's name has a standard format.
ReportStyler(UpdateRunnerReport report_object)
          Create an Update XML and HTML, then add them to a directory and to a jar file.
 
Method Summary
(package private)  void addCompareSchemaReportToJar(File report_xml_file)
           
private  void addFilesToJar(File[] files)
          Use File objects representing existing files to add to the archive jar file.
 void addFileToJar(File file_with_dot_extension)
          Add an existing file to an archive jar file.
private  void bufferInputStreamToOutputStream(InputStream input_stream, OutputStream output_stream)
          Use input and output streams to over-write files with new data.
private  void copyJarFile(File temp_jar)
          Copy the entries from the jar file into a temporary one.
private  File getIndexHtmlFile()
          The HTML description of the contents of the jar file.
private  File getIndexXmlFile()
          The XML description of the contents of the jar file.
private  String getPackageAsPath()
          Supports getStyleSheetInputStream by turning this class's package into a path that is terminated with a forward slash.
 String getReportName()
          The file name includes the phase that was just executed, along with host_port_sid and the simple date and time stamp.
private  InputStream getStyleSheetInputStream(String xsl_file)
          Supports xslTransform by loading the stylesheet from the directory that this class is in.
 File getTransformedUpdateReport()
          Supports PhaseCompleted.
private  UpgradeContext getUpgradeContext()
          The Upgrade Context holds general information
private  void setTransformedUpdateReport(File update_report_html_file)
          Supports PhaseCompleted.
private  void setUpgradeContext()
          Retrieves an instance of UpgradeContext to be used in this class.
private  void updateIndexWith(File index_xml_file, String new_file_to_index, String report_type)
          Creates an index_entry and calls the method that will actually update the index.xml file.
private  void updateIndexWithMoreThanOneLink(File index_xml_file, ReportStyler.IndexEntry[] links_to_index)
          File names that were generated from files are added to the index.xml file that will be generated into links.
 File upgradePhaseReportDirectory()
          Access the Upgrade Phase's Report Directory.
private  boolean writeUpdateReport(File xml_file)
          Write the UpdateReport to the specified File.
private  boolean xslTransform(File xml_file, String xsl_name, File html_file)
          Obtain a HTML File from a XML File using a XSL file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEX_XSL

private final String INDEX_XSL
See Also:
Constant Field Values

CSR_XSL

private final String CSR_XSL
See Also:
Constant Field Values

UPDATE_XSL

private final String UPDATE_XSL
See Also:
Constant Field Values

CSR_REPORT_TAG

private final String CSR_REPORT_TAG
See Also:
Constant Field Values

SQL_REPORT_TAG

private final String SQL_REPORT_TAG
See Also:
Constant Field Values

TXT_REPORT_TAG

private final String TXT_REPORT_TAG
See Also:
Constant Field Values

XML_REPORT_TAG

private final String XML_REPORT_TAG
See Also:
Constant Field Values

reportName_

private String reportName_

updateReport_

private UpdateRunnerReport updateReport_

upgradeDirectory_

private File upgradeDirectory_

upgradeReportDirectory_

private File upgradeReportDirectory_

upgradePhaseReportDirectory_

private File upgradePhaseReportDirectory_

upgradeArchiveJarFile_

private File upgradeArchiveJarFile_

updateReportHtmlFile_

private File updateReportHtmlFile_

context_

private UpgradeContext context_
Constructor Detail

ReportStyler

public ReportStyler()
Used to copy general files to an archive jar file, but the jar copy's name has a standard format.


ReportStyler

public ReportStyler(UpdateRunnerReport report_object)
             throws Throwable
Create an Update XML and HTML, then add them to a directory and to a jar file.

Parameters:
report_object - An object that holds an equivalent of XML information for a report.
Method Detail

addCompareSchemaReportToJar

void addCompareSchemaReportToJar(File report_xml_file)
                           throws Throwable
Throws:
Throwable

addFileToJar

public void addFileToJar(File file_with_dot_extension)
                  throws Throwable
Add an existing file to an archive jar file.

Throws:
Throwable

writeUpdateReport

private boolean writeUpdateReport(File xml_file)
Write the UpdateReport to the specified File.

Returns:
true if saving the XML file was successful.

updateIndexWith

private void updateIndexWith(File index_xml_file,
                             String new_file_to_index,
                             String report_type)
                      throws Throwable
Creates an index_entry and calls the method that will actually update the index.xml file.

Parameters:
index_xml_file - The file to be updated with a new file name.
new_file_to_index - Add a link for this new file to a copy of the jar's index.xml file.
report_type - Type of report it is, MigrationXMLReport, TXTFile, or SQLFile
Throws:
Throwable

updateIndexWithMoreThanOneLink

private void updateIndexWithMoreThanOneLink(File index_xml_file,
                                            ReportStyler.IndexEntry[] links_to_index)
                                     throws Throwable
File names that were generated from files are added to the index.xml file that will be generated into links.

Parameters:
links_to_index - An array of IndexEntry that is to update the index_xml_file
Throws:
Throwable

addFilesToJar

private void addFilesToJar(File[] files)
Use File objects representing existing files to add to the archive jar file.

Parameters:
files - An Array of File objects.

xslTransform

private boolean xslTransform(File xml_file,
                             String xsl_name,
                             File html_file)
Obtain a HTML File from a XML File using a XSL file

Parameters:
xml_file - This file exists and contains the XML.
xsl_name - This file exists and contains the XSL.
html_file - This file does not exist but is created and populated with HTML contents.
Returns:
true if the transformation succeeded and the HTML file was saved to the directory.

getStyleSheetInputStream

private InputStream getStyleSheetInputStream(String xsl_file)
                                      throws IOException
Supports xslTransform by loading the stylesheet from the directory that this class is in.

Parameters:
xsl_file - The XSL stylesheet that must be in this class's directory.
Returns:
A Streamed XMLSource for the stylesheet (null if file not found).
Throws:
IOException

getPackageAsPath

private String getPackageAsPath()
Supports getStyleSheetInputStream by turning this class's package into a path that is terminated with a forward slash.

Returns:
The Package's path terminated with a forward slash.

getReportName

public String getReportName()
The file name includes the phase that was just executed, along with host_port_sid and the simple date and time stamp.

Returns:
The report file's name.

upgradePhaseReportDirectory

public File upgradePhaseReportDirectory()
Access the Upgrade Phase's Report Directory.

Returns:
A directory

copyJarFile

private void copyJarFile(File temp_jar)
                  throws IOException
Copy the entries from the jar file into a temporary one. A temporary jar file is created for the Index.xsl to retrieve information regarding the reports it has a link to.

Parameters:
temp_jar - A temporary copy of the archive jar.
Throws:
IOException

bufferInputStreamToOutputStream

private void bufferInputStreamToOutputStream(InputStream input_stream,
                                             OutputStream output_stream)
                                      throws IOException
Use input and output streams to over-write files with new data.

Parameters:
input_stream - Holds the new data.
output_stream - To a file that is being over-written.
Throws:
IOException

setTransformedUpdateReport

private void setTransformedUpdateReport(File update_report_html_file)
Supports PhaseCompleted.


getTransformedUpdateReport

public File getTransformedUpdateReport()
Supports PhaseCompleted.

Returns:
The stored Update Report rendered as an HTML file.

setUpgradeContext

private void setUpgradeContext()
Retrieves an instance of UpgradeContext to be used in this class.


getUpgradeContext

private UpgradeContext getUpgradeContext()
The Upgrade Context holds general information

Returns:
The Upgrade Context object.

getIndexXmlFile

private File getIndexXmlFile()
The XML description of the contents of the jar file.

Returns:
The index.xml file that is located under WT_HOME/Upgrade

getIndexHtmlFile

private File getIndexHtmlFile()
The HTML description of the contents of the jar file.

Returns:
The index.html file that is located under WT_HOME/Upgrade