solis 0.73.0 → 0.74.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solis/graph.rb +1 -1
- data/lib/solis/model.rb +40 -10
- data/lib/solis/query.rb +2 -2
- data/lib/solis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 166805286e332f8a5a9f572fa6ab7841f2f234223384b298139fa25d8339cf91
|
4
|
+
data.tar.gz: e43b4f5b33c911c8759e96012165cd9203b6941113e511442d169b0acd61bfe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a091ee239234b0a71cfde2cbebb19905af07af63bf2e58dedb6c0178a7f2c4ac9d3f875df509cecf689857c4dcfac2cc76fa0f4b8dc4ef2d7b1df566af4edc8
|
7
|
+
data.tar.gz: 96dc87a0b2b208f6f56adcae71b391a7cbd18b22ac2ba4ea6d936d87d39bd98d88a2c74bed54d12c6a73fa00896ec23dbd60bf4b52474cc5d7f11f4048188961
|
data/lib/solis/graph.rb
CHANGED
@@ -351,7 +351,7 @@ module Solis
|
|
351
351
|
|
352
352
|
@sparql_client = SPARQL::Client.new(@sparql_endpoint)
|
353
353
|
result = @sparql_client.query("with <#{graph_name}> delete {?s ?p ?o} where{?s ?p ?o}")
|
354
|
-
LOGGER.info(result
|
354
|
+
LOGGER.info(result)
|
355
355
|
true
|
356
356
|
end
|
357
357
|
|
data/lib/solis/model.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
require 'iso8601'
|
3
|
+
require 'hashdiff'
|
3
4
|
require_relative 'query'
|
4
5
|
|
5
6
|
module Solis
|
@@ -173,20 +174,49 @@ values ?s {<#{self.graph_id}>}
|
|
173
174
|
raise Solis::Error::NotFoundError if original_klass.nil?
|
174
175
|
updated_klass = original_klass.deep_dup
|
175
176
|
|
176
|
-
attributes.each_pair do |key, value|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
embedded.
|
182
|
-
|
183
|
-
|
177
|
+
attributes.each_pair do |key, value| # check each key. if it is an entity process it
|
178
|
+
unless original_klass.class.metadata[:attributes][key][:node].nil? #it is an entity
|
179
|
+
value = [value] unless value.is_a?(Array)
|
180
|
+
value.each do |sub_value|
|
181
|
+
embedded = self.class.graph.shape_as_model(original_klass.class.metadata[:attributes][key][:datatype].to_s).new(sub_value)
|
182
|
+
if embedded.exists?(sparql)
|
183
|
+
embedded_data = properties_to_hash(embedded)
|
184
|
+
embedded.update(embedded_data)
|
185
|
+
else
|
186
|
+
embedded.save
|
187
|
+
end
|
184
188
|
end
|
185
189
|
end
|
186
190
|
|
187
191
|
updated_klass.instance_variable_set("@#{key}", value)
|
188
192
|
end
|
189
193
|
|
194
|
+
|
195
|
+
# attributes.each_pair do |key, value|
|
196
|
+
# if value.is_a?(Hash)
|
197
|
+
# embedded = self.class.graph.shape_as_model(original_klass.class.metadata[:attributes][key][:datatype].to_s).new(value)
|
198
|
+
# if embedded.exists?(sparql)
|
199
|
+
# embedded_data = properties_to_hash(embedded)
|
200
|
+
# embedded.update(embedded_data)
|
201
|
+
# else
|
202
|
+
# embedded.save
|
203
|
+
# end
|
204
|
+
# elsif value.is_a?(Array)
|
205
|
+
# value.each do |sub_value|
|
206
|
+
# if sub_value.is_a?(Hash)
|
207
|
+
# if embedded.exists?(sparql)
|
208
|
+
# embedded_data = properties_to_hash(embedded)
|
209
|
+
# embedded.update(embedded_data)
|
210
|
+
# else
|
211
|
+
# embedded.save
|
212
|
+
# end
|
213
|
+
# end
|
214
|
+
# end
|
215
|
+
# end
|
216
|
+
#
|
217
|
+
# updated_klass.instance_variable_set("@#{key}", value)
|
218
|
+
# end
|
219
|
+
|
190
220
|
# attributes.each_pair do |key, value|
|
191
221
|
# updated_klass.instance_variable_set("@#{key}", value)
|
192
222
|
# end
|
@@ -264,9 +294,9 @@ values ?s {<#{self.graph_id}>}
|
|
264
294
|
before_update_proc&.call(original_klass, updated_klass)
|
265
295
|
|
266
296
|
properties_orignal_klass = properties_to_hash(original_klass)
|
267
|
-
|
297
|
+
properties_updated_klass = properties_to_hash(updated_klass)
|
268
298
|
|
269
|
-
if Hashdiff.best_diff(properties_orignal_klass,
|
299
|
+
if Hashdiff.best_diff(properties_orignal_klass, properties_updated_klass).empty?
|
270
300
|
Solis::LOGGER.info("#{original_klass.class.name} unchanged, skipping")
|
271
301
|
data = self.query.filter({ filters: { id: [id] } }).find_all.map { |m| m }&.first
|
272
302
|
else
|
data/lib/solis/query.rb
CHANGED
@@ -191,11 +191,11 @@ order by ?s
|
|
191
191
|
from_cache = Graphiti.context[:object]&.from_cache || '0'
|
192
192
|
if @query_cache.key?(query_key) && from_cache.eql?('1')
|
193
193
|
result = @query_cache[query_key]
|
194
|
-
Solis::LOGGER.info("CACHE: from #{query_key}")
|
194
|
+
Solis::LOGGER.info("CACHE: from #{query_key}") if ConfigFile[:debug]
|
195
195
|
else
|
196
196
|
result = graph_to_object(sparql_client.query(query))
|
197
197
|
@query_cache[query_key] = result unless result.nil? || result.empty?
|
198
|
-
Solis::LOGGER.info("CACHE: to #{query_key}")
|
198
|
+
Solis::LOGGER.info("CACHE: to #{query_key}") if ConfigFile[:debug]
|
199
199
|
end
|
200
200
|
|
201
201
|
result
|
data/lib/solis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.74.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Celik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|