From: Steve F. <sfi...@pc...> - 2005-10-29 02:27:16
|
folks- I have added a new plugin to Community: GUS::Community::Plugin::Undo It is a simple hook to allow other (real) plugins to undo the changes they have made to the database. The Undo plugin is very simple: - it takes a plugin name and a list of algorithm_invocation_ids as arguments - when it runs, it calls a method on the target plugin: $targetPlugin->undo($algInvIds, $dbh) - if the target plugin has not defined such a method, Undo will fail. - if it has, then that method is responsible for performing the undo. - it also provides a convenient method GUS::Community::Plugin::Undo::deleteFromTable($table, $algInvIds, $dbh). This method removes from the specified table all rows with any of the specified algortithm_invocation_ids. The strategy of an plugin's undo method should be: 1. call deleteFromTable on every table that it writes rows into (either directly or indirectly) 2. do so in the proper order, so that children are deleted before parents (otherwise you'll get constraint violations) 3. some tables will need special processing. For example, deleting from tables that have links to themselves (eg NAFeature) must either proceed from child to parent (which is tricky), or, if the links are nullable, must have those links deleted first, before the rows are deleted. This is something of a use-at-your-own-risk plugin. The risks are: 1. you will mistakenly remove an incorrect algorithm_invocation_id, thereby losing valuable data 2. the undo method in the target plugin could be written incorrectly such that it forgets to delete from some tables. There is some protection against this because most tables that a plugin writes to are child tables. It is not possible to forget those because that would cause a constraint violation. It is only a problem if the Undo forgets to delete from tables that have no parents (or whose parents are also forgotten). The advantages are: 1. a correctly written undo() method is much more trustworthy than deleting by hand 2. undoing becomes doable Depending on how things turn out, we may move this to Supported. Feedback? Steve |