From 8da8584ed2c57001e6f4c41656746497052252a2 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 24 Apr 2007 16:15:30 +0000 Subject: [PATCH] part-implemented and *untested* git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@384 be28352e-c001-0410-b1a7-c7978e42abec --- .../ac/vamsas/objects/DocumentUpdaterEngine.java | 130 +++++++++++++++++++- 1 file changed, 124 insertions(+), 6 deletions(-) diff --git a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java index 370fcc8..cb2d2c3 100644 --- a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java +++ b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java @@ -1,25 +1,143 @@ package uk.ac.vamsas.objects; import uk.ac.vamsas.client.IClientDocument; - +import uk.ac.vamsas.objects.core.*; +/** + * Implements a depth first traversal over the document tree calling update handlers based on the Vobject.isUpdated() and Vobject.isNewInDocument() state at each backtrack. + * @author JimP + * + */ public class DocumentUpdaterEngine { - private IDocumentUpdater hander; + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(DocumentUpdaterEngine.class); + private IDocumentUpdater handler; /** * initialise the engine with an implementation * of the interface. * @param hander */ - public DocumentUpdaterEngine(IDocumentUpdater hander) { + public DocumentUpdaterEngine(IDocumentUpdater handler) { super(); - this.hander = hander; + this.handler = handler; } /** * call the necessary update handlers at * each point on the VamsasDocument OM + * TODO: later: Make this more elegant (use reflection and factor to single update(Object) method) ? + * - we take the plodding, explicit approach rather than a funky generalised one here */ public void callHandlers(IClientDocument cdoc) { - // TODO: walk down the hierarchy until we find an update and call the handler for it. + if (cdoc==null) { + log.debug("Null IClientDocument instance."); + return; + } + VAMSAS[] roots = cdoc.getVamsasRoots(); + if (roots!=null) { + for (int r=0; r