Notice

This page is still under construction

In this example three simple reports will be made: a chart, a table with timeserie values and a table with maximum status. With the examples the basis for a report can be made. By changing attributes or elements, the user can expand the reports to their own willing.

Contents:
Set up a workflow to create a report
Create a simple chart report
Create a simple table report

Setting up the workflow

For setting up a workflow in which a simple report is generated, first a couple of files need to be edited or added. These are:

  • Moduledescriptor.xml (not always necessary)
  • (Module instance, eg. Create_Report.xml)
  • ModuleInstanceDescriptors.xml
  • (Workflow, eg. Report.xml)
  • WorkflowDescriptors.xml
  • TaskrunDialog.xml

Moduledescriptor

Make sure the report class is registered. This can be done in the file "\SystemConfigFiles\Moduledescriptors.xml". It is possible that this class is already registered.

<moduleDescriptor id="Reports">
	<description>Reports</description>
	<className>nl.wldelft.fews.system.plugin.report.ReportController</className>
</moduleDescriptor>

The ID we give to the class is "Reports"

Set-up report module instance

For each report we want FEWS to generate, a separate module instance is created. Each module instance for reporting is saved in the folder "ModuleConfigFiles". In this example we create the file "Create_Report.xml". We start with the next lines:

<?xml version="1.0" encoding="UTF-8"?>
<reports version="1.0" xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/reports.xsd">
	<declarations>
		<templateDir>$REPORT_TEMPLATE_DIR$</templateDir>
		<reportsRootDir>$REPORT_ROOT_DIR$</reportsRootDir>
		<sendToLocalFileSystem>true</sendToLocalFileSystem>
	</declarations>
	<report>
		<template>template.htm</template>
		<outputFileName>report.html</outputFileName>
	</report>
</reports>

The templatedir and the reportrootsdir can directly aim at a directory, but it is also possible to use global variables (as in the example).
Later we will expand this module instance.

Register the module instance

The module instance, that creates our simple report, needs to be registered with the other module instances. Therefore the following lines are added to the file "\RegionConfigFile\ModuleInstanceDescriptors.xml":

<moduleInstanceDescriptor id="Create_Report">
	<moduleId>Reports</moduleId>
</moduleInstanceDescriptor>

ID

  • Notice that ModuleId refers to the ID of the Report class we registered in "\SystemConfigFiles\Moduledescriptors.xml"
  • Notice that the moduleInstanceDescriptor ID is the same as the name of the file that contains the settings for the module instance, in our example: "\ModuleConfigFiles\Create_Report.xml"

Workflow for creating the report

For creating the report we will here set up a seperate workflow. Therefore we create a file in the folder "WorkflowFiles", which we call "Report.xml". The file contains the following lines:

<?xml version="1.0" encoding="UTF-8"?>
<workflow xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/workflow.xsd" version="1.1">
	<!--report-->
	<activity>
		<runIndependent>true</runIndependent>
		<moduleInstanceId>Create_Report</moduleInstanceId>
	</activity>
</workflow>

ID

