Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is an import that makes use of the custom import mechanism described in Custom time series import. The WaterML2 import consists of a xml parser, WaterMLTimeSeriesParser.java, a server parser, WaterMlServerParser.java and a bin directory containing all dependant library files (WaterMLWaterMlService-stable-201402-bin.zip).

The WaterML standard has been adopted as an OGC standard. The specifications of the WaterML standard can be found at OGC-WaterML2. This import make use of a Request - Response mechanism. First the WaterMlServerParser makes an XML request file and sends this to the WaterMl2 server. Depending on the request a XML Response file is returned containing the timeseries information. The WaterMlServerParser then hands the returned content over to the WaterMlTimeSeriesParser which extracts the timeseries data from the response.

...

In order to activate the WaterML import as a FEWS import, it is required to setup a TimeSeriesImportRun module configuration file and an accompanying IdMap file. Also the bin directory containing all WaterML resources must be placed in a location that can be accessed by the FEWS system.

WaterML2 Server import

As of Stable 2017.02 the WaterMlServerParser and WaterMlTimeSeriesParser have been moved to the module lib-parsers-serializer. This implies that they can be configured using the importTypeStandard option and that there is no longer a need to provide the parser classes is a separate binary directory.

Version 2017.02 and later

Here is a 2017.02 and later Here is an example import module configuration file that imports data from a WaterMl2 webserver:

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun 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/timeSeriesImportRun.xsd">
    <!-- This is an example import configuration file for importing WaterML data from a WaterMl server    -->
    <import>
        <general>
			<importTypeStandard>wml2_server</importTypeStandard>
              <!-- Class name of WaterML server parser -->     <serverUrl>http://nwisvaws02.er.usgs.gov/ogc-swie/wml2/uv/sos</serverUrl>
			<relativeViewPeriod unit="hour" end="0" start="-3"/>             
			<idMapId>IdImportWaterML2_usgs</idMapId>
            <parserClassName>nl.wldelft.waterml.timeseriesparsers.WaterMlServerParser</parserClassName>

<importTimeZone>
            <!-- Path to directory containing libraries --><timeZoneOffset>-06:00</timeZoneOffset>
            <binDir>%REGION_HOME%/Modules/waterml-bin</binDir>
</importTimeZone>
        </general>
        <properties>
            <!-- Directory from which CSV files are to be imported Optional: Use this option to write request and response messages to file. -->
                   <serverUrl>http://nwisvaws02.er.usgs.gov/ogc-swie/wml2/uv/sos</serverUrl> <string key="RequestsOutputDirectory" value="c:/temp/"/>
            <idMapId>IdImportWaterML2_usgs</idMapId>
            <importTimeZone>
                <timeZoneOffset>-06:00</timeZoneOffset><!-- Optional: Use this option to define what the request string must look like. This depends on how the WaterML2 webservice is setup. By using tags in the 
            </importTimeZone>
     request template it </general>
