Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/tagged-foxml-…
Browse files Browse the repository at this point in the history
…migrations
  • Loading branch information
adam-vessey committed Sep 16, 2024
2 parents af00649 + abd5010 commit a94ac05
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 18 deletions.
122 changes: 110 additions & 12 deletions modules/dgi_migrate_foxml_standard_mods/migrations/dgis_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ destination:
#translations: true
validate: &validate true
process:
_unspecified_term:
- plugin: default_value
default_value: 'Unspecified'
_node_foxml_parsed:
- plugin: dgi_migrate.load_entity
source: fid
Expand Down Expand Up @@ -239,6 +242,9 @@ process:
- '@_sequence_number'
- '@_constituent_sequence'
- plugin: null_coalesce
# Prevent leading zeroes from crashing the migration.
- plugin: callback
callable: intval
- plugin: skip_on_empty
method: process
_mods_xpath:
Expand All @@ -257,6 +263,7 @@ process:
- plugin: dgi_migrate.process.xml.xpath
namespaces:
mods: 'http://www.loc.gov/mods/v3'
etd: 'http://www.ndltd.org/standards/metadata/etdms/1.0'
xsi: 'http://www.w3.org/2001/XMLSchema-instance'
xlink: 'http://www.w3.org/1999/xlink'
_mods_node:
Expand Down Expand Up @@ -1477,7 +1484,7 @@ process:
- plugin: multiple_values
- plugin: dgi_migrate.subproperty
property: nodeValue
field_recording_catalog_language:
field_record_cataloging_language:
- << : *nested_mods_node
query: 'mods:languageOfCataloging'
- plugin: callback
Expand Down Expand Up @@ -1727,11 +1734,14 @@ process:
default_value: genre
<<: *generic_term_after
- <<: *generic_term_extract
_resource_type:
_resource_type_query:
- << : *base_mods_node
query: 'mods:typeOfResource'
- plugin: callback
callable: iterator_to_array
_resource_type:
- plugin: get
source: '@_resource_type_query'
- plugin: skip_on_empty
method: process
- plugin: multiple_values
Expand All @@ -1744,8 +1754,12 @@ process:
<<: *generic_term_after
- <<: *generic_term_extract
_unspecified_resource_type:
- plugin: default_value
default_value: Unspecified
- plugin: get
source: '@_resource_type_query'
- plugin: skip_on_empty
method: process
- plugin: get
source: '@_unspecified_term'
- plugin: gate
use_as_key: '@_resource_type'
valid_keys:
Expand Down Expand Up @@ -2001,7 +2015,7 @@ process:
validate: *validate
field_use_and_reproduction:
- << : *base_mods_node
query: 'mods:accessCondition[@type="use and reproduction"]'
query: 'mods:accessCondition[@type="use and reproduction" or @type="Use and Reproduction"]'
- plugin: callback
callable: iterator_to_array
- plugin: multiple_values
Expand Down Expand Up @@ -2039,11 +2053,14 @@ process:
default_value: degree_names
<<: *generic_term_after
- <<: *generic_term_extract
_degree_level:
_degree_level_query:
- <<: *base_mods_node
query: 'mods:extension/etd:degree/etd:level'
- plugin: callback
callable: iterator_to_array
_degree_level:
- plugin: get
source: '@_degree_level_query'
- plugin: skip_on_empty
method: process
- plugin: multiple_values
Expand All @@ -2056,8 +2073,12 @@ process:
<<: *generic_term_after
- <<: *generic_term_extract
_unspecified_degree_level:
- plugin: default_value
default_value: Unspecified
- plugin: get
source: '@_degree_level_query'
- plugin: skip_on_empty
method: process
- plugin: get
source: '@_unspecified_term'
- plugin: gate
use_as_key: '@_degree_level'
valid_keys:
Expand Down Expand Up @@ -2536,11 +2557,14 @@ process:
- plugin: single_value
- plugin: callback
callable: array_filter
_use_license:
_use_license_query:
- <<: *base_mods_node
query: 'mods:accessCondition[@type="use and reproduction"][@displayLabel="Creative Commons" or @displayLabe="Creative Commons"]'
query: 'mods:accessCondition[@type="use and reproduction" or @type="Use and Reproduction"][@displayLabel="Creative Commons" or @displayLabe="Creative Commons"]'
- plugin: callback
callable: iterator_to_array
_use_license:
- plugin: get
source: '@_use_license_query'
- plugin: skip_on_empty
method: process
- plugin: multiple_values
Expand All @@ -2553,8 +2577,12 @@ process:
<<: *generic_term_after
- <<: *generic_term_extract
_unspecified_use_license:
- plugin: default_value
default_value: Unspecified
- plugin: get
source: '@_use_license_query'
- plugin: skip_on_empty
method: process
- plugin: get
source: '@_unspecified_term'
- plugin: gate
use_as_key: '@_use_license'
valid_keys:
Expand Down Expand Up @@ -2595,6 +2623,76 @@ process:
- '@_use_license'
- '@_unspecified_use_license'
- plugin: flatten
_rights_statement_query:
- <<: *base_mods_node
query: 'mods:accessCondition[@type="rights statement"]'
- plugin: callback
callable: iterator_to_array
_rights_statement:
- plugin: get
source: '@_rights_statement_query'
- plugin: skip_on_empty
method: process
- plugin: multiple_values
- plugin: dgi_migrate.sub_process
process_values: true
values:
_vid:
- plugin: default_value
default_value: rights_statements
<<: *generic_term_after
- <<: *generic_term_extract
- plugin: single_value
- plugin: callback
callable: array_filter
- plugin: null_coalesce
_unspecified_rights_statement:
- plugin: get
source: '@_rights_statement_query'
- plugin: skip_on_empty
method: process
- plugin: get
source: '@_unspecified_term'
- plugin: gate
use_as_key: '@_rights_statement'
valid_keys:
- null
key_direction: unlock
- plugin: dgi_migrate.sub_process
process_values: true
values:
_vid:
- plugin: default_value
default_value: rights_statements
_auth_value_uri:
- plugin: default_value
default_value: ''
_auth_source:
- plugin: default_value
default_value: ''
_value:
- plugin: get
source: parent_value
actual:
- plugin: get
source:
- '@_auth_source'
- '@_auth_value_uri'
- '@_value'
# XXX: Needs to be provided wherever this is used, corresponding
# to the vocab in which to do the things.
- '@_vid'
- plugin: flatten
- plugin: migration_lookup
migration: dgis_stub_terms_generic
stub_id: dgis_stub_terms_generic
- <<: *generic_term_extract
field_rights_statement:
- plugin: get
source:
- '@_rights_statement'
- '@_unspecified_rights_statement'
- plugin: null_coalesce
nid:
- plugin: migration_lookup
source: '@field_pid'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function _dgi_migrate_foxml_standard_mods_xslt_dgis_nodes_migration_alterations(
- plugin: dgi_migrate.process.xml.xpath
namespaces:
mods: 'http://www.loc.gov/mods/v3'
etd: 'http://www.ndltd.org/standards/metadata/etdms/1.0'
xsi: 'http://www.w3.org/2001/XMLSchema-instance'
xlink: 'http://www.w3.org/1999/xlink'
EOI
Expand Down
29 changes: 23 additions & 6 deletions src/Plugin/migrate/process/AssembleDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* The output is handled thus:
* - If a range_start, or a range_end, or both, are provided and not empty, an
* EDTF-style date range will be assembled, and any results from single_date
* will be ignored.
* will be combined.
* - If neither a range_start nor a range_end are provided or are empty, but the
* single_date is provided and has a value, it is returned.
* - If no provided property has a value, null will be returned.
Expand All @@ -37,7 +37,8 @@
* @code
* process:
* - plugin: dgi_migrate.process.assemble_date
* single_date: 2001-01-01
* single_date:
* - 2001-01-01
* range_start: 2002-02-02
* range_end: 2003-03-03
* indicate_open: false
Expand Down Expand Up @@ -108,11 +109,27 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$return_value = $this->getDateRange($value, $migrate_executable, $row);
if (!$return_value) {
$return_value = $this->getValues ? $row->get($this->dates['single_date']) : $this->dates['single_date'];
$return_dates = [];

$date_range = $this->getDateRange($value, $migrate_executable, $row);
if ($date_range !== NULL) {
$return_dates[] = $date_range;
}

// Get single dates and add them to return_dates.
$single_dates = $this->getValues ? $row->get($this->dates['single_date']) : $this->dates['single_date'];
if (is_array($single_dates)) {
$return_dates = array_merge($return_dates, $single_dates);
}
elseif ($single_dates !== NULL) {
$return_dates[] = $single_dates;
}
return $return_value;

if (count($return_dates) === 1) {
return reset($return_dates);
}

return $return_dates;
}

/**
Expand Down

0 comments on commit a94ac05

Please sign in to comment.