id: d7_node_materiau
label: Node Materiau
migration_group: d7_materio
audit: true
migration_tags:
  - Drupal 7
  - Content
  - Materio

source:
  plugin: d7_node_materiau
  node_type: materiau
  batch_size: 500
  # high_water_property:
  #   name: changed
  #   alias: n

destination:
  plugin: entity:node


process:
  # nid: nid
  type:
    plugin: default_value
    default_value: materiau
  title: title
  created: created
  changed: changed

  uid:
    plugin: migration_lookup
    migration: d7_users
    source: uid

  field_short_description: field_nature_titre
  field_migration:
    plugin: default_value
    default_value: 'migration_imported'
  body:
    plugin: iterator
    source: field_description
    process:
      value: value
      format:
        plugin: default_value
        default_value: wysiwyg
  langcode: language
  field_memo: field_memo
  field_workflow:
    -
      plugin: default_value
      source: workflow
      default_value: 2
    # -
    #   plugin: debug
    #   source: workflow
    #   label: workflow_debug
    -
      plugin: static_map
      default_value: 2
      map:
        1: "workflow_creation"
        2: "workflow_hidden"
        3: "workflow_visible"
        4: "workflow_imported"
        5: "workflow_edited"

  field_thesaurus:
    plugin: migration_lookup
    migration: d7_taxonomy_term_thesaurus
    source: field_onthologie
    no_stub: true
  field_tags:
    plugin: migration_lookup
    migration: d7_taxonomy_term_tags
    source: field_tags_libres
    no_stub: true
  field_manufacturer:
    plugin: migration_lookup
    migration: d7_taxonomy_term_company
    source: field_company_fab
    no_stub: true
  field_distributor:
    plugin: migration_lookup
    migration: d7_taxonomy_term_company
    source: field_company_distrib
    no_stub: true
  field_video:
    plugin: iterator
    source: field_video_filter
    process:
      value: url
  field_linked_materials:
    -
      plugin: skip_on_empty
      method: process
      source: linked_materials
    -
      plugin: migration_lookup
      migration: d7_node_materiau
      no_stub: true
  field_linked_articles:
    -
      plugin: skip_on_empty
      method: process
      source: linked_articles
    -
      plugin: migration_lookup
      migration: d7_node_article
      # no_stub: true
  field_materiau_images:
      plugin: iterator
      source: field_materiau_image
      process:
        target_id:
          plugin: migration_lookup
          migration: d7_allpublicfiles
          source: fid
          no_stub: true
        alt: alt
        title: title
        height: height
        width: width
  field_attachments:
      plugin: iterator
      source: field_attachments
      process:
        target_id:
          plugin: migration_lookup
          migration: d7_allpublicfiles
          source: fid
          no_stub: true
        # there is no description field filled
        description: description
  field_famille: field_famille
  field_index: field_identifiant
  field_reference: field_reference_materio
  # just archives
  field_localisation_old: field_localisation
  # custom module rebuilded
  field_samples:
    plugin: iterator
    source: field_location
    process:
      location: location
      target_id:
        plugin: migration_lookup
        migration: d7_taxonomy_term_showroom
        source: showroom_tid
        no_stub: true


migration_dependencies:
  required:
    - d7_allpublicfiles
    - d7_users
    - d7_taxonomy_term_thesaurus
    - d7_taxonomy_term_tags
    - d7_taxonomy_term_company
    - d7_taxonomy_term_showroom
  # optional:
  #   - d7_node_article
