Skip to content

Commit

Permalink
Merge to master: release 3.0.1 (#135)
Browse files Browse the repository at this point in the history
* add paging by default to /artefacts (#125)

* remove appuser from the dockerfile (#133)

* Feature: add / route for SemanticartefactCatalog (#117)

* add / route for SemanticartefactCatalog

* add /doc/api route

* refactor home controller

* add pandoc-ruby for documentation and update Gemfile.lock

* update ontologie_linked_data

* handle getting all the attributes

* update Gemfile.lock

* use development for ontologies_linked_data

* add pandoc so to render the documentation (#136)

---------

Co-authored-by: Imad Bourouche <[email protected]>
  • Loading branch information
syphax-bouazzouni and imadbourouche authored Feb 25, 2025
1 parent 7a8a421 commit ad9d940
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 23 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ RUN apt-get update && \
git \
curl \
libffi-dev \
pandoc \
pkg-config && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -48,10 +49,6 @@ COPY . .
RUN cp config/environments/config.rb.sample config/environments/development.rb && \
cp config/environments/config.rb.sample config/environments/production.rb

# Create non-root user
RUN adduser --disabled-password --gecos "" appuser && \
chown -R appuser:appuser /srv/ontoportal

# Expose port
EXPOSE 9393

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ gem 'unicorn-worker-killer'
# Templating
gem 'haml', '~> 5.2.2'
gem 'rack-contrib'
gem 'pandoc-ruby'

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'ncbo_annotator', git: 'https://github.com/ontoportal-lirmm/ncbo_annotator.git', branch: 'development'
Expand Down
15 changes: 9 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_cron.git
revision: c863617c47ee224905d845a4baa5558b674a7b91
revision: cc4cd9218db7181c4843772631b7f3a96c74a4aa
branch: master
specs:
ncbo_cron (0.0.1)
Expand Down Expand Up @@ -57,7 +57,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 728ac871578d607d1c4e4e7a4f0800e8d263890f
revision: b321d73a28b4f60fc5969da7a071b3c19c1a84f3
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -274,7 +274,8 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
httpclient (2.9.0)
mutex_m
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.1)
Expand Down Expand Up @@ -308,7 +309,7 @@ GEM
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2025.0204)
mime-types-data (3.2025.0220)
mini_mime (1.1.5)
minitest (5.25.4)
minitest-fail-fast (0.1.0)
Expand Down Expand Up @@ -357,6 +358,7 @@ GEM
logger
os (1.1.4)
ostruct (0.6.1)
pandoc-ruby (2.1.10)
parallel (1.26.3)
parseconfig (1.1.2)
parser (3.3.7.1)
Expand Down Expand Up @@ -408,7 +410,7 @@ GEM
rdf-xsd (3.3.0)
rdf (~> 3.3)
rexml (~> 3.2)
redis (5.3.0)
redis (5.4.0)
redis-client (>= 0.22.0)
redis-client (0.23.2)
connection_pool
Expand All @@ -434,7 +436,7 @@ GEM
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
rubocop (1.72.1)
rubocop (1.72.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand Down Expand Up @@ -545,6 +547,7 @@ DEPENDENCIES
newrelic_rpm
oj
ontologies_linked_data!
pandoc-ruby
parallel
parseconfig
rack
Expand Down
8 changes: 3 additions & 5 deletions controllers/artefacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ class ArtefactsController < ApplicationController
# Get all Semantic Artefacts
get do
check_last_modified_collection(LinkedData::Models::SemanticArtefact)
options = {
also_include_views: params['also_include_views'] ||= false,
includes: LinkedData::Models::SemanticArtefact.goo_attrs_to_load([])
}
artefacts = LinkedData::Models::SemanticArtefact.all_artefacts(options)
attributes, page, pagesize, _, _ = settings_params(LinkedData::Models::SemanticArtefact)
pagesize = 20 if params["pagesize"].nil?
artefacts = LinkedData::Models::SemanticArtefact.all_artefacts(attributes, page, pagesize)
reply artefacts
end

Expand Down
50 changes: 42 additions & 8 deletions controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,36 @@ class HomeController < ApplicationController
routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix + route_no_slash
end

config = LinkedData::Models::PortalConfig.current_portal_config
catalog_class = LinkedData::Models::SemanticArtefactCatalog
catalog = catalog_class.all.first || create_catalog
attributes_to_include = includes_param[0] == :all ? catalog_class.attributes(:all) : catalog_class.goo_attrs_to_load(includes_param)
catalog.bring(*attributes_to_include)
if catalog.loaded_attributes.include?(:federated_portals)
catalog.federated_portals = catalog.federated_portals.map { |item| JSON.parse(item.gsub('=>', ':').gsub('\"', '"')) }
catalog.federated_portals.each { |item| item.delete('apikey') }
end
if catalog.loaded_attributes.include?(:fundedBy)
catalog.fundedBy = catalog.fundedBy.map { |item| JSON.parse(item.gsub('=>', ':').gsub('\"', '"')) }
end
catalog.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) }

reply catalog
end

federated_portals = config.federated_portals
federated_portals.transform_values! { |v| v.delete(:apikey); v }
config.init_federated_portals_settings(federated_portals)
config.id = RDF::URI.new(LinkedData.settings.id_url_prefix)
config.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) }
patch do
catalog = LinkedData::Models::SemanticArtefactCatalog.where.first
error 422, "There is no catalog configs in the triple store" if catalog.nil?
populate_from_params(catalog, params)
if catalog.valid?
catalog.save
status 200
else
error 422, catalog.errors
end
end

reply config
get "doc/api" do
redirect "/documentation", 301
end

get "documentation" do
Expand All @@ -49,7 +70,20 @@ class HomeController < ApplicationController

private


def create_catalog
catalog = nil
catalogs = LinkedData::Models::SemanticArtefactCatalog.all
if catalogs.nil? || catalogs.empty?
catalog = instance_from_params(LinkedData::Models::SemanticArtefactCatalog, {"test_attr_to_persist" => "test_to_persist"})
if catalog.valid?
catalog.save
else
error 422, catalog.errors
end
end
catalog
end


end
end
3 changes: 3 additions & 0 deletions controllers/submission_metadata_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ class SubmissionMetadataController < ApplicationController
reply klass_metadata(LinkedData::Models::Ontology, "ontology_metadata")
end

get "/catalog_metadata" do
reply klass_metadata(LinkedData::Models::SemanticArtefactCatalog, "catalog_metadata")
end
end

0 comments on commit ad9d940

Please sign in to comment.