Skip to content

Commit 5f257bc

Browse files
authored
Merge pull request #17 from ncbo/master
Sync: BioPortal v6.6.1 release
2 parents c3fb559 + 3aabf12 commit 5f257bc

24 files changed

Lines changed: 381562 additions & 121 deletions

Gemfile.lock

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ GIT
2727

2828
GIT
2929
remote: https://github.com/ncbo/ncbo_cron.git
30-
revision: ffd62d61f36b9c58fef65afa082d200747a33893
30+
revision: 8d67188e7f21014234359b71bb93a9d1256c320c
3131
branch: master
3232
specs:
3333
ncbo_cron (0.0.1)
@@ -56,7 +56,7 @@ GIT
5656

5757
GIT
5858
remote: https://github.com/ncbo/ontologies_linked_data.git
59-
revision: 098c1e1b00a04a5b0f3c9eb335f95e12bc7e7829
59+
revision: 5a4f4d39aeb3ec567038b88ea962b796b2715915
6060
branch: master
6161
specs:
6262
ontologies_linked_data (0.0.1)
@@ -73,7 +73,7 @@ GIT
7373
rack
7474
rack-test
7575
rsolr
76-
rubyzip
76+
rubyzip (~> 3.0)
7777

7878
GIT
7979
remote: https://github.com/ncbo/sparql-client.git
@@ -146,7 +146,7 @@ GEM
146146
docile (1.4.1)
147147
domain_name (0.6.20240107)
148148
ed25519 (1.4.0)
149-
faraday (2.13.2)
149+
faraday (2.13.4)
150150
faraday-net_http (>= 2.0, < 3.5)
151151
json
152152
logger
@@ -167,7 +167,7 @@ GEM
167167
ffi (1.17.2-x86_64-darwin)
168168
ffi (1.17.2-x86_64-linux-gnu)
169169
ffi (1.17.2-x86_64-linux-musl)
170-
gapic-common (1.0.0)
170+
gapic-common (1.0.1)
171171
faraday (>= 1.9, < 3.a)
172172
faraday-retry (>= 1.0, < 3.a)
173173
google-cloud-env (~> 2.2)
@@ -213,22 +213,31 @@ GEM
213213
multi_json (~> 1.11)
214214
os (>= 0.9, < 2.0)
215215
signet (>= 0.16, < 2.a)
216-
grpc (1.73.0)
216+
grpc (1.74.0)
217217
google-protobuf (>= 3.25, < 5.0)
218218
googleapis-common-protos-types (~> 1.0)
219-
grpc (1.73.0-aarch64-linux)
219+
grpc (1.74.0-aarch64-linux-gnu)
220220
google-protobuf (>= 3.25, < 5.0)
221221
googleapis-common-protos-types (~> 1.0)
222-
grpc (1.73.0-arm64-darwin)
222+
grpc (1.74.0-aarch64-linux-musl)
223223
google-protobuf (>= 3.25, < 5.0)
224224
googleapis-common-protos-types (~> 1.0)
225-
grpc (1.73.0-x86-linux)
225+
grpc (1.74.0-arm64-darwin)
226226
google-protobuf (>= 3.25, < 5.0)
227227
googleapis-common-protos-types (~> 1.0)
228-
grpc (1.73.0-x86_64-darwin)
228+
grpc (1.74.0-x86-linux-gnu)
229229
google-protobuf (>= 3.25, < 5.0)
230230
googleapis-common-protos-types (~> 1.0)
231-
grpc (1.73.0-x86_64-linux)
231+
grpc (1.74.0-x86-linux-musl)
232+
google-protobuf (>= 3.25, < 5.0)
233+
googleapis-common-protos-types (~> 1.0)
234+
grpc (1.74.0-x86_64-darwin)
235+
google-protobuf (>= 3.25, < 5.0)
236+
googleapis-common-protos-types (~> 1.0)
237+
grpc (1.74.0-x86_64-linux-gnu)
238+
google-protobuf (>= 3.25, < 5.0)
239+
googleapis-common-protos-types (~> 1.0)
240+
grpc (1.74.0-x86_64-linux-musl)
232241
google-protobuf (>= 3.25, < 5.0)
233242
googleapis-common-protos-types (~> 1.0)
234243
haml (5.2.2)
@@ -240,15 +249,15 @@ GEM
240249
domain_name (~> 0.5)
241250
i18n (1.14.7)
242251
concurrent-ruby (~> 1.0)
243-
json (2.13.0)
252+
json (2.13.2)
244253
json-schema (2.8.1)
245254
addressable (>= 2.4)
246255
json_pure (2.8.1)
247256
jwt (2.10.2)
248257
base64
249258
kgio (2.11.4)
250259
language_server-protocol (3.17.0.5)
251-
libxml-ruby (5.0.4)
260+
libxml-ruby (5.0.5)
252261
lint_roller (1.1.0)
253262
logger (1.7.0)
254263
macaddr (1.7.2)
@@ -262,15 +271,15 @@ GEM
262271
mime-types (3.7.0)
263272
logger
264273
mime-types-data (~> 3.2025, >= 3.2025.0507)
265-
mime-types-data (3.2025.0715)
274+
mime-types-data (3.2025.0819)
266275
mini_mime (1.1.5)
267276
minitest (5.25.5)
268277
minitest-hooks (1.5.2)
269278
minitest (> 5.3)
270279
minitest-stub_any_instance (1.0.3)
271280
mlanett-redis-lock (0.2.7)
272281
redis
273-
multi_json (1.15.0)
282+
multi_json (1.17.0)
274283
net-ftp (0.3.8)
275284
net-protocol
276285
time
@@ -337,7 +346,7 @@ GEM
337346
redcarpet (3.6.1)
338347
redis (5.4.1)
339348
redis-client (>= 0.22.0)
340-
redis-client (0.25.1)
349+
redis-client (0.25.2)
341350
connection_pool
342351
redis-rack-cache (2.2.1)
343352
rack-cache (>= 1.10, < 2)
@@ -367,12 +376,12 @@ GEM
367376
rubocop-ast (>= 1.45.1, < 2.0)
368377
ruby-progressbar (~> 1.7)
369378
unicode-display_width (>= 2.4.0, < 4.0)
370-
rubocop-ast (1.45.1)
379+
rubocop-ast (1.46.0)
371380
parser (>= 3.3.7.2)
372381
prism (~> 1.4)
373382
ruby-progressbar (1.13.0)
374383
ruby-xxHash (0.4.0.2)
375-
rubyzip (2.4.1)
384+
rubyzip (3.0.1)
376385
rufus-scheduler (2.0.24)
377386
tzinfo (>= 0.3.22)
378387
signet (0.20.0)
@@ -387,7 +396,7 @@ GEM
387396
simplecov-cobertura (3.0.0)
388397
rexml
389398
simplecov (~> 0.19)
390-
simplecov-html (0.13.1)
399+
simplecov-html (0.13.2)
391400
simplecov_json_formatter (0.1.4)
392401
sinatra (1.4.8)
393402
rack (~> 1.5)

