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

Code
Comments
Other
Rev Date Author Line
6959 01 Oct 15 nicklas 1 /**
6959 01 Oct 15 nicklas 2   $I$
6959 01 Oct 15 nicklas 3
6959 01 Oct 15 nicklas 4   Copyright (C) 2015 Nicklas Nordborg
6959 01 Oct 15 nicklas 5
6959 01 Oct 15 nicklas 6   This file is part of BASE - BioArray Software Environment.
6959 01 Oct 15 nicklas 7   Available at http://base.thep.lu.se/
6959 01 Oct 15 nicklas 8
6959 01 Oct 15 nicklas 9   BASE is free software; you can redistribute it and/or
6959 01 Oct 15 nicklas 10   modify it under the terms of the GNU General Public License
6959 01 Oct 15 nicklas 11   as published by the Free Software Foundation; either version 3
6959 01 Oct 15 nicklas 12   of the License, or (at your option) any later version.
6959 01 Oct 15 nicklas 13
6959 01 Oct 15 nicklas 14   BASE is distributed in the hope that it will be useful,
6959 01 Oct 15 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
6959 01 Oct 15 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6959 01 Oct 15 nicklas 17   GNU General Public License for more details.
6959 01 Oct 15 nicklas 18
6959 01 Oct 15 nicklas 19   You should have received a copy of the GNU General Public License
6959 01 Oct 15 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
6959 01 Oct 15 nicklas 21 */
6959 01 Oct 15 nicklas 22 package net.sf.basedb.util.overview.loader;
6959 01 Oct 15 nicklas 23
6959 01 Oct 15 nicklas 24
6959 01 Oct 15 nicklas 25 import net.sf.basedb.core.DbControl;
6959 01 Oct 15 nicklas 26 import net.sf.basedb.core.Experiment;
6959 01 Oct 15 nicklas 27 import net.sf.basedb.core.PermissionDeniedException;
6959 01 Oct 15 nicklas 28 import net.sf.basedb.core.Item;
6959 01 Oct 15 nicklas 29 import net.sf.basedb.core.ItemQuery;
6959 01 Oct 15 nicklas 30 import net.sf.basedb.core.ItemResultIterator;
6959 01 Oct 15 nicklas 31 import net.sf.basedb.core.RawBioAssay;
6959 01 Oct 15 nicklas 32 import net.sf.basedb.core.RootRawBioAssay;
6959 01 Oct 15 nicklas 33 import net.sf.basedb.util.overview.Node;
6959 01 Oct 15 nicklas 34 import net.sf.basedb.util.overview.NodeAttribute;
6959 01 Oct 15 nicklas 35 import net.sf.basedb.util.overview.OverviewContext;
6959 01 Oct 15 nicklas 36 import net.sf.basedb.util.overview.node.ChildNodeDirection;
6959 01 Oct 15 nicklas 37 import net.sf.basedb.util.overview.node.NameableNameGenerator;
6959 01 Oct 15 nicklas 38 import net.sf.basedb.util.overview.node.NodeFactory;
6959 01 Oct 15 nicklas 39
6959 01 Oct 15 nicklas 40 /**
6959 01 Oct 15 nicklas 41   Node loader implementation for root raw bioassays. Used in the 
6959 01 Oct 15 nicklas 42   reverse-loading direction only when going from experiments
6959 01 Oct 15 nicklas 43   to raw bioassays. This loader replaces the raw bioassays
6959 01 Oct 15 nicklas 44   loader.
6959 01 Oct 15 nicklas 45
6959 01 Oct 15 nicklas 46   @author Nicklas
6959 01 Oct 15 nicklas 47   @since 3.6
6959 01 Oct 15 nicklas 48 */
6959 01 Oct 15 nicklas 49 public class RootRawBioAssayLoader
6959 01 Oct 15 nicklas 50   extends BasicItemNodeLoader<RootRawBioAssay>
6959 01 Oct 15 nicklas 51 {
6959 01 Oct 15 nicklas 52   public RootRawBioAssayLoader()
6959 01 Oct 15 nicklas 53   {
6959 01 Oct 15 nicklas 54     super(Item.ROOTRAWBIOASSAY, DENY_ROOT_NODE, 
6959 01 Oct 15 nicklas 55         new NameableNameGenerator<RootRawBioAssay>("rawbioassay", "Raw bioassay"));
6959 01 Oct 15 nicklas 56   }
6959 01 Oct 15 nicklas 57
6959 01 Oct 15 nicklas 58   /*
6959 01 Oct 15 nicklas 59     From the NodeLoader interface
6959 01 Oct 15 nicklas 60     ------------------------------
6959 01 Oct 15 nicklas 61   */
6959 01 Oct 15 nicklas 62
6959 01 Oct 15 nicklas 63   /**
6959 01 Oct 15 nicklas 64     Create a reverse-loading raw bioassay nodes from a given experiment node.
6959 01 Oct 15 nicklas 65     The returned node is a folder-type node containing nodes for each raw
6959 01 Oct 15 nicklas 66     bioassay is part of the experiment.
6959 01 Oct 15 nicklas 67     @return The folder node for the raw bioassays
6959 01 Oct 15 nicklas 68   */
6959 01 Oct 15 nicklas 69   @Override
6959 01 Oct 15 nicklas 70   public Node createReverseNode(DbControl dc, OverviewContext context, Node experimentNode)
6959 01 Oct 15 nicklas 71   {
6959 01 Oct 15 nicklas 72     NodeFactory<RootRawBioAssay> nf = getNodeFactory(dc, context);
6959 01 Oct 15 nicklas 73     Node folderNode = null;
6959 01 Oct 15 nicklas 74     Experiment experiment = (Experiment)experimentNode.getItem(dc);
6959 01 Oct 15 nicklas 75     ItemQuery<RootRawBioAssay> query = context.initQuery(experiment.getRootRawBioAssays(), "name");
6959 01 Oct 15 nicklas 76     ItemResultIterator<RootRawBioAssay> it = query.iterate(dc);
6959 01 Oct 15 nicklas 77     while (it.hasNext())
6959 01 Oct 15 nicklas 78     {
6959 01 Oct 15 nicklas 79       RootRawBioAssay root = it.next();
6959 01 Oct 15 nicklas 80       RawBioAssay raw = root.getRawBioAssay();
6959 01 Oct 15 nicklas 81       if (folderNode == null)
6959 01 Oct 15 nicklas 82       {
6959 01 Oct 15 nicklas 83         folderNode =  new Node("rawbioassays", "Raw bioassays", experimentNode, ChildNodeDirection.REVERSE);
6959 01 Oct 15 nicklas 84       }
6959 01 Oct 15 nicklas 85       Node rawNode = createItemNode(nf, root, root, false, folderNode, ChildNodeDirection.REVERSE);
6959 01 Oct 15 nicklas 86       try
6959 01 Oct 15 nicklas 87       {
6959 01 Oct 15 nicklas 88         // We must set the EXTRACT attribute so that upstream loaders
6959 01 Oct 15 nicklas 89         // follow the correct path when reaching the biomaterials section
6959 01 Oct 15 nicklas 90         rawNode.setAttribute(NodeAttribute.EXTRACT, raw.getParentExtract());
6959 01 Oct 15 nicklas 91       }
6959 01 Oct 15 nicklas 92       catch (PermissionDeniedException ex)
6959 01 Oct 15 nicklas 93       {}
6959 01 Oct 15 nicklas 94     }
6959 01 Oct 15 nicklas 95     postValidateFolder(nf, folderNode, experimentNode, false);
6959 01 Oct 15 nicklas 96     return folderNode;
6959 01 Oct 15 nicklas 97   }
6959 01 Oct 15 nicklas 98   // ------------------------------
6959 01 Oct 15 nicklas 99   
6959 01 Oct 15 nicklas 100   /*
6959 01 Oct 15 nicklas 101     From the AbstractNodeLoader class
6959 01 Oct 15 nicklas 102     ----------------------------------
6959 01 Oct 15 nicklas 103   */
6959 01 Oct 15 nicklas 104   /**
6959 01 Oct 15 nicklas 105     Load property nodes for a raw bioassay:
6959 01 Oct 15 nicklas 106     <ul>
6959 01 Oct 15 nicklas 107     <li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 108     <li>Data files: {@link DataFileLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 109     <li>Platform: {@link PlatformLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 110     <li>Protocol: {@link ProtocolLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 111     <li>Software: {@link SoftwareLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 112     <li>Array design: {@link ArrayDesignLoader#createPropertyNode(DbControl, OverviewContext, Node)}
6959 01 Oct 15 nicklas 113     </ul>
6959 01 Oct 15 nicklas 114   */
6959 01 Oct 15 nicklas 115   @Override
6959 01 Oct 15 nicklas 116   protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode)
6959 01 Oct 15 nicklas 117   {
6959 01 Oct 15 nicklas 118     getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 119     getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 120     getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 121     getNodeLoader(context, Item.PLATFORM).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 122     getNodeLoader(context, Item.ARRAYDESIGN).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 123     getNodeLoader(context, Item.PROTOCOL).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 124     getNodeLoader(context, Item.SOFTWARE).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 125     getNodeLoader(context, Item.ANYTOANY).createPropertyNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 126   }
6959 01 Oct 15 nicklas 127   /**
6959 01 Oct 15 nicklas 128     Loads the derived bioassay node that this raw bioassay is created from.
6959 01 Oct 15 nicklas 129     @see DerivedBioAssayLoader#createReverseNode(DbControl, OverviewContext, Node)
6959 01 Oct 15 nicklas 130   */
6959 01 Oct 15 nicklas 131   @Override
6959 01 Oct 15 nicklas 132   protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode)
6959 01 Oct 15 nicklas 133   {
6959 01 Oct 15 nicklas 134     getNodeLoader(context, Item.DERIVEDBIOASSAY).createReverseNode(dc, context, rawBioAssayNode);
6959 01 Oct 15 nicklas 135   }
6959 01 Oct 15 nicklas 136   // --------------------------------
6959 01 Oct 15 nicklas 137
6959 01 Oct 15 nicklas 138 }