Event-Condition-Action Rules with SPARQLMotion
Several customers have requested a mechanism to trigger certain actions in response to changes to an RDF source. This can be used, for example, to update entries in some database when new triples come in, or send a message to someone to notify her about changes, or simply to synchronize dependencies among multiple data spaces. For the new beta 2 release of TopBraid, I have added a mechanism that can execute arbitrary SPARQLMotion scripts in response to changes to a model.
Here is an example of how it works. Download 3.0 and drop this file into your workspace. The file contains a SPARQLMotion script. The file is ending with .sms.n3 which instructs TopBraid to load this file into memory when the system starts up. The script (shown below) contains a module of type sml:TrackChanges. Any script with such a module will be executed whenever a change has been made to the current RDF model in TopBraid.
The basic mechanism is as follows: The TrackChanges module produces instances of the class Change from a simple change ontology. Each Change points to reified triples (instances of rdf:Statement) via change:added or change:deleted. The modules that follow the TrackChanges module can now query the Change objects and decide what to do with it. In the example above, the script iterates over all subjects that have changed their firstName or lastName and then runs the aforementioned DELETE and INSERT calls. Any other module could also be inserted though, for example to send an email, write something to a log or whatever else SPARQLMotion offers.
For the next release I plan to complete the integration of this mechanism with TopBraid Ensemble. Since Ensemble applications store their internal state in RDF, this would make it possible to perform changes to the user interface (alerts, status changes, updating charts) as a result of changes to the database. This will make it possible to implement knowledge-based stock tickers, new forms of social networks, intelligent collaboration platforms, pro-active agents etc - all with a declarative engine and no low-level coding involved apart from SPARQL. Stay tuned...
0 Comments:
Post a Comment
<< Home