Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This option is available since midPoint 3.8. This version brought so called Partitioned tasks. Although this feature is primarily used for partitioning standard tasks (like Reconciliation or Validity scanning), nothing prevents us from using it for custom tasks as well.

The following composite task prepares a CSV file and imports it.

Code Block
xml
xml
<task oid="8f8de5ad-e699-439e-8362-77cbb994117c"
       xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
       xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
       xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
       xmlns:se="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:noop="http://midpoint.evolveum.com/xml/ns/public/task/noop/handler-3"
       xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
       xmlns:org='http://midpoint.evolveum.com/xml/ns/public/common/org-3'>
     <name>Prepare and import CSV file</name>
     <extension xmlns:mext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ExtensionType">
         <!-- This extension is copied to both partitions (subtasks). Each one takes items that are relevant to it. -->
         <mext:kind>account</mext:kind>
         <mext:objectclass>ri:AccountObjectClass</mext:objectclass>
         <se:executeScript xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
             <s:action>
                 <s:type>execute-script</s:type>
                 <s:parameter>
                     <s:name>script</s:name>
                     <c:value xsi:type="c:ScriptExpressionEvaluatorType">
                         <c:code>
                              File file = new File("C:/tmp/file.csv")
                              file.write "ident,number,firstname,lastname\nferko,11,Ferko,Mrkvicka\njanko,12,Janko,Novak"
                         </c:code>
                     </c:value>
                 </s:parameter>
                 <s:parameter>
                     <s:name>forWholeInput</s:name>
                     <c:value>true</c:value>
                 </s:parameter>
             </s:action>
         </se:executeScript>
     </extension>
     <ownerRef oid="00000000-0000-0000-0000-000000000002"/>
     <objectRef oid="ef2bc95b-76e0-48e2-86d6-3d4f02d3fafe" relation="org:default" type="c:ResourceType"/>    
     <executionStatus>runnable</executionStatus>
     <handlerUri>http://midpoint.evolveum.com/xml/ns/public/task/generic-partitioning/handler-3</handlerUri>
     <workManagement>
         <taskKind>partitionedMaster</taskKind>
         <partitions>
             <copyMasterExtension>true</copyMasterExtension>
             <partition>
                 <index>1</index>
                 <taskName>Prepare CSV</taskName>
                 <handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3</handlerUri>
             </partition>
             <partition>
                 <index>2</index>
                 <taskName>Import CSV</taskName>
                 <handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/import/handler-3</handlerUri>
             </partition>
         </partitions>
     </workManagement>
     <recurrence>single</recurrence>
 </task>

...