Class FWSimPostProcessManager
java.lang.Object
net.simplace.sim.io.postprocess.FWSimPostProcessManager
Post-processing of a session: after the run, the CSV output files are loaded into a temporary in-memory database
(H2), SQL statements summarize them, and query results are written to files.
Declaration, like the outputs: element postprocess after outputs in the solution or in
the project file. Without project file the one of the solution is run; with project file only the one of the
project file (none if the project file has none).
<postprocess>
<sql>CREATE TABLE yearly AS SELECT simulationid, YEAR("CURRENT.DATE") AS year, SUM(rain) AS rain
FROM daily GROUP BY simulationid, YEAR("CURRENT.DATE")</sql>
<write interface="summaryfile">SELECT * FROM yearly ORDER BY simulationid, year</write>
</postprocess>
Steps, in the order of the file:
sql: one or more SQL statements separated by;(H2 syntax), e.g. CREATE TABLE ... AS SELECT, UPDATE, DELETEwrite: a query whose result is written to the file of the CSV interface named byinterface(interfaces of the solution or the project file), seeResultFileWriter
${...} tokens of the solution (e.g. ${_OUTPUTDIR_}), as the file name
of the interface. Tables: one per CSV output, named like the output, see OutputTableLoader. Identifiers are
case-insensitive and keep their case (an alias AS year is written as year in the header
line); column names with special characters (e.g. "CURRENT.DATE") have to be quoted. YEAR,
MONTH, DAY, HOUR, MINUTE, SECOND and VALUE are usable as column names without quotes.
Runs: automatically at the end of a session (FWSimSession.finalize()) if the run has written output files,
once per session; again without simulation with FWSimSession.postprocess() (console command
postprocess), which loads the files on disk matching the output file names. An error stops the
post-processing and is thrown with the step and statement.
- Author:
- Andreas Enders, Claude (Anthropic), co-author
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.jdom2.ElementgetPostProcess(FWSimSession aSession) voidprocess(FWSimSession aSession) Runs the post-processing on the output files on disk, without simulation (console commandpostprocess).voidprocessAfterRun(FWSimSession aSession) Runs the post-processing at the end of a session (called byFWSimSession.finalize()), once, and only if the session has one and the run has written CSV output files.voidsetProjectPostProcess(org.jdom2.Element aPostProcessElement)
-
Constructor Details
-
FWSimPostProcessManager
public FWSimPostProcessManager()
-
-
Method Details
-
setProjectPostProcess
public void setProjectPostProcess(org.jdom2.Element aPostProcessElement) - Parameters:
aPostProcessElement- thepostprocesselement of the project file, ornull
-
getPostProcess
- Parameters:
aSession- the session- Returns:
- the post-processing to run: of the project file if the session has one, otherwise of the solution;
nullif there is none
-
processAfterRun
Runs the post-processing at the end of a session (called byFWSimSession.finalize()), once, and only if the session has one and the run has written CSV output files.- Parameters:
aSession- the session; its output files have to be closed- Throws:
Exception- if a step fails
-
process
Runs the post-processing on the output files on disk, without simulation (console commandpostprocess).- Parameters:
aSession- the prepared session- Throws:
Exception- if a step fails
-