<?xml version="1.0" encoding="UTF-8"?>
<!--Delft FEWS (Copyright 2003 WL | Delft Hydraulics) -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:fews="http://www.wldelft.nl/fews" targetNamespace="http://www.wldelft.nl/fews" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
  <include schemaLocation="sharedTypes.xsd"/>
  <include schemaLocation="taskProperties.xsd"/>
  <!-- moduleRun -->
  <element name="workflowTestRun" type="fews:WftrComplexType">
    <annotation>
      <documentation>Configuration for a single run of a Workflow test. </documentation>
    </annotation>
  </element>
  <complexType name="WftrComplexType">
    <sequence>
      <element name="general" type="fews:WftrGeneralComplexType"/>
      <element name="activities" type="fews:WftrActivitiesComplexType"/>
    </sequence>
  </complexType>
  <!--WftrGeneralComplexType -->
  <complexType name="WftrGeneralComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0"/>
      <element name="dirDefinition" type="fews:WftrDirDefinition" minOccurs="0" maxOccurs="unbounded"/>
      <element name="systemTime" type="fews:DateTimeComplexType" minOccurs="0"/>
      <element name="testReport" type="fews:WftrTestReport" minOccurs="0" maxOccurs="1" />
    </sequence>
  </complexType>

  <simpleType name="reportType">
    <annotation>
        <documentation>all possible report types</documentation>
    </annotation>
    <restriction base="string">
        <enumeration value="junitXml"/>
    </restriction>
  </simpleType>
  <complexType name="WftrTestReport">
    <sequence>
        <element minOccurs="1" maxOccurs="1" name="reportType" type="fews:reportType">
            <annotation>
                <documentation>Since 2022.01. Write a test report into the configured directory in the specified format.</documentation>
            </annotation>
        </element>
    </sequence>
    <attribute name="dir" type="fews:directoryStringType"/>
  </complexType>

  <!--WftrActivitiesComplexType -->
  <complexType name="WftrActivitiesComplexType">
    <sequence>
      <choice minOccurs="0" maxOccurs="unbounded">
        <element name="purgeActivity" type="fews:WftrPurgeActivityComplexType">
          <annotation>
            <documentation>Purges a single file or a set of files within a directory.</documentation>
          </annotation>
        </element>
        <element name="copyActivity" type="fews:WftrCopyActivityComplexType"/>
        <element name="workflowActivity" type="fews:WftrWorkflowActivityComplexType"/>
        <element name="checkPerformanceActivity" type="fews:WtfrCheckPerformanceActivityComplexType"/>
        <element name="exportTimeSeriesActivity" type="fews:WftrExportTimeSeriesActivityComplexType">
          <annotation>
            <documentation>Exports time series.</documentation>
          </annotation>
        </element>
        <element name="exportLogsActivity" type="fews:WftrExportLogsActivityComplexType">
          <annotation>
            <documentation>Since 2013.01. FEWS-8609. Exports log messages produced during last workflow run.</documentation>
          </annotation>
        </element>
        <element name="setSystemTimeActivity" type="fews:WftrSetSystemTimeActivityComplexType">
          <annotation>
            <documentation>Since 2013.01. FEWS-8609. Set new system time.</documentation>
          </annotation>
        </element>
        <element name="compareActivity" type="fews:WftrCompareActivityComplexType"/>
        <element name="refreshActivity" type="anyType">
            <annotation>
                <documentation>Since 2014.01. FEWS-10162. Refresh datastore.</documentation>
            </annotation>
        </element>
          <element name="containsActivity" type="fews:WftrContainsActivityComplexType">
              <annotation>
                  <documentation>Since 2014.01. FEWS-10162. Search text in file. All configured search texts have to be found. It is also possible to check if the text file is empty</documentation>
              </annotation>
          </element>
          <element name="notContainsActivity" type="fews:WftrNotContainsActivityComplexType">
              <annotation>
                  <documentation>Since 2023.02. Search if text is not found in file. None of the configured search texts have to be found. It is also possible to check if the text file is not empty</documentation>
              </annotation>
          </element>
          <element name="sleepActivity" type="fews:WftrSleepActivityComplexType">
              <annotation>
                  <documentation>Since 2014.01. FEWS-10162. Pauses execution of tests.</documentation>
              </annotation>
          </element>
      </choice>
    </sequence>
  </complexType>
    <!--WftrPurgeActivityComplexType -->
    <complexType name="WftrPurgeActivityComplexType">
        <sequence>
            <element name="description" type="string" minOccurs="0">
                <annotation>
                    <documentation>Optional description for the activity.</documentation>
                </annotation>
            </element>
            <element name="filter" type="fews:fileStringType">
                <annotation>
                    <documentation>File or files to be deleted. Use * and ? as wild cards.</documentation>
                </annotation>
            </element>
            <element name="maxAge" type="fews:TimeSpanComplexType" minOccurs="0">
                <annotation>
                    <documentation>The maximum age a file can be before it must be purged.</documentation>
                </annotation>
            </element>
        </sequence>
    </complexType>
  <!--WftrCopyActivityComplexType-->
  <complexType name="WftrCopyActivityComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0"/>
      <element name="src" type="fews:fileStringType"/>
      <element name="dest" type="fews:fileStringType"/>
    </sequence>
  </complexType>
  <!--WftrCompareActivityComplexType-->
  <complexType name="WftrCompareActivityComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0"/>
      <element name="exportFile" type="fews:fileStringType"/>
      <element name="compareFile" type="fews:fileStringType"/>
    </sequence>
  </complexType>
  <!--WftrActivityComplexType-->
  <complexType name="WftrWorkflowActivityComplexType">
    <annotation>
      <documentation>
                Defines an activity of a workflow. Activities are executed
                in the same order as defined in the workflow XML file.
            </documentation>
    </annotation>
	  <choice>
		  <group ref="fews:WftrWorkflowGroup"/>
		  <element name="taskProperties" type="fews:TaskPropertiesComplexType">
			  <annotation>
				  <documentation>Since 2015.02</documentation>
			  </annotation>
		  </element>
	  </choice>
  </complexType>
  <!--WftrCheckPerformanceActivityComplexType-->
    <complexType name="WtfrCheckPerformanceActivityComplexType">
        <annotation>
            <documentation>
                Defines an activity for checking the performance of a given workflow.
            </documentation>
        </annotation>
        <sequence>
            <element name="workflowId" type="fews:idStringType"/>
            <element name="systemTime" type="fews:DateTimeComplexType" minOccurs="0">
                <annotation>
                    <documentation>Since 2021.02. FEWS-25824</documentation>
                </annotation>
            </element>
            <element name="maximumRuntime" type="fews:TimeSpanComplexType"/>
        </sequence>
    </complexType>
  <!-- WftrExportTimeSeriesActivityComplexType -->
  <complexType name="WftrExportTimeSeriesActivityComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0">
        <annotation>
          <documentation>Optional description for the activity.</documentation>
        </annotation>
      </element>
      <element name="exportFile" type="fews:fileStringType">
        <annotation>
          <documentation>File to which the data will be exported. This file is always placed in exportDir.</documentation>
        </annotation>
      </element>
      <element name="exportBinFile" type="boolean" default="false" minOccurs="0">
        <annotation>
          <documentation>When true the events in the PI time series file are written to a binary file instead of the xml file.
                        The written xml file will only contain the time series headers and optionally a time zone.
                        The binary file has the same name as the xml file only the extension is "bin" instead of "xml"
                        During PI time series import the bin file is automatically read when available. The byte order in the bin file is always
                        Intel x86.
                </documentation>
        </annotation>
      </element>
      <element name="timeSeriesSets" type="fews:WftrTimeSeriesSetsComplexType">
        <annotation>
          <documentation>TimeSeriesSet that defines what data is to be exported.</documentation>
        </annotation>
      </element>
      <element name="omitMissingValues" type="boolean" minOccurs="0">
        <annotation>
          <documentation>Are missing values to be written to the export file or should they be left out.</documentation>
        </annotation>
      </element>
      <element name="piVersion" type="fews:piVersionString" default="1.2" minOccurs="0">
          <annotation>
              <documentation>Since 2022.02. Version of the PI specification that is supported by the time series export.</documentation>
          </annotation>
      </element>
    </sequence>
  </complexType>
    <!--
        WftrExportLogsActivityComplexType
        Export all log messages generated by the last workflow activity
    -->
  <complexType name="WftrExportLogsActivityComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0">
        <annotation>
          <documentation>Optional description for the activity.</documentation>
        </annotation>
      </element>
      <element name="exportFile" type="fews:fileStringType">
        <annotation>
          <documentation>File to which the data will be exported. This file is always placed in exportDir.</documentation>
        </annotation>
      </element>
      <element name="logLevel" type="fews:logLevelEnumStringType" minOccurs="0" default="INFO">
        <annotation>
          <documentation>Log level for export (DEBUG, INFO, WARN or ERROR).</documentation>
        </annotation>
      </element>
        <element name="moduleInstanceId" type="string" minOccurs="0">
          <annotation>
            <documentation>Export only messages logged by specific ModuleInstanceRun. If omitted all messages
            logged during the taskRun will be exported.</documentation>
          </annotation>
        </element>
    </sequence>
  </complexType>
    <!--
        WftrSetSystemTimeActivityComplexType
        set new system time
    -->
  <complexType name="WftrSetSystemTimeActivityComplexType">
    <sequence>
      <element name="description" type="string" minOccurs="0">
        <annotation>
          <documentation>Optional description for the activity.</documentation>
        </annotation>
      </element>
      <element name="systemTime" type="fews:DateTimeComplexType" />
    </sequence>
  </complexType>
  <!--Wftr TimeSeriesSetsComplexType -->
  <complexType name="WftrTimeSeriesSetsComplexType">
    <sequence>
      <element name="timeSeriesSet" type="fews:TimeSeriesSetComplexType" maxOccurs="unbounded"/>
    </sequence>
  </complexType>
  <complexType name="WftrDirDefinition">
      <attribute name="refName" type="string"/>
      <attribute name="dir" type="fews:directoryStringType"/>
  </complexType>
    <!--
        search for text in file
    -->
    <complexType name="WftrContainsActivityComplexType">
        <sequence>
            <element name="description" type="string" minOccurs="0">
                <annotation>
                    <documentation>Optional description for the activity.</documentation>
                </annotation>
            </element>
            <choice>
                <element name="searchString" type="string" maxOccurs="unbounded"/>
                <element name="emptyFile" type="anyType" />
            </choice>
            <element name="searchFile" type="fews:fileStringType"/>
        </sequence>
    </complexType>
    <complexType name="WftrNotContainsActivityComplexType">
        <sequence>
            <element name="description" type="string" minOccurs="0">
                <annotation>
                    <documentation>Optional description for the activity.</documentation>
                </annotation>
            </element>
            <choice>
                <element name="searchString" type="string" maxOccurs="unbounded"/>
                <element name="emptyFile" type="anyType" />
            </choice>
            <element name="searchFile" type="fews:fileStringType"/>
        </sequence>
    </complexType>
    <complexType name="WftrSleepActivityComplexType">
        <sequence>
            <element name="description" type="string" minOccurs="0">
                <annotation>
                    <documentation>Optional description for the activity.</documentation>
                </annotation>
            </element>
            <element name="sleepTimeMillis" type="long" />
        </sequence>
    </complexType>
	<group name="WftrWorkflowGroup">
		<sequence>
			<element name="workflowId" type="fews:idStringType"/>
			<element name="systemTime" type="fews:DateTimeComplexType" minOccurs="0">
				<annotation>
					<documentation>Since 2013.01. FEWS-8609</documentation>
				</annotation>
			</element>
            <element name="warmStateSearchPeriod" type="fews:PeriodComplexType" minOccurs="0"/>
		</sequence>
	</group>
</schema>
