<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>stac-item</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description>Builds a STAC item with nested properties and a dynamic assets object from repeated asset rows.</description>
    <extended_description>Demonstrates the JSON Object Builder: typed field mappings, JSON Pointer insertion at /properties and /assets, dynamic object keys from the asset_key field, and grouped merging of all asset rows of an item into one JSON object. The result is written to ${OUTPUT_DIR}/stac-item.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 asset. Item fields repeat on every row; the JSON Object Builder merges all rows of an item into one JSON document with a dynamic "assets" object (grouped by item_id, input sorted by item_id).</note>
      <width>655</width>
    </notepad>
  </notepads>
  <order>
    <hop><from>Read STAC metadata</from><to>Sort by item</to><enabled>Y</enabled></hop>
    <hop><from>Sort by item</from><to>Asset object</to><enabled>Y</enabled></hop>
    <hop><from>Asset object</from><to>Item base</to><enabled>Y</enabled></hop>
    <hop><from>Item base</from><to>Properties</to><enabled>Y</enabled></hop>
    <hop><from>Properties</from><to>Assets</to><enabled>Y</enabled></hop>
    <hop><from>Assets</from><to>Write STAC item</to><enabled>Y</enabled></hop>
  </order>
  <transform>
    <type>DataGrid</type>
    <name>Read STAC metadata</name>
    <description/>
    <data>
      <line>
        <item>ch.so.agi.gemeindegrenzen-2026-09-01</item>
        <item>ch.so.agi.gemeindegrenzen</item>
        <item>Gemeindegrenzen Kanton Solothurn</item>
        <item>2026-09-01T00:00:00Z</item>
        <item>[7.34, 47.07, 8.03, 47.5]</item>
        <item>{"type":"Polygon","coordinates":[[[7.34,47.07],[8.03,47.07],[8.03,47.5],[7.34,47.5],[7.34,47.07]]]}</item>
        <item>geoparquet</item>
        <item>GeoParquet</item>
        <item>https://files.geo.so.ch/ch.so.agi.gemeindegrenzen/2026-09-01/gemeindegrenzen.parquet</item>
        <item>application/vnd.apache.parquet</item>
      </line>
      <line>
        <item>ch.so.agi.gemeindegrenzen-2026-09-01</item>
        <item>ch.so.agi.gemeindegrenzen</item>
        <item>Gemeindegrenzen Kanton Solothurn</item>
        <item>2026-09-01T00:00:00Z</item>
        <item>[7.34, 47.07, 8.03, 47.5]</item>
        <item>{"type":"Polygon","coordinates":[[[7.34,47.07],[8.03,47.07],[8.03,47.5],[7.34,47.5],[7.34,47.07]]]}</item>
        <item>interlis</item>
        <item>INTERLIS XTF</item>
        <item>https://files.geo.so.ch/ch.so.agi.gemeindegrenzen/2026-09-01/gemeindegrenzen.xtf</item>
        <item>application/xml</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>collection</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>title</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>datetime</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>bbox_json</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>geometry_json</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>asset_key</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>asset_title</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>asset_href</name>
        <type>String</type>
        <length>-1</length>
        <precision>-1</precision>
        <set_empty_string>N</set_empty_string>
      </field>
      <field>
        <name>asset_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</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>asset_key</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>Asset object</name>
    <output_field>asset_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>href</key>
        <value_source>FIELD</value_source>
        <value_field>asset_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>asset_type</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>title</key>
        <value_source>FIELD</value_source>
        <value_field>asset_title</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>roles</key>
        <value_source>LITERAL</value_source>
        <value>["data"]</value>
        <value_type>JSON</value_type>
        <skip_if_null>N</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_OBJECT_BUILDER</type>
    <name>Item base</name>
    <output_field>item_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>stac_version</key>
        <value_source>LITERAL</value_source>
        <value>1.1.0</value>
        <value_type>STRING</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>type</key>
        <value_source>LITERAL</value_source>
        <value>Feature</value>
        <value_type>STRING</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>id</key>
        <value_source>FIELD</value_source>
        <value_field>item_id</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>collection</key>
        <value_source>FIELD</value_source>
        <value_field>collection</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>bbox</key>
        <value_source>FIELD</value_source>
        <value_field>bbox_json</value_field>
        <value_type>JSON</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>geometry</key>
        <value_source>FIELD</value_source>
        <value_field>geometry_json</value_field>
        <value_type>JSON</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
    </mappings>
    <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>JSON_OBJECT_BUILDER</type>
    <name>Properties</name>
    <output_field>item_json</output_field>
    <output_type>JSON</output_type>
    <pretty_print>N</pretty_print>
    <mode>INSERT</mode>
    <base_json_field>item_json</base_json_field>
    <json_pointer>/properties</json_pointer>
    <mappings>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>datetime</key>
        <value_source>FIELD</value_source>
        <value_field>datetime</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
      <mapping>
        <key_source>LITERAL</key_source>
        <key>title</key>
        <value_source>FIELD</value_source>
        <value_field>title</value_field>
        <value_type>AUTO</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
    </mappings>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>1040</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>JSON_OBJECT_BUILDER</type>
    <name>Assets</name>
    <output_field>item_json</output_field>
    <output_type>JSON</output_type>
    <pretty_print>Y</pretty_print>
    <mode>INSERT</mode>
    <base_json_field>item_json</base_json_field>
    <json_pointer>/assets</json_pointer>
    <mappings>
      <mapping>
        <key_source>FIELD</key_source>
        <key_field>asset_key</key_field>
        <value_source>FIELD</value_source>
        <value_field>asset_json</value_field>
        <value_type>JSON</value_type>
        <skip_if_null>N</skip_if_null>
      </mapping>
    </mappings>
    <group_by_fields>
      <group_by_field>item_id</group_by_field>
    </group_by_fields>
    <distribute>N</distribute>
    <copies>1</copies>
    <GUI><xloc>1280</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform>
    <type>TextFileOutput</type>
    <name>Write STAC item</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}/stac-item</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>item_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>1520</xloc><yloc>120</yloc></GUI>
    <partitioning><method>none</method><schema_name/></partitioning>
    <attributes/>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
