Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add the attributes dcterms:created and dcterms:modified to classes model #161

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/ontologies_linked_data/config/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/ontologies_linked_data/models/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions test/data/ontology_files/BRO_v3.4.owl
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@
<core:prefLabel rdf:datatype="&xsd;string">Activity</core:prefLabel>
<desc:definition rdf:datatype="&xsd;string">Activity of interest that may be related to a BRO:Resource.</desc:definition>
<core:altLabel>activities</core:altLabel>
<dct:created rdf:datatype="xsd:dateTime">2015-06-29</dct:created>
<dct:modified rdf:datatype="xsd:dateTime">2015-10-01</dct:modified>
</owl:Class>


Expand Down
21 changes: 21 additions & 0 deletions test/models/test_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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