controllers/classes_controller.rb

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@ class ClassesController < ApplicationController
88
ont, submission = get_ontology_and_submission
99
cls_count = submission.class_count(LOGGER)
1010
error 403, "Unable to display classes due to missing metrics for #{submission.id.to_s}. Please contact the administrator." if cls_count < 0
11+
12+
attributes, page, size, order_by_hash, bring_unmapped_needed = settings_params(LinkedData::Models::Class)
1113
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
12-
page, size = page_params
13-
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
14-
unmapped = ld.delete(:properties)
15-
page_data = LinkedData::Models::Class.in(submission).include(ld).page(page,size).page_count_set(cls_count).all
1614

17-
if unmapped && page_data.length > 0
18-
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
15+
index = LinkedData::Models::Class.in(submission)
16+
if order_by_hash
17+
index = index.order_by(order_by_hash)
18+
cls_count = nil
19+
# Add index here when, indexing fixed
20+
# index_name = 'classes_sort_by_date'
21+
# index = index.index_as(index_name)
22+
# index = index.with_index(index_name)
1923
end
24+
25+
page_data = index
26+
page_data = page_data.include(attributes).page(page, size).page_count_set(cls_count).all
2027
reply page_data
2128
end
2229

@@ -28,7 +35,8 @@ class ClassesController < ApplicationController
2835
load_attrs = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
2936
unmapped = load_attrs.delete(:properties)
3037
page, size = page_params
31-
roots = submission.roots(load_attrs, page, size)
38+
39+
roots = submission.roots(load_attrs, page, size, concept_schemes: concept_schemes, concept_collections: concept_collections)
3240

