diff --git a/modules/datastore/src/Drush.php b/modules/datastore/src/Drush.php index c205462324..63fc837513 100755 --- a/modules/datastore/src/Drush.php +++ b/modules/datastore/src/Drush.php @@ -242,7 +242,7 @@ public function drop(string $identifier, array $options = ['keep-local' => FALSE // is a type that will never be imported, such as a ZIP file. $this->logger->warning('Unable to drop datastore for ' . $identifier); } - $post_import_result = $this->postImportResultFactory->InitializeFromDatasetInfo(['resource_id' => $identifier]); + $post_import_result = $this->postImportResultFactory->initializeFromDistribution(['resource_id' => $identifier]); $post_import_result->removeJobStatus(); $this->logger->notice('Successfully removed the post import job status for resource ' . $identifier); } diff --git a/modules/datastore/src/Form/DashboardForm.php b/modules/datastore/src/Form/DashboardForm.php index f9f386e3ae..9e1b78f718 100644 --- a/modules/datastore/src/Form/DashboardForm.php +++ b/modules/datastore/src/Form/DashboardForm.php @@ -461,7 +461,7 @@ protected function buildRevisionRow(array $rev, int $resourceCount, string $harv */ protected function buildResourcesRow($dist): array { if (is_array($dist) && isset($dist['distribution_uuid'])) { - $postImportResult = $this->postImportResultFactory->initializeFromDatasetInfo($dist); + $postImportResult = $this->postImportResultFactory->initializeFromDistribution($dist); $postImportInfo = $postImportResult->retrieveJobStatus(); $status = $postImportInfo ? $postImportInfo['post_import_status'] : "waiting"; $error = $postImportInfo ? $postImportInfo['post_import_error'] : NULL; diff --git a/modules/datastore/src/PostImportResultFactory.php b/modules/datastore/src/PostImportResultFactory.php index 97b0b46486..edb00e3c82 100644 --- a/modules/datastore/src/PostImportResultFactory.php +++ b/modules/datastore/src/PostImportResultFactory.php @@ -65,19 +65,20 @@ public function initializeFromResource($status, $message, DataResource $resource /** * Creates a PostImportResult instance. * - * Passes the dataset info when initialized. + * Passes the distribution when initialized. * - * @param array $datasetInfo - * The dataset info. + * @param array $distribution + * The distribution. * * @return \Drupal\datastore\PostImportResult * The PostImportResult object. */ - public function initializeFromDatasetInfo(array $datasetInfo): PostImportResult { - $resource = $this->resourceMapper->get($datasetInfo['resource_id']); + public function initializeFromDistribution(array $distribution): PostImportResult { + // Retrieve the data resource object. + $resource = $this->resourceMapper->get($distribution['resource_id']); return new PostImportResult( - '', - '', + NULL, + NULL, $resource, $this->connection, ); diff --git a/modules/datastore/tests/src/Unit/Form/DashboardFormTest.php b/modules/datastore/tests/src/Unit/Form/DashboardFormTest.php index 796027cd8c..eb3301a694 100644 --- a/modules/datastore/tests/src/Unit/Form/DashboardFormTest.php +++ b/modules/datastore/tests/src/Unit/Form/DashboardFormTest.php @@ -138,7 +138,7 @@ public function testBuildTableRowsWithHarvestIdFilter() { $container = $this->buildContainerChain() ->add(RequestStack::class, 'getCurrentRequest', new Request(['harvest_id' => 'dataset-1'])) ->add(DatasetInfo::class, 'gather', ['latest_revision' => $info + ['distributions' => [$distribution]]]) - ->add(PostImportResultFactory::class, 'initializeFromDatasetInfo', $postImportResultMock) + ->add(PostImportResultFactory::class, 'initializeFromDistribution', $postImportResultMock) ->getMock(); \Drupal::setContainer($container); $form = DashboardForm::create($container)->buildForm([], new FormState()); @@ -194,7 +194,7 @@ public function testBuildTableRowsWithUuidFilter() { $container = $this->buildContainerChain() ->add(RequestStack::class, 'getCurrentRequest', new Request(['uuid' => 'test'])) ->add(DatasetInfo::class, 'gather', ['latest_revision' => $info + ['distributions' => [$distribution]]]) - ->add(PostImportResultFactory::class, 'initializeFromDatasetInfo', $postImportResultMock) + ->add(PostImportResultFactory::class, 'initializeFromDistribution', $postImportResultMock) ->getMock(); \Drupal::setContainer($container); $form = DashboardForm::create($container)->buildForm([], new FormState()); @@ -285,7 +285,7 @@ public function testBuildTableRowsWithAllDatasets() { ->add(MetastoreService::class, 'count', 2) ->add(MetastoreService::class, 'getIdentifiers', [$datasetInfo['latest_revision']['uuid'], $nonHarvestDatasetInfo['latest_revision']['uuid']]) ->add(DatasetInfo::class, 'gather', $datasetInfoOptions) - ->add(PostImportResultFactory::class, 'initializeFromDatasetInfo', $postImportResultMock); + ->add(PostImportResultFactory::class, 'initializeFromDistribution', $postImportResultMock); \Drupal::setContainer($container->getMock()); $form = DashboardForm::create($container->getMock())->buildForm([], new FormState()); @@ -392,7 +392,7 @@ public function testBuildTableRowsDatasetMultipleDistribution() { ->add(MetastoreService::class, 'count', 1) ->add(MetastoreService::class, 'getIdentifiers', [$datasetInfo['latest_revision']['uuid']]) ->add(DatasetInfo::class, 'gather', $datasetInfo) - ->add(PostImportResultFactory::class, 'initializeFromDatasetInfo', $postImportResultMock) + ->add(PostImportResultFactory::class, 'initializeFromDistribution', $postImportResultMock) ->getMock(); \Drupal::setContainer($container);