From f7f143222f3bd265c671a74df555c85a9fff8909 Mon Sep 17 00:00:00 2001 From: fmizzell Date: Tue, 3 Dec 2019 11:04:26 -0800 Subject: [PATCH] Fix the GUI to add data nodes. (#265) --- modules/custom/dkan_data/dkan_data.module | 6 +++++- .../Plugin/Validation/Constraint/ProperJsonValidator.php | 8 +++++++- .../tests/src/Unit/WebServiceApiDocsTest.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/custom/dkan_data/dkan_data.module b/modules/custom/dkan_data/dkan_data.module index e958a5d31..3bbc62219 100644 --- a/modules/custom/dkan_data/dkan_data.module +++ b/modules/custom/dkan_data/dkan_data.module @@ -68,6 +68,10 @@ function dkan_data_entity_presave(EntityInterface $entity) { return; } + if (empty($entity->get('field_data_type')->value)) { + $entity->set('field_data_type', "dataset"); + } + if ($entity->get('field_data_type')->value != 'dataset') { return; } @@ -88,7 +92,7 @@ function dkan_data_entity_presave(EntityInterface $entity) { if (!isset($metadata->identifier)) { $metadata->identifier = $entity->uuid(); } - // If one exists in the uui it should be the same in the table. + // If one exists in the uuid it should be the same in the table. else { $entity->set('uuid', $metadata->identifier); } diff --git a/modules/custom/dkan_data/src/Plugin/Validation/Constraint/ProperJsonValidator.php b/modules/custom/dkan_data/src/Plugin/Validation/Constraint/ProperJsonValidator.php index 7f1a2b038..5e81aaed5 100644 --- a/modules/custom/dkan_data/src/Plugin/Validation/Constraint/ProperJsonValidator.php +++ b/modules/custom/dkan_data/src/Plugin/Validation/Constraint/ProperJsonValidator.php @@ -32,7 +32,13 @@ public function validate($items, Constraint $constraint) { */ protected function isProper($value) { // @codeCoverageIgnoreStart - return \Drupal::service("dkan_api.controller")->getEngine()->validate($value); + /* @var $saeFactory SaeFactory */ + $saeFactory = \Drupal::service("dkan_metastore.sae_factory"); + + /* @var $engine Sae */ + $engine = $saeFactory->getInstance('dataset'); + + return $engine->validate($value); // @codeCoverageIgnoreEnd } diff --git a/modules/custom/dkan_metastore/tests/src/Unit/WebServiceApiDocsTest.php b/modules/custom/dkan_metastore/tests/src/Unit/WebServiceApiDocsTest.php index 9bd716bf8..fdd866e9a 100644 --- a/modules/custom/dkan_metastore/tests/src/Unit/WebServiceApiDocsTest.php +++ b/modules/custom/dkan_metastore/tests/src/Unit/WebServiceApiDocsTest.php @@ -22,7 +22,7 @@ class WebServiceApiDocsTest extends TestCase { public function testGetDatasetSpecific() { $mockChain = $this->getCommonMockChain(); - // Test against ./docs/dkan_api_openapi_spec.yml + // Test against ./docs/dkan_api_openapi_spec.yml. $endpointsToKeep = [ // Target paths. '/api/1/metastore/schemas/dataset/items/{identifier}' => ['get'],