is possible to insert the import parameters at <properties>run-time.
            <!-- Optional: Use this option to write request and response messages to file. -->
            <string key="RequestsOutputDirectory" value="c:/temp/"/>
            <!-- Optional: Use this option to define what the request string must look like. This depends on how the WaterML2 webservice is setup. By using tags in the      The following tags can be set:
				 @starttime@ = start time request period
				 @endtime@ = end time of request period
				 @locationid@ = location identifier
				 @parameterid@ = parameter identifier
				 @qualifier0@ = qualifier value 0 (can be used freely for additional purposes if required)
				 @qualifier1@ = qualifier value 1
				 @qualifier2@ = qualifier value 2
				 @qualifier3@ = qualifier value 3
            -->
            <string key="requestTemplate" value="format=wml2&amp;from=@starttime@&amp;to=@endtime@&amp;loc_id=@locationid@@&amp;par_id=@parameterid@"/>
   request  template it is possible to insert the import parameters at run-time.
                 The following tags can be set:
				 @starttime@ = start time request period
				 @endtime@ = end time of request period
				 @locationid@ = location identifier
				 @parameterid@ = parameter identifier
				 @qualifier0@ = qualifier value 0 (can be used freely for additional purposes if required)
				 @qualifier1@ = qualifier value 1
				 @qualifier2@ = qualifier value 2
				 @qualifier3@ = qualifier value 3<!-- Optional: Maximum time in millis before a read action times-out. Read time is defined by the time betweend sending a request and start reading the response -->
            <int key="ReadTimeoutMillis" value="10000"/>
            <!-- Optional: Maximum time in millis for making the connection to the WaterML2 service. -->
            <int key="ConnectionTimeoutMillis" value="1000"/>
            <!-->
 Optional: Option to import multiple locations in single request. -->
     <string       <bool key="requestTemplateRequestMultipleLocations" value="format=wml2&amp;from=@starttime@&amp;to=@endtime@&amp;loc_id=@locationid@@&amp;par_id=@parameterid@true"/>
        </properties>
     <!-- Optional: Maximum <timeSeriesSet>
 time in millis before a read action times-out. Read time is defined by the time betweend sending a request and start reading the response --> <moduleInstanceId>ImportWaterML2_usgs</moduleInstanceId>
            <valueType>scalar</valueType>
            <string key="ReadTimeoutMillis" value="10000"/><parameterId>MyPar</parameterId>
            <!-- Optional: Maximum time in millis for making the connection to the WaterML2 service. --><locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType>
            <string<timeStep keyunit="ConnectionTimeoutMillis" value="c:/temp/nonequidistant"/>
        </properties>
        <timeSeriesSet><readWriteMode>add originals</readWriteMode>
            <moduleInstanceId>ImportWaterML2_usgs<<synchLevel>1</moduleInstanceId>synchLevel>
            <valueType>scalar</valueType></timeSeriesSet>
    </import>
</timeSeriesImportRun>

Note that when using qualifiers in the timeSeriesSet, in the idMapping both an internal and external qualifier need to be defined (with the same value):

<map externalParameter="206194010" internalParameter="DP.obs" internalQualifier="normal" externalQualifier="normal"/>

Versions before 2017.02

Here is a pre-2017.02 example import module configuration file that imports data from a WaterMl2 webserver:

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun 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/timeSeriesImportRun.xsd">
    <!-- This is an example import configuration file for importing WaterML data from a WaterMl server    -->
    <import>
        <general>
           <!-- Class name of WaterML server parser -->
            <parserClassName>nl.wldelft.waterml.timeseriesparsers.WaterMlServerParser</parserClassName>

            <!-- Path to directory containing libraries -->
            <binDir>%REGION_HOME%/Modules/waterml-bin</binDir>

            <!-- Directory from which CSV files are to be imported -->
            <serverUrl>http://nwisvaws02.er.usgs.gov/ogc-swie/wml2/uv/sos</serverUrl>
            <idMapId>IdImportWaterML2_usgs</idMapId>
            <importTimeZone>
                <timeZoneOffset>-06:00</timeZoneOffset>
            </importTimeZone>
        </general>
        <properties>
            <!-- Optional: Use this option to write request and response messages to file. -->
            <string key="RequestsOutputDirectory" value="c:/temp/"/>
            <!-- Optional: Use this option to define what the request string must look like. This depends on how the WaterML2 webservice is setup. By using tags in the 
                 request template it is possible to insert the import parameters at run-time.
                 The following tags can be set:
				 @starttime@ = start time request period
				 @endtime@ = end time of request period
				 @locationid@ = location identifier
				 @parameterid@ = parameter identifier
				 @qualifier0@ = qualifier value 0 (can be used freely for additional purposes if required)
				 @qualifier1@ = qualifier value 1
				 @qualifier2@ = qualifier value 2
				 @qualifier3@ = qualifier value 3
            -->
            <string key="requestTemplate" value="format=wml2&amp;from=@starttime@&amp;to=@endtime@&amp;loc_id=@locationid@@&amp;par_id=@parameterid@"/>
            <!-- Optional: Maximum time in millis before a read action times-out. Read time is defined by the time betweend sending a request and start reading the response -->
            <int key="ReadTimeoutMillis" value="10000"/>
            <!-- Optional: Maximum time in millis for making the connection to the WaterML2 service. -->
            <int key="ConnectionTimeoutMillis" value="1000"/>
            <!-- Optional: Option to import multiple locations in single request. -->
            <bool key="RequestMultipleLocations" value="true"/>

        </properties>
        <timeSeriesSet>
            <moduleInstanceId>ImportWaterML2_usgs</moduleInstanceId>
            <valueType>scalar</valueType>
            <parameterId>MyPar</parameterId>
            <locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType>
            <timeStep unit="nonequidistant"/>
            <readWriteMode>add originals</readWriteMode>
            <synchLevel>1</synchLevel>
        </timeSeriesSet>
    </import>
</timeSeriesImportRun>

WaterML2 file import

Version 2017.02 and later

Here is a 2017.02 and later example import module configuration file that imports data from a directory

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun 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/timeSeriesImportRun.xsd">
    <!-- This is an example import configuration file for importing WaterML data from a WaterMl server    -->
    <import>
        <general>
            <importTypeStandard>wml2</importTypeStandard>

            <!-- Directory from which CSV files are to be imported -->
  	        <folder>$IMPORT_FOLDER_WATERML$</folder>
            <idMapId>IdImportWaterML2_usgs</idMapId>
            <importTimeZone>
                <timeZoneOffset>-06:00</timeZoneOffset>
            </importTimeZone>
        </general>
        <timeSeriesSet>
            <moduleInstanceId>ImportWaterML2_usgs</moduleInstanceId>
            <valueType>scalar</valueType>
            <parameterId>MyPar</parameterId>
            <locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType>
            <timeStep unit="nonequidistant"/>
            <readWriteMode>add originals</readWriteMode>
            <synchLevel>1</synchLevel>
        </timeSeriesSet>
    </import>
</timeSeriesImportRun>

Versions before 2017.02

Here is a pre-2017.02 example import module configuration file that imports data from a directory:

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun 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/timeSeriesImportRun.xsd">
    <!-- This is an example import configuration file for importing WaterML data from a WaterMl server    -->
    <import>
        <general>
           <!-- Class name of WaterML server parser -->
            <parserClassName>nl.wldelft.waterml.timeseriesparsers.WaterMlTimeSeriesParser</parserClassName>

            <!-- Path to directory containing libraries -->
            <binDir>%REGION_HOME%/Modules/waterml-bin</binDir>

            <!-- Directory from which CSV files are to be imported -->
	    <folder>$IMPORT_FOLDER_WATERML$</folder>
            <idMapId>IdImportWaterML2_usgs</idMapId>
            <importTimeZone>
                <timeZoneOffset>-06:00</timeZoneOffset>
            </importTimeZone>
        </general>
        <timeSeriesSet>
            <moduleInstanceId>ImportWaterML2_usgs</moduleInstanceId>
            <valueType>scalar</valueType>
            <parameterId>MyPar</parameterId>
            <locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType>
            <timeStep         <parameterId>MyPar</parameterId>
            <locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType>
            <timeStep unit="nonequidistant"/>
            <readWriteMode>add originals</readWriteMode>
            <synchLevel>1</synchLevel>
        </timeSeriesSet>
    </import>
</timeSeriesImportRun>

WaterML2

...

Authentication

Currently the server import support two types of authentication: Basic Authentication and OAuth2.

Basic Authentication

Here is an example import module configuration file that imports data from a directoryconfiguration example showing how to configure Basic Authentication. Only a user name and password need to be configured.

Code Block
<general>
	<importTypeStandard>wml2_server</importTypeStandard>
    <serverUrl>https://dummy_hostname/KiWIS/KiWIS</serverUrl>
    <user>dummy_username</user>
    <password>dummy_password</password>
	...
 </general>


As of release 2017.02 it is also possible to configure OAuth2 authentication. This functionality has been backported to Stable 2016.02 and 2017.01, however the way to configure this in the older releases differs.

OAuth2 Authentication version 2017.02 and later

Code Block
<general>
	<importTypeStandard>wml2_server</importTypeStandard>
    <serverUrl>https://dummy_hostname/KiWIS/KiWIS</serverUrl>
    <!-- <user>dummy_username</user> -->				<!-- normally not required for OAuth2 -->
    <!-- <password>dummy_password</password> -->	<!-- normally not required for OAuth2 -->
    <oauth2Config>
		<!-- Required: URL from which to receive the access token
