Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1045 from ec-europa/ISAICP-4211
Browse files Browse the repository at this point in the history
4211: Discover graphs as config entities
  • Loading branch information
idimopoulos authored Jan 23, 2018
2 parents fa64962 + 51b159c commit 6dbd8f5
Show file tree
Hide file tree
Showing 77 changed files with 1,506 additions and 1,318 deletions.
2 changes: 1 addition & 1 deletion build.project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@

<target name="restore-databases" depends="restore-mysql-dump, virtuoso-restore-backup" />

<target name="rebuild-environment" depends="restore-databases, import-rdf-fixtures, execute-updates" />
<target name="rebuild-environment" depends="restore-databases, execute-updates" />

<!-- Set up PHPUnit. -->
<target name="setup-phpunit" description="Generate the configuration file for PHPUnit.">
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"drupal/piwik": "~1.0",
"drupal/piwik_reporting_api": "^1.0-beta2",
"drupal/r4032login": "dev-1.x#391f10d69b9b8c466a2fddac2a6b99f1289e7781",
"drupal/rdf_entity": "dev-pathauto-support",
"drupal/rdf_entity": "dev-graph-refactor",
"drupal/redirect": "^1.0",
"drupal/redis": "^1.0@RC",
"drupal/search_api": "~1.5",
Expand Down Expand Up @@ -205,9 +205,6 @@
},
"drupal/video_embed_field": {
"Allow also YouTube embed URLs. Improve the YT regexp @see https://www.drupal.org/node/2899093": "https://www.drupal.org/files/issues/2899093-8.patch"
},
"drupal/rdf_entity": {
"Allow created date to be visible in the form. @see https://github.com/ec-europa/rdf_entity/pull/10": "https://patch-diff.githubusercontent.com/raw/ec-europa/rdf_entity/pull/10.patch"
}
}
},
Expand Down
34 changes: 10 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/features/asset_release/asset_release.moderation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Feature: Asset release moderation
| name | type |
| Kenny Logan | Private Individual(s) |
And the following contact:
| name | SheriMoore |
| email | SheriMoore @example.com |
| name | SheriMoore |
| email | SheriMoore@example.com |
And users:
| Username | E-mail | First name | Family name | Roles |
| Bonnie Holloway | bonnie.holloway@example.com | Bonnie | Holloway | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ config_devel:
- field.storage.rdf_entity.field_ad_gitb_compliant
- field.storage.rdf_entity.field_ad_licence
- field.storage.rdf_entity.field_ad_repr_technique
- rdf_entity.mapping.rdf_entity.asset_distribution
- rdf_entity.rdfentity.asset_distribution
- views.view.asset_distribution_downloads
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
langcode: en
status: true
dependencies:
config:
- rdf_entity.graph.default
- rdf_entity.rdfentity.asset_distribution
third_party_settings: { }
id: rdf_entity.asset_distribution
entity_type_id: rdf_entity
bundle: asset_distribution
rdf_type: 'http://www.w3.org/ns/adms#AssetDistribution'
base_fields_mapping:
rid:
target_id:
predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
format: resource
uid:
target_id:
predicate: ''
format: ''
label:
value:
predicate: 'http://purl.org/dc/terms/title'
format: t_literal
created:
value:
predicate: 'http://purl.org/dc/terms/issued'
format: 'xsd:dateTime'
changed:
value:
predicate: 'http://purl.org/dc/terms/modified'
format: 'xsd:dateTime'
uuid:
value:
predicate: ''
format: ''
langcode:
value:
predicate: 'http://joinup.eu/language'
format: t_literal
default_langcode:
value:
predicate: 'http://joinup.eu/language/default'
format: literal
content_translation_source:
value:
predicate: 'http://joinup.eu/language/translation_source'
format: t_literal
content_translation_outdated:
value:
predicate: 'http://joinup.eu/language/translation_outdated'
format: t_literal
content_translation_uid:
target_id:
predicate: 'http://joinup.eu/language/translation_author'
format: t_literal
content_translation_status:
value:
predicate: 'http://joinup.eu/language/translation_status'
format: t_literal
content_translation_created:
value:
predicate: 'http://joinup.eu/language/translation_created_time'
format: t_literal
content_translation_changed:
value:
predicate: 'http://joinup.eu/language/translation_changed_time'
format: t_literal
graph:
default: 'http://joinup.eu/asset_distribution/published'
entity_id_plugin: joinup_po_namespace
Original file line number Diff line number Diff line change
@@ -1,70 +1,7 @@
langcode: en
status: true
dependencies: { }
third_party_settings:
rdf_entity:
rdf_type: 'http://www.w3.org/ns/adms#AssetDistribution'
mapping:
rid:
target_id:
predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
format: resource
uid:
target_id:
predicate: ''
format: ''
label:
value:
predicate: 'http://purl.org/dc/terms/title'
format: t_literal
created:
value:
predicate: 'http://purl.org/dc/terms/issued'
format: 'xsd:dateTime'
changed:
value:
predicate: 'http://purl.org/dc/terms/modified'
format: 'xsd:dateTime'
uuid:
value:
predicate: ''
format: ''
langcode:
value:
predicate: 'http://joinup.eu/language'
format: t_literal
default_langcode:
value:
predicate: 'http://joinup.eu/language/default'
format: literal
content_translation_source:
value:
predicate: 'http://joinup.eu/language/translation_source'
format: t_literal
content_translation_outdated:
value:
predicate: 'http://joinup.eu/language/translation_outdated'
format: t_literal
content_translation_uid:
target_id:
predicate: 'http://joinup.eu/language/translation_author'
format: t_literal
content_translation_status:
value:
predicate: 'http://joinup.eu/language/translation_status'
format: t_literal
content_translation_created:
value:
predicate: 'http://joinup.eu/language/translation_created_time'
format: t_literal
content_translation_changed:
value:
predicate: 'http://joinup.eu/language/translation_changed_time'
format: t_literal
graph:
default: 'http://joinup.eu/asset_distribution/published'
draft: 'http://joinup.eu/asset_distribution/draft'
entity_id_plugin: joinup_po_namespace
third_party_settings: { }
name: Distribution
rid: asset_distribution
description: ''
1 change: 1 addition & 0 deletions web/modules/custom/asset_release/asset_release.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ config_devel:
- field.storage.rdf_entity.field_isr_solution_type
- field.storage.rdf_entity.field_isr_state
- field.storage.rdf_entity.field_isr_translation
- rdf_entity.mapping.rdf_entity.asset_release
- rdf_entity.rdfentity.asset_release
15 changes: 5 additions & 10 deletions web/modules/custom/asset_release/asset_release.module
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\og\Og;
use Drupal\rdf_entity\Entity\Rdf;
use Drupal\rdf_entity\RdfEntityGraphInterface;
use Drupal\rdf_entity\RdfInterface;

