Exporter gears in RED FLAGS engine
Package: hu.petabyte.redflags.gear.export
FlagExporter
Generates a CSV file where rows are notices, columns are the indicators, and cells are the indicator results. Has two special methods that can be overridden to add filtering functionality:
shouldInclude(AbstractIndicator)
- filtering the indicatorsshouldInclude(Notice)
- filtering notices
The default is return true
for both of them.
The output file will be named like this: redflags-yyyyMMdd-HHmmss.csv
. It is generated by filename()
method which can also be overridden.
Be aware that this gear stores every relevant data in the memory during the whole session, the file will be created at the end.
Depends on:
GearLoader
- calls it to gather indicator classes
Before session:
- gathers indicators to be included in export
- generates output filename
After session:
- sorts notice rows
- adds header rows
- writes out the file
MySQLExporter
Exports notices' data into a MySQL database. It generates data files on-the-fly then uses LOAD DATA INFILE
MySQL command to import them. This method is chosen because it is much faster then any other batch insert solution.
You can read about the database structure above.
Parameters:
||
---------|--------|---
db
| int | 0 or 1 means this gear is turned off or on
dbhost
| String | database host:port
dbname
| String | database name
dbuser
| String | database username
dbpass
| String | database user's password
rev
| int | database revision (data version) to be stored in all tables, for all records
The rev
value is useful when you have a large database and you need to update it after modifying an indicator. In this case 1) you increase this number in the configuration, 2) run the engine to overwrite the data in the databse, 3) then you can delete those records that have the old rev
value.
Before session:
- creates database connection
After session:
- writes out table data which have been gathered during the session (e.g. types, CPV codes)
- imports data files into MySQL
TD3CFlagExporter
Descendant of FlagExporter
with the following overridings:
- includes only indicators that are implementations of
AbstractTD3CIndicator
- includes only notices that have
TD-3
orTD-C
document type which means they are either Contract notices or Works concessions. - replaces the filename suffix from
.csv
to-H1.csv
TD7FlagExporter
Descendant of FlagExporter
with the following overridings:
- includes only indicators that are implementations of
AbstractTD7Indicator
- includes only notices that have
TD-7
document type which means they are Contract award notices - replaces the filename suffix from
.csv
to-H2.csv