# Explicit create, update and delete.
# Although the source is the same file, changes are made explicit in
# different JSON fields, thus we need 3 sources with another iterator.

prefixes:
  ex: http://example.com/
  as: https://www.w3.org/ns/activitystreams#

sources:
  source-create: [base.json~jsonpath, '$.addition[*]']
  source-update: [base.json~jsonpath, '$.modification[*]']
  source-delete: [base.json~jsonpath, '$.deletion[*]']

targets:
  target-ldes:
    access: output-base.nq
    type: void
    serialization: nquads
    ldes:
      id: ex:ldes
      timestampPath: dcterms:created     # Added to the EventStream object, but not used in member objects in this test case
      versionOfPath: dcterms:isVersionOf # Added to the EventStream object, but not used in member objects in this test case
      generateImmutableIRI: false

mappings:

  # The values of the sensors. These 'sensor objects' become member of an LDES
  sensor-reading:

    subjects:
      - value: ex:sensor/$(sensor)
        targets: target-ldes

    predicateobjects:
      - [ex:pressure, $(pressure)]
      - [ex:temperature, $(temperature)]

    changeDetection:
      create:
        explicit: true
        mappingAdd:
          sources: source-create
          graphs: ex:create

      update:
        explicit: true
        mappingAdd:
          sources: source-update
          graphs: ex:update

      delete:
        explicit: true
        mappingAdd:
          sources: source-delete
          graphs: ex:delete
          po: [[ex:currentState, deleted]]


  # Each LDES member is part of a graph, which describes the operation
  # performed: create, update or delete. We describe the graphs as
  # Activity Streams event
  # This should generate a static triples map (and new RML has this feature!)

  graph-create:
    subjects: ex:create
    predicateobjects:
      - [a, as:Create~iri]
      - [as:actor, ex:dataset~iri]

  graph-update:
    subjects: ex:update
    predicateobjects:
      - [a, as:Update~iri]
      - [as:actor, ex:dataset~iri]

  graph-delete:
    subjects: ex:delete
    predicateobjects:
      - [a, as:Delete~iri]
      - [as:actor, ex:dataset~iri]