/**
Expand Down Expand Up @@ -203,17 +204,16 @@ function asset_release_rdf_entity_presave(EntityInterface $entity) {
\Drupal::service('asset_release.relations')->syncFieldsFromParentSolution($entity);
}

$enabled_bundles = \Drupal::config('rdf_draft.settings')->get('revision_bundle_rdf_entity');
if (empty($enabled_bundles) || !in_array($entity->bundle(), $enabled_bundles)) {
if (!\Drupal::service('sparql.graph_handler')->bundleHasGraph('rdf_entity', 'asset_release', 'draft')) {
return;
}

$state = $entity->field_isr_state->value;
if (in_array($state, ['draft', 'needs_update'])) {
\Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->getGraphHandler()->setTargetGraphToEntity($entity, 'draft');
$entity->set('graph', 'draft');
}
elseif (in_array($state, ['validated'])) {
\Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->getGraphHandler()->setTargetGraphToEntity($entity, 'default');
$entity->set('graph', RdfEntityGraphInterface::DEFAULT);
}
elseif (empty($state)) {
throw new \Exception("State field not found while trying to get the appropriate graph.");
Expand All @@ -231,12 +231,7 @@ function asset_release_rdf_entity_presave(EntityInterface $entity) {
*/
function asset_release_entity_update(EntityInterface $entity) {
// Quick escape check to avoid unnecessary loadings.
if ($entity->bundle() != 'asset_release') {
return;
}

$enabled_bundles = \Drupal::config('rdf_draft.settings')->get('revision_bundle_rdf_entity');
if (empty($enabled_bundles) || !in_array($entity->bundle(), $enabled_bundles)) {
if ($entity->bundle() !== 'asset_release' || !\Drupal::service('sparql.graph_handler')->bundleHasGraph('rdf_entity', 'asset_release', 'draft')) {
return;
}

Expand Down
Loading

0 comments on commit 6dbd8f5

Please sign in to comment.