Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/indispensable.git
\appendix

\chapter{\label{cha:Source-Files}Source Files}

This appendix lists where to find files referenced throughout the
manual, and in some cases defines files as well. All files can be
found within a subdirectory of the \path{source} directory.


\section{Batch Files}

The Windows batch files are in the \path{scripts} directory.


\subsection{\label{sub:\filebatchbridge}\filebatchbridge}

This file starts the \appphpjavabridge{}.


\subsection{\label{sub:\filebatchtomcatenv}\filebatchtomcatenv}

This file sets the CLASSPATH before \appapachetomcat{} is launched.


\subsection{\label{sub:\filebatchdeploy}\filebatchdeploy}

This file helps create and deploy the \filename{\filewarcity} file,
which contains JavaServer Pages. When run, it pauses for a moment.
Before pressing the space bar to continue, wait until \appapachetomcat{}
terminates. Otherwise, when the script attempts to start \appapachetomcat{},
it may fail because the instance that is shutting down has not released
its lock on the port.


\subsection{\label{sub:\filebatchhighlight}\filebatchhighlight}

This file creates images of syntax-highlighted source code.


\section{Shell Scripts}

The Unix shell script files are in the \path{scripts} directory.


\subsection{\label{sub:\fileshellimages}\fileshellimages{}}

This file normalizes images of various shapes and sizes to a consistent
size and file type.


\subsection{\label{sub:fileshellbridge}\fileshellbridge{}}

This file starts the \appphpjavabridge{}.


\subsection{\label{sub:filebshelltomcatenv}\fileshelltomcatenv}

This file sets the CLASSPATH before \appapachetomcat{} is launched.


\section{HTML Files}

All HTML files are in the \path{html} directory.


\subsection{\label{sub:\filehtmlfilter}\filehtmlfilter}

This file is a web page that provides input parameters to filter the
city report.


\section{\label{sec:PHP-Source-Files}PHP Source Files}

All PHP files are in the\textbf{ }\path{php} directory.


\subsection{\label{sub:\filephppdf}\filephppdf}

This file contains a minimal implementation to create a report as
a PDF file.


\subsection{\label{sub:\filephpcity}\filephpcity}

This file shows how to call the \texttt{report\_execute} function
to run the city report.


\subsection{\label{sub:\filephpconstants}\filephpconstants}

This file contains various constants required to configure the database
connectivity.


\subsection{\label{sub:\filephpjasper}\filephpjasper}

This file translates abstracted code into a re-usable function.


\subsection{\label{sub:\filephpdemo}\filephpdemo}

This file demonstrates calling Java from PHP.


\subsection{\label{sub:\filephpparameters}\filephpparameters}

This file parses parameters before passing them to \appjasperreports{}.


\section{\appjava{} Source Code}

The source code is split into the following packages:
\begin{itemize}
\item \textbf{com.whitemagicsoftware.reports.} This contains the report
customizer described in \vref{sec:Series-Customizer}.
\item \textbf{com.whitemagicsoftware.report.} This contains the report integration
framework described in \ref{cha:JasperReports-and-Java}.
\end{itemize}
For implementation technical details, generate and review the Javadocs
for the \appjava{} source code.


\section{JavaServer Pages}

All JavaServer Pages files are in the \path{jsp} directory.


\subsection{\label{sub:\filejspdemo}\filejspdemo}

This file contains a simple message to demonstrate that installation
and configuration of the web server is successful.


\subsection{\label{sub:\filejspcity}\filejspcity}

This file produces a PDF file of cities to prove that integration
of the web server with \appjasperreports{} is successful.


\subsection{\label{sub:filexhtmlindex}\filexhtmlindex}

This file redirects the browser to \filename{\filexhtmlcity}.


\subsection{\label{sub:filexhtmlcity}\filexhtmlcity}

This file produces a web page that allows users to restrict the results
from a report listing a number of cities.


\section{SQL Scripts}

All SQL scripts are in the \path{sql} directory. Unless otherwise
stated, all scripts require a PostgreSQL database. If you are not
using a PostgreSQL database, you will have to change the files according
to the equivalent set of instructions for your database.


\subsection{\label{sub:\filesqlclimate}\filesqlclimate}

Run the following code to do the following:
\begin{itemize}
\item Create the climate schema. 
\item Create a city table in the climate schema 
\item Populate the table with ten cities. 
\end{itemize}

\subsection{\label{sub:\filesqlcasts}\filesqlcasts}

Run the SQL to enable implicit type casts in PosgreSQL. Without executing
this SQL, any attempts to filter reports using a list of values will
result in an error such as the following:

\begin{displayed}\texttt{operator does not exist: integer = character
varying}\end{displayed}


\subsection{\label{sub:\filesqlplrtemplate}\filesqlplrtemplate}

This SQL script creates a \appplr{} function that returns a set of
random integer values.


