SU-HKKU/cardinal_service_profile

View on GitHub
config/sync/migrate_plus.migration.stanford_publications.yml

Summary

Maintainability
Test Coverage
uuid: 1707c850-9841-44fc-bdcd-53381c6d6d7c
langcode: en
status: true
dependencies:
  module:
    - migrate_source_csv
    - stanford_migrate
id: stanford_publications
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: {  }
migration_group: default
label: 'Publications Importer (experimental)'
source:
  plugin: csv
  csv_help:
    - '<strong>CAUTION:</strong> Be sure to visit our <a href="https://userguide.sites.stanford.edu/tour/publications/importer">user-guide</a> to learn more about working with this CSV template.'
  path: /tmp/foo.csv
  ids:
    - id
  constants:
    status: 1
    basic_html: stanford_html
    minimal_html: stanford_minimal_html
    alt: ''
    file_destination: 'public://media/publications/'
  fields:
    -
      name: id
      label: ID
      selector: id
    -
      name: citationType
      label: 'Citation Type'
      selector: citationType
    -
      name: title
      label: Title
      selector: title
    -
      name: subtitle
      label: Subtitle
      selector: subtitle
    -
      name: authors
      label: Author(s)
      selector: authors
    -
      name: pubPlace
      label: 'Publication Place'
      selector: pubPlace
    -
      name: publisher
      label: Publisher
      selector: publisher
    -
      name: volume
      label: Volume
      selector: volume
    -
      name: issue
      label: Issue
      selector: issue
    -
      name: edition
      label: Edition
      selector: edition
    -
      name: page
      label: Page(s)
      selector: page
    -
      name: month
      label: Month
      selector: month
    -
      name: day
      label: Day
      selector: day
    -
      name: year
      label: Year
      selector: year
    -
      name: doi
      label: DOI
      selector: doi
    -
      name: url
      label: 'External Source URL'
      selector: url
    -
      name: image
      label: 'Image URL'
      selector: image
    -
      name: topics
      label: 'Topic Terms'
      selector: topics
    -
      name: body
      label: 'Text Body'
      selector: body
    -
      name: ctaUrl
      label: 'CTA Button URL'
      selector: ctaUrl
    -
      name: ctaTitle
      label: 'CTA Button Title'
      selector: ctaTitle
    -
      name: genre
      label: Genre
      selector: genre
process:
  skip:
    plugin: skip_on_empty
    method: row
    source: id
  title: title
  status:
    plugin: default_value
    source: published
    default_value: 1
  su_publication_cta/uri: ctaUrl
  su_publication_cta/title: ctaTitle
  su_publication_topics:
    -
      plugin: skip_on_empty
      source: topics
      method: process
    -
      plugin: explode
      delimiter: '|'
    -
      plugin: entity_generate
      entity_type: taxonomy_term
      bundle_key: vid
      bundle: stanford_publication_topics
      value_key: name
      ignore_case: true
  su_publication_text_area:
    -
      plugin: skip_on_empty
      source: body
      method: process
    -
      plugin: entity_revision_generate
      entity_type: paragraph
      bundle_key: type
      bundle: stanford_wysiwyg
      value_key: su_wysiwyg_text
      ignore_case: true
      values:
        su_wysiwyg_text/value: body
        su_wysiwyg_text/format: constants/basic_html
  text_area_target_id:
    -
      plugin: skip_on_empty
      source: '@su_publication_text_area'
      method: process
    -
      plugin: extract
      index:
        - 0
  text_area_target_revision_id:
    -
      plugin: skip_on_empty
      source: '@su_publication_text_area'
      method: process
    -
      plugin: extract
      index:
        - 1
  su_publication_components:
    -
      plugin: skip_on_empty
      source: '@text_area_target_id'
      method: process
    -
      plugin: entity_revision_generate
      entity_type: paragraph_row
      bundle_key: type
      bundle: su_pub_rows
      value_key: su_pubs_components
      ignore_case: true
      values:
        su_pubs_components/target_id: '@text_area_target_id'
        su_pubs_components/target_revision_id: '@text_area_target_revision_id'
  citation_url:
    plugin: url_check
    source: url
    method: process
  citation_authors:
    -
      plugin: skip_on_empty
      source: authors
      method: process
    -
      plugin: explode
      delimiter: '|'
    -
      plugin: name_field
  citation_type:
    -
      plugin: skip_on_empty
      source: citationType
      method: process
    -
      plugin: str_replace
      case_insensitive: true
      search:
        - 'Article Newspaper/Magazine'
        - Book
        - 'Journal Article'
        - Other
        - Thesis
      replace:
        - su_article_newspaper
        - su_book
        - su_article_journal
        - su_other
        - su_thesis
  su_publication_citation:
    -
      plugin: gate
      use_as_key: '@citation_type'
      key_direction: unlock
      valid_keys:
        - su_article_newspaper
        - su_book
        - su_article_journal
        - su_other
        - su_thesis
    -
      plugin: entity_generate_no_lookup
      source: title
      entity_type: citation
      bundle_key: type
      bundle: su_other
      value_key: title
      ignore_case: true
      values:
        title: title
        type: '@citation_type'
        su_day: day
        su_month: month
        su_year: year
        su_doi: doi
        su_edition: edition
        su_genre: genre
        su_issue: issue
        su_page: page
        su_publisher_place: pubPlace
        su_publisher: publisher
        su_subtitle: subtitle
        su_volume: volume
        su_url: '@citation_url'
        su_author: '@citation_authors'
  image_file:
    -
      plugin: skip_on_empty
      method: process
      source: image
    -
      plugin: image_dimension_skip
      method: process
      width: 10
      height: 10
    -
      plugin: file_import
      destination: constants/file_destination
      id_only: true
      reuse: true
      max_size: 5MB
  su_publication_image/target_id:
    -
      plugin: skip_on_empty
      method: process
      source: '@image_file'
    -
      plugin: entity_generate
      source: '@image_file'
      value_key: field_media_image
      bundle_key: bundle
      bundle: image
      entity_type: media
      ignore_case: true
      values:
        name: '@title'
        field_media_image/target_id: '@image_file'
        field_media_image/alt: constants/alt
destination:
  plugin: 'entity:node'
  default_bundle: stanford_publication
  overwrite_properties:
    - citation_authors
    - citation_type
    - citation_url
    - image_file
    - skip
    - su_publication_citation
    - su_publication_components
    - su_publication_cta/title
    - su_publication_cta/uri
    - su_publication_image/target_id
    - su_publication_text_area
    - su_publication_topics
    - text_area_target_id
    - text_area_target_revision_id
    - text_body
    - title
migration_dependencies:
  required: {  }