From 2a4a3cab1d47b214afcebcf4cf70efaa6cb26579 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Thu, 3 Nov 2022 17:51:18 +0100 Subject: [PATCH 1/3] add dcterms namespace --- lib/ontologies_linked_data/config/config.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_linked_data/config/config.rb b/lib/ontologies_linked_data/config/config.rb index a01a9faa7..8786e3c3f 100644 --- a/lib/ontologies_linked_data/config/config.rb +++ b/lib/ontologies_linked_data/config/config.rb @@ -166,8 +166,9 @@ def goo_namespaces conf.add_namespace(:oboinowl_gen, RDF::Vocabulary.new("http://www.geneontology.org/formats/oboInOwl#")) conf.add_namespace(:obo_purl, RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")) - conf.add_namespace(:umls, - RDF::Vocabulary.new("http://bioportal.bioontology.org/ontologies/umls/")) + conf.add_namespace(:umls, RDF::Vocabulary.new("http://bioportal.bioontology.org/ontologies/umls/")) + conf.add_namespace(:dcterms, RDF::Vocabulary.new("http://purl.org/dc/terms/")) + conf.id_prefix = "http://data.bioontology.org/" conf.pluralize_models(true) end From f4df352d97aef0823daddb35e6e4a23225db8e76 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Thu, 3 Nov 2022 17:51:56 +0100 Subject: [PATCH 2/3] add the attributes dcterms:created and dcterms:modified to classes model --- lib/ontologies_linked_data/models/class.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ontologies_linked_data/models/class.rb b/lib/ontologies_linked_data/models/class.rb index 20d74a56f..12841bb77 100644 --- a/lib/ontologies_linked_data/models/class.rb +++ b/lib/ontologies_linked_data/models/class.rb @@ -77,10 +77,12 @@ def self.urn_id(acronym,classId) attribute :notes, inverse: { on: :note, attribute: :relatedClass } + attribute :created, namespace: :dcterms + attribute :modified, namespace: :dcterms # Hypermedia settings embed :children, :ancestors, :descendants, :parents - serialize_default :prefLabel, :synonym, :definition, :cui, :semanticType, :obsolete, :matchType, :ontologyType, :provisional # an attribute used in Search (not shown out of context) + serialize_default :prefLabel, :synonym, :definition, :cui, :semanticType, :obsolete, :matchType, :ontologyType, :provisional, :created, :modified # an attribute used in Search (not shown out of context) serialize_methods :properties, :childrenCount, :hasChildren serialize_never :submissionAcronym, :submissionId, :submission, :descendants aggregates childrenCount: [:count, :children] From 1e318a08770f0bed327735e5ef8e807c326394ae Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Sat, 17 Dec 2022 22:58:41 +0100 Subject: [PATCH 3/3] add class date attributes tests --- test/data/ontology_files/BRO_v3.4.owl | 2 ++ test/models/test_class.rb | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/test/data/ontology_files/BRO_v3.4.owl b/test/data/ontology_files/BRO_v3.4.owl index aee5caa9c..e8b77122c 100644 --- a/test/data/ontology_files/BRO_v3.4.owl +++ b/test/data/ontology_files/BRO_v3.4.owl @@ -618,6 +618,8 @@ Activity Activity of interest that may be related to a BRO:Resource. activities + 2015-06-29 + 2015-10-01 diff --git a/test/models/test_class.rb b/test/models/test_class.rb index d5d70cd4b..21bb18a40 100644 --- a/test/models/test_class.rb +++ b/test/models/test_class.rb @@ -351,4 +351,25 @@ def test_xml_literal_serialization assert_equal String, xml_comment.class assert_equal comment, xml_comment end + + def test_fetch_date_attributes + acronym = 'BRO' + # Create a 1st version for BRO + submission_parse(acronym, "BRO", + "./test/data/ontology_files/BRO_v3.4.owl", 1, + process_rdf: true, index_search: false, + run_metrics: false, reasoning: false, + diff: true, delete: false) + + os = LinkedData::Models::OntologySubmission.where(ontology: [ acronym: acronym ], + submissionId: 1).all + assert(os.length == 1) + os = os[0] + + class_id = RDF::URI.new "http://bioontology.org/ontologies/Activity.owl#Activity" + cls = LinkedData::Models::Class.find(class_id).in(os).include(:created, :modified).first + assert_equal '2015-06-29', cls.created + assert_equal '2015-10-01', cls.modified + + end end