Skip to content
Alpha: see what works today →
Menu

Lens

export

A stricter lens, for records sent elsewhere: a person's judgment counts unless retracted or replaced, and a matcher judgment only when the Cascade matcher made it resting on the same code, or code and date, or code and period, made with current reference versions, and asserted under a version whose row for its rule has the query hash of the current rule list version's row for it, by an assertion no retraction invalidates. A retracted judgment replaces nothing.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>

CONSTRUCT { ?j cascade:countsUnderLens true }
WHERE {
  { ?j a cascade:Judgment ; prov:wasAttributedTo/a prov:Person .
    FILTER NOT EXISTS {
      ?replacing dct:replaces ?j
      OPTIONAL { ?undoing prov:invalidated ?replacing }
      FILTER (!BOUND(?undoing))
    }
    FILTER NOT EXISTS { ?retraction prov:invalidated ?j } }
  UNION
  { { SELECT DISTINCT ?j
          WHERE {
            { SELECT DISTINCT ?rule ?hash
              WHERE { ?ruleList pav:hasCurrentVersion ?current .
                      ?currentRow cascade:rowOfRuleListVersion ?current ; cascade:matcherRule ?rule ; cascade:queryHash ?hash } }
            ?assertedRow cascade:matcherRule ?rule ; cascade:queryHash ?hash ; cascade:rowOfRuleListVersion ?asserted .
            ?assertion cascade:assertedUnderRuleListVersion ?asserted ; cascade:assertedJudgment ?j .
            FILTER NOT EXISTS { ?assertionRetraction prov:invalidated ?assertion }
            ?j cascade:matcherRule ?rule .
          } }
    ?j a cascade:Judgment ; prov:wasAttributedTo cascade:CascadeMatcher ; cascade:justification ?why .
    FILTER (?why IN (cascade:SameCode, cascade:SameCodeAndDate, cascade:SameCodeAndPeriod))
    FILTER NOT EXISTS {
      ?replacing dct:replaces ?j
      OPTIONAL { ?undoing prov:invalidated ?replacing }
      FILTER (!BOUND(?undoing))
    }
    FILTER NOT EXISTS { ?retraction prov:invalidated ?j }
    MINUS {
      ?j prov:wasDerivedFrom ?input .
      ?input prov:specializationOf ?series .
      ?series a cascade:ReferenceSeries ; pav:hasCurrentVersion ?now .
      FILTER (?now != ?input)
    } }
}

Terms it reads

cascade:CascadeMatcher · cascade:Judgment · cascade:ReferenceSeries · cascade:SameCode · cascade:SameCodeAndDate · cascade:SameCodeAndPeriod · cascade:assertedJudgment · cascade:assertedUnderRuleListVersion · cascade:countsUnderLens · cascade:justification · cascade:matcherRule · cascade:queryHash · cascade:rowOfRuleListVersion · dct:replaces · pav:hasCurrentVersion · prov:Person · prov:invalidated · prov:specializationOf · prov:wasAttributedTo · prov:wasDerivedFrom

Rules and decision notes that name it

No rule or decision note writes its path.

queries/lenses/export.rq on GitHub ↗