<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>links-array</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description>Builds a STAC links array from one row per link.</description>
    <extended_description>Demonstrates the JSON Array Builder: one JSON object is created per link row with the JSON Object Builder and all rows of an item are aggregated into one JSON array (grouped by item_id, input sorted by item_id and rel). The link without media type shows the skip when null option. The result is written to ${OUTPUT_DIR}/links.json.</extended_description>
    <pipeline_version/>
    <pipeline_type>Normal</pipeline_type>
    <parameters>
      <parameter>
        <name>OUTPUT_DIR</name>
        <default_value>${java.io.tmpdir}</default_value>
      </parameter>
    </parameters>
    <capture_transform_performance>N</capture_transform_performance>
    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
    <created_user>-</created_user>
    <created_date>2026/09/01 00:00:00.000</created_date>
    <modified_user>-</modified_user>
    <modified_date>2026/09/01 00:00:00.000</modified_date>
  </info>
  <notepads>
    <notepad>
      <backgroundcolorblue>251</backgroundcolorblue>
      <backgroundcolorgreen>232</backgroundcolorgreen>
      <backgroundcolorred>201</backgroundcolorred>
      <bordercolorblue>90</bordercolorblue>
      <bordercolorgreen>58</bordercolorgreen>
      <bordercolorred>14</bordercolorred>
      <fontbold>N</fontbold>
      <fontcolorblue>90</fontcolorblue>
      <fontcolorgreen>58</fontcolorgreen>
      <fontcolorred>14</fontcolorred>
      <fontitalic>N</fontitalic>
      <fontname>Segoe UI</fontname>
      <fontsize>11</fontsize>
      <height>78</height>
      <xloc>64</xloc>
      <yloc>32</yloc>
      <note>One row per link. The JSON Array Builder aggregates all link objects of an item into one JSON array (grouped by item_id, input sorted by item_id and rel).</note>
      <width>655</width>
    </notepad>
  </notepads>
  <order>
    <hop><from>Read links</from><to>Sort by item and rel</to><enabled>Y</enabled></hop>
    <hop><from>Sort by item and rel</from><to>Link object</to><enabled>Y</enabled></hop>
    <hop><from>Link object</from><to>Links array</to><enabled>Y</enabled></hop>
    <hop><from>Links array</from><to>Write links</to><enabled>Y</enabled></hop>
  </order>
  <transform>
    <type>DataGrid</type>
    <name>Read links</name>
    <description/>
    <data>
      <line>
        <item>ch.so.agi.gemeindegrenzen-2026-09-01</item>
        <item>self</item>
        <item>https://data.example.ch/stac/collections/gemeindegrenzen/items/2026-09-01</item>
        <item>application/json</item>
      </line>
      <line>
        <item>ch.so.agi.gemeindegrenzen-2026-09-01</item>
        <item>collection</item>
        <item>https://data.example.ch/stac/collections/gemeindegrenzen</item>
        <item>application/json</item>
      </line>
      <line>
        <item>ch.so.agi.gemeindegrenzen-2026-09-01</item>
        <item>root</item>
        <item>https://data.example.ch/stac/</item>
        <item/>
      </line>
    </data>
    <fields>
      <field>
        <name>item_id</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>rel</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>href</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>media_type</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
    </fields>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>80</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>SortRows</type>
    <name>Sort by item and rel</name>
    <description/>
    <directory>${java.io.tmpdir}</directory>
    <prefix>out</prefix>
    <sort_size>1000000</sort_size>
    <free_memory/>
    <compress>N</compress>
    <compress_variable/>
    <unique_rows>N</unique_rows>
    <fields>
      <field>
        <name>item_id</name>
        <ascending>Y</ascending>
        <case_sensitive>N</case_sensitive>
        <collator_enabled>N</collator_enabled>
        <collator_strength>0</collator_strength>
        <presorted>N</presorted>
      </field>
      <field>
        <name>rel</name>
        <ascending>Y</ascending>
        <case_sensitive>N</case_sensitive>
        <collator_enabled>N</collator_enabled>
        <collator_strength>0</collator_strength>
        <presorted>N</presorted>
      </field>
    </fields>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>320</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>JSON_OBJECT_BUILDER</type>
    <name>Link object</name>
    <output_field>link_json</output_field>
    <output_type>JSON</output_type>
    <pretty_print>N</pretty_print>
    <mode>CREATE</mode>
    <base_json_field/>
    <json_pointer/>
    <mappings>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>rel</key>
        <value_source>FIELD</value_source>
        <value_field>rel</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>href</key>
        <value_source>FIELD</value_source>
        <value_field>href</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>type</key>
        <value_source>FIELD</value_source>
        <value_field>media_type</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>Y</skip_if_null>
      </mapping>
    </mappings>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>560</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>JSON_ARRAY_BUILDER</type>
    <name>Links array</name>
    <output_field>links_json</output_field>
    <output_type>JSON</output_type>
    <pretty_print>Y</pretty_print>
    <element_mode>FIELD_VALUE</element_mode>
    <element_field>link_json</element_field>
    <element_type>JSON</element_type>
    <insert_into_target>N</insert_into_target>
    <base_json_field/>
    <json_pointer/>
    <group_by_fields>
      <group_by_field>item_id</group_by_field>
    </group_by_fields>
    <skip_null_elements>N</skip_null_elements>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>800</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>TextFileOutput</type>
    <name>Write links</name>
    <description/>
    <compression>None</compression>
    <separator>;</separator>
    <enclosure>"</enclosure>
    <enclosure_forced>N</enclosure_forced>
    <enclosure_fix_disabled>N</enclosure_fix_disabled>
    <header>N</header>
    <footer>N</footer>
    <format>UNIX</format>
    <encoding>UTF-8</encoding>
    <endedLine/>
    <fileNameInField>N</fileNameInField>
    <fileNameField/>
    <create_parent_folder>Y</create_parent_folder>
    <file>
      <name>${OUTPUT_DIR}/links</name>
      <servlet_output>N</servlet_output>
      <do_not_open_new_file_init>Y</do_not_open_new_file_init>
      <extension>json</extension>
      <append>N</append>
      <split>N</split>
      <haspartno>N</haspartno>
      <add_date>N</add_date>
      <add_time>N</add_time>
      <SpecifyFormat>N</SpecifyFormat>
      <date_time_format/>
      <add_to_result_filenames>N</add_to_result_filenames>
      <pad>N</pad>
      <fast_dump>N</fast_dump>
      <splitevery/>
    </file>
    <fields>
      <field>
        <name>links_json</name>
        <type>JSON</type>
        <format/>
        <currency/>
        <decimal/>
        <group/>
        <nullif/>
        <trim_type>both</trim_type>
        <length>-1</length>
        <precision>-1</precision>
      </field>
    </fields>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>1040</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
