Skip to content

Commit

Permalink
Merge pull request #1 from ontoportal-lirmm/master
Browse files Browse the repository at this point in the history
Merge the lastes version of Agroportal into the branch ontoportal-lirmm
  • Loading branch information
syphax-bouazzouni committed Sep 12, 2023
2 parents 3d73f62 + a5f0c71 commit 6d3d046
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 98 deletions.
66 changes: 35 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ncbo/ncbo_ontology_recommender.git
revision: 6010ff60b99dc1282822b8a1fb59bd59f453755f
revision: d0ac992c88bd417f2f2137ba62934c3c41b6db7c
branch: master
specs:
ncbo_ontology_recommender (0.0.1)
Expand All @@ -11,8 +11,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: 92968978e5d2436c648bf7956e25aff05440b59d
branch: master
revision: cda6aff2338e2a2831e4e7bf716abdf8fa8483d2
branch: development
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -37,13 +37,13 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_cron.git
revision: d09999177235029ba30a00cd59d10f7ca1a1fa93
revision: 8db3481116c57d2a21dc8f32bcd1695d95442280
branch: master
specs:
ncbo_cron (0.0.1)
dante
goo
google-api-client
google-apis-analytics_v3
mlanett-redis-lock
multi_json
ncbo_annotator
Expand All @@ -53,8 +53,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 9c5c56cf7b4546ccc45431a82bbce9a33184e4cc
branch: master
revision: e9b708c40b2b22b935fb48d18ed19de8148fca35
branch: development
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -125,16 +125,16 @@ GEM
capistrano (~> 3.1)
sshkit (~> 1.3)
coderay (1.1.3)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.0)
cube-ruby (0.0.3)
dante (0.2.0)
date (3.3.2)
date (3.3.3)
declarative (0.0.20)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ed25519 (1.3.0)
faraday (1.10.2)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -160,22 +160,24 @@ GEM
ffi (1.15.5)
get_process_mem (0.2.7)
ffi (~> 1.0)
google-api-client (0.52.0)
google-apis-analytics_v3 (0.12.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-core (0.11.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.9)
httpclient (>= 2.8.1, < 3.0)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
retriable (>= 2.0, < 4.a)
rexml
signet (~> 0.12)
googleauth (0.17.1)
faraday (>= 0.17.3, < 2.0)
webrick
googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.15)
signet (>= 0.16, < 2.a)
haml (5.2.2)
temple (>= 0.8.0)
tilt
Expand All @@ -189,13 +191,13 @@ GEM
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.6.3)
jwt (2.5.0)
jwt (2.7.0)
kgio (2.11.4)
libxml-ruby (3.2.4)
libxml-ruby (4.0.0)
logger (1.5.3)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
Expand All @@ -211,9 +213,9 @@ GEM
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
multipart-post (2.2.3)
multipart-post (2.3.0)
net-http-persistent (2.9.4)
net-imap (0.3.2)
net-imap (0.3.4)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -226,15 +228,15 @@ GEM
net-protocol
net-ssh (7.0.1)
netrc (0.11.0)
newrelic_rpm (8.14.0)
newrelic_rpm (8.16.0)
oj (2.18.5)
omni_logger (0.1.4)
logger
os (1.1.4)
parseconfig (1.1.2)
pony (1.13.1)
mail (>= 2.0)
pry (0.14.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.1)
Expand All @@ -258,8 +260,8 @@ GEM
rake (10.5.0)
rdf (1.0.8)
addressable (>= 2.2)
redcarpet (3.5.1)
redis (4.8.0)
redcarpet (3.6.0)
redis (4.8.1)
redis-activesupport (5.3.0)
activesupport (>= 3, < 8)
redis-store (>= 1.3, < 2)
Expand Down Expand Up @@ -292,7 +294,7 @@ GEM
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.21.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
Expand All @@ -318,11 +320,11 @@ GEM
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
systemu (2.6.5)
temple (0.9.1)
temple (0.10.0)
tilt (2.0.11)
timeout (0.3.1)
timeout (0.3.2)
trailblazer-option (0.1.2)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unf (0.1.4)
Expand All @@ -336,8 +338,10 @@ GEM
unicorn (>= 4, < 7)
uuid (2.3.9)
macaddr (~> 1.0)
webrick (1.8.1)

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
2 changes: 1 addition & 1 deletion 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, filter_by_label, 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 Down
2 changes: 1 addition & 1 deletion controllers/collection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CollectionsController < ApplicationController

get '/members' do
ont, submission = get_ontology_and_submission
attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Class)
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Class)
collection_uri = get_collection_uri(params)
data = LinkedData::Models::Class.where(memberOf: collection_uri).in(submission).include(attributes).page(page,size).all
reply data
Expand Down
16 changes: 8 additions & 8 deletions controllers/instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class InstancesController < ApplicationController
check_last_modified_segment(LinkedData::Models::Instance, [ont.acronym])
cls = get_class(sub)
error 404 if cls.nil?

attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)
filter_by_label = label_regex_filter
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)



Expand All @@ -20,7 +20,7 @@ class InstancesController < ApplicationController
page_data.order_by(order_by) unless order_by.nil?
page_data = page_data.page(page,size).all

bring_unmapped_to page_data , sub if bring_unmapped_needed
bring_unmapped_to page_data , sub, LinkedData::Models::Instance if bring_unmapped_needed

reply page_data
end
Expand All @@ -30,8 +30,8 @@ class InstancesController < ApplicationController
get do
ont, sub = get_ontology_and_submission
check_last_modified_segment(LinkedData::Models::Instance, [ont.acronym])

attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)
filter_by_label = label_regex_filter
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)


