src/core/net/sf/basedb/util/overview/node/ChildNodeDirection.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.node;
4740 05 Feb 09 nicklas 23
4740 05 Feb 09 nicklas 24 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 25
4740 05 Feb 09 nicklas 26
4740 05 Feb 09 nicklas 27 /**
4740 05 Feb 09 nicklas 28   Represents the direction to use for loading child nodes in a tree.
4740 05 Feb 09 nicklas 29   We need to keep track of this since we need to support rooting a tree
4740 05 Feb 09 nicklas 30   at any type of item (eg. at an experiment, hybridization, biosource, etc).
4740 05 Feb 09 nicklas 31   <p>
4740 05 Feb 09 nicklas 32   
6881 21 Apr 15 nicklas 33   For every tree there is a <i>natural</i> order of items. For example,
4740 05 Feb 09 nicklas 34   BioSource -&gt; Sample -&gt; Extract -&gt; ... -&gt; Experiment.
4740 05 Feb 09 nicklas 35   The natural order is the forward-loading direction and the opposite
4740 05 Feb 09 nicklas 36   order is the reverse-loading direction.
4740 05 Feb 09 nicklas 37   <p>
4740 05 Feb 09 nicklas 38   
4740 05 Feb 09 nicklas 39   For example, if we root the tree at a Hybridization we will load children 
4740 05 Feb 09 nicklas 40   in the forward-loading direction down to experiment and in the 
4740 05 Feb 09 nicklas 41   revers-loading direction up to biosource and array design. For each node
4740 05 Feb 09 nicklas 42   that is added to a tree we need to keep track if we should continue up
4740 05 Feb 09 nicklas 43   or down the natural order. Otherwise we will end up in an infinite loop.
4740 05 Feb 09 nicklas 44   <p>
4740 05 Feb 09 nicklas 45   
4740 05 Feb 09 nicklas 46   In a tree there can also be side-nodes that in most cases are end-point or
4740 05 Feb 09 nicklas 47   leaf nodes. This is for example nodes containing information about
4740 05 Feb 09 nicklas 48   protocol, software, annotations, etc. We call such nodes <i>property</i>
4740 05 Feb 09 nicklas 49   nodes and they are usually loaded in both the forward- and reverse-loading
4740 05 Feb 09 nicklas 50   directions.
4740 05 Feb 09 nicklas 51   
4740 05 Feb 09 nicklas 52   @author Nicklas
4740 05 Feb 09 nicklas 53   @version 2.10
4740 05 Feb 09 nicklas 54   @base.modified $Date$
4740 05 Feb 09 nicklas 55   @see Node#getChildNodeDirection()
4740 05 Feb 09 nicklas 56 */
4740 05 Feb 09 nicklas 57 public enum ChildNodeDirection
4740 05 Feb 09 nicklas 58 {
4740 05 Feb 09 nicklas 59   /**
4740 05 Feb 09 nicklas 60     Represents an end-point node. No more child nodes should be loaded,
4740 05 Feb 09 nicklas 61     not even property nodes.
4740 05 Feb 09 nicklas 62   */
4740 05 Feb 09 nicklas 63   NONE(false, false, false),
4740 05 Feb 09 nicklas 64   
4740 05 Feb 09 nicklas 65   /**
4740 05 Feb 09 nicklas 66     Only property child nodes should be loaded.
4740 05 Feb 09 nicklas 67   */
4740 05 Feb 09 nicklas 68   PROPERTY(false, false, true),
4740 05 Feb 09 nicklas 69   
4740 05 Feb 09 nicklas 70   /**
4740 05 Feb 09 nicklas 71     Child nodes should be loaded in the forward-loading direction.
4740 05 Feb 09 nicklas 72     Property nodes should also be loaded.
4740 05 Feb 09 nicklas 73   */
4740 05 Feb 09 nicklas 74   FORWARD(true, false, true), 
4740 05 Feb 09 nicklas 75   
4740 05 Feb 09 nicklas 76   /**
4740 05 Feb 09 nicklas 77     Child nodes should be loaded in the reverse-loading direction.
4740 05 Feb 09 nicklas 78     Property nodes should also be loaded.
4740 05 Feb 09 nicklas 79   */
4740 05 Feb 09 nicklas 80   REVERSE(false, true, true), 
4740 05 Feb 09 nicklas 81   
4740 05 Feb 09 nicklas 82   /*
4740 05 Feb 09 nicklas 83     Child nodes should be loaded in the all directions. This 
4740 05 Feb 09 nicklas 84     is usually only used on the root node.
4740 05 Feb 09 nicklas 85   */
4740 05 Feb 09 nicklas 86   ALL(true, true, true);
4740 05 Feb 09 nicklas 87   
4740 05 Feb 09 nicklas 88   private final boolean loadForward;
4740 05 Feb 09 nicklas 89   private final boolean loadReverse;
4740 05 Feb 09 nicklas 90   private final boolean loadProperty;
4740 05 Feb 09 nicklas 91   
4740 05 Feb 09 nicklas 92   private ChildNodeDirection(boolean loadForward, boolean loadReverse, boolean loadProperty)
4740 05 Feb 09 nicklas 93   {
4740 05 Feb 09 nicklas 94     this.loadForward = loadForward;
4740 05 Feb 09 nicklas 95     this.loadReverse = loadReverse;
4740 05 Feb 09 nicklas 96     this.loadProperty = loadProperty;
4740 05 Feb 09 nicklas 97   }
4740 05 Feb 09 nicklas 98   
4740 05 Feb 09 nicklas 99   /**
4740 05 Feb 09 nicklas 100     @return TRUE if child nodes in the reverse-loading 
4740 05 Feb 09 nicklas 101       direction should be loaded
4740 05 Feb 09 nicklas 102   */
4740 05 Feb 09 nicklas 103   public boolean loadReverse()
4740 05 Feb 09 nicklas 104   {
4740 05 Feb 09 nicklas 105     return loadReverse;
4740 05 Feb 09 nicklas 106   }
4740 05 Feb 09 nicklas 107
4740 05 Feb 09 nicklas 108   /**
4740 05 Feb 09 nicklas 109     @return TRUE if child nodes in the forward-loading 
4740 05 Feb 09 nicklas 110       direction should be loaded
4740 05 Feb 09 nicklas 111   */
4740 05 Feb 09 nicklas 112   public boolean loadForward()
4740 05 Feb 09 nicklas 113   {
4740 05 Feb 09 nicklas 114     return loadForward;
4740 05 Feb 09 nicklas 115   }
4740 05 Feb 09 nicklas 116   
4740 05 Feb 09 nicklas 117   /**
4740 05 Feb 09 nicklas 118     @return TRUE if property child nodes should be loaded
4740 05 Feb 09 nicklas 119   */
4740 05 Feb 09 nicklas 120   public boolean loadProperty()
4740 05 Feb 09 nicklas 121   {
4740 05 Feb 09 nicklas 122     return loadProperty;
4740 05 Feb 09 nicklas 123   }
4740 05 Feb 09 nicklas 124   
4740 05 Feb 09 nicklas 125 }