src/core/net/sf/basedb/util/overview/loader/PlatformLoader.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.ArrayDesign;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.core.BasicItem;
4740 05 Feb 09 nicklas 26 import net.sf.basedb.core.DbControl;
4740 05 Feb 09 nicklas 27 import net.sf.basedb.core.Item;
4740 05 Feb 09 nicklas 28 import net.sf.basedb.core.PermissionDeniedException;
4740 05 Feb 09 nicklas 29 import net.sf.basedb.core.Platform;
4740 05 Feb 09 nicklas 30 import net.sf.basedb.core.PlatformVariant;
4740 05 Feb 09 nicklas 31 import net.sf.basedb.core.RawBioAssay;
6959 01 Oct 15 nicklas 32 import net.sf.basedb.core.RootRawBioAssay;
4740 05 Feb 09 nicklas 33 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 34 import net.sf.basedb.util.overview.OverviewContext;
4740 05 Feb 09 nicklas 35 import net.sf.basedb.util.overview.node.ChildNodeDirection;
4740 05 Feb 09 nicklas 36 import net.sf.basedb.util.overview.node.NameableNameGenerator;
4740 05 Feb 09 nicklas 37 import net.sf.basedb.util.overview.node.NodeFactory;
4740 05 Feb 09 nicklas 38 import net.sf.basedb.util.overview.node.NodeNameGenerator;
4740 05 Feb 09 nicklas 39
4740 05 Feb 09 nicklas 40 /**
4740 05 Feb 09 nicklas 41   Node loader implementation for platform and platform variant. Both are 
4740 05 Feb 09 nicklas 42   loaded as end-point property nodes with no children. It can't be a root 
4740 05 Feb 09 nicklas 43   node or a forward/reverse-loading node.
4740 05 Feb 09 nicklas 44   
4740 05 Feb 09 nicklas 45   @author Nicklas
4740 05 Feb 09 nicklas 46   @version 2.10
4740 05 Feb 09 nicklas 47   @base.modified $Date$
4740 05 Feb 09 nicklas 48 */
4740 05 Feb 09 nicklas 49 public class PlatformLoader
4740 05 Feb 09 nicklas 50   extends BasicItemNodeLoader<Platform>
4740 05 Feb 09 nicklas 51 {
4740 05 Feb 09 nicklas 52   
4740 05 Feb 09 nicklas 53   public PlatformLoader()
4740 05 Feb 09 nicklas 54   {
4740 05 Feb 09 nicklas 55     super(Item.PLATFORM, DENY_ROOT_NODE, 
4740 05 Feb 09 nicklas 56         new NameableNameGenerator<Platform>("platform", "Platform"));
4740 05 Feb 09 nicklas 57   }
4740 05 Feb 09 nicklas 58   
4740 05 Feb 09 nicklas 59   /*
4740 05 Feb 09 nicklas 60     From the NodeLoader interface
4740 05 Feb 09 nicklas 61     ------------------------------
4740 05 Feb 09 nicklas 62   */
4740 05 Feb 09 nicklas 63   @Override
4740 05 Feb 09 nicklas 64   public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
4740 05 Feb 09 nicklas 65   {
4740 05 Feb 09 nicklas 66     NodeFactory<Platform> nf = getNodeFactory(dc, context);
4740 05 Feb 09 nicklas 67     Platform platform = null;
4740 05 Feb 09 nicklas 68     PlatformVariant variant = null;
4740 05 Feb 09 nicklas 69     boolean denied = false;
4740 05 Feb 09 nicklas 70     try
4740 05 Feb 09 nicklas 71     {
4740 05 Feb 09 nicklas 72       BasicItem parentItem = parentNode.getItem(dc);
6959 01 Oct 15 nicklas 73       if (parentItem instanceof RootRawBioAssay)
6959 01 Oct 15 nicklas 74       {
6959 01 Oct 15 nicklas 75         // The parent may be a root raw bioasay if the overview starts at the
6959 01 Oct 15 nicklas 76         // experiment level
6959 01 Oct 15 nicklas 77         parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
6959 01 Oct 15 nicklas 78       }
4740 05 Feb 09 nicklas 79       if (parentItem instanceof RawBioAssay)
4740 05 Feb 09 nicklas 80       {
4740 05 Feb 09 nicklas 81         RawBioAssay rba = (RawBioAssay)parentItem;
4740 05 Feb 09 nicklas 82         platform = rba.getPlatform();
4740 05 Feb 09 nicklas 83         variant = rba.getVariant();
4740 05 Feb 09 nicklas 84       }
4740 05 Feb 09 nicklas 85       else if (parentItem instanceof ArrayDesign)
4740 05 Feb 09 nicklas 86       {
4740 05 Feb 09 nicklas 87         ArrayDesign ad = (ArrayDesign)parentItem;
4740 05 Feb 09 nicklas 88         platform = ad.getPlatform();
4740 05 Feb 09 nicklas 89         variant = ad.getVariant();
4740 05 Feb 09 nicklas 90       }
4740 05 Feb 09 nicklas 91       // If there are other items with a platform
4740 05 Feb 09 nicklas 92       // we should add more cases here
4740 05 Feb 09 nicklas 93     }
4740 05 Feb 09 nicklas 94     catch (PermissionDeniedException ex)
4740 05 Feb 09 nicklas 95     {
4740 05 Feb 09 nicklas 96       denied = true;
4740 05 Feb 09 nicklas 97     }
6520 18 Aug 14 nicklas 98     Node platformNode = createItemNode(nf, platform, variant != null ? variant : platform, denied, parentNode, ChildNodeDirection.NONE);
6520 18 Aug 14 nicklas 99     if (platformNode != null && variant != null && platformNode.getChild("variant") == null)
4740 05 Feb 09 nicklas 100     {
4740 05 Feb 09 nicklas 101       NodeNameGenerator<PlatformVariant> nameGenerator = 
4740 05 Feb 09 nicklas 102         new NameableNameGenerator<PlatformVariant>("variant", "Variant");
4740 05 Feb 09 nicklas 103       NodeFactory<PlatformVariant> variantNodeFactory = 
4740 05 Feb 09 nicklas 104         new NodeFactory<PlatformVariant>(dc, context, null, nameGenerator);
6520 18 Aug 14 nicklas 105       variantNodeFactory.createNode(variant, null, platformNode, ChildNodeDirection.NONE);
4740 05 Feb 09 nicklas 106     }
4740 05 Feb 09 nicklas 107     return platformNode;
4740 05 Feb 09 nicklas 108   }
4740 05 Feb 09 nicklas 109   // -----------------------------------
4740 05 Feb 09 nicklas 110   
4740 05 Feb 09 nicklas 111 }