Skip to content
Snippets Groups Projects
Verified Commit 230f81c6 authored by Alexandre Dias's avatar Alexandre Dias
Browse files

ISAICP-9210: Remove ADMS leftover check.

parent ecb66fe1
No related branches found
No related tags found
2 merge requests!197Release 2.0.2,!196Release 2.0.1
<?php
/**
* @file
* Post update functions for the Joinup RDF module.
*/
declare(strict_types=1);
/**
* Performs checks for the RDF entities and its storage.
*
* Performs the following checks:
* - Checks for leftover graphs from the ADMS validation.
* - Checks for orphaned triples.
*/
function joinup_rdf_requirements(string $phase): array {
if ($phase !== 'runtime') {
return [];
}
$requirements = [];
// Ensure that leftover graphs from the ADMS validation graph do not exist.
$requirements['joinup_rdf_content_integrity'] = [
'title' => t('RDF content integrity'),
'description' => t('A series of requirements that ensure the consistency in the SPARQL database.'),
'severity' => REQUIREMENT_OK,
'value' => t('No issues found.'),
];
if ($errors = \Drupal::getContainer()->get('joinup_rdf.requirements_helper')->getRequirementErrors()) {
$requirements['joinup_rdf_content_integrity']['severity'] = REQUIREMENT_ERROR;
$requirements['joinup_rdf_content_integrity']['value'] = $errors;
}
return $requirements;
}
...@@ -6,10 +6,6 @@ services: ...@@ -6,10 +6,6 @@ services:
class: Drupal\joinup_rdf\VocabularyFixturesHelper class: Drupal\joinup_rdf\VocabularyFixturesHelper
arguments: [ 'rdf_sync.connection' ] arguments: [ 'rdf_sync.connection' ]
joinup_rdf.requirements_helper:
class: Drupal\joinup_rdf\RequirementsHelper
arguments: ['@rdf_sync.connection', '@string_translation']
# Move in joinup_rdf. See ISAICP-9156. # Move in joinup_rdf. See ISAICP-9156.
joinup_rdf.legacy_rdf_url.subscriber: joinup_rdf.legacy_rdf_url.subscriber:
class: Drupal\joinup_rdf\EventSubscriber\LegacyRdfUrlSubscriber class: Drupal\joinup_rdf\EventSubscriber\LegacyRdfUrlSubscriber
......
<?php
declare(strict_types=1);
namespace Drupal\joinup_rdf;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationManager;
use Drupal\rdf_sync\RdfSyncConnectionInterface;
/**
* Implements helper methods related to the requirements.
*
* @todo Evaluate in ISAICP-8376 if this is still needed.
*/
class RequirementsHelper {
use StringTranslationTrait;
/**
* Constructs a new RequirementsHelper.
*
* @param \Drupal\rdf_sync\RdfSyncConnectionInterface $sparql
* The SQL connection class for the SPARQL database storage.
* @param \Drupal\Core\StringTranslation\TranslationManager $translation
* The translation manager service.
*/
public function __construct(
protected RdfSyncConnectionInterface $sparql,
protected TranslationManager $translation,
) {}
/**
* Returns a list of error messages for the joinup_rdf requirements.
*
* @return array
* A list of error messages.
*/
public function getRequirementErrors(): array {
$errors = [];
if ($graphs = $this->getLeftoverFederationGraphs()) {
$errors[] = [
'#markup' => $this->t('Leftover graphs were found:'),
'children' => [
'#items' => $graphs,
],
];
}
if ($errors) {
return [
'#theme' => 'item_list',
'#items' => $errors,
];
}
return $errors;
}
/**
* Fetches the number of leftover graphs.
*
* @return array
* The leftover graphs.
*/
protected function getLeftoverFederationGraphs(): array {
$query = <<<QUERY
SELECT DISTINCT ?g WHERE { GRAPH ?g {?s ?p ?o} } ORDER BY ?g
QUERY;
$graphs = $this->sparql->query($query);
$errors = [];
foreach ($graphs as $graph) {
$uri = $graph->g->getUri();
if (str_starts_with($uri, 'http://adms-validator/')) {
$errors[] = $uri;
}
}
return $errors;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment