Class: SHACL::Algebra::QualifiedValueShape
- Inherits:
-
Operator
- Object
- SPARQL::Algebra::Operator
- Operator
- SHACL::Algebra::QualifiedValueShape
- Defined in:
- lib/shacl/algebra/qualified_value_shape.rb
Constant Summary collapse
- NAME =
:qualifiedValueShape
Constants inherited from Operator
Instance Attribute Summary
Attributes inherited from Operator
Instance Method Summary collapse
-
#conforms(node, path:, value_nodes:, depth: 0, **options) ⇒ Array<SHACL::ValidationResult>
Specifies the condition that a specified number of value nodes conforms to the given shape.
Methods inherited from Operator
apply_op, #comment, #deactivated?, from_expanded_value, from_json, #id, iri, #iri, #label, #not_satisfied, parse_path, #satisfy, to_rdf, #to_sxp_bin, #type
Instance Method Details
#conforms(node, path:, value_nodes:, depth: 0, **options) ⇒ Array<SHACL::ValidationResult>
Specifies the condition that a specified number of value nodes conforms to the given shape. Each ‘sh:qualifiedValueShape` can have: one value for `sh:qualifiedMinCount`, one value for s`h:qualifiedMaxCount` or, one value for each, at the same subject.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shacl/algebra/qualified_value_shape.rb', line 12 def conforms(node, path:, value_nodes:, depth: 0, **) log_debug(NAME, depth: depth) {SXP::Generator.string({node: node, value_nodes: value_nodes}.to_sxp_bin)} max_count = .fetch(:qualifiedMaxCount, 0).to_i min_count = .fetch(:qualifiedMinCount, 0).to_i # FIXME: figure this out disjoint = [:qualifiedValueShapesDisjoint] operands.map do |op| results = value_nodes.map do |n| op.conforms(n, depth: depth + 1, **) end.flatten.compact count = results.select(&:conform?).length log_debug(NAME, depth: depth) {"#{count}/#{results} conforming shapes"} if count < min_count not_satisfied(focus: node, path: path, message: "only #{count} conforming values, requires at least #{min_count}", resultSeverity: .fetch(:severity), component: RDF::Vocab::SHACL.QualifiedMinCountConstraintComponent, depth: depth, **) elsif count > max_count not_satisfied(focus: node, path: path, message: "#{count} conforming values, requires at most #{max_count}", resultSeverity: .fetch(:severity), component: RDF::Vocab::SHACL.QualifiedMaxCountConstraintComponent, depth: depth, **) else satisfy(focus: node, path: path, message: "#{min_count} <= #{count} <= #{max_count} values conform", component: RDF::Vocab::SHACL.QualifiedMinCountConstraintComponent, depth: depth, **) end end end |