<!--
Copyright (C) 2012-2022 Greenbone AG

SPDX-License-Identifier: AGPL-3.0-or-later
-->

<!--
  This wizard deletes all reports of a task and performs an optional action
  afterwards.

  Required parameters:
  task_id : The ID of the task to reset.

  Optional parameters:
  next_action: The action to perform after the reports are deleted:
                start : starts the task.

  To run this wizard, use the GMP command RUN_WIZARD.
  Please see the GMP documentation for details.
 -->

<wizard>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <get_tasks task_id="{/wizard/params/param[name='task_id']/value}" details="1"></get_tasks>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <get_version/>
          <xsl:for-each select="/wizard/previous/response/get_tasks_response/task/reports/report">
            <delete_report report_id="{@id}" />
          </xsl:for-each>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
  <step>
    <command>
      <xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
          method="xml"
          encoding="UTF-8"/>
        <xsl:template match="/">
          <xsl:choose>
            <xsl:when test="/wizard/params/param[name='next_action']/value = 'start'">
              <start_task task_id="{/wizard/params/param[name='task_id']/value}"/>
            </xsl:when>
            <xsl:otherwise>
              <get_version/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
</wizard>
