4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
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 |
A node loader is an object that knows how to create a node for some |
4740 |
05 Feb 09 |
nicklas |
specific item and how to load forward and reverse nodes for related |
4740 |
05 Feb 09 |
nicklas |
items. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
34 |
|
4740 |
05 Feb 09 |
nicklas |
NOTE! This interface is not fixed on the implementor side. We reserve |
4740 |
05 Feb 09 |
nicklas |
the right to add new methods and functionality to this interface without |
4740 |
05 Feb 09 |
nicklas |
warning. We recommend that all implementations are subclasses of {@link |
4740 |
05 Feb 09 |
nicklas |
AbstractNodeLoader} since this class will get default implementation of |
4740 |
05 Feb 09 |
nicklas |
all new funcationality. |
4740 |
05 Feb 09 |
nicklas |
40 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@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 |
Create a root node for the given item. A root node is a node with |
4740 |
05 Feb 09 |
nicklas |
no parent. Typically, the direction of the created node is |
4740 |
05 Feb 09 |
nicklas |
{@link ChildNodeDirection#ALL} so that both forward and reverse |
4740 |
05 Feb 09 |
nicklas |
child nodes are loaded. |
4740 |
05 Feb 09 |
nicklas |
53 |
|
4740 |
05 Feb 09 |
nicklas |
@param dc The DbControl to use for database access |
4740 |
05 Feb 09 |
nicklas |
@param context The overview context |
4740 |
05 Feb 09 |
nicklas |
@param item The root item |
4740 |
05 Feb 09 |
nicklas |
@return A root node |
4740 |
05 Feb 09 |
nicklas |
@throws UnsupportedOperationException If the current item can't |
4740 |
05 Feb 09 |
nicklas |
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 |
Create a forward-loading (from parent to child) node for the given parent node. |
4740 |
05 Feb 09 |
nicklas |
The loader should use the information on the parent node to get the correct item |
4740 |
05 Feb 09 |
nicklas |
(of type I) and create a node for that item. If the parent can have many child nodes, |
4740 |
05 Feb 09 |
nicklas |
the loader should first create a folder-type node |
4740 |
05 Feb 09 |
nicklas |
and put the children inside that. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
The direction of the node(s) should usually be {@link ChildNodeDirection#FORWARD}. |
4740 |
05 Feb 09 |
nicklas |
In case there is an error (permission denied, etc.) {@link |
4740 |
05 Feb 09 |
nicklas |
ChildNodeDirection#NONE} should be used. If there is no child item null |
4740 |
05 Feb 09 |
nicklas |
should be returned. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
Errors, missing items, etc. should be reported as failures to the {@link |
4740 |
05 Feb 09 |
nicklas |
OverviewContext}. |
4740 |
05 Feb 09 |
nicklas |
77 |
|
4740 |
05 Feb 09 |
nicklas |
@param dc The DbControl to use for database access |
4740 |
05 Feb 09 |
nicklas |
@param context The overview context |
4740 |
05 Feb 09 |
nicklas |
@param parentNode The parent node |
4740 |
05 Feb 09 |
nicklas |
@return A forward-loading node (may be a folder-type node with many subnodes), |
4740 |
05 Feb 09 |
nicklas |
or null |
4740 |
05 Feb 09 |
nicklas |
@throws UnsupportedOperationException If the current item can't |
4740 |
05 Feb 09 |
nicklas |
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 |
Create a reverse-loading (from child to parent) node for the given child node. |
4740 |
05 Feb 09 |
nicklas |
The loader should use the information on the child node to get the correct item |
4740 |
05 Feb 09 |
nicklas |
(of type I) and create a node for that item. If the child can have many parent nodes, |
4740 |
05 Feb 09 |
nicklas |
the loader should first create a folder-type node |
4740 |
05 Feb 09 |
nicklas |
and put the parents inside that. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
The direction of the node(s) should usually be {@link ChildNodeDirection#REVERSE}. |
4740 |
05 Feb 09 |
nicklas |
In case there is an error (permission denied, etc.) {@link |
4740 |
05 Feb 09 |
nicklas |
ChildNodeDirection#NONE} should be used. If there is no parent item null |
4740 |
05 Feb 09 |
nicklas |
should be returned. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
Errors, missing items, etc. should be reported as failures to the {@link |
4740 |
05 Feb 09 |
nicklas |
OverviewContext}. |
4740 |
05 Feb 09 |
nicklas |
102 |
|
4740 |
05 Feb 09 |
nicklas |
@param dc The DbControl to use for database access |
4740 |
05 Feb 09 |
nicklas |
@param context The overview context |
4740 |
05 Feb 09 |
nicklas |
@param childNode The child node |
4740 |
05 Feb 09 |
nicklas |
@return A reverse-loading node (may be a folder-type node with many subnodes), |
4740 |
05 Feb 09 |
nicklas |
or null |
4740 |
05 Feb 09 |
nicklas |
@throws UnsupportedOperationException If the current item can't |
4740 |
05 Feb 09 |
nicklas |
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 |
Create a property node for the given parent node. A property node is a node |
4740 |
05 Feb 09 |
nicklas |
that is not on the main parent-child path. It is typically a node that |
4740 |
05 Feb 09 |
nicklas |
can't be used a root node (for example, a protocol or software). If the |
4749 |
11 Feb 09 |
nicklas |
parent node can have many properties of this type the loader can decide if |
4749 |
11 Feb 09 |
nicklas |
it should first create a folder-type node and put the children inside the |
4749 |
11 Feb 09 |
nicklas |
folder, or if all child nodes should be created directly in the |
4749 |
11 Feb 09 |
nicklas |
parent node. In the first case, the folder node should be returned. In |
4749 |
11 Feb 09 |
nicklas |
the latter case, null should be returned. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
The direction of the node(s) should usually be {@link ChildNodeDirection#NONE}, but |
4749 |
11 Feb 09 |
nicklas |
it may also be {@link ChildNodeDirection#PROPERTY} in case the property has sub-properties. |
4740 |
05 Feb 09 |
nicklas |
One example is the {@link ProtocolLoader} which loads the |
4740 |
05 Feb 09 |
nicklas |
protocol parameters as child nodes. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
In case there is an error (permission denied, etc.) {@link |
4740 |
05 Feb 09 |
nicklas |
ChildNodeDirection#NONE} should be used. If there is no property item null |
4749 |
11 Feb 09 |
nicklas |
should be returned (but this may also indicate that more than one node |
4749 |
11 Feb 09 |
nicklas |
was created). |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
Errors, missing items, etc. should be reported as failures to the {@link |
4740 |
05 Feb 09 |
nicklas |
OverviewContext}. |
4740 |
05 Feb 09 |
nicklas |
135 |
|
4740 |
05 Feb 09 |
nicklas |
@param dc The DbControl to use for database access |
4740 |
05 Feb 09 |
nicklas |
@param context The overview context |
4740 |
05 Feb 09 |
nicklas |
@param parentNode The parent node |
4740 |
05 Feb 09 |
nicklas |
@return A node (may be a folder-type node with many subnodes), |
4740 |
05 Feb 09 |
nicklas |
or null |
4740 |
05 Feb 09 |
nicklas |
@throws UnsupportedOperationException If the current item can't |
4740 |
05 Feb 09 |
nicklas |
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 |
Load child nodes of the current node unless they have been loaded already. |
4740 |
05 Feb 09 |
nicklas |
Note that which child nodes to load depends on the {@link Node#getChildNodeDirection()} |
4740 |
05 Feb 09 |
nicklas |
of the node. |
4740 |
05 Feb 09 |
nicklas |
150 |
|
4740 |
05 Feb 09 |
nicklas |
@param dc The DbControl to use for database access |
4740 |
05 Feb 09 |
nicklas |
@param context The overview context |
4740 |
05 Feb 09 |
nicklas |
@param node The node |
4740 |
05 Feb 09 |
nicklas |
@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 |
} |