Saturday, March 15, 2008

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:

  1. Take the selected resource as input and bind it to the variable ?resource.
  2. Run the SPARQL call INSERT { ?resource dc:creator "John Doe" }
  3. 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.

Tuesday, March 11, 2008

Creating Web Services with SPARQLMotion

A week ago we have officially launched SPARQLMotion 1.0 as part of the latest TopBraid Suite release. SPARQLMotion is a visual scripting language based on Semantic Web standards. The language is particularly useful to automate all kinds of data integration tasks because SPARQLMotion has built-in facilities to merge, map and transform data from various sources and formats. Furthermore, being a visual language, little programming skills beyond SPARQL are required to use SPARQLMotion and its tools.

One of the new features of SPARQLMotion 1.0 is that it can be used to create customized Web Services. TopBraid users can visually define REST-style web services and execute them within Maestro or the TopBraid Live server. I am describing a small example SPARQLMotion web service on our web page, but here is a screenshot of the script for your convenience.



This small SPARQLMotion script takes a calling code such as "61" as input, sends it in a SELECT query to the DBPedia SPARQL end point, and then sends a string response such as "61 is the calling code of Australia." back to the client. (Thanks to Henry Story for a variation of this scenario!)

This particular example only highlights one aspect of the possibilities of SPARQLMotion, namely the ability to create wrappers of arbitrary SPARQL calls. However, imagine that you can also define any sequence of processing steps in the middle (between the green start and the red end module). You could mash up data from multiple newsfeeds, databases, spreadsheets or XML sources, include data from external web services, construct new triples, define iterations and if-then-else branches, apply inference engines, send emails, construct complex web pages using JSPs or other templates, etc. With SPARQLMotion, defining useful Web Services becomes a matter of drag and drop - at least that's our goal at TopQuadrant.

There are many other SPARQLMotion improvements in the latest TopBraid Composer release, and we are incrementally adding examples and documentation - finally also including a user's guide. The tool now also provides a visual script debugger. Realistically there are still some rough edges that demand for improvements, but there are also quite a lot of opportunities to discover in this new semantic programming paradigm. Just make a mark and see where it takes you.

Monday, March 03, 2008

Editing Oracle 11g RDF Rules in TopBraid

Oracle has been supporting native RDF/OWL support since version 10g of their database. Now in its second release as 11g, Oracle has become a very serious option for projects that operate on large amounts of data. Many of our own customers already have Oracle installed in their enterprise and trust the infrastructure that Oracle provides. However, Oracle does not yet offer complete solutions that would also involve ontology editors, rule editors, semantic data browsers, semantic information integration tools, etc. This is where TopBraid Suite is well established, so that using TopBraid on top of Oracle is an attractive option. In fact, in the last couple of months, the majority of our customers has explicitly asked for this combination.

In response to this increasing interest in using Oracle in conjunction with TopBraid, we have added some native Oracle capabilities to our platform, based on the Oracle Jena API for the connection. In particular, TopBraid Composer 2.5.1 includes a feature to edit user-defined native Oracle rules, and to run server-side inferences. The following screenshot shows TopBraid's basic Oracle rules editor.




With this rule editing support, TopBraid users can select one or more user-defined rule bases and also combine them with the pre-defined Oracle rule sets RDFS, RDFS++, OWLSIF and OWLPRIME. The rule language supported by Oracle includes triple patterns. This is enough for the most common needs like the infamous "uncle" relationship which goes beyond the expressivity of OWL.

The major difference between using Oracle's native rule support and any of the other inference engines built into TopBraid is that Oracle rules are executed server-side. This makes execution significantly faster than executing them inside a TopBraid client. This is because if the rules were executed in TopBraid, then the rule engine would need to fetch lots of query results from the database, process the results and then continue with the next loop. Native Oracle avoids this communication overhead. Furthermore, Oracle rules are executed incrementally on each database commit, making it easier to maintain up-to-date inferences. There are several disadvantages though as well: TopBraid cannot distinguish inferred triples from asserted triples (at least not yet), making it for example unclear which triples can be deleted or not. A more critical limitation though is that the rules operating on Oracle would not "see" any imported triples, or triples that were inferred in other ways. This favors scenarios in which all RDF data can reside in a single Oracle model.

By the way, TopBraid Composer now also has features to execute arbitrary SQL commands and SELECT queries directly on the Oracle database, displaying the results in a console together with other status reports. With these capabilities, TopBraid Composer can be used to set up and maintain Oracle databases including rule bases, so that the Oracle database can be accessed in the desired way by end-user applications (such as TopBraid Live or Ensemble). In a sense, in addition to all its other Semantic Web features, TopBraid is becoming an admin tool for Oracle RDF...