Class: SHACL::Algebra::NotConstraintComponent

Inherits:
ConstraintComponent show all
Defined in:
lib/shacl/algebra/not.rb

Constant Summary collapse

NAME =
:not

Constants inherited from Operator

Operator::BUILTIN_KEYS, Operator::PARAMETERS

Instance Attribute Summary

Attributes inherited from Operator

#graph, #options, #shapes_graph

Instance Method Summary collapse

Methods inherited from ConstraintComponent

from_json, ncname

Methods inherited from Operator

add_component, apply_op, #comment, component_params, #deactivated?, from_expanded_value, from_json, #id, iri, #iri, #label, #not_satisfied, params, 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 cannot conform to a given shape. This is comparable to negation and the logical “not” operator.

Parameters:

  • node (RDF::Term)

    focus node

  • path (RDF::URI, SPARQL::Algebra::Expression) (defaults to: nil)

    (nil) the property path from the focus node to the value nodes.

  • options (Hash{Symbol => Object})

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/shacl/algebra/not.rb', line 13

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.any?(&:conform?)
      return not_satisfied(focus: node, path: path,
        message: "node does not conform to some shape",
        resultSeverity: options.fetch(:severity),
        component: RDF::Vocab::SHACL.NotConstraintComponent,
        value: node, depth: depth, **options)
    end
  end
  satisfy(focus: node, path: path,
    message: "node conforms to all shapes",
    component: RDF::Vocab::SHACL.NotConstraintComponent,
    value: node, depth: depth, **options)
end