Class: Dbd::ProvenanceFact

Inherits:
Fact
  • Object
show all
Defined in:
lib/dbd/provenance_fact.rb

Overview

ProvenanceFact

ProvenanceFact is derived from Fact and behaves very similar.

The ProvenanceFacts with same subject form a ProvenanceResource and this is used as the target for the provenance_subject of a Fact.

The provenance_subject of a ProvenanceFact itself is empty, so the usage of provenance_subject is not recursive on this level (this allows efficient single pass loading in an underlying database).

In the serialisation of a fact stream, the presence or absence of a provenance_subject marks the difference between a (base) Fact and a ProvenanceFact.

The predicates in a ProvenanceFact would typically come from a defined "provenance ontology". An experimental example of a provenance ontology is built-up on https://data.vandenabeele.com/ontologies/provenance.

Instance Method Summary collapse

Methods inherited from Fact

attributes, #errors, new_id, new_subject, #provenance_subject=, #subject=, #time_stamp=, #values

Constructor Details

#initialize(options) ⇒ ProvenanceFact

Builds a new ProvenanceFact.

Parameters:

  • options (Hash{Symbol => Object})

Options Hash (options):

  • :subject (Fact::Subject) — default: new_subject

    Optional: the subject for the ProvenanceFact

  • :predicate (String)

    Required: the subject for the ProvenanceFact

  • :object (String)

    Required: the object for the ProvenanceFact



31
32
33
34
# File 'lib/dbd/provenance_fact.rb', line 31

def initialize(options)
  validate_provenance_subject(options)
  super
end

Instance Method Details

#dup_with_subject(subject_arg) ⇒ ProvenanceFact

Builds duplicate with the subject set.

Parameters:

Returns:



60
61
62
63
64
65
# File 'lib/dbd/provenance_fact.rb', line 60

def dup_with_subject(subject_arg)
  self.class.new(
   subject: subject_arg, # from arg
   predicate: predicate,
   object: object)
end

#provenance_subject_error(provenance_subject) ⇒ Object

Validates the presence or absence of provenance_subject.

Here, in the derived ProvenanceFact, it must not be present. Return [nil, String] nil if valid, an error message if not

Parameters:

  • provenance_subject (#nil?)


51
52
53
# File 'lib/dbd/provenance_fact.rb', line 51

def provenance_subject_error(provenance_subject)
  "Provenance subject should not be present in Provenance Fact" if provenance_subject
end

#update_used_provenance_subjects(h) ⇒ Object

Executes the required update in used_provenance_subjects.

For a ProvenanceFact, there is no provenance_subject, so pointless to mark it in used_provenance_subjects hash.



41
42
43
# File 'lib/dbd/provenance_fact.rb', line 41

def update_used_provenance_subjects(h)
  # Do nothing (override the behaviour from super).
end