src/core/net/sf/basedb/util/overview/loader/ArrayDesignLoader.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.ArrayBatch;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.core.ArrayDesign;
6959 01 Oct 15 nicklas 26 import net.sf.basedb.core.BasicItem;
4740 05 Feb 09 nicklas 27 import net.sf.basedb.core.DbControl;
4740 05 Feb 09 nicklas 28 import net.sf.basedb.core.Item;
4740 05 Feb 09 nicklas 29 import net.sf.basedb.core.PermissionDeniedException;
4740 05 Feb 09 nicklas 30 import net.sf.basedb.core.RawBioAssay;
6959 01 Oct 15 nicklas 31 import net.sf.basedb.core.RootRawBioAssay;
4740 05 Feb 09 nicklas 32 import net.sf.basedb.util.overview.OverviewContext;
4740 05 Feb 09 nicklas 33 import net.sf.basedb.util.overview.node.ChildNodeDirection;
4740 05 Feb 09 nicklas 34 import net.sf.basedb.util.overview.node.NameableNameGenerator;
4740 05 Feb 09 nicklas 35 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 36 import net.sf.basedb.util.overview.node.NodeFactory;
4740 05 Feb 09 nicklas 37
4740 05 Feb 09 nicklas 38 /**
4740 05 Feb 09 nicklas 39   Node loader implementation for array designs. Array designs are
4740 05 Feb 09 nicklas 40   an endpoint node with the forward-loading direction going to 
4740 05 Feb 09 nicklas 41   {@link ArrayDesign}:s -&gt; {@link ArrayBatch}:s. An array design can 
4740 05 Feb 09 nicklas 42   also be loaded as a property node from a raw bioassay.
4740 05 Feb 09 nicklas 43
4740 05 Feb 09 nicklas 44   @author Nicklas
4740 05 Feb 09 nicklas 45   @version 2.10
4740 05 Feb 09 nicklas 46   @base.modified $Date$
4740 05 Feb 09 nicklas 47 */
4740 05 Feb 09 nicklas 48 public class ArrayDesignLoader
4740 05 Feb 09 nicklas 49   extends BasicItemNodeLoader<ArrayDesign>
4740 05 Feb 09 nicklas 50 {
4740 05 Feb 09 nicklas 51
4740 05 Feb 09 nicklas 52   public ArrayDesignLoader()
4740 05 Feb 09 nicklas 53   {
4740 05 Feb 09 nicklas 54     super(Item.ARRAYDESIGN, ALLOW_ROOT_NODE, 
4740 05 Feb 09 nicklas 55         new NameableNameGenerator<ArrayDesign>("arraydesign", "Array design"));
4740 05 Feb 09 nicklas 56   }
4740 05 Feb 09 nicklas 57   
4740 05 Feb 09 nicklas 58   /*
4740 05 Feb 09 nicklas 59     From the NodeLoader interface
4740 05 Feb 09 nicklas 60     ------------------------------
4740 05 Feb 09 nicklas 61   */
4740 05 Feb 09 nicklas 62   /**
4740 05 Feb 09 nicklas 63     Create a reverse-loading array design node from an array batch node.
4740 05 Feb 09 nicklas 64     @return An array design node, or null if the batch doesn't have a design
4740 05 Feb 09 nicklas 65   */
4740 05 Feb 09 nicklas 66   @Override
4740 05 Feb 09 nicklas 67   public Node createReverseNode(DbControl dc, OverviewContext context, Node batchNode)
4740 05 Feb 09 nicklas 68   {
4740 05 Feb 09 nicklas 69     NodeFactory<ArrayDesign> nf = getNodeFactory(dc, context);
4740 05 Feb 09 nicklas 70     ArrayDesign design = null;
4740 05 Feb 09 nicklas 71     boolean denied = false;
4740 05 Feb 09 nicklas 72     try
4740 05 Feb 09 nicklas 73     {
4740 05 Feb 09 nicklas 74       design = ((ArrayBatch)batchNode.getItem(dc)).getArrayDesign();
4740 05 Feb 09 nicklas 75     }
4740 05 Feb 09 nicklas 76     catch (PermissionDeniedException ex)
4740 05 Feb 09 nicklas 77     {
4740 05 Feb 09 nicklas 78       denied = true;
4740 05 Feb 09 nicklas 79     }
4740 05 Feb 09 nicklas 80     Node designNode = createItemNode(nf, design, design, denied, 
4740 05 Feb 09 nicklas 81         batchNode, ChildNodeDirection.REVERSE);
4740 05 Feb 09 nicklas 82     return designNode;
4740 05 Feb 09 nicklas 83   }
4740 05 Feb 09 nicklas 84   /**
6959 01 Oct 15 nicklas 85     Create an array design property node from a raw bioassay or 
6959 01 Oct 15 nicklas 86     root raw bioassay node.
6959 01 Oct 15 nicklas 87     @return An array design node, or null if the raw bioassay doesn't have a design
4740 05 Feb 09 nicklas 88   */
4740 05 Feb 09 nicklas 89   @Override
6959 01 Oct 15 nicklas 90   public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
4740 05 Feb 09 nicklas 91   {
4740 05 Feb 09 nicklas 92     NodeFactory<ArrayDesign> nf = getNodeFactory(dc, context);
4740 05 Feb 09 nicklas 93     ArrayDesign design = null;
4740 05 Feb 09 nicklas 94     boolean denied = false;
4740 05 Feb 09 nicklas 95     try
4740 05 Feb 09 nicklas 96     {
6959 01 Oct 15 nicklas 97       BasicItem parentItem = parentNode.getItem(dc);
6959 01 Oct 15 nicklas 98       if (parentItem instanceof RootRawBioAssay)
6959 01 Oct 15 nicklas 99       {
6959 01 Oct 15 nicklas 100         // The parent may be a root raw bioasay if the overview starts at the
6959 01 Oct 15 nicklas 101         // experiment level
6959 01 Oct 15 nicklas 102         parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
6959 01 Oct 15 nicklas 103       }
6959 01 Oct 15 nicklas 104       if (parentItem instanceof RawBioAssay)
6959 01 Oct 15 nicklas 105       {
6959 01 Oct 15 nicklas 106         RawBioAssay rba = (RawBioAssay)parentItem;
6959 01 Oct 15 nicklas 107         design = rba.getArrayDesign();
6959 01 Oct 15 nicklas 108       }
4740 05 Feb 09 nicklas 109     }
4740 05 Feb 09 nicklas 110     catch (PermissionDeniedException ex)
4740 05 Feb 09 nicklas 111     {
4740 05 Feb 09 nicklas 112       denied = true;
4740 05 Feb 09 nicklas 113     }
4740 05 Feb 09 nicklas 114     Node designNode = createItemNode(nf, design, design, denied, 
6959 01 Oct 15 nicklas 115         parentNode, ChildNodeDirection.PROPERTY);
4740 05 Feb 09 nicklas 116     return designNode;
4740 05 Feb 09 nicklas 117   }  
4740 05 Feb 09 nicklas 118   // --------------------------------
4740 05 Feb 09 nicklas 119   /*
4740 05 Feb 09 nicklas 120     From the AbstractNodeLoader class
4740 05 Feb 09 nicklas 121     ----------------------------------
4740 05 Feb 09 nicklas 122   */
4740 05 Feb 09 nicklas 123   /**
4740 05 Feb 09 nicklas 124     Loads property nodes of an array design. 
4740 05 Feb 09 nicklas 125     <ul>
4740 05 Feb 09 nicklas 126     <li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)}
4740 05 Feb 09 nicklas 127     <li>Data files: {@link DataFileLoader#createPropertyNode(DbControl, OverviewContext, Node)}
4740 05 Feb 09 nicklas 128     <li>Platform: {@link PlatformLoader#createPropertyNode(DbControl, OverviewContext, Node)}
4740 05 Feb 09 nicklas 129     </ul>
4740 05 Feb 09 nicklas 130   */
4740 05 Feb 09 nicklas 131   @Override
4740 05 Feb 09 nicklas 132   protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node designNode)
4740 05 Feb 09 nicklas 133   {
4740 05 Feb 09 nicklas 134     getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, designNode);
4740 05 Feb 09 nicklas 135     getNodeLoader(context, Item.PLATFORM).createPropertyNode(dc, context, designNode);
4740 05 Feb 09 nicklas 136     getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, designNode);
5500 18 Nov 10 nicklas 137     getNodeLoader(context, Item.ANYTOANY).createPropertyNode(dc, context, designNode);
4740 05 Feb 09 nicklas 138   }
4740 05 Feb 09 nicklas 139
4740 05 Feb 09 nicklas 140   /**
4740 05 Feb 09 nicklas 141     Loads the array batch nodes that has been created with the given design node.
4740 05 Feb 09 nicklas 142     @see ArrayBatchLoader#createForwardNode(DbControl, OverviewContext, Node)
4740 05 Feb 09 nicklas 143   */
4740 05 Feb 09 nicklas 144   @Override
4740 05 Feb 09 nicklas 145   protected void loadForwardChildNodes(DbControl dc, OverviewContext context, Node designNode)
4740 05 Feb 09 nicklas 146   {
4740 05 Feb 09 nicklas 147     getNodeLoader(context, Item.ARRAYBATCH).createForwardNode(dc, context, designNode);
4740 05 Feb 09 nicklas 148   }
4740 05 Feb 09 nicklas 149   // ---------------------------------------
4740 05 Feb 09 nicklas 150
4740 05 Feb 09 nicklas 151 }