<?xml version="1.0"?>
<dc-workflow xmlns:i18n="http://xml.zope.org/namespaces/i18n"
             workflow_id="bika_arimport_workflow"
             title="Bika ARImport Workflow"
             description=""
             state_variable="review_state"
             initial_state="invalid"
             manager_bypass="False"
             i18n:domain="senaite.core">

  <permission>Modify portal content</permission>
  <permission>BIKA: Manage ARImport</permission>

  <state state_id="imported" title="Imported"  i18n:attributes="title">
    <exit-transition transition_id="" />
    <permission-map name="Modify portal content" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
    <permission-map name="BIKA: Manage ARImport" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
  </state>

  <state state_id="invalid" title="Invalid"  i18n:attributes="title">
    <exit-transition transition_id="validate" />
    <permission-map name="Modify portal content" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
    <permission-map name="BIKA: Manage ARImport" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
  </state>

  <state state_id="valid" title="Valid"  i18n:attributes="title">
    <exit-transition transition_id="import" />
    <permission-map name="Modify portal content" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
    <permission-map name="BIKA: Manage ARImport" acquired="False">
      <permission-role>LabClerk</permission-role>
      <permission-role>LabManager</permission-role>
      <permission-role>Manager</permission-role>
    </permission-map>
  </state>

  <transition transition_id="import" title="Import" new_state="imported" trigger="USER" before_script="" after_script="" i18n:attributes="title">
    <action url="" category="workflow" icon="">Import</action>
    <guard>
      <guard-permission>BIKA: Manage ARImport</guard-permission>
    </guard>
  </transition>

  <transition transition_id="validate" title="Validate" new_state="valid" trigger="USER" before_script="" after_script="" i18n:attributes="title">
    <action url="" category="workflow" icon="">Validate</action>
    <guard>
      <guard-permission>BIKA: Manage ARImport</guard-permission>
      <guard-expression>python:here.guard_validate_transition()</guard-expression>
    </guard>
  </transition>

  <variable variable_id="action" for_catalog="False" for_status="True" update_always="True">
    <description>Previous transition</description>
    <default>
      <expression>transition/getId|nothing</expression>
    </default>
    <guard>
    </guard>
  </variable>

  <variable variable_id="actor" for_catalog="False" for_status="True" update_always="True">
    <description>The ID of the user who performed the last transition</description>
    <default>
      <expression>user/getId</expression>
    </default>
    <guard>
    </guard>
  </variable>

  <variable variable_id="comments" for_catalog="False" for_status="True" update_always="True">
    <description>Comment about the last transition</description>
    <default>
      <expression>python:state_change.kwargs.get('comment', '')</expression>
    </default>
    <guard>
    </guard>
  </variable>

  <variable variable_id="review_history" for_catalog="False" for_status="False" update_always="False">
    <description>Provides access to workflow history</description>
    <default>
      <expression>state_change/getHistory</expression>
    </default>
    <guard>
      <guard-permission>Request review</guard-permission>
      <guard-permission>Review portal content</guard-permission>
    </guard>
  </variable>

  <variable variable_id="time" for_catalog="False" for_status="True" update_always="True">
    <description>When the previous transition was performed</description>
    <default>
      <expression>state_change/getDateTime</expression>
    </default>
    <guard>
    </guard>
  </variable>

</dc-workflow>
