# 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:
  sensors: [base.json~jsonpath, '$.sensors[*]']

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:

    sources: sensors

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

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

    changeDetection:
      create:
        explicit: false
        mappingAdd:
          graphs: ex:create

      update:
        explicit: false
        mappingAdd:
          graphs: ex:update
        watchedProperties: $(temperature)


  # 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]
