langcode: en
status: true
dependencies:
  enforced:
    module:
      - farm_input
      - farm_migrate
id: farm_migrate_log_input
label: 'Logs (Inputs)'
migration_group: farm_migrate_log
migration_tags:
  - 'Drupal 7'
  - 'farmOS 1.x'
class: Drupal\migrate\Plugin\Migration
field_plugin_method: null
cck_plugin_method: null
source:
  plugin: d7_farm_log
  bundle: farm_input
destination:
  plugin: 'entity:log'
process:
  # Hard-code the bundle.
  type:
    plugin: default_value
    default_value: input
  # Maintain the log ID.
  id:
    plugin: get
    source: id
  # Input specific fields.
  lot_number:
    plugin: get
    source: field_farm_lot_number
  method:
    plugin: get
    source: field_farm_input_method
  purchase_date:
    plugin: get
    source: field_farm_date_purchase
  source:
    plugin: get
    source: field_farm_input_source
  # Save the material_type in a pseudo field.
  _material_type:
    plugin: sub_process
    source: field_farm_material
    process:
      target_id:
        plugin: migration_lookup
        migration: farm_migrate_taxonomy_material_type
        source: tid
  # Migrate the field_farm_material term reference into a material quantity.
  _material_quantities:
    # Build the quantity.
    plugin: create_quantity
    source: '@_material_type'
    default_values:
      type: 'material'
    values:
      uid: '@uid'
      created: '@created'
      changed: '@changed'
      material_type: target_id
  # Merge the material quantity with other log quantities.
  quantity:
    plugin: merge
    source:
      - '@_log_quantities'
      - '@_material_quantities'
migration_dependencies:
  required:
    - farm_migrate_taxonomy_material_type
  optional: {  }
