Overview

The Akvo import function (<importType>Akvo</importType>) imports from the Akvo Flow REST service:

https://github.com/akvo/akvo-flow-api/wiki/Akvo-Flow-REST-API

https://github.com/akvo/akvo-flow-api/wiki/Authentication

Currently the following Akvo Flow question types are supported by the import:

Number: questions of type number will be stored as a fews parameter with the question name as parameter name. In this example the pH parameter is configured as a Number.


Option: questions of type Option will be stored as a fews qualifier with the question name followed by the option value. For example: colour_Red.


Caddisfly tests will be stored as parameter values.


Configuring the Import

For the import configuration 2 properties are required. The siteRegisrationSurveyId and the siteMonitoringSurveyId. The id's can be found in the akvo flow web interface. See the following screenshots where the site monitoring survey id = 170003 and the registration survey id = 1100001:


To connect with akvo an access key and secret is required. They can be created on the akvo flow interface and should be set as the username and password in the general section of the import configuration.

In the following configuration all locations are configured one by one for demonstration purposes. A locationSet would be more appropriated. The location id's can be found in the Akvo app. They are also logged by FEWS during the import.

An example of the Akvo import configuration is given here. The importType is named Akvo which should be configured in the general section of the import. De URL to the rest service should be configured here as well.

<?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">
	<import>
		<general>
			<importType>Akvo</importType>
			<serverUrl>https://api.akvo.org/flow/orgs/deltares</serverUrl>
			<user>dummy_akvo_access_key</user> <!-- akvo open id connect user name -->
			<password>dummy_akvo_secret</password> <!-- akvo open id connect password -->
			<relativeViewPeriod unit="day" start="-20" end="0" startOverrulable="true" endOverrulable="false"/> <!-- read all survey instances of the last 20 days -->
			<idMapId>idAkvo</idMapId>
		</general>
		<properties>
			<string value="1100001" key="siteRegistrationSurveyId"></string>
			<string value="170003" key="siteMonitoringSurveyId"></string>
            <string value="https://login.akvo.org/auth/realms/akvo/protocol/openid-connect/token" key="openIdConnectUrl"></string>
		</properties>
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>pH</parameterId>
			<locationId>b1b2-8xh1-pt21</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>pH</parameterId>
			<locationId>4yes-fjqk-ceh5</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>pH</parameterId>
			<locationId>ycwm-vu8j-2ts1</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>Nitrate Nitrogen</parameterId>
			<locationId>65d4-2628-1r55</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>Nitrite Nitrogen</parameterId>
			<locationId>65d4-2628-1r55</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>				
		<timeSeriesSet>
			<moduleInstanceId>ImportAkvo</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>pH</parameterId>
			<locationId>65d4-2628-1r55</locationId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant" />
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>				
	</import>
</timeSeriesImportRun>


To make the importer known to FEWS, the import module has to be declared in the moduleInstanceDescriptors.xml in the RegionConfigFiles directory of the FEWS configuration:

<?xml version="1.0" encoding="UTF-8"?>
<moduleInstanceDescriptors 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/moduleInstanceDescriptors.xsd" version="1.0">
...
		<moduleInstanceDescriptor id="ImportAkvo">
		<moduleId>TimeSeriesImportRun</moduleId>
	</moduleInstanceDescriptor>
...
</moduleInstanceDescriptors>