Extending your tools with SPARQLMotion
A few days ago I wrote about how to create Web Services with SPARQLMotion. The basic idea is that SPARQLMotion scripts can take parameters as external input and then process these parameters in SPARQL queries etc. With today's release of TopBraid Composer Maestro 2.5.2, we have applied this idea to create a new mechanism that can be used to extend the tool itself.
Here is an example. This simple SPARQLMotion script (SetCreatorService.sms.n3) takes the currently selected resource as input and adds the triple ?resource dc:creator "John Doe" using a SPARQL Update language call.
From top to bottom the steps are:
- Take the selected resource as input and bind it to the variable ?resource.
- Run the SPARQL call INSERT { ?resource dc:creator "John Doe" }
- Done
Download the script and put it into your TopBraid workspace, then open the context menu (Resource menu) of any resource. This will insert a new menu item "Set creator" to execute the script on the selected resource:
When executed, the selected resource will be edited automatically, by the SPARQLMotion script. Needless to say, more complex SPARQLMotion services could be run as well.
The trick is that TopBraid is scanning your workspace for all files ending with .sms.xyz (where xyz might be n3). If these files contain a service that takes the selected resource as input (sml:BindWithSelectedResource), then TopBraid will add a menu item for the corresponding sml:ReturnXYZ module.
Here is another example, that is also explained in depth on our web site (click on the image for details).
This service can actually be used to send an email from TopBraid Composer. It demonstrates that these services can also be supplied with a pre-condition, so that the menu item only shows up for certain resources. This is implemented by means of an ASK query in the sml:BindWithSelectedResource module.
It is easy to see that this feature is potentially yet another disruptive move in the direction of model-driven applications. SPARQLMotion can be used to extend the TopBraid Composer tool itself to provide convenient short-cuts to frequently needed activities. Instead of having to rely on your IT department to write plug-ins in a programming language like Java, users of the tool can now do such things themselves. No more need to learn complex APIs, fiddle with the extension mechanisms, just plain modeling. The tricky parts of connecting the dots are already solved by the SPARQLMotion engine.