I have an application wherein I used SPIN constructors as a means to implement Event/Condition/Action (ECA) policies. ECA is one classic construct for policies. The Event, in this case, was always the assertion of a class on an individual which caused that class's SPIN constructors to run on that new individual. The Condition was the pattern expressed in my SPARQL WHERE
clause, and the Action was provided by assertions in a SPARQL CONSTRUCT
clause. My understanding is that the SPIN constructor would only run on the new individual of the class, not on all individuals of the class.
I'm now looking into switching to SHACL as the successor to SPIN. I'm developing in TopBraid Composer Maestro Edition, and I could implement using the Jena SHACL API.
Suppose that I express an ECA policy as a SHACL shape and target a class via the sh:targetClass
SHACL predicate. Let's say my target class is family:Person
. Every time I assert a new family:Person
individual, I'd like to run my ECA policy (expressed as a SHACL shape) on only that new individual. I'm aware that a listener could be used to sense new class membership. I'm also aware that methods such as RuleUtil.executeRules()
could be used once a change is sensed to execute all rules on all targeted nodes (individuals of the family:Person
class, in my example). But, is there a way to apply SHACL shapes to only the new individuals of a targeted class? In my application, individuals would be accumulated over time and could become quite numerous. I'm concerned that the computational load of running shapes repeatedly against the same, old, unaltered individuals would become significant.