Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 5, 2023
2 parents a199eff + c20e1d3 commit 9dd8d03
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 103 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ end
group :development do
gem 'rubocop', require: false
end

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development'
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'master'
gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'master'
26 changes: 11 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: 5979402d5138850fb9bdb34edfa350e9af1b5d22
branch: development
revision: 74ea47defc7f6260b045a6c6997bbe6a59c7bf62
branch: master
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -36,7 +36,7 @@ GEM
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
bcrypt (3.1.19)
bcrypt (3.1.20)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.2.2)
Expand All @@ -47,8 +47,7 @@ GEM
daemons (1.4.1)
date (3.3.4)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
domain_name (0.6.20231109)
email_spec (2.2.2)
htmlentities (~> 4.3.3)
launchy (~> 2.1)
Expand Down Expand Up @@ -86,8 +85,8 @@ GEM
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.6.3)
json_pure (2.6.3)
json (2.7.1)
json_pure (2.7.1)
jwt (2.7.1)
language_server-protocol (3.17.0.3)
launchy (2.5.2)
Expand Down Expand Up @@ -115,7 +114,7 @@ GEM
multi_json (1.15.0)
multipart-post (2.3.0)
net-http-persistent (2.9.4)
net-imap (0.4.4)
net-imap (0.4.7)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -139,7 +138,7 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.3)
public_suffix (5.0.4)
racc (1.7.3)
rack (1.6.13)
rack-test (0.8.3)
Expand All @@ -152,7 +151,7 @@ GEM
redis-client (>= 0.17.0)
redis-client (0.18.0)
connection_pool
regexp_parser (2.8.2)
regexp_parser (2.8.3)
request_store (1.5.1)
rack (>= 1.4)
rest-client (2.1.0)
Expand All @@ -163,15 +162,15 @@ GEM
rexml (3.2.6)
rsolr (1.1.2)
builder (>= 2.1.2)
rubocop (1.57.2)
rubocop (1.58.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
Expand All @@ -198,9 +197,6 @@ GEM
thread_safe (0.3.6)
timeout (0.4.1)
tzinfo (0.3.62)
unf (0.1.4)
unf_ext
unf_ext (0.0.9)
unicode-display_width (2.5.0)
uuid (2.3.9)
macaddr (~> 1.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/ontologies_linked_data/models/ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OntologyAnalyticsError < StandardError; end

attribute :acl, enforce: [:list, :user]

attribute :viewOf, enforce: [:ontology]
attribute :viewOf, enforce: [:ontology], onUpdate: :update_submissions_has_part
attribute :views, :inverse => { on: :ontology, attribute: :viewOf }
attribute :ontologyType, enforce: [:ontology_type], default: lambda { |record| LinkedData::Models::OntologyType.find("ONTOLOGY").include(:code).first }

Expand Down
33 changes: 16 additions & 17 deletions lib/ontologies_linked_data/serializers/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.serialize(obj, options = {})
end

# Add the type
hash["@type"] = type(current_cls, hashed_obj) if hash["@id"]
hash["@type"] = type(current_cls, hashed_obj) if hash["@id"]

# Generate links
# NOTE: If this logic changes, also change in xml.rb
Expand All @@ -39,8 +39,8 @@ def self.serialize(obj, options = {})
end
elsif (hashed_obj.instance_of?(LinkedData::Models::ExternalClass) || hashed_obj.instance_of?(LinkedData::Models::InterportalClass)) && !current_cls.embedded?
# Add context for ExternalClass
context_hash = {"@vocab" => Goo.vocabulary.to_s, "prefLabel" => "http://data.bioontology.org/metadata/skosprefLabel"}
context = {"@context" => context_hash}
context_hash = { "@vocab" => Goo.vocabulary.to_s, "prefLabel" => "http://data.bioontology.org/metadata/skosprefLabel" }
context = { "@context" => context_hash }
hash.merge!(context)
end
hash['@context']['@language'] = result_lang if hash['@context']
Expand Down Expand Up @@ -103,17 +103,17 @@ def self.generate_context(object, serialized_attrs = [], options = {})

if linked_model && linked_model.ancestors.include?(Goo::Base::Resource) && !embedded?(object, attr)
# linked object
predicate = {"@id" => linked_model.type_uri.to_s, "@type" => "@id"}
predicate = { "@id" => linked_model.type_uri.to_s, "@type" => "@id" }
else
# use the original predicate property if set
predicate_attr = current_cls.model_settings[:attributes][attr][:property] || attr
predicate_attr = current_cls.model_settings[:attributes][attr][:property] || attr
# predicate with custom namespace
# if the namespace can be resolved by the namespaces added in Goo then it will be resolved.
predicate = "#{Goo.vocabulary(current_cls.model_settings[:attributes][attr][:namespace])&.to_s}#{predicate_attr}"
end
hash[attr] = predicate unless predicate.nil?
end
context = {"@context" => hash}
context = { "@context" => hash }
CONTEXTS[object.hash] = context
context = remove_unused_attrs(context, serialized_attrs) unless options[:params] && options[:params]["full_context"].eql?("true")
context
Expand All @@ -126,12 +126,12 @@ def self.generate_links_context(object)
links.each do |link|
links_context[link.type] = link.type_uri.to_s
end
return {"@context" => links_context}
return { "@context" => links_context }
end

def self.remove_unused_attrs(context, serialized_attrs = [])
new_context = context["@context"].reject {|k,v| !serialized_attrs.include?(k) && !k.to_s.start_with?("@")}
{"@context" => new_context}
new_context = context["@context"].reject { |k, v| !serialized_attrs.include?(k) && !k.to_s.start_with?("@") }
{ "@context" => new_context }
end

def self.embedded?(object, attribute)
Expand All @@ -148,20 +148,19 @@ def self.generate_context?(options)
params = options[:params]
params.nil? ||
(params["no_context"].nil? ||
!params["no_context"].eql?("true")) &&
(params["display_context"].nil? ||
!params["display_context"].eql?("false"))
!params["no_context"].eql?("true")) &&
(params["display_context"].nil? ||
!params["display_context"].eql?("false"))
end

def self.generate_links?(options)
params = options[:params]
params.nil? ||
(params["no_links"].nil? ||
!params["no_links"].eql?("true")) &&
(params["display_links"].nil? ||
!params["display_links"].eql?("false"))
!params["no_links"].eql?("true")) &&
(params["display_links"].nil? ||
!params["display_links"].eql?("false"))
end
end
end
end

end
Loading

0 comments on commit 9dd8d03

Please sign in to comment.