Skip to content

Commit

Permalink
make the class tree endpoit load isInActiveScheme and isInActiveColle…
Browse files Browse the repository at this point in the history
…ction for the select class
  • Loading branch information
syphax-bouazzouni committed Oct 17, 2023
1 parent 11e7729 commit 110e97b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
6 changes: 0 additions & 6 deletions controllers/classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,7 @@ def includes_param_check
end
end

def concept_schemes
params["concept_schemes"]&.split(',') || []
end

def concept_collections
params["concept_collections"]&.split(',') || []
end

def request_display(attrs)

Expand Down
41 changes: 26 additions & 15 deletions helpers/classes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,19 @@ def get_class(submission, load_attrs=nil)
load_children = load_attrs.delete :children
load_has_children = load_attrs.delete :hasChildren

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

if load_children.length == 0
load_children = nil
end
if !load_children.nil?
load_attrs = load_attrs.select { |x| !(x.instance_of?(Hash) && x.include?(:children)) }
end
load_children = nil if load_children.length == 0
load_attrs = load_attrs.select { |x| !(x.instance_of?(Hash) && x.include?(:children)) } unless load_children.nil?
end


cls_uri = notation_to_class_uri(submission)

if cls_uri.nil?
cls_uri = RDF::URI.new(params[:cls])

if !cls_uri.valid?
unless cls_uri.valid?
error 400, "The input class id '#{params[:cls]}' is not a valid IRI"
end
end
Expand All @@ -62,23 +58,38 @@ def get_class(submission, load_attrs=nil)
error 404,
"Resource '#{params[:cls]}' not found in ontology #{submission.ontology.acronym} submission #{submission.submissionId}"
end
unless load_has_children.nil?
cls.load_has_children
end

if !load_children.nil?

extra_include = []

extra_include << :hasChildren if load_has_children
extra_include << :isInActiveScheme if load_attrs.include?(:inScheme) && params[:concept_schemes]
extra_include << :isInActiveCollection if load_attrs.include?(:memberOf) && params[:concept_collections]

cls.load_computed_attributes(to_load: extra_include ,
options: {schemes: concept_schemes, collections: concept_collections})


unless load_children.nil?
LinkedData::Models::Class.partially_load_children(
[cls],500,cls.submission)
[cls], 500, cls.submission)
unless load_has_children.nil?
cls.children.each do |c|
c.load_has_children
end
end
end
return cls
cls
end

end
def concept_schemes
params["concept_schemes"]&.split(',') || []
end

def concept_collections
params["concept_collections"]&.split(',') || []
end
end
end

Expand Down

0 comments on commit 110e97b

Please sign in to comment.