langcode: en
status: true
dependencies:
  enforced:
    module:
      - farm_migrate
id: farm_migrate_log
label: 'farmOS 1.x Log Migration'
description: 'Migrates logs from farmOS 1.x to farmOS 2.x'
source_type: 'farmOS 1.x'
module: null
shared_configuration:
  destination:
    validate: true
  process:
    name:
      plugin: get
      source: name
    uid:
      -
        plugin: migration_lookup
        migration: farm_migrate_user
        source: uid
        no_stub: true
      -
        plugin: default_value
        default_value: 1
    timestamp:
      plugin: get
      source: timestamp
    created:
      plugin: get
      source: created
    changed:
      plugin: get
      source: changed
    status:
      plugin: static_map
      source: done
      map:
        0: pending
        1: done
    notes:
      plugin: sub_process
      source: field_farm_notes
      process:
        value:
          plugin: get
          source: value
        format:
          plugin: static_map
          source: format
          map:
            farm_format: default
            plain_text: plain_text
          default_value: default
    data:
      plugin: get
      source: field_farm_data
    asset:
      plugin: sub_process
      source: field_farm_asset
      process:
        target_id:
          plugin: farm_migration_group_lookup
          migration_group: farm_migrate_asset
          source: target_id
    location:
      plugin: sub_process
      source: field_farm_area
      process:
        target_id:
          plugin: farm_migration_group_lookup
          migration_group: farm_migrate_area
          source: tid
    geometry:
      plugin: geofield_d7d8
      source: field_farm_geofield
    is_movement:
      plugin: get
      source: is_movement
    # Equipment used field.
    # This is added by the farm_equipment_field module in farmOS 1.x, and the
    # farm_equipment module in farmOS 2.x.
    equipment:
      plugin: sub_process
      source: field_farm_equipment
      process:
        target_id:
          plugin: migration_lookup
          migration: farm_migrate_asset_equipment
          source: target_id
    # Group reference field.
    # This is added by the farm_group module in farmOS, which is required in
    # 1.x and optional in 2.x.
    group:
      plugin: sub_process
      source: log_groups
      process:
        target_id:
          plugin: migration_lookup
          migration: farm_migrate_asset_group
          source: target_id
    is_group_assignment:
      plugin: get
      source: is_group_assignment
    category:
      plugin: sub_process
      source: field_farm_log_category
      process:
        target_id:
          plugin: migration_lookup
          migration: farm_migrate_taxonomy_log_category
          source: tid
    flag:
      plugin: get
      source: field_farm_flags
    owner:
      plugin: sub_process
      source: field_farm_log_owner
      process:
        target_id:
          plugin: migration_lookup
          migration: farm_migrate_user
          source: target_id
          no_stub: true
    file:
      plugin: sub_process
      source: field_farm_files
      process:
        target_id:
          plugin: migration_lookup
          migration:
            - farm_migrate_file
            - farm_migrate_file_private
          no_stub: true
          source: fid
        display: display
        description: description
    image:
      plugin: sub_process
      source: field_farm_images
      process:
        target_id:
          plugin: migration_lookup
          migration:
            - farm_migrate_file
            - farm_migrate_file_private
          no_stub: true
          source: fid
        alt: alt
        title: title
        width: width
        height: height
    # Save quantities as a pseudo field and let log types migrate themselves.
    _log_quantities:
      -
        plugin: farm_migration_group_lookup
        migration_group: farm_migrate_quantity
        source: log_quantities
        no_stub: true
      -
        plugin: skip_on_empty
        method: process
      -
        plugin: sub_process
        process:
          target_id: '0'
          target_revision_id: '1'
    quick:
      plugin: get
      source: quick
  migration_dependencies:
    required:
      - farm_migrate_file
      - farm_migrate_file_private
      - farm_migrate_user
      - farm_migrate_taxonomy_log_category
      - farm_migrate_quantity_standard
    optional:
      - farm_migrate_asset_equipment
      - farm_migrate_asset_group