3341
if unmapped && roots.length > 0
3442
LinkedData::Models::Class.in(submission).models(roots).include(:unmapped).all
@@ -44,13 +52,16 @@ class ClassesController < ApplicationController
4452
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
4553
load_attrs = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
4654
unmapped = load_attrs.delete(:properties)
47-
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
48-
roots = nil
55+
load_attrs += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?
56+
57+
request_display(load_attrs.join(','))
58+
59+
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
4960

5061
if sort
51-
roots = submission.roots_sorted(load_attrs)
62+
roots = submission.roots_sorted(load_attrs, concept_schemes: concept_schemes, concept_collections: concept_collections)
5263
else
53-
roots = submission.roots(load_attrs)
64+
roots = submission.roots(load_attrs, concept_schemes: concept_schemes, concept_collections: concept_collections)
5465
end
5566

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

6879
load_children = ld.delete :children
69-
if !load_children
80+
unless load_children
7081
load_children = ld.select { |x| x.instance_of?(Hash) && x.include?(:children) }
7182
if load_children
7283
ld = ld.select { |x| !(x.instance_of?(Hash) && x.include?(:children)) }
7384
end
7485
end
7586

7687
unmapped = ld.delete(:properties) ||
77-
(includes_param && includes_param.include?(:all))
88+
(includes_param && includes_param.include?(:all))
89+
90+
ld << :memberOf if includes_param.include?(:all)
91+
7892
cls = get_class(submission, ld)
7993
if unmapped
8094
LinkedData::Models::Class.in(submission)
81-
.models([cls]).include(:unmapped).all
95+
.models([cls]).include(:unmapped).all
8296
end
8397
if includes_param.include?(:hasChildren)
8498
cls.load_has_children
8599
end
86-
if !load_children.nil? and load_children.length >0
87-
LinkedData::Models::Class.partially_load_children([cls],500,cls.submission)
100+
if !load_children.nil? and load_children.length > 0
101+
LinkedData::Models::Class.partially_load_children([cls], 500, cls.submission)
88102
if includes_param.include?(:hasChildren)
89103
cls.children.each do |c|
90104
c.load_has_children
@@ -104,35 +118,27 @@ class ClassesController < ApplicationController
104118
reply cls.paths_to_root
105119
end
106120

107-
# Get a tree view
121+
# Get a tree view (returns the tree from the roots classes to the specified class)
108122
get '/:cls/tree' do
109123
params ||= @params
110124
includes_param_check
111-
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
125+
sort = params["sort"].eql?('true') || params["sort"].eql?('1') # default = false
112126
# We override include values other than the following, user-provided include ignored
113-
display_attrs = "prefLabel,hasChildren,children,obsolete,subClassOf"
114-
params["display"] = display_attrs
115-
params["serialize_nested"] = true # Override safety check and cause children to serialize
116-
117-
# Make sure Rack gets updated
118-
req = Rack::Request.new(env)
119-
req.update_param("display", display_attrs)
120-
req.update_param("serialize_nested", true)
121-
122127
ont, submission = get_ontology_and_submission
123128
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
124129
cls = get_class(submission)
125-
root_tree = nil
126-
roots = nil
127-
130+
display_attrs = [:prefLabel, :hasChildren, :children, :obsolete, :subClassOf]
131+
display_attrs += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?
132+
request_display(display_attrs.join(','))
133+
extra_include = [:hasChildren, :isInActiveScheme, :isInActiveCollection]
128134
if sort
129-
root_tree = cls.tree_sorted
130-
#add the other roots to the response
131-
roots = submission.roots_sorted(extra_include=[:hasChildren])
135+
roots = submission.roots_sorted(extra_include, concept_schemes: concept_schemes, concept_collections: concept_collections)
136+
root_tree = cls.tree_sorted(concept_schemes: concept_schemes, concept_collections: concept_collections, roots: roots)
137+
# add the other roots to the response
132138
else
133-
root_tree = cls.tree
134-
#add the other roots to the response
135-
roots = submission.roots(extra_include=[:hasChildren])
139+
roots = submission.roots(extra_include, concept_schemes: concept_schemes, concept_collections: concept_collections)
140+
root_tree = cls.tree(concept_schemes: concept_schemes, concept_collections: concept_collections, roots: roots)
141+
# add the other roots to the response
136142
end
137143

