Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4b5839e
add collection, schemes and skos labels endpoints and tests
syphax-bouazzouni Jun 23, 2025
9c7b68f
update instance controller to use the Instance model
syphax-bouazzouni Jun 23, 2025
c1b007a
update classes to endpoint to order or filter by an attribute, scheme…
syphax-bouazzouni Jun 23, 2025
c266098
fix skos tests
syphax-bouazzouni Jun 23, 2025
78afc21
fix instances tests
syphax-bouazzouni Jun 23, 2025
90ec0c7
add class filtering by inScheme and memberOf
syphax-bouazzouni Jun 23, 2025
0228715
clean code
syphax-bouazzouni Jun 23, 2025
58339bb
fixed instances incompatibility with the linked data that supports en…
mdorf Jun 30, 2025
1757dc7
Merge branch 'develop' into feature/enhanced-skos-support
alexskr Jul 16, 2025
4c5a2ed
Gemfile update
mdorf Jul 16, 2025
5975a4c
Merge add-skos-temp into feature/enhanced-skos-support
mdorf Jul 16, 2025
72fcf9d
merged with latest
mdorf Jul 16, 2025
6d6a21f
renamed collection_controller to collections_controller
mdorf Jul 16, 2025
26f41fe
Gemfile update
mdorf Jul 16, 2025
20a4a67
Gemfile.lock update
mdorf Jul 16, 2025
ff52428
Gemfile.lock update
alexskr Jul 16, 2025
a45de95
Gemfile.lock update
alexskr Jul 17, 2025
6eade35
Merge pull request #190 from ncbo/fix/notes-controller-creator-assign…
alexskr Jul 17, 2025
3341c66
Merge branch 'fix/notes-controller-creator-assignment' into feature/e…
alexskr Jul 17, 2025
514b731
Merge pull request #192 from ncbo/feature/enhanced-skos-support
alexskr Jul 17, 2025
612139f
Merge pull request #193 from ncbo/develop
alexskr Jul 29, 2025
acddf34
Gemfile.lock update
alexskr Jul 29, 2025
889d8be
Enforce system-controlled attribute restrictions in populate_from_params
alexskr Aug 6, 2025
7ceff8f
Gemfile.lock update
alexskr Aug 6, 2025
7f793b8
test: switch oLD gem to feature/submission-version-validation for val…
alexskr Aug 6, 2025
6485d4c
Gemfile.lock update
alexskr Aug 6, 2025
7f3b51a
Gemfile.lock update
alexskr Aug 7, 2025
ed72c58
Gemfile.lock update
alexskr Aug 8, 2025
158cb53
Merge branch 'master' into develop
alexskr Aug 8, 2025
c01aba6
Merge pull request #194 from ncbo/develop
alexskr Aug 8, 2025
3aabf12
Gemfile.lock update
alexskr Aug 19, 2025
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
47 changes: 28 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_cron.git
revision: ffd62d61f36b9c58fef65afa082d200747a33893
revision: 8d67188e7f21014234359b71bb93a9d1256c320c
branch: master
specs:
ncbo_cron (0.0.1)
Expand Down Expand Up @@ -56,7 +56,7 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 098c1e1b00a04a5b0f3c9eb335f95e12bc7e7829
revision: 5a4f4d39aeb3ec567038b88ea962b796b2715915
branch: master
specs:
ontologies_linked_data (0.0.1)
Expand All @@ -73,7 +73,7 @@ GIT
rack
rack-test
rsolr
rubyzip
rubyzip (~> 3.0)

