src/core/net/sf/basedb/util/overview/loader/SoftwareLoader.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.BasicItem;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.core.DbControl;
5685 04 Aug 11 nicklas 26 import net.sf.basedb.core.DerivedBioAssay;
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.RawBioAssay;
6959 01 Oct 15 nicklas 30 import net.sf.basedb.core.RootRawBioAssay;
4740 05 Feb 09 nicklas 31 import net.sf.basedb.core.Software;
4740 05 Feb 09 nicklas 32 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 33 import net.sf.basedb.util.overview.OverviewContext;
4740 05 Feb 09 nicklas 34 import net.sf.basedb.util.overview.node.ChildNodeDirection;
4740 05 Feb 09 nicklas 35 import net.sf.basedb.util.overview.node.NameableNameGenerator;
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 software. Software is loaded as
4740 05 Feb 09 nicklas 40   end-point property nodes with no children. It can't be a root 
4740 05 Feb 09 nicklas 41   node or a forward/reverse-loading node.
4740 05 Feb 09 nicklas 42   
4740 05 Feb 09 nicklas 43   @author Nicklas
4740 05 Feb 09 nicklas 44   @version 2.10
4740 05 Feb 09 nicklas 45   @base.modified $Date$
4740 05 Feb 09 nicklas 46 */
4740 05 Feb 09 nicklas 47 public class SoftwareLoader
4740 05 Feb 09 nicklas 48   extends BasicItemNodeLoader<Software>
4740 05 Feb 09 nicklas 49 {
4740 05 Feb 09 nicklas 50
4740 05 Feb 09 nicklas 51   public SoftwareLoader()
4740 05 Feb 09 nicklas 52   {
4740 05 Feb 09 nicklas 53     super(Item.SOFTWARE, DENY_ROOT_NODE, 
4740 05 Feb 09 nicklas 54         new NameableNameGenerator<Software>("software", "Software"));
4740 05 Feb 09 nicklas 55   }
4740 05 Feb 09 nicklas 56   
4740 05 Feb 09 nicklas 57   /*
4740 05 Feb 09 nicklas 58     From the NodeLoader interface
4740 05 Feb 09 nicklas 59     ------------------------------
4740 05 Feb 09 nicklas 60   */
4740 05 Feb 09 nicklas 61   @Override
4740 05 Feb 09 nicklas 62   public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
4740 05 Feb 09 nicklas 63   {
4740 05 Feb 09 nicklas 64     NodeFactory<Software> nf = getNodeFactory(dc, context);
4740 05 Feb 09 nicklas 65     Software software = null;
4740 05 Feb 09 nicklas 66     boolean denied = false;
4740 05 Feb 09 nicklas 67     try
4740 05 Feb 09 nicklas 68     {
4740 05 Feb 09 nicklas 69       BasicItem parentItem = parentNode.getItem(dc);
6959 01 Oct 15 nicklas 70       if (parentItem instanceof RootRawBioAssay)
6959 01 Oct 15 nicklas 71       {
6959 01 Oct 15 nicklas 72         // The parent may be a root raw bioasay if the overview starts at the
6959 01 Oct 15 nicklas 73         // experiment level
6959 01 Oct 15 nicklas 74         parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
6959 01 Oct 15 nicklas 75       }
4740 05 Feb 09 nicklas 76       if (parentItem instanceof RawBioAssay)
4740 05 Feb 09 nicklas 77       {
4740 05 Feb 09 nicklas 78         software = ((RawBioAssay)parentItem).getSoftware();
4740 05 Feb 09 nicklas 79       }
5685 04 Aug 11 nicklas 80       else if (parentItem instanceof DerivedBioAssay)
5652 10 Jun 11 nicklas 81       {
5685 04 Aug 11 nicklas 82         software = ((DerivedBioAssay)parentItem).getSoftware();
5652 10 Jun 11 nicklas 83       }
5652 10 Jun 11 nicklas 84
4740 05 Feb 09 nicklas 85       // If there are other items with a software
4740 05 Feb 09 nicklas 86       // we should add more cases here
4740 05 Feb 09 nicklas 87     }
4740 05 Feb 09 nicklas 88     catch (PermissionDeniedException ex)
4740 05 Feb 09 nicklas 89     {
4740 05 Feb 09 nicklas 90       denied = true;
4740 05 Feb 09 nicklas 91     }
4740 05 Feb 09 nicklas 92     Node softwareNode = createItemNode(nf, software, software, denied, 
6334 16 Oct 13 olle 93         parentNode, ChildNodeDirection.PROPERTY);
4740 05 Feb 09 nicklas 94     return softwareNode;
4740 05 Feb 09 nicklas 95   }
4740 05 Feb 09 nicklas 96   // -----------------------------------
6334 16 Oct 13 olle 97   /*
6334 16 Oct 13 olle 98     From the AbstractNodeLoader class
6334 16 Oct 13 olle 99     ----------------------------------
6334 16 Oct 13 olle 100   */
6334 16 Oct 13 olle 101   /**
6334 16 Oct 13 olle 102     Loads annotations and software parameters for the given software node.
6334 16 Oct 13 olle 103     @see RawBioAssayLoader#createForwardNode(DbControl, OverviewContext, Node)
6334 16 Oct 13 olle 104   */
6334 16 Oct 13 olle 105   @Override
6334 16 Oct 13 olle 106   protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node softwareNode)
6334 16 Oct 13 olle 107   {
6334 16 Oct 13 olle 108     getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, softwareNode);
6334 16 Oct 13 olle 109   }
6334 16 Oct 13 olle 110   // -------------------------------------  
4740 05 Feb 09 nicklas 111 }