diff --git a/config/install/migrate_plus.migration.ead_media_to_node.yml b/config/install/migrate_plus.migration.ead_media_to_node.yml index 830859c..ec9ad33 100644 --- a/config/install/migrate_plus.migration.ead_media_to_node.yml +++ b/config/install/migrate_plus.migration.ead_media_to_node.yml @@ -13,9 +13,7 @@ source: - 'http://vocab.getty.edu/page/aat/300026539' Prefix_date_bulk: 'Bulk: ' plugin: media_xml_data - high_water_property: - name: file_changed - alias: fc + track_changes: true namespaces: ead: 'urn:isbn:1-931666-22-9' xlink: 'http://www.w3.org/1999/xlink' diff --git a/src/Plugin/migrate/source/MediaXmlData.php b/src/Plugin/migrate/source/MediaXmlData.php index 4c4e908..bb5b324 100644 --- a/src/Plugin/migrate/source/MediaXmlData.php +++ b/src/Plugin/migrate/source/MediaXmlData.php @@ -39,8 +39,6 @@ class MediaXmlData extends SourcePluginBase implements ContainerFactoryPluginInt * @var array */ protected $parsedData = []; - protected string $eadXmlDir; - const SAVE_BASE_URI = 'private://findingaid'; /** * {@inheritdoc} @@ -49,15 +47,6 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition parent::__construct($configuration, $plugin_id, $plugin_definition, $migration); $this->entityTypeManager = $entity_type_manager; $this->fileSystem = $file_system; - - //handle field uri scheme - $fieldConfig = \Drupal::entityTypeManager() - ->getStorage('field_config') - ->load("media.findingaid.field_media_file"); - - $f_uri_scheme = ($fieldConfig === null) ? 'private' : ($fieldConfig->getSetting('uri_scheme') ?? 'private'); - $f_sub_dir = ($fieldConfig === null) ? 'findingaid' : ($fieldConfig->getSetting('file_directory') ?? 'findingaid'); - $this->eadXmlDir = $f_uri_scheme . '://' . trim($f_sub_dir, '/'); } /** @@ -152,13 +141,6 @@ protected function parseMediaXmlFiles() { //$file_path = $this->fileSystem->realpath($file_uri); $file_changed = $file->getChangedTime(); - // Determine if we should process this media - $should_process = $this->shouldProcessMedia($media, $file_changed); - - if (!$should_process) { - continue; - } - // Check if it's an XML file $mime_type = $file->getMimeType(); if (in_array($mime_type, ['application/xml', 'text/xml']) || @@ -175,43 +157,6 @@ protected function parseMediaXmlFiles() { } } - /** - * Determine if a media entity should be processed. - * - * @param \Drupal\media\Entity\Media $media: media entity - * @param int $file_changed: file changed timestamp. - * - * @return bool: TRUE if should process, FALSE otherwise. - */ - protected function shouldProcessMedia($media, $file_changed) { - // Check if media has an associated node in field_media_of - if ($media->hasField('field_media_of') && !$media->get('field_media_of')->isEmpty()) { - $node_id = $media->get('field_media_of')->target_id; - $node_storage = $this->entityTypeManager->getStorage('node'); - $node = $node_storage->load($node_id); - - if ($node) { - $node_changed = $node->getChangedTime(); - - // Process if file timestamp is greater than node timestamp - // This will trigger a reimport and override the existing node - if ($file_changed > $node_changed) { - return TRUE; - } - - // File hasn't changed since node was last updated, skip - return FALSE; - } - - // Referenced node doesn't exist, should process - return TRUE; - } - - // No associated node (field_media_of is empty) - // Always process to create new node - return TRUE; - } - /** * Parse an XML file and extract data based on configuration. *