Skip to content

Instantly share code, notes, and snippets.

@seth-shaw-unlv
Created March 26, 2020 15:35
Show Gist options
  • Save seth-shaw-unlv/79147b82513b2b9b9bb25160215d90d7 to your computer and use it in GitHub Desktop.
Save seth-shaw-unlv/79147b82513b2b9b9bb25160215d90d7 to your computer and use it in GitHub Desktop.
Example migration using a parent child relationship based on parents using a base ID (e.g. 'did0001') and children with a padded integer appended with a hyphen (e.g. 'did0001-001' and 'did0001-002').
langcode: en
status: true
dependencies: { }
id: node
label: 'Nodes for paged content'
source:
plugin: csv
path: modules/my_module/metadata/nodes.csv
delimiter: ','
header_row_count: 1
constants:
uid: 1
parent_model: 'Paged Content'
child_model: 'Page'
keys:
- digital_id
column_names:
-
digital_id: 'Digital Identifier'
-
title: Title
-
description: Description
-
part_of: 'ArchivesSpace Source Reference ID'
process:
uid: constants/uid
field_digital_id: digital_id
title:
plugin: callback
callable: utf8_encode
source: title
body/format:
plugin: default_value
default_value: full_html
body/value:
plugin: callback
callable: utf8_encode
source: description
temp_archival_object_parent:
-
plugin: skip_on_empty
method: process
source: part_of
-
plugin: entity_lookup
value_key: field_as_ref_id
bundle_key: type
bundle: archival_object
entity_type: node
ignore_case: true
temp_digital_object_parent:
-
plugin: skip_on_regex
method: process
not_equals: true
value: '|-|'
source: digital_id
-
plugin: str_replace
regex: true
search: '/-.*/i'
replace: ''
-
plugin: entity_lookup
value_key: field_digital_id
bundle_key: type
bundle: dc_object
entity_type: node
ignore_case: true
field_member_of:
-
plugin: get
source:
- '@temp_archival_object_parent'
- '@temp_digital_object_parent'
-
plugin: flatten
field_weight:
-
plugin: skip_on_regex
method: process
not_equals: true
value: '|-|'
source: digital_id
-
plugin: str_replace
regex: true
search: '/.*-/i'
replace: ''
-
plugin: callback
callable: intval
temp_parent_model:
-
plugin: skip_on_regex
method: process
not_equals: true
value: '|-|'
source: digital_id
-
plugin: entity_lookup
source: constants/parent_model
value_key: name
bundle_key: vid
bundle: islandora_models
entity_type: taxonomy_term
ignore_case: true
temp_parent_model:
-
plugin: skip_on_regex
method: process
not_equals: false
value: '|-|'
source: digital_id
-
plugin: entity_lookup
source: constants/child_model
value_key: name
bundle_key: vid
bundle: islandora_models
entity_type: taxonomy_term
ignore_case: true
field_model:
-
plugin: get
source:
- '@temp_parent_model'
- '@temp_child_model'
-
plugin: flatten
destination:
plugin: 'entity:node'
default_bundle: islandora_object
migration_dependencies: null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment