public class ReportWorker.Library extends java.lang.Object implements XmlConstants
addMatchCategory(long, java.lang.String, int)
and addMatch(long, boolean, java.lang.String, java.lang.String)
) and/or on
an automated basis (see addMatchMultiplexed(long, boolean, java.lang.String, int)
). Provides helpers
to generate reports. This class is a PatternEngine
worker
library.Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
defFilterSpecs
Set of default file filter wildcard specifications
|
private java.util.Map<java.lang.Long,ReportDefinition> |
reports
Map of report definitions to process.
|
ATTR_ADMIN, ATTR_COND, ATTR_DB, ATTR_DUMPEXPR, ATTR_DUMPLVL, ATTR_DUMPTYPE, ATTR_ID, ATTR_MULTIPLEX, ATTR_NAME, ATTR_PASS_CHANGED, ATTR_PASSWORD, ATTR_SALT, ATTR_SORT, ATTR_SPEC, ATTR_SUPPORT, ATTR_TAG, ATTR_TITLE, ATTR_USER, ATTR_WILD, AUTO_EXPORT_FILTER_PATH, AUTO_EXPORT_RPT_SPEC, AUTO_EXPORT_SRCH_PATH, AUTO_EXPORT_USER_PATH, ELEM_FILTER, ELEM_LIST, ELEM_PROFILE, ELEM_RPT, ELEM_SEARCH, ELEM_USER, RPT_PATH, RPT_SUFFIX
Constructor and Description |
---|
Library()
Constructs a default instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addMatch(long rid,
boolean databaseMode,
java.lang.String shortName,
java.lang.String type)
Adds a match to a specific match category that already exists in our
list of watched categories.
|
void |
addMatchCategory(long rid,
java.lang.String name,
int lvl)
Manually adds a match category to the list of watched categories, using a
short name as a key (so that it can be referenced again later)
and a long descriptive name that can be used in reports.
|
void |
addMatchMultiplexed(long rid,
boolean databaseMode,
java.lang.String type,
int lvl)
Automatically adds a match category to the list of watched categories if it
doesn't already exist AND always adds a match to that match category.
|
void |
addMatchMultiplexed(long rid,
boolean databaseMode,
java.lang.String name,
java.lang.String type,
int lvl)
Automatically adds a match category to the list of watched categories if it
doesn't already exist AND always adds a match to that match category.
|
private void |
dumpStatMatches(int cid)
Writes the matches for a single match category to STDOUT.
|
void |
generateCustomReport(boolean databaseMode,
java.lang.String title,
java.util.List<CustomColumn> colDefs,
java.util.List<java.util.List<java.lang.Object>> rows,
java.util.Set<java.lang.String> tags,
int totalMatches,
int totalFiles)
Generates a custom report using the same formatting as for standard
reports, but using data provided by the caller.
|
void |
initializeDatabase(java.lang.String adminPass)
Initialize the database, dropping and creating all tables.
|
void |
postprocessFile()
Perform any per-file postprocessing.
|
void |
postprocessPipeline(boolean databaseMode,
java.util.List<ReportDefinition> reports,
boolean incremental)
Post-process database after a report run.
|
void |
prepareDatabaseStatements(boolean incremental)
Create all prepared statements needed to collect report information.
|
void |
registerReports(java.util.ArrayList<ReportDefinition> reports,
boolean databaseMode,
boolean incremental)
Register the list of all report definitions that will be processed.
|
void |
reset()
Clear all any report-specific data from memory.
|
void |
setMasterReportCategory(java.util.Set<java.lang.String> tagList)
Associate the given text tags with the current report.
|
void |
storeSourceFile(Aast root,
boolean databaseMode,
boolean df)
Store information about a source file, including its name, AST ID, and lines of code.
|
private java.util.Map<java.lang.Long,ReportDefinition> reports
private java.util.Set<java.lang.String> defFilterSpecs
public void initializeDatabase(java.lang.String adminPass)
If any user accounts previously were exported, import them now. Otherwise, create a default admin user.
If any search history previously was exported, import it now.
adminPass
- Initial password for the application admin user (should be changed when that
user first logs into the web application).public void prepareDatabaseStatements(boolean incremental)
incremental
- True
if running in incremental reporting mode, else false
.public void postprocessFile()
public void postprocessPipeline(boolean databaseMode, java.util.List<ReportDefinition> reports, boolean incremental)
databaseMode
- True
if this was a schema report run; false
if it was a code
report run.reports
- List of report definitions.incremental
- True
if this was an incremental report run; false
if batch.public void storeSourceFile(Aast root, boolean databaseMode, boolean df)
root
- Root AST for the source file.databaseMode
- True
if this is a schema report run; false
if it is a code
report run.df
- True
if the current source file is schema DF file, else false
.public void registerReports(java.util.ArrayList<ReportDefinition> reports, boolean databaseMode, boolean incremental)
reports
- The list to register.public void addMatchCategory(long rid, java.lang.String name, int lvl) throws java.lang.IllegalArgumentException
Matches can be counted for such match categories by using addMatch(long, boolean, java.lang.String, java.lang.String)
with the short name as the key. In addition, if the short name is
the same as the one that would be computed by
addMatchMultiplexed(long, boolean, java.lang.String, int)
, then that method can be used as
well.
Reasons to use this manual approach include providing more control over the report output (the description which is not available in the multiplexed approach) and the ability to match on a different or more complicated condition. Another reason is that once a match category is loaded this way, even if there are no matches an entry in the summary report and a detailed report will be created for this match category. This fact can be useful if one wants to explicitly see the number of matches as 0 for a match category that isn't matched.
rid
- Report ID.name
- A string that is used as a key to reference this match category
and as a description in reports.lvl
- The support level for the given match category.java.lang.IllegalArgumentException
public void addMatchMultiplexed(long rid, boolean databaseMode, java.lang.String type, int lvl) throws java.lang.IllegalArgumentException, AstException
The name is derived using the AST provided description for the token
type of the matched AST. Uses the addMatchCategory(long, java.lang.String, int)
and
addMatch(long, boolean, java.lang.String, java.lang.String)
functions as workers.
rid
- Report ID.type
- The string describing the type of text dump to use in
match processing. See addMatch
.lvl
- The support level for the given match category.java.lang.IllegalArgumentException
AstException
public void addMatchMultiplexed(long rid, boolean databaseMode, java.lang.String name, java.lang.String type, int lvl) throws java.lang.IllegalArgumentException, AstException
Uses the addMatchCategory(long, java.lang.String, int)
and addMatch(long, boolean, java.lang.String, java.lang.String)
functions as
workers.
rid
- Report ID.name
- The name which is used (1) as a key to identify the
match category being matched, possibly translated, and
(2) as the long name of the match category in the report summary.type
- The string describing the type of text dump to use in
match processing.lvl
- The support level for the given match category.java.lang.IllegalArgumentException
AstException
public void addMatch(long rid, boolean databaseMode, java.lang.String shortName, java.lang.String type) throws java.lang.IllegalArgumentException, AstException
This function will use the short name for the match category as a key to find the proper match category.
The text that will be dumped depends on the dump type specified by the caller. The following types are supported:
If this dump type is not one of the above specified type strings, then the dump type string itself is used as the literal text of the match. This allows the caller to assert complete control over the match text (and format of the contents).
rid
- Report ID.shortName
- The key which is used to identify the match category being
matched.type
- The string describing the type of text dump to use in
match processing. If this is not one of the above
specified strings, then this string is used as the
literal text of the match.java.lang.IllegalArgumentException
AstException
public void reset()
public void setMasterReportCategory(java.util.Set<java.lang.String> tagList)
tagList
- The set of tags to add to the master report index.private void dumpStatMatches(int cid)
cid
- The match category for which to dump matches.public void generateCustomReport(boolean databaseMode, java.lang.String title, java.util.List<CustomColumn> colDefs, java.util.List<java.util.List<java.lang.Object>> rows, java.util.Set<java.lang.String> tags, int totalMatches, int totalFiles)
databaseMode
- true
if database mode, else false
.title
- The report's title.colDefs
- A list of column definitions to store in the database for this
custom report.rows
- An ordered list containing all row data. This is a list
which contains lists of each column's data for each row in
the table. This must be a list with elements that are
lists with elements of type String
. The
number of elements in each contained list must be the same
as the number of elements of the headers
list.tags
- The set of categories with which this report is tagged.totalMatches
- The total number of matches to be shown in the master
report index for this report.totalFiles
- The total number of files (that had any matches) to be
shown in the master report index for this report.