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

Fix: Class children not filtred by a scheme #104

Merged
Merged
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
6 changes: 3 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: c0f8697529ebfca2c3fe90d46d9482ac72f13362
revision: 312ef426eeaa461e88fa23124ea5fd531f4276ba
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -211,7 +211,7 @@ GEM
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.3)
json (2.7.5)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
Expand Down Expand Up @@ -353,7 +353,7 @@ GEM
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
rubocop-ast (1.33.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby-xxHash (0.4.0.2)
Expand Down
53 changes: 18 additions & 35 deletions controllers/classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ClassesController < ApplicationController
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)
attributes, page, size, order_by_hash, bring_unmapped_needed = settings_params(LinkedData::Models::Class)
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])

index = LinkedData::Models::Class.in(submission)
Expand All @@ -23,7 +23,7 @@ class ClassesController < ApplicationController
end

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

Expand Down Expand Up @@ -56,7 +56,7 @@ class ClassesController < ApplicationController

request_display(load_attrs.join(','))

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

if sort
roots = submission.roots_sorted(load_attrs, concept_schemes: concept_schemes, concept_collections: concept_collections)
Expand Down Expand Up @@ -85,20 +85,20 @@ class ClassesController < ApplicationController
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 @@ -122,7 +122,7 @@ class ClassesController < ApplicationController
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
ont, submission = get_ontology_and_submission
check_last_modified_segment(LinkedData::Models::Class, [ont.acronym])
Expand All @@ -134,11 +134,11 @@ class ClassesController < ApplicationController
if sort
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
# add the other roots to the response
else
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
# 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 @@ -149,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 @@ -165,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 @@ -175,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 @@ -198,24 +198,11 @@ 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)
ld += LinkedData::Models::Class.concept_is_in_attributes if submission.skos?

request_display(ld.join(','))
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) || ld.include?(:isInActiveScheme) || ld.include?(:isInActiveCollection)
page_data.each do |c|
c.load_computed_attributes(to_load: ld,
options: { schemes: concept_schemes, collections: concept_collections })
end
end

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 @@ -246,8 +233,6 @@ class ClassesController < ApplicationController
reply cls.parents.select { |x| !x.id.to_s["owl#Thing"] }
end



private

def includes_param_check
Expand All @@ -262,8 +247,6 @@ def includes_param_check
end
end



def request_display(attrs)

params["display"] = attrs
Expand Down
Loading