Skip to content

Commit

Permalink
Merge branch 'feature/add-unmapped-for-properties' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jul 25, 2024
2 parents 1c372b0 + 04946f0 commit 4144ed9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
12 changes: 9 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 8123ae61988a265daab1664deaed515718827c48
revision: c4dbcc14a3eb75343e597679ea4532ba53785b8f
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -138,7 +138,7 @@ GEM
dante (0.2.0)
date (3.3.4)
declarative (0.0.20)
docile (1.4.0)
docile (1.4.1)
domain_name (0.6.20240107)
ed25519 (1.3.0)
faraday (1.10.3)
Expand Down Expand Up @@ -211,6 +211,12 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.65.1)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.65.1-x86_64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.65.1-x86_64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
Expand Down Expand Up @@ -272,7 +278,7 @@ GEM
net-protocol
net-ssh (7.2.3)
netrc (0.11.0)
newrelic_rpm (9.11.0)
newrelic_rpm (9.12.0)
oj (3.16.1)
omni_logger (0.1.4)
logger
Expand Down
4 changes: 3 additions & 1 deletion controllers/properties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class PropertiesController < ApplicationController
get '/:property' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
bring_unmapped = bring_unmapped?(includes_param)

p = ont.property(prop, submission, display_all_attributes: bring_unmapped)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?
reply 200, p
end
Expand Down
57 changes: 38 additions & 19 deletions test/controllers/test_properties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ class TestPropertiesController < TestCase

def self.before_suite
count, acronyms, bro = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options:{process_rdf: true, extract_metadata: false},
acronym: "BROSEARCHTEST",
name: "BRO Search Test",
file_path: "./test/data/ontology_files/BRO_v3.2.owl",
ont_count: 1,
submission_count: 1,
ontology_type: "VALUE_SET_COLLECTION"
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false },
acronym: "BROSEARCHTEST",
name: "BRO Search Test",
file_path: "./test/data/ontology_files/BRO_v3.2.owl",
ont_count: 1,
submission_count: 1,
ontology_type: "VALUE_SET_COLLECTION"
})

count, acronyms, mccl = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
process_options:{process_rdf: true, extract_metadata: true},
acronym: "MCCLSEARCHTEST",
name: "MCCL Search Test",
file_path: "./test/data/ontology_files/CellLine_OWL_BioPortal_v1.0.owl",
ont_count: 1,
submission_count: 1
process_submission: true,
process_options: { process_rdf: true, extract_metadata: true },
acronym: "MCCLSEARCHTEST",
name: "MCCL Search Test",
file_path: "./test/data/ontology_files/CellLine_OWL_BioPortal_v1.0.owl",
ont_count: 1,
submission_count: 1
})
@@ontologies = bro.concat(mccl)
@@acronyms = @@ontologies.map { |ont| ont.bring_remaining; ont.acronym }
Expand All @@ -47,14 +47,33 @@ def test_single_property
get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23Originator"
assert last_response.ok?
results = MultiJson.load(last_response.body)

assert results.is_a?(Hash)
assert_equal ["Originator"], results["label"]
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Originator", results["@id"]
assert results.key?('range')
assert results.key?('domain')

get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23DummyProp"
assert_equal 404, last_response.status
end

def test_single_property_all_attributes
get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fbioontology.org%2Fontologies%2FBiomedicalResourceOntology.owl%23Originator?display=all"
assert last_response.ok?
results = MultiJson.load(last_response.body)
assert_equal ["Originator"], results["label"]
assert results.key?('range')
assert results.key?('domain')
assert_equal results["properties"], { "http://www.w3.org/2000/01/rdf-schema#comment" => ["Originator of a class"],
"http://www.w3.org/2004/02/skos/core#prefLabel" => ["Originator"],
"http://data.bioontology.org/metadata/def/prefLabel" => ["Originator"],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" => ["http://www.w3.org/2002/07/owl#DatatypeProperty"],
"http://www.w3.org/2000/01/rdf-schema#domain" => ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Algorithm"],
"http://www.w3.org/2000/01/rdf-schema#label" => ["Originator"],
"http://www.w3.org/2004/02/skos/core#definition" => ["Originator of a class"] }
end

def test_property_roots
get "/ontologies/#{@@acronyms.first}/properties/roots"
assert last_response.ok?
Expand All @@ -66,10 +85,10 @@ def test_property_roots
assert_includes [18, 13], opr.length
# count datatype properties
dpr = pr.select { |p| p["@type"] == "http://www.w3.org/2002/07/owl#DatatypeProperty" }
assert_includes [32,31], dpr.length
assert_includes [32, 31], dpr.length
# count annotation properties
apr = pr.select { |p| p["@type"] == "http://www.w3.org/2002/07/owl#AnnotationProperty" }
assert_includes [12,8], apr.length
assert_includes [12, 8], apr.length
# check for non-root properties

assert_empty pr.select { |p| ["http://www.w3.org/2004/02/skos/core#broaderTransitive",
Expand Down Expand Up @@ -174,7 +193,7 @@ def test_property_descendants
dn = MultiJson.load(last_response.body)
assert_equal 2, dn.length
assert_equal ["http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#overExpress",
"http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#underExpress"].sort, dn.map { |d| d["@id"] }.sort
"http://www.semanticweb.org/ontologies/2009/9/12/Ontology1255323704656.owl#underExpress"].sort, dn.map { |d| d["@id"] }.sort
end

def test_property_parents
Expand Down Expand Up @@ -207,7 +226,7 @@ def test_property_children
assert_empty ch

get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23semanticRelation"
return unless last_response.ok? #depending if owlapi import SKOS
return unless last_response.ok? # depending if owlapi import SKOS

get "/ontologies/#{@@acronyms.first}/properties/http%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23semanticRelation/children"
assert last_response.ok?
Expand Down

0 comments on commit 4144ed9

Please sign in to comment.