page_data = LinkedData::Models::Instance.where
Expand All @@ -42,7 +42,7 @@ class InstancesController < ApplicationController
page_data.order_by(order_by) unless order_by.nil?
page_data = page_data.page(page,size).all

bring_unmapped_to page_data , sub if bring_unmapped_needed
bring_unmapped_to page_data , sub, LinkedData::Models::Instance if bring_unmapped_needed

reply page_data
end
Expand All @@ -51,11 +51,11 @@ class InstancesController < ApplicationController
ont, sub = get_ontology_and_submission
check_last_modified_segment(LinkedData::Models::Instance, [ont.acronym])

attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::Instance)

page_data = LinkedData::Models::Instance.find(@params["inst"]).include(attributes).in(sub).first

bring_unmapped_to [page_data] , sub if bring_unmapped_needed
bring_unmapped_to [page_data] , sub, LinkedData::Models::Instance if bring_unmapped_needed

reply page_data
end
Expand Down
4 changes: 2 additions & 2 deletions controllers/skos_xl_label_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class SkosXlLabelController < ApplicationController
namespace "/ontologies/:ontology/skos_xl_labels" do
get do
ont, submission = get_ontology_and_submission
attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Label)
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Label)
labels = LinkedData::Models::SKOS::Label.where.in(submission).include(attributes).page(page, size).all
if labels && bring_unmapped_needed
LinkedData::Models::SKOS::Label.in(submission).models(labels).include(:unmapped).all
Expand All @@ -13,7 +13,7 @@ class SkosXlLabelController < ApplicationController

get '/:id' do
ont, submission = get_ontology_and_submission
attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Label)
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Label)
label = LinkedData::Models::SKOS::Label.find(params[:id]).in(submission).include(attributes).first
if label && bring_unmapped_needed
LinkedData::Models::SKOS::Label.in(submission).models([label]).include(:unmapped).all
Expand Down
11 changes: 5 additions & 6 deletions helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,14 @@ def retrieve_latest_submissions(options = {})
end

submissions_query = submissions_query.filter(Goo::Filter.new(ontology: [:viewOf]).unbound) unless include_views
submissions_query = submissions_query.filter(filter) if filter?
# When asking to display all metadata, we are using bring_remaining on each submission. Slower but best way to retrieve all attrs
if includes_param.first == :all
including = [:submissionId, {:contact=>[:name, :email], :ontology=>[:administeredBy, :acronym, :name, :summaryOnly, :ontologyType, :viewingRestriction, :acl,
includes = [:submissionId, {:contact=>[:name, :email], :ontology=>[:administeredBy, :acronym, :name, :summaryOnly, :ontologyType, :viewingRestriction, :acl,
:group, :hasDomain, :views, :viewOf, :flat], :submissionStatus=>[:code], :hasOntologyLanguage=>[:acronym]}, :submissionStatus]
submissions = submissions_query.include(including).to_a
else
submissions = submissions_query.include(includes).to_a
end

submissions = submissions_query.include(includes).to_a

# Figure out latest parsed submissions using all submissions
latest_submissions = {}
submissions.each do |sub|
Expand All @@ -391,7 +390,7 @@ def retrieve_latest_submissions(options = {})
latest_submissions[sub.ontology.acronym] ||= sub
latest_submissions[sub.ontology.acronym] = sub if sub.submissionId.to_i > latest_submissions[sub.ontology.acronym].submissionId.to_i
end
return latest_submissions
latest_submissions
end

def get_ontology_and_submission
Expand Down
2 changes: 1 addition & 1 deletion helpers/collections_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Helpers
module CollectionsHelper
def collections_setting_params
ont, submission = get_ontology_and_submission
attributes, page, size, filter_by_label, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Collection)
attributes, page, size, order_by, bring_unmapped_needed = settings_params(LinkedData::Models::SKOS::Collection)
[submission, attributes, bring_unmapped_needed]
end

Expand Down
48 changes: 1 addition & 47 deletions helpers/instances_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,12 @@
module Sinatra
module Helpers
module InstancesHelper

# TODO: generalize this to all routes (maybe in application_helper)
def settings_params(klass)
page, size = page_params
attributes = get_attributes_to_include(includes_param, klass)
order_by = get_order_by_from(@params)
bring_unmapped = bring_unmapped?(includes_param)
filter_by_label = label_regex_filter

[attributes, page, size, filter_by_label, order_by, bring_unmapped]
end

def is_set?(param)
!param.nil? && param != ""
end

def label_regex_filter
(Goo::Filter.new(:label).regex(@params["search"])) if is_set?(@params["search"])
end

def filter_classes_by(class_uri)
class_uri.nil? ? nil :{types: RDF::URI.new(class_uri.to_s)}
end

def get_order_by_from(params, default_order = :asc)
if is_set?(params['sortby'])
orders = (params["order"] || default_order.to_s).split(',')
out = params['sortby'].split(',').map.with_index do |param, index|
sort_order_item(param, orders[index] || default_order)
end
out.to_h
end

end

def get_attributes_to_include(includes_param, klass)
ld = klass.goo_attrs_to_load(includes_param)
ld.delete(:properties)
ld
end

def bring_unmapped?(includes_param)
(includes_param && includes_param.include?(:all))
end

def bring_unmapped_to(page_data, sub, klass = LinkedData::Models::Instance)
klass.in(sub).models(page_data).include(:unmapped).all
end

private
def sort_order_item(param , order)
[param.to_sym, order.to_sym]
class_uri.nil? ? nil : { types: RDF::URI.new(class_uri.to_s) }
end
end
end
Expand Down
Loading

0 comments on commit 6d3d046

Please sign in to comment.