6041 |
02 Apr 12 |
nicklas |
1 |
/** |
6041 |
02 Apr 12 |
nicklas |
$Id$ |
6041 |
02 Apr 12 |
nicklas |
3 |
|
6041 |
02 Apr 12 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
6041 |
02 Apr 12 |
nicklas |
5 |
|
6041 |
02 Apr 12 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
6041 |
02 Apr 12 |
nicklas |
Available at http://base.thep.lu.se/ |
6041 |
02 Apr 12 |
nicklas |
8 |
|
6041 |
02 Apr 12 |
nicklas |
BASE is free software; you can redistribute it and/or |
6041 |
02 Apr 12 |
nicklas |
modify it under the terms of the GNU General Public License |
6041 |
02 Apr 12 |
nicklas |
as published by the Free Software Foundation; either version 3 |
6041 |
02 Apr 12 |
nicklas |
of the License, or (at your option) any later version. |
6041 |
02 Apr 12 |
nicklas |
13 |
|
6041 |
02 Apr 12 |
nicklas |
BASE is distributed in the hope that it will be useful, |
6041 |
02 Apr 12 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
6041 |
02 Apr 12 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6041 |
02 Apr 12 |
nicklas |
GNU General Public License for more details. |
6041 |
02 Apr 12 |
nicklas |
18 |
|
6041 |
02 Apr 12 |
nicklas |
You should have received a copy of the GNU General Public License |
6041 |
02 Apr 12 |
nicklas |
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 |
Name generator implementation for {@link BioPlate} items. The |
6041 |
02 Apr 12 |
nicklas |
implementation use the {@link NameableNameGenerator} but appends |
6041 |
02 Apr 12 |
nicklas |
the coordinate of the biomaterial if the parent node is a |
6210 |
06 Dec 12 |
nicklas |
biomaterial node. Eg. <code>My plate [A2]</code>. If the parent |
6210 |
06 Dec 12 |
nicklas |
node is a bioplate event, it appends the {@link BioPlateEventParticipant#getRole()} |
6210 |
06 Dec 12 |
nicklas |
to the title. |
6041 |
02 Apr 12 |
nicklas |
36 |
|
6041 |
02 Apr 12 |
nicklas |
@author Nicklas |
6041 |
02 Apr 12 |
nicklas |
@since 3.2 |
6041 |
02 Apr 12 |
nicklas |
@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 |
Create a new name generator. |
6041 |
02 Apr 12 |
nicklas |
@param namePrefix The prefix to use in node names |
6041 |
02 Apr 12 |
nicklas |
@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 |
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 |
The base of the title is generated by the superclass. This |
6041 |
02 Apr 12 |
nicklas |
implementation adds a suffix to the title with the coordinate |
6041 |
02 Apr 12 |
nicklas |
of the biomaterial if the parent node is a biomaterial node. |
6210 |
06 Dec 12 |
nicklas |
If the parent node is a bioplate event, the role of the bioplate |
6210 |
06 Dec 12 |
nicklas |
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 |
Set the current bioplate event participant object that should be used when |
6210 |
06 Dec 12 |
nicklas |
generating names for bioplates that are part of a bioplate event. |
6210 |
06 Dec 12 |
nicklas |
@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 |
Set the current biowell object that should be used when |
6210 |
06 Dec 12 |
nicklas |
generating names for bioplates that are reached by navigating via a biomaterial. |
6210 |
06 Dec 12 |
nicklas |
@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 |
|