SU-HKKU/cardinal_service_profile

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

Summary

Maintainability
Test Coverage
uuid: 103e71ad-e428-44e6-89d1-3eac01fdfae4
langcode: en
status: false
dependencies: {  }
id: cs_events_importer
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: stanford_events
label: 'CS Opportunity Events importer'
source:
  track_changes: true
  plugin: url
  data_fetcher_plugin: http
  urls:
    - 'https://events-legacy.stanford.edu/xml/drupal/v2.php?category=11'
  data_parser_plugin: simple_xml
  item_selector: /EventList/Event
  orphan_action: delete
  fields:
    -
      name: guid
      label: GUID
      selector: guid
    -
      name: event_id
      label: 'Event ID'
      selector: eventID
    -
      name: title
      label: 'Event Title'
      selector: title
    -
      name: body
      label: Description
      selector: description
    -
      name: event_start
      label: 'Event start'
      selector: isoEventDate
    -
      name: event_end
      label: 'Event end'
      selector: isoEventEndDate
    -
      name: link
      label: 'Event Link'
      selector: link
    -
      name: audience
      label: 'Event Audience'
      selector: audiences
    -
      name: categories
      label: Categories
      selector: categories
    -
      name: location
      label: Location
      selector: locationText
    -
      name: map_link
      label: 'Map Link'
      selector: mapUrl
    -
      name: event_sponsor
      label: Sponsor
      selector: sponsor
    -
      name: contact_email
      label: 'Contact Email'
      selector: contactEmail
    -
      name: contact_phone
      label: 'Contact Phone'
      selector: contactPhone
    -
      name: image
      label: Image
      selector: imageUrl
    -
      name: event_status
      label: 'Event Status'
      selector: eventStatus
  ids:
    event_id:
      type: string
    event_start:
      type: string
    event_end:
      type: string
  constants:
    status: 1
    type: su_opportunity
    stanford_html: stanford_html
    stanford_minimal_html: stanford_minimal_html
    map_title: 'Open in map'
    image_path: 'public://events/'
    image_alt: ''
    link_text: 'Learn More'
process:
  canceled:
    plugin: skip_on_value
    source: event_status
    method: row
    value: CANCELED
  status: constants/status
  type: constants/type
  title: title
  body/value: body
  body/format: constants/stanford_html
  su_opp_contact_email: contact_email
  su_opp_contact_phone: contact_phone
  su_opp_sponsor:
    -
      plugin: explode
      source: event_sponsor
      delimiter: ', '
      limit: 100
    -
      plugin: callback
      callable: trim
    -
      plugin: entity_generate
      entity_type: taxonomy_term
      bundle_key: vid
      bundle: su_opportunity_sponsor
      value_key: name
      ignore_case: true
  su_opp_learn_more/uri: link
  su_opp_learn_more/title: constants/link_text
  su_opp_solo_url/uri: link
  su_opp_solo_url/title: constants/link_text
  su_opp_duration/value:
    -
      plugin: format_date
      source: event_start
      from_format: 'Y-m-d H:i:s O'
      to_format: 'Y-m-d\TH:i:s'
      to_timezone: UTC
  su_opp_duration/end_value:
    -
      plugin: format_date
      source: event_end
      from_format: 'Y-m-d H:i:s O'
      to_format: 'Y-m-d\TH:i:s'
      to_timezone: UTC
  su_opp_application_deadline:
    plugin: format_date
    source: event_start
    from_format: 'Y-m-d H:i:s O'
    to_format: 'Y-m-d\TH:i:s'
    to_timezone: UTC
  su_opp_event_date: '@su_opp_application_deadline'
  su_opp_service_theme:
    -
      plugin: str_replace
      source: categories
      search: ', '
      replace: ;
    -
      plugin: str_replace
      source: categories
      search:
        - Arts
        - Education
        - Engineering
        - 'Law & Justice'
        - 'Environment / Sustainability'
        - 'Health / Wellness'
        - 'Public Service'
      replace:
        - 'Arts & Media'
        - 'Education & Youth Development'
        - 'Technology & Engineering'
        - 'Law, Policy & Justice'
        - 'Environmental Sustainability'
        - Health
    -
      plugin: explode
      delimiter: ;
    -
      plugin: callback
      callable: trim
    -
      plugin: entity_lookup
      entity_type: taxonomy_term
      bundle_key: vid
      bundle: su_opportunity_service_theme
      value_key: name
      ignore_case: true
  su_opp_open_to:
    -
      plugin: str_replace
      source: audience
      search:
        - Students
        - 'General Public'
      replace:
        - 'Undergraduates, Graduate Students'
        - 'General Public, Graduate Students, Undergraduates, Co-term, Faculty/Staff'
    -
      plugin: explode
      delimiter: ','
    -
      plugin: callback
      callable: trim
    -
      plugin: entity_generate
      access_check: false
      entity_type: taxonomy_term
      bundle_key: vid
      bundle: su_opportunity_open_to
      value_key: name
      ignore_case: true
    -
      plugin: deduplicate_array
  su_opp_type:
    -
      plugin: default_value
      default_value: 'Event / Workshop'
    -
      plugin: entity_lookup
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_type
      entity_type: taxonomy_term
      ignore_case: true
  image_file:
    -
      plugin: skip_on_empty
      method: process
      source: image
    -
      plugin: file_import
      destination: constants/image_path
      id_only: true
      reuse: true
  su_opp_image/target_id:
    -
      plugin: skip_on_empty
      method: process
      source: image
    -
      plugin: skip_on_empty
      method: process
      source: '@image_file'
    -
      plugin: entity_generate
      source: title
      value_key: name
      bundle_key: bundle
      bundle: image
      entity_type: media
      ignore_case: true
      values:
        field_media_image/target_id: '@image_file'
        field_media_image/alt: constants/image_alt
destination:
  plugin: 'entity:node'
  overwrite_properties:
    - type
    - title
    - body/value
    - body/format
    - su_opp_contact_email
    - su_opp_contact_phone
    - su_opp_sponsor
    - su_opp_learn_more/uri
    - su_opp_learn_more/title
    - su_opp_solo_url/uri
    - su_opp_solo_url/title
    - su_opp_duration/value
    - su_opp_duration/end_value
    - su_opp_application_deadline
    - su_opp_event_date
    - su_opp_service_theme
    - su_opp_open_to
    - su_opp_type
    - su_opp_image/target_id
migration_dependencies: {  }