Notice that ModuleInstanceId refers to the name of the file that contains the module instance (ModuleConfigFiles\Create_Report.xml!

Register the new workflow

The new workflow in the file "WorkflowFiles\report.xml" needs to be registered in the file "RegionConfigFiles\WorkflowDescriptors.xml":

<workflowDescriptor id="report" forecast="false" visible="true" autoApprove="false">
	<description>Creates web reports</description>
</workflowDescriptor>

ID

Notice that the WorkflowDescriptor Id is the same as the file which contains the workflow! In this case it is "report", which is the same as the file "\WorkflowFiles\report.xml"!

Adding the workflow to the list of tasks

To be able to run the workflow manually, it needs to be registered as a task. Therefore in the file "Taskrundialog.xml" in the folder "DisplayConfigFiles" the following information is added:

<simpleTask name="MakeReport" workflowId="report">
	<relativePeriod unit="hour" start="-24" end="0"/>
</simpleTask>

The name, which appears in the tasklist is "MakeReport".

ID

Notice that the WorkflowId is the same as the name of the file which contains the workflow! In this case it is "report", which is the same as the file "\WorkflowFiles\report.xml"!

Setting up a report with a chart

The report configuration file contains two main parts: The "declarations" and the "reports".
The "declarations" section describes how the report items (like graphs, texts and tables) should look like. Therefore it is actually a template for the report items in this report module.
In the "reports" section the data items are configured that are to be displayed in the report. This forms this way a coupling between timeseries/data and the templates. For example: we have ten time series with water levels. We want them to be displayed in a chart. Of course the layout of the charts should be the same. The layout of the chart is described in the "declarations" section. The connection between the template chart and the timeseries is configured in the "reports sections".

Declaration

In the next code block is a configuration of a simple chart:

<chartFormat id="ChartFormat1">
	<includeTime0>true</includeTime0>
	<includeLegend>false</includeLegend>
	<bottomAxis>
		<format>dd/MM HH:mm</format>
		<centerLabelsBetweenTicks>false</centerLabelsBetweenTicks>
	</bottomAxis>
</chartFormat>

<templateDir>$REPORT_TEMPLATE_DIR$</templateDir>
<reportsRootDir>$REPORT_ROOT_DIR$</reportsRootDir>
<sendToLocalFileSystem>true</sendToLocalFileSystem>

The first part is the chart format. Very important is the Chartformat ID. This ID is later used to connect the timeseries to this chart layout.
The second part contains some global settings, that are valid for all the reports in this configuration file. These are (in this example) the templatedir, the report root dir and a boolean value which tells FEWS to save the report files as local files. If set to false, the results will be stored in a database.

Report

In the next block of code we connect the chart layout to a time serie.

<report>
		<inputVariable variableId="OB_H1" variableType="any">
			<timeSeriesSet>
				<moduleInstanceId>ImportAquaView</moduleInstanceId>
				<valueType>scalar</valueType>
				<parameterId>H.meting</parameterId>
				<locationSetId>OB_H.meting</locationSetId>
				<timeSeriesType>external historical</timeSeriesType>
				<timeStep unit="minute" multiplier="5"/>
				<relativeViewPeriod unit="hour" start="-10" end="10"/>
				<readWriteMode>read only</readWriteMode>
			</timeSeriesSet>
		</inputVariable>
		<chart id="chartMainH" formatId="ChartFormat1" width="600" height="300">
			<leftAxisScaleUnit>0.2</leftAxisScaleUnit>
			<timeSeries>OB_H1</timeSeries>
		</chart>
		<template>template.html</template>
		<outputFileName>chartreport.html</outputFileName>
	</report>

In the report there are three sections:

  • Input variables
  • Report elements (in this example the chart)
  • Other properties

In the input variables the timeseries are defined that are to be shown in the chart (it is also possible to declare them in the declarations section of the report!). The relative view period defines what part of the time serie is to be shown in the chart. The variable ID is used later when assigning the time serie to a chart!

In the chart section the connection is made between the time serie(s) and the chart layout (as defined in the declarations section).

The formatID should be the same as the ID of the chartFormat as defined in the declarations section!
The element "Timeseries" contains the ID of the inputvariable!
The ID of the chart (in this example "chartMainH") will appear later in the template HTML file (see next paragraph).

The HTML file "template.html" will be used to create the report. The outputfile will be "chartreport.html"

HTML template

The chart will be placed in a HTML file. The HTML file is based on a template file (name and location of the template file was configured in above sections). The template file is a simple HTML file which can be layouted by the user. For the report module to know where to place the chart, a Tag needs to be placed in the HTML file. The TAG for a chart is: $CHART(ID_of_the_chart)$.
An example of an HTML template is given below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
	<TITLE>Management Report: System Status Report</TITLE>
	<!--check for right levels up-->
	<link href="css\styles.css" rel="styleSheet" type="text/css">
	<link href="css\tables.css" rel="styleSheet" type="text/css">
</head>
<body>

$CHART(chartMainH)$


</BODY>
</HTML>

Setting up a report with a table

In this example we will create a report with a table containing water levels at a specific location. The descriptions of the elements, as in the previous chapter, are not repeated.

Declaration

In the next code block is a configuration of a simple chart:

<htmlTableFormat id="SimpleTable" tableStyle="tableStyle1">
			<column>allSeries</column>
			<row>time</row>
			<includeBeforeOrEqualToTimeZeroInChoiceFormat>false</includeBeforeOrEqualToTimeZeroInChoiceFormat>
			<relativeWholePeriod start="-5" end="5" unit="day"/>
			<topLeftText>Datum-Tijd</topLeftText>
			<cellFormat>{0,number,0.00}</cellFormat>
			<topFormat/>
			<leftFormat>{0,date,dd MM yyyy HH mm}</leftFormat>
			<missingValueText>#</missingValueText>
			<nullValueText>-</nullValueText>
		</htmlTableFormat>

Different tablestyles can be chosen. Here examples of the different standard table styles can be found.
The HTMLTableFormat ID will later be used to refer to this layout. In above section is described what information is to be placed in the columns and in the rows. In this case the columns contain the locations, and the rows the date/time.

Report

In the next block of code we connect the chart layout to a time serie.

<report>
		<inputVariable variableId="OB_H1" variableType="any">
			<timeSeriesSet>
				<moduleInstanceId>ImportAquaView</moduleInstanceId>
				<valueType>scalar</valueType>
				<parameterId>H.meting</parameterId>
				<locationSetId>OB_H.meting</locationSetId>
				<timeSeriesType>external historical</timeSeriesType>
				<timeStep unit="minute" multiplier="5"/>
				<relativeViewPeriod unit="hour" start="-10" end="10"/>
				<readWriteMode>read only</readWriteMode>
			</timeSeriesSet>
		</inputVariable>
<htmlTable id="test_tabel" formatId="SimpleTable">
			<timeSeries>OB_H1</timeSeries>
		</htmlTable>
		<template>template.html</template>
		<outputFileName>chartreport.html</outputFileName>
	</report>

In the htmlTable section the connection is made between the time serie(s) and the table layout (as defined in the declarations section).

The formatID should be the same as the ID of the HTMLFormat as defined in the declarations section!
The element "Timeseries" contains the ID of the inputvariable!
The ID of the table(in this example "tabel") will appear later in the template HTML file.

HTML template file

The template file for the HTML table is the same as for the chart, except that the tag is different:
$TABLE(test_tabel)$

  • No labels