Class: SHACL::Algebra::And

Inherits:
Operator
  • Object
show all
Defined in:
lib/shacl/algebra/and.rb

Constant Summary collapse

NAME =
:and

Constants inherited from Operator

Operator::ALL_KEYS

Instance Attribute Summary

Attributes inherited from Operator

#graph, #options

Instance Method Summary collapse

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: nil, depth: 0, **options) ⇒ Array<SHACL::ValidationResult>

Specifies the condition that each value node conforms to all provided shapes. This is comparable to conjunction and the logical “and” operator.

Examples:

ex:SuperShape
	a sh:NodeShape ;
	sh:property [
		sh:path ex:property ;
		sh:minCount 1 ;
	] .

ex:ExampleAndShape
	a sh:NodeShape ;
	sh:targetNode ex:ValidInstance, ex:InvalidInstance ;
	sh:and (
		ex:SuperShape
		[
			sh:path ex:property ;
			sh:maxCount 1 ;
		]
	) .

Parameters:

  • node (RDF::Term)
  • options (Hash{Symbol => Object})

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/shacl/algebra/and.rb', line 31

def conforms(node, path: nil, depth: 0, **options)
  log_debug(NAME, depth: depth) {SXP::Generator.string({node: node}.to_sxp_bin)}
  operands.each do |op|
    results = op.conforms(node, depth: depth + 1, **options)
    if !results.all?(&:conform?)
      return not_satisfied(focus: node, path: path,
        value: node,
        message: "node does not conform to all shapes",
        resultSeverity: options.fetch(:severity),
        component: RDF::Vocab::SHACL.AndConstraintComponent,
        depth: depth, **options)
    end
  end
  satisfy(focus: node, path: path,
    value: node,
    message: "node conforms to all shapes",
    component: RDF::Vocab::SHACL.AndConstraintComponent,
    depth: depth, **options)
end