Code Block
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun 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/timeSeriesImportRun.xsd">
    <!-- This is an example import configuration file for importing WaterML data from a WaterMl server    -->
    <import>
        <general>
           <!-- Class name of WaterML server parser -->
            <parserClassName>nl.wldelft.waterml.timeseriesparsers.WaterMlTimeSeriesParser</parserClassName>

            <!-- Path to directory containing libraries	<authUrl>https://dummy_hostname/auth</authUrl>
 		<!-- Optional: For proper OAuth2 authentication a client_id and client_secret are required. However in some cases the authentication URL does not require this. 
			 Instead Basic Authentication is required to access the authUrl. Here the user and password fields shown above are required -->
		<clientId>openid client id</clientId>
		<clientSecret>openid client secret</clientSecret>
		<!-- Optional Array: Scope of request -->
            <binDir>%REGION_HOME%/Modules/waterml-bin</binDir>

<scope>openid</scope>
            <scope>email</scope>
		<!-- DirectoryOptional fromArray: whichAudience CSVfor fileswhom arerequest tois beintended. imported -->
	    <folder>$IMPORT_FOLDER_WATERML$</folder>
            <idMapId>IdImportWaterML2_usgs</idMapId>Used to validate response. If omitted the clientId and username become are used -->
            <importTimeZone><audience>audienceId</audience>
        <audience>audienceId2</audience>
        <timeZoneOffset>-06:00</timeZoneOffset>
            </importTimeZone>
        </general><!-- Optional: Issuer of the access token. Used to validate response. If omitted the root url of authUrl is used. -->
        <timeSeriesSet>
<issuer>http://localhost:8080/KiWebPortal/auth</issuer>
       <!-- Optional: A refresh token can  <moduleInstanceId>ImportWaterML2_usgs</moduleInstanceId>
     be used if provider supports this. -->
       <valueType>scalar</valueType>
 <refreshToken>refresh access token</refreshToken>
	</oauth2Config>
	...
 </general>

OAuth2 Authentication versions before 2017.02

Code Block
<general>
	<importTypeStandard>wml2_server</importTypeStandard>
    <serverUrl>https://dummy_hostname/KiWIS/KiWIS</serverUrl>
     <parameterId>MyPar</parameterId>
       <!-- <user>dummy_username</user> -->				<!-- normally not required for OAuth2 -->
     <locationSetId>MyLocSet</locationSetId>
            <timeSeriesType>external historical</timeSeriesType><!-- <password>dummy_password</password> -->	<!-- normally not required for OAuth2 -->    
	...
 </general>
<properties>
   <string         <timeStep unit="nonequidistant"/>
            <readWriteMode>add originals</readWriteMode>key="authUrl" value="https://dummy_hostname/auth" />
   <string key="issuer" value="http://dummy_hostname_2:8080/KiWebPortal/auth" />
   <string key="clientId"  <synchLevel>1</synchLevel>value="id...." />
   <string     </timeSeriesSet>
    </import>
</timeSeriesImportRun>
key="clientSecret" value="*****" />
</properties>

WaterML2 IdMap configuration

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<!--NFFS EA TimeSeriesDataExchangeFormat flag conversion file for Import-->
<flagConversions 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/flagConversions.xsd">
    <flagConversion>
        <inputFlag>
            <name>External01</name>
            <value>E01</value>
        </inputFlag>
        <outputFlag>
            <name>ORIGINAL_RELIABLE</name>
            <value>0</value>
            <description>Observed value retrieved from external data source. Value is valid, marked as original reliable as validation is yet to be done</description>
        </outputFlag>
    </flagConversion>
    <flagConversion>
        <inputFlag>
            <name>External02</name>
            <value>E02</value>
        </inputFlag>
        <outputFlag>
            <name>COMPLETED_RELIABLE</name>
            <value>2</value>
            <description>Original value was missing. Value has been filled in through byteerpolation, transformation (e.g. stage discharge) or a model</description>
        </outputFlag>
    </flagConversion>
    <defaultOuputFlag>
        <name>ORIGINAL_RELIABLE</name>
        <value>0</value>
        <description>The data value is the original value retrieved from an external source and it successfully passes all validation criteria set.</description>
    </defaultOuputFlag>
    <missingValueFlag>
        <name>ORIGINAL_MISSING</name>
        <value>9</value>
    </missingValueFlag>
</flagConversions>

 


Parsing of response HRef items

...

result: GageHeight (element after last ':')