SU-HKKU/cardinal_service_profile

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

Summary

Maintainability
Test Coverage
uuid: 18fe55a6-a1f6-47c9-b079-992ef831c99b
langcode: en
status: true
dependencies: {  }
id: solo_opportunities
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: {  }
migration_group: opportunities
label: 'SOLO Opportunities'
source:
  track_changes: true
  plugin: url
  data_fetcher_plugin: file
  data_parser_plugin: simple_xml
  urls:
    - 'https://solo.stanford.edu/data/opportunities.xml?type=236'
  constants:
    status: 1
    type: su_opportunity
    basic_html: stanford_html
    minimal_html: stanford_minimal_html
    image_destination: 'public://media/image/solo/'
    apply_link_title: Apply
    learn_more_link_title: 'Learn More'
    image_alt: ''
  item_selector: /OPPORTUNITIES/OPPORTUNITY
  fields:
    -
      name: id
      label: ID
      selector: ID
    -
      name: title
      label: Title
      selector: TITLE
    -
      name: url
      label: URL
      selector: URL
    -
      name: submission_open
      label: 'Submission Open Date'
      selector: SUBMISSIONS_OPEN
    -
      name: application_deadline
      label: 'Application Deadline'
      selector: APPLICATION_DEADLINE
    -
      name: start
      label: Start
      selector: DURATION/START
    -
      name: end
      label: End
      selector: DURATION/END
    -
      name: sponsor
      label: Sponsor
      selector: SPONSOR
    -
      name: teaser
      label: Teaser
      selector: TEASER
    -
      name: body
      label: Body
      selector: DESCRIPTION
    -
      name: image
      label: Image
      selector: IMAGE
    -
      name: eligibility
      label: Eligibility
      selector: ELIGIBILITY
    -
      name: type
      label: Type
      selector: TYPE
    -
      name: time_of_year
      label: 'Time of the Year'
      selector: TIME_OF_YEAR
    -
      name: open_to
      label: 'Open To'
      selector: OPEN_TO
    -
      name: location
      label: Location
      selector: LOCATION
    -
      name: contact_name
      label: 'Contact Name'
      selector: CONTACT_NAME
    -
      name: contact_email
      label: 'Contact Email'
      selector: CONTACT_EMAIL
    -
      name: contact_phone
      label: 'Contact Phone Number'
      selector: CONTACT_PHONE
    -
      name: learn_more
      label: 'Learn More Link'
      selector: LEARN_MORE
    -
      name: service_theme
      label: 'Service Theme'
      selector: SERVICE_THEME
    -
      name: dimension
      label: 'CS Dimension'
      selector: CARDINAL_SERVICE
  ids:
    id:
      type: string