138144
# if this path' root does not get returned by the submission.roots call, manually add it
@@ -143,7 +149,7 @@ class ClassesController < ApplicationController
143149
if r.id == root_tree.id
144150
roots[i] = root_tree
145151
else
146-
roots[i].instance_variable_set("@children",[])
152+
roots[i].instance_variable_set("@children", [])
147153
roots[i].loaded_attributes << :children
148154
end
149155
end
@@ -159,7 +165,7 @@ class ClassesController < ApplicationController
159165
error 404 if cls.nil?
160166
ancestors = cls.ancestors
161167
LinkedData::Models::Class.in(submission).models(ancestors)
162-
.include(:prefLabel,:synonym,:definition).all
168+
.include(:prefLabel, :synonym, :definition).all
163169
reply ancestors
164170
end
165171

@@ -169,13 +175,13 @@ class ClassesController < ApplicationController
169175
ont, submission = get_ontology_and_submission
170176
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
171177
page, size = page_params
172-
cls = get_class(submission,load_attrs=[])
178+
cls = get_class(submission, load_attrs = [])
173179
error 404 if cls.nil?
174180
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
175181
unmapped = ld.delete(:properties)
176-
page_data = cls.retrieve_descendants(page,size)
182+
page_data = cls.retrieve_descendants(page, size)
177183
LinkedData::Models::Class.in(submission).models(page_data)
178-
.include(:prefLabel,:synonym,:definition).all
184+
.include(:prefLabel, :synonym, :definition).all
179185
if unmapped
180186
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
181187
end
@@ -192,20 +198,12 @@ class ClassesController < ApplicationController
192198
cls = get_class(submission)
193199
error 404 if cls.nil?
194200
ld = LinkedData::Models::Class.goo_attrs_to_load(includes_param)
195-
unmapped = ld.delete(:properties)
196-
aggregates = LinkedData::Models::Class.goo_aggregates_to_load(ld)
197-
page_data_query = LinkedData::Models::Class.where(parents: cls).in(submission).include(ld)
198-
page_data_query.aggregate(*aggregates) unless aggregates.empty?
199-
page_data = page_data_query.page(page,size).all
200-
if unmapped
201-
LinkedData::Models::Class.in(submission).models(page_data).include(:unmapped).all
202-
end
203-
page_data.delete_if { |x| x.id.to_s == cls.id.to_s }
204-
if ld.include?(:hasChildren)
205-
page_data.each do |c|
206-
c.load_has_children
207-
end
208-
end
201+
ld += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?
202+
request_display(ld.join(','))
203+
204+
page_data = submission.children(cls, includes_param: includes_param, concept_schemes: concept_schemes,
205+
concept_collections: concept_collections, page: page, size: size)
206+
209207
reply page_data
210208
end
211209

@@ -236,6 +234,7 @@ class ClassesController < ApplicationController
236234
end
237235

238236
private
237+
239238
def includes_param_check
240239
if includes_param
241240
if includes_param.include?(:all)
@@ -248,5 +247,15 @@ def includes_param_check
248247
end
249248
end
250249

250+
def request_display(attrs)
251+
252+
params["display"] = attrs
253+
params["serialize_nested"] = true # Override safety check and cause children to serialize
254+
255+
# Make sure Rack gets updated
256+
req = Rack::Request.new(env)
257+
req.update_param("display", attrs)
258+
req.update_param("serialize_nested", true)
259+
end
251260
end
252261
end

0 commit comments

Comments
 (0)