solis 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d5926e4dab3d02865ae5333e319a8973c79e1b0b49d1fc86ec5cd17d32204ed
4
- data.tar.gz: d33d664a73dcb56231d1fc0364314100a114d83b0c2c75c7c11479aa00fba4b7
3
+ metadata.gz: 1ea2b39d46de37ed36dd0132d993c82abac68da1fddc43c7ccae04ada175dbd1
4
+ data.tar.gz: 482e9fd7e9da74e9324f9836e2d820dea97918458d48c598e3267145d78337ae
5
5
  SHA512:
6
- metadata.gz: 64bc93c8a1767fc786d2c2528762e7707aad9e33cbe1ec9d9d1208ccbd12f76d65e8bbd244ae88a7a2a89147eb7facc4194d41bcf38cc04c6c0d29a055da207f
7
- data.tar.gz: ce928eaf3a1b43bf1a93678dd5f47544265f47e71df9c61c64d5c1819056aade67fd175fc54b611e03a6e8eb0d5d7c2b9c761b812c0e3a8a2c16a2557130d5c0
6
+ metadata.gz: 654347d6d6a72464e6b513be9cbf31412f5fde09da73cf013bda2a46e7a205839af11550fe7b0b2c4b77c55b370c08b6e1f3e651c5168a894b46544060e7be45
7
+ data.tar.gz: 38631633199f44e18b21cd07833f0a3b79e851276bf41b2fad49639eb23f1350d69fa811cb55cd2535fa4a4f756867994bb3630c59fae5da4cb549c54889d55b
data/lib/solis/graph.rb CHANGED
@@ -292,6 +292,23 @@ module Solis
292
292
  "#{resource.class.graph_name.gsub(/\/$/,'')}/#{belongs_to_resource_name.tableize}?filter[id]=#{resource_ids.join(',')}" unless remote_resources.nil? || resource_ids.empty?
293
293
  end
294
294
  end
295
+ elsif (value[:mincount] && value[:mincount] == 1) || (value[:maxcount] && value[:maxcount] == 1)
296
+ has_one_resource_name = value[:datatype].nil? ? value[:class].gsub(self.model.graph_name, '') : value[:datatype].to_s.classify
297
+ LOGGER.info "\t\t\t#{resource_name}(#{resource_name.gsub('Resource','').tableize.singularize}) has_one #{has_one_resource_name}(#{key})"
298
+ resource.has_one(key.to_sym, foreign_key: :id, primary_key: :id, resource: graph.shape_as_resource("#{has_one_resource_name}", stack_level << has_one_resource_name)) do
299
+ link do |resource|
300
+ remote_resources = resource.instance_variable_get("@#{key}")
301
+ if remote_resources
302
+ remote_resources = [remote_resources] unless remote_resources.is_a?(Array)
303
+ resource_ids = remote_resources.map do |remote_resource|
304
+ remote_resource.id =~ /^http/ ? remote_resource.id.split('/').last : remote_resource.id
305
+ end
306
+
307
+ end
308
+
309
+ "#{resource.class.graph_name.gsub(/\/$/,'')}/#{has_one_resource_name.tableize}?filter[id]=#{resource_ids.join(',')}" unless remote_resources.nil? || resource_ids.empty?
310
+ end
311
+ end
295
312
  else
296
313
  has_many_resource_name = value[:datatype].nil? ? value[:class].gsub(self.model.graph_name, '') : value[:datatype].to_s.classify
297
314
  LOGGER.info "\t\t\t#{resource_name}(#{resource_name.gsub('Resource','').tableize.singularize}) has_many #{has_many_resource_name}(#{key})"
data/lib/solis/model.rb CHANGED
@@ -225,6 +225,9 @@ values ?s {<#{self.graph_id}>}
225
225
  end
226
226
  end
227
227
 
228
+ maxcount = original_klass.class.metadata[:attributes][key][:maxcount]
229
+ value = value.first if maxcount && maxcount == 1 && value.is_a?(Array)
230
+
228
231
  updated_klass.instance_variable_set("@#{key}", value)
229
232
  end
230
233
 
@@ -483,7 +486,12 @@ values ?s {<#{self.graph_id}>}
483
486
  end
484
487
  end
485
488
 
486
- make_graph(graph, hierarchy, id, original_klass, klass_metadata, resolve_all)
489
+ begin
490
+ make_graph(graph, hierarchy, id, original_klass, klass_metadata, resolve_all)
491
+ rescue => e
492
+ Solis::LOGGER.error(e.message)
493
+ raise e
494
+ end
487
495
 
488
496
  hierarchy.pop
489
497
  id
data/lib/solis/query.rb CHANGED
@@ -320,7 +320,7 @@ PREFIX #{@model.class.graph_prefix}: <#{@model.class.graph_name}>"
320
320
 
321
321
  if data.key?(attribute) # attribute exists
322
322
  raise "Cardinality error, max = #{solution_model.metadata[:attributes][attribute][:maxcount]}" if solution_model.metadata[:attributes][attribute][:maxcount] == 0
323
- if solution_model.metadata[:attributes][attribute][:maxcount] == 1 && data.key?(attribute)
323
+ if solution_model.metadata[:attributes][attribute][:maxcount] == 1 && data.key?(attribute) && data[attribute].is_a?(Array) && data[attribute].length > 1
324
324
  raise "Cardinality error, max = #{solution_model.metadata[:attributes][attribute][:maxcount]}"
325
325
  elsif solution_model.metadata[:attributes][attribute][:maxcount] == 1
326
326
  data[attribute] = object
@@ -11,7 +11,7 @@ module Solis
11
11
  @endpoint = endpoint
12
12
  @graph_name = graph_name
13
13
 
14
- @pool = ConnectionPool.new(size:5, timeout: 60) do
14
+ @pool = ConnectionPool.new(size:5, timeout: 160) do
15
15
  SPARQL::Client.new(@endpoint, graph: @graph_name)
16
16
  #SPARQL::Client.new(@endpoint)
17
17
  end
data/lib/solis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Solis
2
- VERSION = "0.87.0"
2
+ VERSION = "0.88.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.87.0
4
+ version: 0.88.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Celik
@@ -335,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
335
  - !ruby/object:Gem::Version
336
336
  version: '0'
337
337
  requirements: []
338
- rubygems_version: 3.6.8
338
+ rubygems_version: 3.6.9
339
339
  specification_version: 4
340
340
  summary: Turn any SHACL file into an API, ORM, documentation, ...
341
341
  test_files: []