src/core/net/sf/basedb/util/overview/loader/HardwareLoader.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.BasicItem;
6042 03 Apr 12 nicklas 26 import net.sf.basedb.core.BioPlate;
6210 06 Dec 12 nicklas 27 import net.sf.basedb.core.BioPlateEvent;
4740 05 Feb 09 nicklas 28 import net.sf.basedb.core.DbControl;
5685 04 Aug 11 nicklas 29 import net.sf.basedb.core.DerivedBioAssay;
4740 05 Feb 09 nicklas 30 import net.sf.basedb.core.Hardware;
5651 08 Jun 11 nicklas 31 import net.sf.basedb.core.MeasuredBioMaterial;
5642 26 May 11 nicklas 32 import net.sf.basedb.core.PhysicalBioAssay;
4740 05 Feb 09 nicklas 33 import net.sf.basedb.core.Item;
4740 05 Feb 09 nicklas 34 import net.sf.basedb.core.PermissionDeniedException;
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.OverviewContext;
4740 05 Feb 09 nicklas 37 import net.sf.basedb.util.overview.Validator;
4740 05 Feb 09 nicklas 38 import net.sf.basedb.util.overview.node.ChildNodeDirection;
4740 05 Feb 09 nicklas 39 import net.sf.basedb.util.overview.node.NameableNameGenerator;
4740 05 Feb 09 nicklas 40 import net.sf.basedb.util.overview.node.NodeFactory;
4740 05 Feb 09 nicklas 41
4740 05 Feb 09 nicklas 42 /**
4740 05 Feb 09 nicklas 43   Node loader implementation for hardware. Hardware is loaded as
4740 05 Feb 09 nicklas 44   end-point property nodes with no children. It can't be a root 
4740 05 Feb 09 nicklas 45   node or a forward/reverse-loading node.
4740 05 Feb 09 nicklas 46   <p>
4740 05 Feb 09 nicklas 47   Validations:
4740 05 Feb 09 nicklas 48   <ul>
4740 05 Feb 09 nicklas 49   <li>Missing hardware: {@link Validator#MISSING_HARDWARE}
4740 05 Feb 09 nicklas 50   <li>Denied hardware: {@link Validator#DENIED_HARDWARE}
4740 05 Feb 09 nicklas 51   <li>Incorrect hardware type: {@link Validator#INCORRECT_HARDWARETYPE} 
4740 05 Feb 09 nicklas 52   <li>Non-default hardware: {@link Validator#NONDEFAULT_HARDWARE} 
4740 05 Feb 09 nicklas 53   </ul>
4740 05 Feb 09 nicklas 54   
4740 05 Feb 09 nicklas 55   @author Nicklas
4740 05 Feb 09 nicklas 56   @version 2.10
4740 05 Feb 09 nicklas 57   @base.modified $Date$
4740 05 Feb 09 nicklas 58 */
4740 05 Feb 09 nicklas 59 public class HardwareLoader
4740 05 Feb 09 nicklas 60   extends BasicItemNodeLoader<Hardware>
4740 05 Feb 09 nicklas 61 {
4740 05 Feb 09 nicklas 62   
4740 05 Feb 09 nicklas 63   public HardwareLoader()
4740 05 Feb 09 nicklas 64   {
4740 05 Feb 09 nicklas 65     super(Item.HARDWARE, DENY_ROOT_NODE, 
4740 05 Feb 09 nicklas 66         new NameableNameGenerator<Hardware>("hardware", "Hardware"));
4740 05 Feb 09 nicklas 67   }
4740 05 Feb 09 nicklas 68   
4740 05 Feb 09 nicklas 69   /*
4740 05 Feb 09 nicklas 70     From the NodeLoader interface
4740 05 Feb 09 nicklas 71     ------------------------------
4740 05 Feb 09 nicklas 72   */
4740 05 Feb 09 nicklas 73   @Override
4740 05 Feb 09 nicklas 74   public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
4740 05 Feb 09 nicklas 75   {
4740 05 Feb 09 nicklas 76     Hardware hardware = null;
4740 05 Feb 09 nicklas 77     boolean denied = false;
4740 05 Feb 09 nicklas 78     try
4740 05 Feb 09 nicklas 79     {
6870 16 Apr 15 nicklas 80       BasicItem parentItem = parentNode.getItem(dc);
5685 04 Aug 11 nicklas 81       if (parentItem instanceof DerivedBioAssay)
4740 05 Feb 09 nicklas 82       {
5685 04 Aug 11 nicklas 83         hardware = ((DerivedBioAssay)parentItem).getHardware();
4740 05 Feb 09 nicklas 84       }
5642 26 May 11 nicklas 85       else if (parentItem instanceof PhysicalBioAssay)
4740 05 Feb 09 nicklas 86       {
5642 26 May 11 nicklas 87         hardware = ((PhysicalBioAssay)parentItem).getCreationEvent().getHardware();
4740 05 Feb 09 nicklas 88       }
5651 08 Jun 11 nicklas 89       else if (parentItem instanceof MeasuredBioMaterial)
5651 08 Jun 11 nicklas 90       {
5651 08 Jun 11 nicklas 91         hardware = ((MeasuredBioMaterial)parentItem).getCreationEvent().getHardware();
5651 08 Jun 11 nicklas 92       }
4740 05 Feb 09 nicklas 93       else if (parentItem instanceof ArrayBatch)
4740 05 Feb 09 nicklas 94       {
4740 05 Feb 09 nicklas 95         hardware = ((ArrayBatch)parentItem).getPrintRobot();
4740 05 Feb 09 nicklas 96       }
6042 03 Apr 12 nicklas 97       else if (parentItem instanceof BioPlate)
6042 03 Apr 12 nicklas 98       {
6042 03 Apr 12 nicklas 99         hardware = ((BioPlate)parentItem).getFreezer();
6042 03 Apr 12 nicklas 100       }
6210 06 Dec 12 nicklas 101       else if (parentItem instanceof BioPlateEvent)
6210 06 Dec 12 nicklas 102       {
6210 06 Dec 12 nicklas 103         hardware = ((BioPlateEvent)parentItem).getHardware();
6210 06 Dec 12 nicklas 104       }
4740 05 Feb 09 nicklas 105       // If there are other items with a software
4740 05 Feb 09 nicklas 106       // we should add more cases here
4740 05 Feb 09 nicklas 107     }
4740 05 Feb 09 nicklas 108     catch (PermissionDeniedException ex)
4740 05 Feb 09 nicklas 109     {
4740 05 Feb 09 nicklas 110       denied = true;
4740 05 Feb 09 nicklas 111     }
4740 05 Feb 09 nicklas 112     
5651 08 Jun 11 nicklas 113     NodeFactory<Hardware> nf = getNodeFactory(dc, context);
4740 05 Feb 09 nicklas 114     Node hardwareNode = createItemNode(nf, hardware, hardware, denied, 
6328 15 Oct 13 olle 115         parentNode, ChildNodeDirection.PROPERTY);
4740 05 Feb 09 nicklas 116     return hardwareNode;
4740 05 Feb 09 nicklas 117   }
4740 05 Feb 09 nicklas 118   // -----------------------------------
6328 15 Oct 13 olle 119   /*
6328 15 Oct 13 olle 120     From the AbstractNodeLoader class
6328 15 Oct 13 olle 121     ----------------------------------
6328 15 Oct 13 olle 122   */
6328 15 Oct 13 olle 123   /**
6328 15 Oct 13 olle 124     Loads annotations and hardware parameters for the given hardware node.
6328 15 Oct 13 olle 125     @see RawBioAssayLoader#createForwardNode(DbControl, OverviewContext, Node)
6328 15 Oct 13 olle 126   */
6328 15 Oct 13 olle 127   @Override
6328 15 Oct 13 olle 128   protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node hardwareNode)
6328 15 Oct 13 olle 129   {
6328 15 Oct 13 olle 130     getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, hardwareNode);
6328 15 Oct 13 olle 131   }
6328 15 Oct 13 olle 132   // -------------------------------------  
4740 05 Feb 09 nicklas 133 }