From: Steve F. <sfi...@pc...> - 2005-10-29 12:05:58
|
i have adjusted the Undo api. Here is the usage from the Undo plugin: DESCRIPTION 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->undoTables() - if the target plugin has not defined such a method, Undo will fail. - if it has, then that method returns a list of tables to undo from. Undo will remove fr om each of those tables any rows whose row_alg_invocation_id is in the list supplied on the com mand line. The order of the tables in the list returned by undoTables() must be such that chil d tables come before parent tables. Otherwise you will get constraint violations. - Undo also deletes from AlgorithmParam and AlgorithmInvocation. - All deletes are performed as part of one trancation. The deletes are only commited if Undo is run with --commit This is something of a use-at-your-own-risk plugin. The risks are: 1. you will mistakenly undo an incorrect algorithm_invocation_id, thereby losing valuable data 2. the undoTables() method in the target plugin could be written incorrectly such that it forgets 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 cons traint 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 undoTables() method is much more trustworthy than deleting by hand 2. undoing becomes doable Steve Fischer wrote: > 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 > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > Gusdev-gusdev mailing list > Gus...@li... > https://lists.sourceforge.net/lists/listinfo/gusdev-gusdev |