Rollbacks in Moriarty
Editing resources in the metabox of Talis Platform stores is done with Changesets. If you choose to use the versioned changesets API, your changesets will be stored as data in the metabox as well.
The great practical benefit of doing this is you can then reverse previous ChangeSets to return a resource to its previous state. You can read about one way to reverse changesets on the wiki. You can also now create rollback changesets from Moriarty with the new Rollback class.
To use it:
define('MORIARTY_ARC_DIR', 'arc/');
require 'moriarty/store.class.php';
require 'moriarty/rollback.class.php';
//create a store object
$store = new Store('http://api.talis.com/stores/my_store');
//Instantiate the Rollback class with a sparql service object:
$sparql = $store->get_sparql_service();
$rollback = new Rollback($sparql);
//Call the to_changeset method, with a changeset's uri as the argument
$HTTP_Response = $rollback->to_changeset('http://api.talis.com/stores/my_store/items/1200302910905#self');
// the body of the response is the changeset you need to revert back to the
// state of the resource before the changeset that you have given the URI of
if($HTTP_Response->is_success()){
//submit changeset
$rollbackResponse = $store->apply_versioned_changeset($HTTP_Response->body);
if($rollbackResponse->is_success()){
//relax!
}else{
// throw an error
}
}

