src/core/net/sf/basedb/util/overview/loader/NodeLoader.java

Code
Comments
Other
Rev Date Author Line
4740 05 Feb 09 nicklas 1 /**
4740 05 Feb 09 nicklas 2   $Id$
4740 05 Feb 09 nicklas 3
4740 05 Feb 09 nicklas 4   Copyright (C) 2008 Nicklas Nordborg
4740 05 Feb 09 nicklas 5
4740 05 Feb 09 nicklas 6   This file is part of BASE - BioArray Software Environment.
4740 05 Feb 09 nicklas 7   Available at http://base.thep.lu.se/
4740 05 Feb 09 nicklas 8
4740 05 Feb 09 nicklas 9   BASE is free software; you can redistribute it and/or
4740 05 Feb 09 nicklas 10   modify it under the terms of the GNU General Public License
4740 05 Feb 09 nicklas 11   as published by the Free Software Foundation; either version 3
4740 05 Feb 09 nicklas 12   of the License, or (at your option) any later version.
4740 05 Feb 09 nicklas 13
4740 05 Feb 09 nicklas 14   BASE is distributed in the hope that it will be useful,
4740 05 Feb 09 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4740 05 Feb 09 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4740 05 Feb 09 nicklas 17   GNU General Public License for more details.
4740 05 Feb 09 nicklas 18
4740 05 Feb 09 nicklas 19   You should have received a copy of the GNU General Public License
4740 05 Feb 09 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4740 05 Feb 09 nicklas 21 */
4740 05 Feb 09 nicklas 22 package net.sf.basedb.util.overview.loader;
4740 05 Feb 09 nicklas 23
4740 05 Feb 09 nicklas 24 import net.sf.basedb.core.DbControl;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.util.overview.OverviewContext;
4740 05 Feb 09 nicklas 26 import net.sf.basedb.util.overview.node.ChildNodeDirection;
4740 05 Feb 09 nicklas 27 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 28
4740 05 Feb 09 nicklas 29 /**
4740 05 Feb 09 nicklas 30   A node loader is an object that knows how to create a node for some
4740 05 Feb 09 nicklas 31   specific item and how to load forward and reverse nodes for related
4740 05 Feb 09 nicklas 32   items.
4740 05 Feb 09 nicklas 33   <p>
4740 05 Feb 09 nicklas 34   
4740 05 Feb 09 nicklas 35   NOTE! This interface is not fixed on the implementor side. We reserve
4740 05 Feb 09 nicklas 36   the right to add new methods and functionality to this interface without
4740 05 Feb 09 nicklas 37   warning. We recommend that all implementations are subclasses of {@link
4740 05 Feb 09 nicklas 38   AbstractNodeLoader} since this class will get default implementation of
4740 05 Feb 09 nicklas 39   all new funcationality.
4740 05 Feb 09 nicklas 40   
4740 05 Feb 09 nicklas 41   @author Nicklas
4740 05 Feb 09 nicklas 42   @version 2.10
4740 05 Feb 09 nicklas 43   @base.modified $Date$
4740 05 Feb 09 nicklas 44 */
4740 05 Feb 09 nicklas 45 public interface NodeLoader<I>
4740 05 Feb 09 nicklas 46 {
4740 05 Feb 09 nicklas 47   
4740 05 Feb 09 nicklas 48   /**
4740 05 Feb 09 nicklas 49     Create a root node for the given item. A root node is a node with
4740 05 Feb 09 nicklas 50     no parent. Typically, the direction of the created node is
4740 05 Feb 09 nicklas 51     {@link ChildNodeDirection#ALL} so that both forward and reverse
4740 05 Feb 09 nicklas 52     child nodes are loaded.
4740 05 Feb 09 nicklas 53     
4740 05 Feb 09 nicklas 54     @param dc The DbControl to use for database access
4740 05 Feb 09 nicklas 55     @param context The overview context
4740 05 Feb 09 nicklas 56     @param item The root item
4740 05 Feb 09 nicklas 57     @return A root node
4740 05 Feb 09 nicklas 58     @throws UnsupportedOperationException If the current item can't
4740 05 Feb 09 nicklas 59       be used as a root node
4740 05 Feb 09 nicklas 60   */
4740 05 Feb 09 nicklas 61   public Node createRootNode(DbControl dc, OverviewContext context, I item);
4740 05 Feb 09 nicklas 62
4740 05 Feb 09 nicklas 63   /**
4740 05 Feb 09 nicklas 64     Create a forward-loading (from parent to child) node for the given parent node. 
4740 05 Feb 09 nicklas 65     The loader should use the information on the parent node to get the correct item 
4740 05 Feb 09 nicklas 66     (of type I) and create a node for that item. If the parent can have many child nodes,
4740 05 Feb 09 nicklas 67     the loader should first create a folder-type node 
4740 05 Feb 09 nicklas 68     and put the children inside that.
4740 05 Feb 09 nicklas 69     <p>
4740 05 Feb 09 nicklas 70     The direction of the node(s) should usually be {@link ChildNodeDirection#FORWARD}. 
4740 05 Feb 09 nicklas 71     In case there is an error (permission denied, etc.) {@link 
4740 05 Feb 09 nicklas 72     ChildNodeDirection#NONE} should be used. If there is no child item null
4740 05 Feb 09 nicklas 73     should be returned.
4740 05 Feb 09 nicklas 74     <p>
4740 05 Feb 09 nicklas 75     Errors, missing items, etc. should be reported as failures to the {@link
4740 05 Feb 09 nicklas 76     OverviewContext}.
4740 05 Feb 09 nicklas 77     
4740 05 Feb 09 nicklas 78     @param dc The DbControl to use for database access
4740 05 Feb 09 nicklas 79     @param context The overview context
4740 05 Feb 09 nicklas 80     @param parentNode The parent node
4740 05 Feb 09 nicklas 81     @return A forward-loading node (may be a folder-type node with many subnodes),
4740 05 Feb 09 nicklas 82       or null
4740 05 Feb 09 nicklas 83     @throws UnsupportedOperationException If the current item can't
4740 05 Feb 09 nicklas 84       be used as a forward-loading node
4740 05 Feb 09 nicklas 85   */
4740 05 Feb 09 nicklas 86   public Node createForwardNode(DbControl dc, OverviewContext context, Node parentNode);
4740 05 Feb 09 nicklas 87   
4740 05 Feb 09 nicklas 88   /**
4740 05 Feb 09 nicklas 89     Create a reverse-loading (from child to parent) node for the given child node. 
4740 05 Feb 09 nicklas 90     The loader should use the information on the child node to get the correct item 
4740 05 Feb 09 nicklas 91     (of type I) and create a node for that item. If the child can have many parent nodes,
4740 05 Feb 09 nicklas 92     the loader should first create a folder-type node 
4740 05 Feb 09 nicklas 93     and put the parents inside that.
4740 05 Feb 09 nicklas 94     <p>
4740 05 Feb 09 nicklas 95     The direction of the node(s) should usually be {@link ChildNodeDirection#REVERSE}. 
4740 05 Feb 09 nicklas 96     In case there is an error (permission denied, etc.) {@link 
4740 05 Feb 09 nicklas 97     ChildNodeDirection#NONE} should be used. If there is no parent item null
4740 05 Feb 09 nicklas 98     should be returned.
4740 05 Feb 09 nicklas 99     <p>
4740 05 Feb 09 nicklas 100     Errors, missing items, etc. should be reported as failures to the {@link
4740 05 Feb 09 nicklas 101     OverviewContext}.
4740 05 Feb 09 nicklas 102     
4740 05 Feb 09 nicklas 103     @param dc The DbControl to use for database access
4740 05 Feb 09 nicklas 104     @param context The overview context
4740 05 Feb 09 nicklas 105     @param childNode The child node
4740 05 Feb 09 nicklas 106     @return A reverse-loading node (may be a folder-type node with many subnodes),
4740 05 Feb 09 nicklas 107       or null
4740 05 Feb 09 nicklas 108     @throws UnsupportedOperationException If the current item can't
4740 05 Feb 09 nicklas 109       be used as a reverse-loading node
4740 05 Feb 09 nicklas 110   */
4740 05 Feb 09 nicklas 111   public Node createReverseNode(DbControl dc, OverviewContext context, Node childNode);
4740 05 Feb 09 nicklas 112   
4740 05 Feb 09 nicklas 113   /**
4740 05 Feb 09 nicklas 114     Create a property node for the given parent node. A property node is a node
4740 05 Feb 09 nicklas 115     that is not on the main parent-child path. It is typically a node that
4740 05 Feb 09 nicklas 116     can't be used a root node (for example, a protocol or software). If the
4749 11 Feb 09 nicklas 117     parent node can have many properties of this type the loader can decide if
4749 11 Feb 09 nicklas 118     it should first create a folder-type node and put the children inside the
4749 11 Feb 09 nicklas 119     folder, or if all child nodes should be created directly in the 
4749 11 Feb 09 nicklas 120     parent node. In the first case, the folder node should be returned. In
4749 11 Feb 09 nicklas 121     the latter case, null should be returned.
4740 05 Feb 09 nicklas 122     <p>
4740 05 Feb 09 nicklas 123     The direction of the node(s) should usually be {@link ChildNodeDirection#NONE}, but
4749 11 Feb 09 nicklas 124     it may also be {@link ChildNodeDirection#PROPERTY} in case the property has sub-properties.
4740 05 Feb 09 nicklas 125     One example is the {@link ProtocolLoader} which loads the
4740 05 Feb 09 nicklas 126     protocol parameters as child nodes.
4740 05 Feb 09 nicklas 127     <p>
4740 05 Feb 09 nicklas 128     In case there is an error (permission denied, etc.) {@link 
4740 05 Feb 09 nicklas 129     ChildNodeDirection#NONE} should be used. If there is no property item null
4749 11 Feb 09 nicklas 130     should be returned (but this may also indicate that more than one node
4749 11 Feb 09 nicklas 131     was created).
4740 05 Feb 09 nicklas 132     <p>
4740 05 Feb 09 nicklas 133     Errors, missing items, etc. should be reported as failures to the {@link
4740 05 Feb 09 nicklas 134     OverviewContext}.
4740 05 Feb 09 nicklas 135     
4740 05 Feb 09 nicklas 136     @param dc The DbControl to use for database access
4740 05 Feb 09 nicklas 137     @param context The overview context
4740 05 Feb 09 nicklas 138     @param parentNode The parent node
4740 05 Feb 09 nicklas 139     @return A node (may be a folder-type node with many subnodes),
4740 05 Feb 09 nicklas 140       or null
4740 05 Feb 09 nicklas 141     @throws UnsupportedOperationException If the current item can't
4740 05 Feb 09 nicklas 142       be used as a property node
4740 05 Feb 09 nicklas 143   */
4740 05 Feb 09 nicklas 144   public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode);
4740 05 Feb 09 nicklas 145   
4740 05 Feb 09 nicklas 146   /**
4740 05 Feb 09 nicklas 147     Load child nodes of the current node unless they have been loaded already.
4740 05 Feb 09 nicklas 148     Note that which child nodes to load depends on the {@link Node#getChildNodeDirection()}
4740 05 Feb 09 nicklas 149     of the node.
4740 05 Feb 09 nicklas 150     
4740 05 Feb 09 nicklas 151     @param dc The DbControl to use for database access
4740 05 Feb 09 nicklas 152     @param context The overview context
4740 05 Feb 09 nicklas 153     @param node The node
4740 05 Feb 09 nicklas 154     @return TRUE if the call resulted in new nodes being loaded, FALSE otherwise
4740 05 Feb 09 nicklas 155   */
4740 05 Feb 09 nicklas 156   public boolean loadChildNodes(DbControl dc, OverviewContext context, Node node);
4740 05 Feb 09 nicklas 157   
4740 05 Feb 09 nicklas 158 }