\section{\label{sec:Data-Dictionary-Scripts}SQL Scripts - Data Dictionary}

A number of SQL scripts were written to help populate and maintain
the data dictionary. These are in the \path{data-dictionary} subdirectory:
\begin{itemize}
\item \path{ddl} - Script to create the data dictionary against a PostgreSQL
database.
\item \path{functions} - Supporting functions to create the business area
and column cluster relationships.
\item \path{maintenance} - Views to help create statements that insert
and update the data dictionary.
\item \path{usage} - Views related to using the data dictionary to generate
resource bundles and search the database.
\end{itemize}

\subsection{DDL}

This is a file with database instructions to create the data dictionary
tables.


\subsubsection{\label{sub:filesqlcreatedatadictionary}\filesqlcreatedatadictionary}

This file provides an example data dictionary, created in the \texttt{dictionary}
schema.


\subsection{Functions}

This section lists database functions that help insert information
into the data dictionary.


\subsubsection{\label{sub:filesqlbusinessclusterrelation}\filesqlbusinessclusterrelation}

This file provides a function to create an association between a business
area and a column cluster within the data dictionary.


\subsubsection{\label{sub:filesqlgetentitycolumnpk}\filesqlgetentitycolumnpk}

This file provides a function to retrieve the primary key for the
relationship between a database entity (table or view) and one of
its columns.


\subsection{Maintenance}

This section lists database views and statements that help keep the
data dictionary in synchronization with the database.


\subsubsection{\label{sub:filesqlentitycolumn}\filesqlentitycolumn}

This file provides a view to generate a list of \texttt{DELETE} and
\texttt{INSERT} statements that update the data dictionary's list
of entities (tables and views). Any entities that were added to the
database, but are not in the data dictionary result in an \texttt{INSERT}
statement being generated to add the entities to the data dictionary.
Any entities that are removed from the database result in a \texttt{DELETE}
statement being generated to remove the entity from the data dictionary.


\subsubsection{\label{sub:filesqlcolumntext}\filesqlcolumntext}

This file provides a view to generate \texttt{INSERT} statements for
missing database columns into the data dictionary. The column translations
are populated using the name of the column. If the database column
names have underscores, this code can be modified to replace the underscores
with spaces, and call \texttt{initcap} to capitalize the first word
(prior to insertion into the data dictionary).


\subsubsection{\label{sub:filesqlrelateentitycolumn}\filesqlrelateentitycolumn}

This file provides an \texttt{INSERT} statement to associate all columns
with their respective entities within the data dictionary. This file
inserts only new relationships that were not previously recorded in
the data dictionary. Further, only run this statement after the statements
generated in \ref{sub:filesqlentitycolumn} and \ref{sub:filesqlcolumntext}
are executed. For databases with many tables, views, and columns,
the statement as written can take several minutes to finish running.


\subsection{Usage}

This section lists database views that query the data dictionary for
various purposes.


\subsubsection{\label{sub:filesqltranslation}\filesqltranslation}

This file provides a straightforward join view for the data dictionary's
column-to-human-readable mapping. This allows developers to find database
columns, generate resource bundles, and more.


\subsubsection{\label{sub:filesqlresourcebundle}\filesqlresourcebundle}

This file contains a SQL statement that generates resource bundles
automatically. The resource bundle keys are used by JasperReports
to look up the human-readable value of a database column. In theory,
the notion of resource bundles can be replaced with a data dictionary
look up.


\subsubsection{\label{sub:filesqlgenerateresourcebundle}\filesqlgenerateresourcebundle}

This file contains a SQL statement that generates a resource bundle
that is suitable for use in iReport.


\subsubsection{\label{sub:filesqlregeneratebusinessclusters}\filesqlregeneratebusinessclusters}

Generates create statements for inserting business clusters. Business
area and column cluster relationships must be defined by hand, so
this view allows those relationships to be recreated. Depending on
your migration process, such a view might not be useful.


\subsubsection{\label{sub:filesqlsearch}\filesqlsearch}

This file provides an example of using the data dictionary to find
column names when only the English name is known.


\section{Report Files}

All files required and used by JasperReports are located in the \path{reports}
directory, or one of its subdirectories.


\subsection{\label{sub:\filejrxmlcity}\filejrxmlcity}

This file generates a list of cities (for a PDF file).


\subsection{\label{sub:\filejrxmlmaster}\filejrxmlmaster}

This file shows how to eliminate duplication by using a parameter
to change the report's content.


\subsection{\label{sub:\filejrxmlheader}\filejrxmlheader}

This is a subreport used by the master report.


\subsection{\label{sub:\filejrxmlmulticolumn}\filejrxmlmulticolumn}

This file demonstrates using the \textbf{Background} band on a multi-column
report.


\section{XML Files}

All XML files are in the \path{xml} directory.