src/core/net/sf/basedb/util/overview/node/BioPlateNameGenerator.java

Code
Comments
Other
Rev Date Author Line
6041 02 Apr 12 nicklas 1 /**
6041 02 Apr 12 nicklas 2   $Id$
6041 02 Apr 12 nicklas 3
6041 02 Apr 12 nicklas 4   Copyright (C) 2012 Nicklas Nordborg
6041 02 Apr 12 nicklas 5
6041 02 Apr 12 nicklas 6   This file is part of BASE - BioArray Software Environment.
6041 02 Apr 12 nicklas 7   Available at http://base.thep.lu.se/
6041 02 Apr 12 nicklas 8
6041 02 Apr 12 nicklas 9   BASE is free software; you can redistribute it and/or
6041 02 Apr 12 nicklas 10   modify it under the terms of the GNU General Public License
6041 02 Apr 12 nicklas 11   as published by the Free Software Foundation; either version 3
6041 02 Apr 12 nicklas 12   of the License, or (at your option) any later version.
6041 02 Apr 12 nicklas 13
6041 02 Apr 12 nicklas 14   BASE is distributed in the hope that it will be useful,
6041 02 Apr 12 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
6041 02 Apr 12 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6041 02 Apr 12 nicklas 17   GNU General Public License for more details.
6041 02 Apr 12 nicklas 18
6041 02 Apr 12 nicklas 19   You should have received a copy of the GNU General Public License
6041 02 Apr 12 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
6041 02 Apr 12 nicklas 21 */
6041 02 Apr 12 nicklas 22 package net.sf.basedb.util.overview.node;
6041 02 Apr 12 nicklas 23
6041 02 Apr 12 nicklas 24 import net.sf.basedb.core.BioPlate;
6210 06 Dec 12 nicklas 25 import net.sf.basedb.core.BioPlateEventParticipant;
6210 06 Dec 12 nicklas 26 import net.sf.basedb.core.BioWell;
6041 02 Apr 12 nicklas 27 import net.sf.basedb.util.overview.Node;
6041 02 Apr 12 nicklas 28
6041 02 Apr 12 nicklas 29 /**
6041 02 Apr 12 nicklas 30   Name generator implementation for {@link BioPlate} items. The 
6041 02 Apr 12 nicklas 31   implementation use the {@link NameableNameGenerator} but appends 
6041 02 Apr 12 nicklas 32   the coordinate of the biomaterial if the parent node  is a 
6210 06 Dec 12 nicklas 33   biomaterial node. Eg. <code>My plate [A2]</code>. If the parent
6210 06 Dec 12 nicklas 34   node is a bioplate event, it appends the {@link BioPlateEventParticipant#getRole()}
6210 06 Dec 12 nicklas 35   to the title.
6041 02 Apr 12 nicklas 36   
6041 02 Apr 12 nicklas 37   @author Nicklas
6041 02 Apr 12 nicklas 38   @since 3.2
6041 02 Apr 12 nicklas 39   @base.modified $Date$
6041 02 Apr 12 nicklas 40 */
6041 02 Apr 12 nicklas 41 public class BioPlateNameGenerator
6041 02 Apr 12 nicklas 42   extends NameableNameGenerator<BioPlate>
6041 02 Apr 12 nicklas 43 {
6041 02 Apr 12 nicklas 44
6210 06 Dec 12 nicklas 45   private BioPlateEventParticipant currentParticipant;
6210 06 Dec 12 nicklas 46   private BioWell currentWell;
6210 06 Dec 12 nicklas 47   
6041 02 Apr 12 nicklas 48   /**
6041 02 Apr 12 nicklas 49     Create a new name generator.
6041 02 Apr 12 nicklas 50     @param namePrefix The prefix to use in node names
6041 02 Apr 12 nicklas 51     @param titlePrefix The prefix to use in node titles
6041 02 Apr 12 nicklas 52   */
6041 02 Apr 12 nicklas 53   public BioPlateNameGenerator(String namePrefix, String titlePrefix)
6041 02 Apr 12 nicklas 54   {
6041 02 Apr 12 nicklas 55     super(namePrefix, titlePrefix);
6041 02 Apr 12 nicklas 56   }
6041 02 Apr 12 nicklas 57   
6041 02 Apr 12 nicklas 58   /*
6041 02 Apr 12 nicklas 59     From the NameableNameGenerator class
6041 02 Apr 12 nicklas 60     ------------------------------------
6041 02 Apr 12 nicklas 61   */
6041 02 Apr 12 nicklas 62   /**
6041 02 Apr 12 nicklas 63     The base of the title is generated by the superclass. This
6041 02 Apr 12 nicklas 64     implementation adds a suffix to the title with the coordinate
6041 02 Apr 12 nicklas 65     of the biomaterial if the parent node is a biomaterial node.
6210 06 Dec 12 nicklas 66     If the parent node is a bioplate event, the role of the bioplate
6210 06 Dec 12 nicklas 67     in the event is added.
6041 02 Apr 12 nicklas 68   */
6041 02 Apr 12 nicklas 69   @Override
6041 02 Apr 12 nicklas 70   public String getNodeTitle(BioPlate item, Node parentNode)
6041 02 Apr 12 nicklas 71   {
6041 02 Apr 12 nicklas 72     String title = super.getNodeTitle(item, parentNode);
6041 02 Apr 12 nicklas 73     try
6041 02 Apr 12 nicklas 74     {
6210 06 Dec 12 nicklas 75       if (currentWell != null)
6041 02 Apr 12 nicklas 76       {
6210 06 Dec 12 nicklas 77         title += " [" + currentWell.getCoordinate() + "]";
6041 02 Apr 12 nicklas 78       }
6210 06 Dec 12 nicklas 79       else if (currentParticipant != null)
6210 06 Dec 12 nicklas 80       {
6210 06 Dec 12 nicklas 81         String role = currentParticipant.getRole();
6210 06 Dec 12 nicklas 82         if (role != null) title += " [" + role + "]";
6210 06 Dec 12 nicklas 83       }
6041 02 Apr 12 nicklas 84     }
6041 02 Apr 12 nicklas 85     catch (RuntimeException ex)
6041 02 Apr 12 nicklas 86     {}
6041 02 Apr 12 nicklas 87     return title;
6041 02 Apr 12 nicklas 88   }
6041 02 Apr 12 nicklas 89   // ------------------------
6210 06 Dec 12 nicklas 90   
6210 06 Dec 12 nicklas 91   /**
6210 06 Dec 12 nicklas 92     Set the current bioplate event participant object that should be used when
6210 06 Dec 12 nicklas 93     generating names for bioplates that are part of a bioplate event.
6210 06 Dec 12 nicklas 94     @since 3.3
6210 06 Dec 12 nicklas 95   */
6210 06 Dec 12 nicklas 96   public void setCurrentEventParticipant(BioPlateEventParticipant participant)
6210 06 Dec 12 nicklas 97   {
6210 06 Dec 12 nicklas 98     this.currentParticipant = participant;
6210 06 Dec 12 nicklas 99   }
6210 06 Dec 12 nicklas 100
6210 06 Dec 12 nicklas 101   /**
6210 06 Dec 12 nicklas 102     Set the current biowell object that should be used when
6210 06 Dec 12 nicklas 103     generating names for bioplates that are reached by navigating via a biomaterial.
6210 06 Dec 12 nicklas 104     @since 3.3
6210 06 Dec 12 nicklas 105   */
6210 06 Dec 12 nicklas 106   public void setCurrentBioWell(BioWell well)
6210 06 Dec 12 nicklas 107   {
6210 06 Dec 12 nicklas 108     this.currentWell = well;
6210 06 Dec 12 nicklas 109   }
6210 06 Dec 12 nicklas 110
6041 02 Apr 12 nicklas 111 }
6210 06 Dec 12 nicklas 112