<!--
OpenVAS Manager
$Id$
Description: OpenVAS Manager Protocol (OMP) reset task wizard.

Authors:
Timo Pollmeier <timo.pollmeier@greenbone.net>

Copyright:
Copyright (C) 2012-2014 Greenbone Networks GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-->

<!--
  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 OMP command RUN_WIZARD.
  Please see the OMP 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="/">
          <commands>
            <xsl:for-each select="/wizard/previous/response/get_tasks_response/task/reports/report">
              <delete_report report_id="{@id}" />
            </xsl:for-each>
          </commands>
        </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>
              <commands/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>
      </xsl:stylesheet>
    </command>
  </step>
</wizard>