process:
  skip:
    -
      plugin: str_replace
      source: sponsor
      search:
        - '/^.*(Bill Lane Center).*/'
        - '/^.*(Freeman Spogli).*/'
        - '/^.*(Stanford Global Studies).*/'
        - '/^.*(King Center on Global Development).*/'
        - '/^.*(Schneider Summer Fellowships).*/'
        - '/^.*(Seed Internships).*/'
        - '/^.*(Stanford Arts).*/'
        - '/^.*(Stanford Energy Internships in California and the West).*/'
      replace: skip
      regex: true
    -
      plugin: skip_on_value
      method: row
      value: skip
  title:
    -
      plugin: str_replace
      source: title
      regex: true
      search: '/^Schneider Summer Fellowships:*?$/'
      replace: ''
    -
      plugin: skip_on_empty
      method: row
  revision_translation_affected:
    -
      plugin: default_value
      default_value: 1
  revision_timestamp:
    plugin: callback
    callable: _stanford_migrate_get_time
  status: constants/status
  type: constants/type
  body/value: body
  body/format: constants/basic_html
  su_opp_summary/value: teaser
  su_opp_summary/format: constants/minimal_html
  su_opp_contact_email: contact_email
  su_opp_contact_name: contact_name
  su_opp_contact_phone:
    -
      plugin: skip_on_empty
      method: process
      source: contact_phone
    -
      plugin: callback
      callable: strip_tags
  su_opp_eligibility/value: eligibility
  su_opp_eligibility/format: constants/basic_html
  su_opp_solo_url/uri: url
  su_opp_dimension:
    source: dimension
    plugin: entity_generate
    value_key: name
    bundle_key: vid
    bundle: su_opportunity_dimension
    entity_type: taxonomy_term
    ignore_case: true
  su_opp_service_theme:
    -
      plugin: skip_on_empty
      source: service_theme
      method: process
    -
      plugin: str_replace
      search: ', '
      replace: ;
    -
      plugin: str_replace
      search: 'Law & Justice'
      replace: 'Law, Policy & Justice'
    -
      plugin: explode
      delimiter: ;
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_service_theme
      entity_type: taxonomy_term
      ignore_case: true
  su_opp_solo_url/title:
    -
      plugin: skip_on_empty
      source: url
      method: process
    -
      plugin: callback
      source: constants/apply_link_title
      callable: ucfirst
  su_opp_learn_more/uri: learn_more
  su_opp_learn_more/title:
    -
      plugin: skip_on_empty
      source: learn_more
      method: process
    -
      plugin: callback
      source: constants/learn_more_link_title
      callable: ucwords
  su_opp_location:
    -
      plugin: skip_on_empty
      source: location
      method: process
    -
      plugin: str_replace
      search:
        - 'East Palo Alto'
        - 'Other Bay Area'
        - 'Redwood City'
      replace: 'Bay Area'
    -
      plugin: str_replace
      search:
        - 'United States of America (Stanford on-campus)'
        - 'Stanford (on-campus)'
        - 'United States of America (Stanford off-campus)'
      replace:
        - Stanford
        - Stanford
        - 'United States'
    -
      plugin: explode
      delimiter: ', '
    -
      plugin: str_replace
      search: '/^(?!.*(Stanford|United States|Bay Area)).*/'
      replace: International
      regex: true
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_location
      entity_type: taxonomy_term
      ignore_case: true
  su_opp_open_to:
    -
      plugin: explode
      source: open_to
      delimiter: ', '
    -
      plugin: str_replace
      search:
        - Freshman
        - Sophomore
        - Junior
        - Senior
        - 'Master''s'
        - PhD
        - Postgraduate
      replace:
        - Undergraduates
        - Undergraduates
        - Undergraduates
        - Undergraduates
        - 'Graduate Students'
        - 'Graduate Students'
        - 'Graduate Students'
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_open_to
      entity_type: taxonomy_term
      ignore_case: true
    -
      plugin: deduplicate_array
  su_opp_time_year:
    -
      plugin: explode
      source: time_of_year
      delimiter: ', '
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_time
      entity_type: taxonomy_term
      ignore_case: true
  image_file:
    -
      plugin: skip_on_empty
      method: process
      source: image
    -
      plugin: file_import
      destination: constants/image_destination
      id_only: true
      reuse: true
  su_opp_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/image_alt
        field_media_image/title: constants/image_alt
  su_opp_submissions_open:
    -
      plugin: skip_on_empty
      method: process
      source: submission_open
    -
      plugin: format_date
      from_format: U
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: America/Los_Angeles
      to_timezone: UTC
      settings:
        validate_format: false
  su_opp_application_deadline:
    -
      plugin: skip_on_empty
      method: process
      source: application_deadline
    -
      plugin: format_date
      from_format: U
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: America/Los_Angeles
      to_timezone: UTC
      settings:
        validate_format: false
    -
      plugin: skip_on_equal
      value: '@su_opp_submissions_open'
      method: process
    -
      plugin: skip_on_time_compare
      compare: '>'
      value: 'now +2years'
      method: process
  su_opp_deadline_time:
    -
      plugin: default_value
      default_value:
        - Autumn
        - Winter
        - Spring
        - Summer
    -
      plugin: entity_lookup
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_deadline
      entity_type: taxonomy_term
      ignore_case: true
  su_opp_duration/value:
    -
      plugin: skip_on_empty
      method: process
      source: start
    -
      plugin: format_date
      from_format: U
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: America/Los_Angeles
      to_timezone: UTC
      settings:
        validate_format: false
  su_opp_duration/end_value:
    -
      plugin: skip_on_empty
      method: process
      source: start
    -
      plugin: format_date
      from_format: U
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: America/Los_Angeles
      to_timezone: UTC
      settings:
        validate_format: false
    -
      plugin: default_value
      default_value: '@su_opp_duration/value'
  su_opp_sponsor:
    -
      plugin: skip_on_empty
      method: process
      source: sponsor
    -
      plugin: explode
      delimiter: ', '
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: su_opportunity_sponsor
      entity_type: taxonomy_term
      ignore_case: true
destination:
  plugin: 'entity:node'
  overwrite_properties:
    - title
    - type
    - body/summary
    - body/value
    - body/format
    - su_opp_contact_email
    - su_opp_contact_name
    - su_opp_contact_phone
    - su_opp_eligibility/value
    - su_opp_eligibility/format
    - su_opp_solo_url/uri
    - su_opp_dimension
    - su_opp_service_theme
    - su_opp_solo_url/title
    - su_opp_learn_more/uri
    - su_opp_learn_more/title
    - su_opp_location
    - su_opp_open_to
    - su_opp_time_year
    - su_opp_image/target_id
    - su_opp_submissions_open
    - su_opp_application_deadline
    - su_opp_deadline_time
    - su_opp_duration/value
    - su_opp_duration/end_value
    - su_opp_sponsor
    - su_opp_summary/value
    - su_opp_summary/format
migration_dependencies:
  required: {  }