solis 0.106.0 → 0.107.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 +4 -4
- data/lib/solis/query/filter.rb +31 -8
- data/lib/solis/sparql_adaptor.rb +25 -1
- data/lib/solis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ce95b73b7c870b2a744239d77e8a590c8793c0f59504c560af96013e82ff42e
|
|
4
|
+
data.tar.gz: 669a40a5a83298d7ec3d46a77ee7c66b9b7075d1a6deca037d7b76ad60a2e18c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39bb7dcce2bc5112dac714a41ad2649267b37be1a5fb3a1c2baf01dcdc61ed919cff7f89422663b9c74e761f3a13e957e1dffd4af8460fbd967ffdc8e9897620
|
|
7
|
+
data.tar.gz: '05931d4a566eb0e560da95d690804b87d51d0a34ce5677e370a775292100077caf1a7bda7237f52fb7dc337e2985d3dbbfffa9f27937ca6faab67d4df087b54d'
|
data/lib/solis/query/filter.rb
CHANGED
|
@@ -75,15 +75,15 @@ module Solis
|
|
|
75
75
|
contains = value[:value].map { |m| m.is_a?(String) ? "CONTAINS(LCASE(str(?__search#{i})), LCASE(\"#{m}\"))" : next }.join(' || ')
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
# Ensure value[:value] is always an array for consistent handling below
|
|
79
|
+
value[:value] = [value[:value]] unless value[:value].is_a?(Array)
|
|
80
|
+
value[:value].flatten!
|
|
81
|
+
|
|
78
82
|
metadata = @metadata[:attributes][key.to_s]
|
|
79
83
|
if metadata
|
|
80
84
|
if metadata[:path] =~ %r{/id$}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
else
|
|
84
|
-
value[:value].flatten!
|
|
85
|
-
contains = value[:value].map { |m| "\"#{m}\"" }.join(',')
|
|
86
|
-
end
|
|
85
|
+
# value[:value] is guaranteed to be an array at this point
|
|
86
|
+
contains = value[:value].map { |m| "\"#{m}\"" }.join(',')
|
|
87
87
|
if value[:is_not]
|
|
88
88
|
value[:value].each do |v|
|
|
89
89
|
v=normalize_string(v)
|
|
@@ -94,9 +94,22 @@ module Solis
|
|
|
94
94
|
end
|
|
95
95
|
else
|
|
96
96
|
datatype = ''
|
|
97
|
-
|
|
97
|
+
case metadata[:datatype]
|
|
98
|
+
when :boolean
|
|
99
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#boolean>"
|
|
100
|
+
when :integer
|
|
101
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#integer>"
|
|
102
|
+
when :float, :double
|
|
103
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#double>"
|
|
104
|
+
when :date
|
|
105
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#date>"
|
|
106
|
+
when :datetime, :time
|
|
107
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#dateTime>"
|
|
108
|
+
when :anyuri
|
|
109
|
+
datatype = "^^<http://www.w3.org/2001/XMLSchema#anyURI>"
|
|
110
|
+
end
|
|
98
111
|
|
|
99
|
-
if ["=", "<", ">"].include?(value[:operator])
|
|
112
|
+
if ["=", "<", ">", ">=", "<="].include?(value[:operator])
|
|
100
113
|
not_operator = value[:is_not] ? '!' : ''
|
|
101
114
|
value[:value].each do |v|
|
|
102
115
|
if metadata[:datatype_rdf].eql?('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString')
|
|
@@ -110,6 +123,16 @@ module Solis
|
|
|
110
123
|
|
|
111
124
|
search_for = normalize_string(search_for)
|
|
112
125
|
filter += "FILTER(str(?__search#{i}) #{not_operator}#{value[:operator]} \"#{search_for}\"#{datatype}) .\n"
|
|
126
|
+
elsif (metadata[:datatype_rdf].eql?('http://www.w3.org/2001/XMLSchema#anyURI') || !metadata[:node].nil?) && ["=", "!="].include?(value[:operator])
|
|
127
|
+
# Special handling for anyURI references to other entities (only for equality/inequality)
|
|
128
|
+
model_graph_name = Solis::Options.instance.get.key?(:graphs) ? Solis::Options.instance.get[:graphs].select{|s| s['type'].eql?(:main)}&.first['name'] : @model.class.graph_name
|
|
129
|
+
if value[:is_not]
|
|
130
|
+
#filter = "filter( !exists {?concept <#{metadata[:path]}> ?__search#{i} . ?__search#{i} <#{model_graph_name}id> \"#{v}\"})"
|
|
131
|
+
filter = "filter( !exists {?concept <#{metadata[:path]}> <#{v}>})"
|
|
132
|
+
else
|
|
133
|
+
#filter = "?concept <#{metadata[:path]}> ?__search#{i} . ?__search#{i} <#{model_graph_name}id> ?__search#{i}_#{i} filter(?__search#{i}_#{i} = \"#{v}\")."
|
|
134
|
+
filter = "?concept <#{metadata[:path]}> <#{v}>."
|
|
135
|
+
end
|
|
113
136
|
else
|
|
114
137
|
v=normalize_string(v)
|
|
115
138
|
filter = "?concept <#{metadata[:path]}> ?__search#{i} FILTER(?__search#{i} #{not_operator}#{value[:operator]} \"#{v}\"#{datatype}) .\n"
|
data/lib/solis/sparql_adaptor.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Solis
|
|
|
42
42
|
integer: [:eq, :not_eq, :gt, :lt],
|
|
43
43
|
float: [:eq, :not_eq, :gt, :lt],
|
|
44
44
|
big_decimal: [:eq, :not_eq, :gt, :lt],
|
|
45
|
-
date: [:eq, :not_eq, :gt, :lt],
|
|
45
|
+
date: [:eq, :not_eq, :gt, :gte, :lt, :lte],
|
|
46
46
|
boolean: [:eq, :not_eq],
|
|
47
47
|
uuid: [:eq, :not_eq],
|
|
48
48
|
enum: [:eq],
|
|
@@ -149,6 +149,30 @@ module Solis
|
|
|
149
149
|
alias :filter_enum_not_lt :filter_not_lt
|
|
150
150
|
alias :filter_datetime_not_lt :filter_not_lt
|
|
151
151
|
|
|
152
|
+
def filter_gte(scope, attribute, value)
|
|
153
|
+
filter_eq(scope, attribute, value, false, '>=')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
alias :filter_date_gte :filter_gte
|
|
157
|
+
|
|
158
|
+
def filter_not_gte(scope, attribute, value)
|
|
159
|
+
filter_eq(scope, attribute, value, true, '>=')
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
alias :filter_date_not_gte :filter_not_gte
|
|
163
|
+
|
|
164
|
+
def filter_lte(scope, attribute, value)
|
|
165
|
+
filter_eq(scope, attribute, value, false, '<=')
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
alias :filter_date_lte :filter_lte
|
|
169
|
+
|
|
170
|
+
def filter_not_lte(scope, attribute, value)
|
|
171
|
+
filter_eq(scope, attribute, value, true, '<=')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
alias :filter_date_not_lte :filter_not_lte
|
|
175
|
+
|
|
152
176
|
def transaction(*)
|
|
153
177
|
yield
|
|
154
178
|
end
|
data/lib/solis/version.rb
CHANGED