GIT
remote: https://github.com/ncbo/sparql-client.git
Expand Down Expand Up @@ -146,7 +146,7 @@ GEM
docile (1.4.1)
domain_name (0.6.20240107)
ed25519 (1.4.0)
faraday (2.13.2)
faraday (2.13.4)
faraday-net_http (>= 2.0, < 3.5)
json
logger
Expand All @@ -167,7 +167,7 @@ GEM
ffi (1.17.2-x86_64-darwin)
ffi (1.17.2-x86_64-linux-gnu)
ffi (1.17.2-x86_64-linux-musl)
gapic-common (1.0.0)
gapic-common (1.0.1)
faraday (>= 1.9, < 3.a)
faraday-retry (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
Expand Down Expand Up @@ -213,22 +213,31 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.73.0)
grpc (1.74.0)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.73.0-aarch64-linux)
grpc (1.74.0-aarch64-linux-gnu)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.73.0-arm64-darwin)
grpc (1.74.0-aarch64-linux-musl)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.73.0-x86-linux)
grpc (1.74.0-arm64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.73.0-x86_64-darwin)
grpc (1.74.0-x86-linux-gnu)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.73.0-x86_64-linux)
grpc (1.74.0-x86-linux-musl)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.74.0-x86_64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.74.0-x86_64-linux-gnu)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.74.0-x86_64-linux-musl)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
haml (5.2.2)
Expand All @@ -240,15 +249,15 @@ GEM
domain_name (~> 0.5)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.13.0)
json (2.13.2)
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.8.1)
jwt (2.10.2)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.5)
libxml-ruby (5.0.4)
libxml-ruby (5.0.5)
lint_roller (1.1.0)
logger (1.7.0)
macaddr (1.7.2)
Expand All @@ -262,15 +271,15 @@ GEM
mime-types (3.7.0)
logger
mime-types-data (~> 3.2025, >= 3.2025.0507)
mime-types-data (3.2025.0715)
mime-types-data (3.2025.0819)
mini_mime (1.1.5)
minitest (5.25.5)
minitest-hooks (1.5.2)
minitest (> 5.3)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
multi_json (1.17.0)
net-ftp (0.3.8)
net-protocol
time
Expand Down Expand Up @@ -337,7 +346,7 @@ GEM
redcarpet (3.6.1)
redis (5.4.1)
redis-client (>= 0.22.0)
redis-client (0.25.1)
redis-client (0.25.2)
connection_pool
redis-rack-cache (2.2.1)
rack-cache (>= 1.10, < 2)
Expand Down Expand Up @@ -367,12 +376,12 @@ GEM
rubocop-ast (>= 1.45.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.45.1)
rubocop-ast (1.46.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
ruby-progressbar (1.13.0)
ruby-xxHash (0.4.0.2)
rubyzip (2.4.1)
rubyzip (3.0.1)
rufus-scheduler (2.0.24)
tzinfo (>= 0.3.22)
signet (0.20.0)
Expand All @@ -387,7 +396,7 @@ GEM
simplecov-cobertura (3.0.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.13.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
sinatra (1.4.8)
rack (~> 1.5)
Expand Down
119 changes: 64 additions & 55 deletions controllers/classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ class ClassesController < ApplicationController
ont, submission = get_ontology_and_submission
cls_count = submission.class_count(LOGGER)
error 403, "Unable to display classes due to missing metrics for #{submission.id.to_s}. Please contact the administrator." if cls_count < 0

attributes, page, size, order_by_hash, bring_unmapped_needed = settings_params(LinkedData::Models::Class)
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
page, size = page_params
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
unmapped = ld.delete(:properties)
page_data = LinkedData::Models::Class.in(submission).include(ld).page(page,size).page_count_set(cls_count).all

if unmapped && page_data.length > 0
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
index = LinkedData::Models::Class.in(submission)
if order_by_hash
index = index.order_by(order_by_hash)
cls_count = nil
# Add index here when, indexing fixed
# index_name = 'classes_sort_by_date'
# index = index.index_as(index_name)
# index = index.with_index(index_name)
end

page_data = index
page_data = page_data.include(attributes).page(page, size).page_count_set(cls_count).all
reply page_data
end

Expand All @@ -28,7 +35,8 @@ class ClassesController < ApplicationController
load_attrs = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
unmapped = load_attrs.delete(:properties)
page, size = page_params
roots = submission.roots(load_attrs, page, size)

roots = submission.roots(load_attrs, page, size, concept_schemes: concept_schemes, concept_collections: concept_collections)

if unmapped && roots.length > 0
LinkedData::Models::Class.in(submission).models(roots).include(:unmapped).all
Expand All @@ -44,13 +52,16 @@ class ClassesController < ApplicationController
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
load_attrs = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
unmapped = load_attrs.delete(:properties)
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
roots = nil
load_attrs += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?

request_display(load_attrs.join(','))

sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false

if sort
roots = submission.roots_sorted(load_attrs)
roots = submission.roots_sorted(load_attrs, concept_schemes: concept_schemes, concept_collections: concept_collections)
else
roots = submission.roots(load_attrs)
roots = submission.roots(load_attrs, concept_schemes: concept_schemes, concept_collections: concept_collections)
end

if unmapped && roots.length > 0
Expand All @@ -66,25 +77,28 @@ class ClassesController < ApplicationController
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)

load_children = ld.delete :children
if !load_children
unless load_children
load_children = ld.select { |x| x.instance_of?(Hash) && x.include?(:children) }
if load_children
ld = ld.select { |x| !(x.instance_of?(Hash) && x.include?(:children)) }
end
end

unmapped = ld.delete(:properties) ||
(includes_param && includes_param.include?(:all))
(includes_param && includes_param.include?(:all))

ld << :memberOf if includes_param.include?(:all)

cls = get_class(submission, ld)
if unmapped
LinkedData::Models::Class.in(submission)
.models([cls]).include(:unmapped).all
.models([cls]).include(:unmapped).all
end
if includes_param.include?(:hasChildren)
cls.load_has_children
end
if !load_children.nil? and load_children.length >0
LinkedData::Models::Class.partially_load_children([cls],500,cls.submission)
if !load_children.nil? and load_children.length > 0
LinkedData::Models::Class.partially_load_children([cls], 500, cls.submission)
if includes_param.include?(:hasChildren)
cls.children.each do |c|
c.load_has_children
Expand All @@ -104,35 +118,27 @@ class ClassesController < ApplicationController
reply cls.paths_to_root
end

# Get a tree view
# Get a tree view (returns the tree from the roots classes to the specified class)
get '/:cls/tree' do
params ||= @params
includes_param_check
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
# We override include values other than the following, user-provided include ignored
display_attrs = "prefLabel,hasChildren,children,obsolete,subClassOf"
params["display"] = display_attrs
params["serialize_nested"] = true # Override safety check and cause children to serialize

# Make sure Rack gets updated
req = Rack::Request.new(env)
req.update_param("display", display_attrs)
req.update_param("serialize_nested", true)

ont, submission = get_ontology_and_submission
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
cls = get_class(submission)
root_tree = nil
roots = nil

display_attrs = [:prefLabel, :hasChildren, :children, :obsolete, :subClassOf]
display_attrs += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?
request_display(display_attrs.join(','))
extra_include = [:hasChildren, :isInActiveScheme, :isInActiveCollection]
if sort
root_tree = cls.tree_sorted
#add the other roots to the response
roots = submission.roots_sorted(extra_include=[:hasChildren])
roots = submission.roots_sorted(extra_include, concept_schemes: concept_schemes, concept_collections: concept_collections)
root_tree = cls.tree_sorted(concept_schemes: concept_schemes, concept_collections: concept_collections, roots: roots)
# add the other roots to the response
else
root_tree = cls.tree
#add the other roots to the response
roots = submission.roots(extra_include=[:hasChildren])
roots = submission.roots(extra_include, concept_schemes: concept_schemes, concept_collections: concept_collections)
root_tree = cls.tree(concept_schemes: concept_schemes, concept_collections: concept_collections, roots: roots)
# add the other roots to the response
end

# if this path' root does not get returned by the submission.roots call, manually add it
Expand All @@ -143,7 +149,7 @@ class ClassesController < ApplicationController
if r.id == root_tree.id
roots[i] = root_tree
else
roots[i].instance_variable_set("@children",[])
roots[i].instance_variable_set("@children", [])
roots[i].loaded_attributes << :children
end
end
Expand All @@ -159,7 +165,7 @@ class ClassesController < ApplicationController
error 404 if cls.nil?
ancestors = cls.ancestors
LinkedData::Models::Class.in(submission).models(ancestors)
.include(:prefLabel,:synonym,:definition).all
.include(:prefLabel, :synonym, :definition).all
reply ancestors
end

Expand All @@ -169,13 +175,13 @@ class ClassesController < ApplicationController
ont, submission = get_ontology_and_submission
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
page, size = page_params
cls = get_class(submission,load_attrs=[])
cls = get_class(submission, load_attrs = [])
error 404 if cls.nil?
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
unmapped = ld.delete(:properties)
page_data = cls.retrieve_descendants(page,size)
page_data = cls.retrieve_descendants(page, size)
LinkedData::Models::Class.in(submission).models(page_data)
.include(:prefLabel,:synonym,:definition).all
.include(:prefLabel, :synonym, :definition).all
if unmapped
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
end
Expand All @@ -192,20 +198,12 @@ class ClassesController < ApplicationController
cls = get_class(submission)
error 404 if cls.nil?
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
unmapped = ld.delete(:properties)
aggregates = LinkedData::Models::Class.goo_aggregates_to_load(ld)
page_data_query = LinkedData::Models::Class.where(parents: cls).in(submission).include(ld)
page_data_query.aggregate(*aggregates) unless aggregates.empty?
page_data = page_data_query.page(page,size).all
if unmapped
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
end
page_data.delete_if { |x| x.id.to_s == cls.id.to_s }
if ld.include?(:hasChildren)
page_data.each do |c|
c.load_has_children
end
end
ld += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?
request_display(ld.join(','))

page_data = submission.children(cls, includes_param: includes_param, concept_schemes: concept_schemes,
concept_collections: concept_collections, page: page, size: size)

reply page_data
end

Expand Down Expand Up @@ -236,6 +234,7 @@ class ClassesController < ApplicationController
end

private

def includes_param_check
if includes_param
if includes_param.include?(:all)
Expand All @@ -248,5 +247,15 @@ def includes_param_check
end
end

def request_display(attrs)

params["display"] = attrs
params["serialize_nested"] = true # Override safety check and cause children to serialize

# Make sure Rack gets updated
req = Rack::Request.new(env)
req.update_param("display", attrs)
req.update_param("serialize_nested", true)
end
end
end
Loading