id: d7_simplenews_nodes
migration_group: d7_materio
dependencies:
  module:
    - migrate_drupal
    - simplenews
label: Simplenews newsletters nodes
migration_tags:
  - Drupal 7
  - Content
  - Materio

source:
  plugin: d7_simplenews_nodes
  node_type: simplenews
  high_water_property:
    name: changed
    alias: n

destination:
  plugin: entity:node

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

  uid:
    plugin: migration_lookup
    migration: d7_users
    source: uid

  field_migration:
    plugin: default_value
    default_value: 'migration_imported'
  body:
    plugin: iterator
    source: body
    process:
      value: value
      format:
        plugin: default_value
        default_value: wysiwyg
  langcode: language

  field_workflow:
    -
      plugin: default_value
      source: workflow
      default_value: 2
    -
      plugin: static_map
      default_value: 2
      map:
        1: "workflow_creation"
        2: "workflow_hidden"
        3: "workflow_visible"
        4: "workflow_imported"
        5: "workflow_edited"

  # https://www.drupal.org/project/simplenews/issues/3037694
  simplenews_issue/target_id:
    -
      plugin: extract
      source: field_simplenews_term
      index:
        - 0
        - tid
    -
      plugin: static_map
      map:
        6585: "test"
        6374: "ze_daily_materio_"
        6274: "materio_newsletter"
        7881: "companies"
  simplenews_issue/sent_count: snn_sent_subscriber_count
  simplenews_issue/status: snn_status
  simplenews_issue/error_count:
    plugin: default_value
    default_value: 0
  simplenews_issue/subscribers: snn_sent_subscriber_count
  simplenews_issue/handler:
    plugin: default_value
    default_value: simplenews_all

migration_dependencies:
  required:
    - d7_allpublicfiles
    - d7_users
