Problem/Motivation

As a developer, I want a queue worker that performs the per-item migration — upload to DAM, change the bundle, populate the DAM fields — resolving dynamic metadata through a mapper, so that each media entity is migrated atomically and safely via cron or Drush with metadata intact.

Acceptance Criteria

Metadata Mapper (MigrationMetadataMapper, service acquia_dam_migration_tools.metadata_mapper):

  • Resolves the stored mapping at upload time, reads Drupal field values via getValue() + getMainPropertyName() (single- and multi-value → string arrays), casts to string, drops empty/NULL values, and returns the fields structure
  • getMetadataFields(EntityInterface $media, string $media_type_id); ALT_TEXT_FIELD special-cases the alt-text mapping (getAltTextValues() reading the source field's alt); no static container access

Queue Worker (MediaMigrationQueueWorker):

  • Extends QueueWorkerBase, ID acquia_dam_media_migration, cron = {"time" = 60}, implements ContainerFactoryPluginInterface
  • processItem() — validates payload (media_id, media_type_id); loads media; skips with a log when already migrated (DB check on the asset-id table); loads source file via source_field_name; collects alt/title for field_media_image
  • Uploads via AcquiaDamUploadService::uploadToDam() (W1) passing ['fields' => $this->metadataMapper->getMetadataFields($media, $media_type_id)] alongside filename/profile/description; throws on missing file/URI or failed upload
  • On success: changeMediaBundle() (transactional DB update of media + media_field_data), reload, set acquia_dam_asset_id (asset_id/version_id/external_id), set target managed field (display = 1 when sync; alt/title for acquia_dam_managed_image), save
  • Progress counters (updateSuccessCount / updateFailureCount) written under a lock (LockBackendInterface)
  • Injects: AcquiaDamUploadService, EntityTypeManager, State, LoggerChannelInterface, FileSystem, LockBackendInterface, MigrationMetadataMapper, database, MigrationQueueService, AcquiaDamMigrationUtilityService

Shared Scaffold Updates:

  • .services.yml ← updated — metadata_mapper service registration + worker constructor wiring

Tests

  • MigrationMetadataMapperTest (unit) — mapping resolution, multi-value fields, casting, empty-value drop, alt-text mapping
  • MediaMigrationQueueWorkerTest (kernel) — missing media_id; missing media_type_id; media not found; file not found; skips already-migrated; success (bundle change + asset id + progress); upload fails and re-throws; progress counters increment (upload service mocked)

Issue fork acquia_dam-3618421

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajeshreeputra created an issue. See original summary.

  • rajeshreeputra committed a094c570 on migration-tools
    Resolve #3618421 "Create Queue Worker and Metadata Mapper Service."
    
rajeshreeputra’s picture

Assigned: rajeshreeputra » Unassigned
Status: Active » Fixed

MR merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • rajeshreeputra committed 55307ffe on migration-tools
    Resolve #3618421 "Create Queue Worker and Metadata Mapper Service."