diff --git a/tests/features/update/ISAICP-9488.feature b/tests/features/update/ISAICP-9488.feature new file mode 100644 index 0000000000000000000000000000000000000000..4e8e80657da8846ce97e354c8279647419e2f917 --- /dev/null +++ b/tests/features/update/ISAICP-9488.feature @@ -0,0 +1,29 @@ +@api @group-clone +Feature: Aliases are not updates. + + @update:joinup_core_deploy_200300 + Scenario Outline: Update collection alias. + Given I am logged in as a user with the "moderator" role + And I visit "<path>" + And I fill in "Short ID" with "<Short ID>" + And I press "Publish" + When I should be on "<expected>" + + Examples: + | path | Short ID | expected | + | /collection/nifo-national-interoperability-framework-observatory/edit | | /collection/iopeu-monitoring | + | /interoperable-europe/edit | inter-europe | /interoperable-europe | + + @update:joinup_core_deploy_200300 + Scenario Outline: Update solution alias. + Given I am logged in as a user with the "moderator" role + And I visit "<path>" + And I fill in "Short ID" with "<Short ID>" + And I select "Architecture Principle" from "Solution type" + And I press "Publish" + When I should be on "<expected>" + + Examples: + | path | Short ID | expected | + | /collection/european-interoperability-reference-architecture-eira/solution/egovera/edit | egovera | /collection/european-interoperability-reference-architecture-eira/solution/egovera | + | /collection/statistics/solution/eurotrace/edit | etsolution | /collection/statistics/solution/etsolution | diff --git a/web/modules/custom/eu_oss_catalogue/src/Plugin/eu_oss_catalogue/Resolver/TaxonomyTermResolver.php b/web/modules/custom/eu_oss_catalogue/src/Plugin/eu_oss_catalogue/Resolver/TaxonomyTermResolver.php index 288316580751f55fe98676afbff80f9d5876f740..e54af45c88ab622e079fae9e8ae91c80443cc580 100644 --- a/web/modules/custom/eu_oss_catalogue/src/Plugin/eu_oss_catalogue/Resolver/TaxonomyTermResolver.php +++ b/web/modules/custom/eu_oss_catalogue/src/Plugin/eu_oss_catalogue/Resolver/TaxonomyTermResolver.php @@ -4,6 +4,7 @@ namespace Drupal\eu_oss_catalogue\Plugin\eu_oss_catalogue\Resolver; +use Drupal\Component\Utility\NestedArray; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; @@ -74,6 +75,9 @@ public function resolve(?array &$value, Project $project, array $metadata, Field return; } + // Remove empty term names. + $value = NestedArray::filter($value); + // Get a flat list of all term names regardless of the language. $allTermNames = array_values(array_merge(...array_values($value))); diff --git a/web/modules/custom/eu_oss_catalogue/tests/fixtures/http_response/github.yml b/web/modules/custom/eu_oss_catalogue/tests/fixtures/http_response/github.yml index 163b6401f79c00cf7f2b5ff27daf4a60573e8aab..40ad488c03b15f134fd265bd8f1d35598abed246 100644 --- a/web/modules/custom/eu_oss_catalogue/tests/fixtures/http_response/github.yml +++ b/web/modules/custom/eu_oss_catalogue/tests/fixtures/http_response/github.yml @@ -159,7 +159,7 @@ default: - website-builder roadmap: http://roadmap.example.com/vendor/solution2 developmentStatus: development - softwareType: library + softwareType: "" description: it: genericName: '[IT] ACME Solution 2' diff --git a/web/modules/custom/joinup_core/joinup_core.deploy.php b/web/modules/custom/joinup_core/joinup_core.deploy.php index 1cac779e67573a30b849945b02ae7400370f057b..b989aa0b66cebe6a99dbf1ff1e0ea0b4c69c585a 100644 --- a/web/modules/custom/joinup_core/joinup_core.deploy.php +++ b/web/modules/custom/joinup_core/joinup_core.deploy.php @@ -14,6 +14,10 @@ declare(strict_types=1); +use Drupal\Core\Database\Database; +use Drupal\interoperable_europe\InteroperableEuropeCollectionInterface; +use Drupal\joinup_assessment\AssessmentInterface; +use Drupal\joinup_oss_catalogue\OssCatalogueCollectionInterface; use EasyRdf\Graph; /** @@ -28,11 +32,57 @@ function joinup_core_deploy_200300(): void { ])->save(); } +/** + * Update pathauto state for "RDF" nodes with aliases. + */ +function joinup_core_deploy_200301(array &$sandbox): string { + $database = Database::getConnection(); + + if (!isset($sandbox['ids'])) { + $query = $database->select('node_field_data', 'nd'); + $query->fields('nd', ['nid']) + ->condition('nd.type', [ + 'collection', + 'solution', + 'distribution', + 'release', + 'contact_information', + 'owner', + ], 'IN'); + $query->join('node', 'n', 'n.nid = nd.nid'); + $query->fields('n', ['uuid']) + ->condition('n.uuid', [ + InteroperableEuropeCollectionInterface::COLLECTION_UUID, + OssCatalogueCollectionInterface::COLLECTION_UUID, + AssessmentInterface::GROUP_UUID, + ], 'NOT IN'); + $query->join('key_value', 'k', 'nd.nid = k.name AND k.collection = :collection', [':collection' => 'pathauto_state.node']); + $query->condition('k.value', 'i:0;'); + + $sandbox['ids'] = $query->execute()->fetchCol(); + $sandbox['total'] = count($sandbox['ids']); + $sandbox['progress'] = 0; + } + + $ids = array_splice($sandbox['ids'], 0, 200); + if (!empty($ids)) { + $database->update('key_value') + ->fields(['value' => 'i:1;']) + ->condition('name', $ids, 'IN') + ->condition('collection', 'pathauto_state.node') + ->execute(); + } + + $sandbox['progress'] += count($ids); + $sandbox['#finished'] = (int) empty($sandbox['ids']); + + return "Processed {$sandbox['progress']} out of {$sandbox['total']}"; +} /** * Gather information about the current state of solution type terms. */ -function joinup_core_deploy_200301(): string { +function joinup_core_deploy_200302(): string { // We only need to check the revision table as all data are there including // the data from the data table. $solution_type_values = \Drupal::database() @@ -70,7 +120,7 @@ function joinup_core_deploy_200301(): string { /** * Deploy EIRA 6.1.0, simplified solution type (EIRA 6.0.0) and eGovERA. */ -function joinup_core_deploy_200302(): void { +function joinup_core_deploy_200303(): void { // Import the simplified EIRA 6.0.0. $graph = new Graph(); $graph->parseFile('../resources/vocab/EIRA_SKOS_v6_0_0.rdf'); @@ -99,7 +149,7 @@ function joinup_core_deploy_200302(): void { /** * Update the solution type field and revision values. */ -function joinup_core_deploy_200303(): string { +function joinup_core_deploy_200304(): string { $data = \Drupal::state()->get('joinup_core_deploy_200200'); if (!$data) { throw new Exception('No relevant data found about solution type field.');