4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
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.BioSource; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.core.DbControl; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.core.Item; |
5985 |
24 Feb 12 |
nicklas |
27 |
import net.sf.basedb.core.ItemSubtype; |
4740 |
05 Feb 09 |
nicklas |
28 |
import net.sf.basedb.core.PermissionDeniedException; |
4740 |
05 Feb 09 |
nicklas |
29 |
import net.sf.basedb.core.Sample; |
4740 |
05 Feb 09 |
nicklas |
30 |
import net.sf.basedb.util.overview.OverviewContext; |
4740 |
05 Feb 09 |
nicklas |
31 |
import net.sf.basedb.util.overview.node.ChildNodeDirection; |
4740 |
05 Feb 09 |
nicklas |
32 |
import net.sf.basedb.util.overview.node.NameableNameGenerator; |
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.node.NodeFactory; |
4740 |
05 Feb 09 |
nicklas |
35 |
|
4740 |
05 Feb 09 |
nicklas |
36 |
/** |
4740 |
05 Feb 09 |
nicklas |
Node loader implementation for biosources. Biosources are |
4740 |
05 Feb 09 |
nicklas |
an endpoint node with the forward-loading direction going to |
4740 |
05 Feb 09 |
nicklas |
{@link BioSource}:s -> {@link Sample}:s. |
4740 |
05 Feb 09 |
nicklas |
40 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
44 |
*/ |
4740 |
05 Feb 09 |
nicklas |
45 |
public class BioSourceLoader |
4740 |
05 Feb 09 |
nicklas |
46 |
extends BasicItemNodeLoader<BioSource> |
4740 |
05 Feb 09 |
nicklas |
47 |
{ |
4740 |
05 Feb 09 |
nicklas |
48 |
|
4740 |
05 Feb 09 |
nicklas |
49 |
public BioSourceLoader() |
4740 |
05 Feb 09 |
nicklas |
50 |
{ |
4740 |
05 Feb 09 |
nicklas |
51 |
super(Item.BIOSOURCE, ALLOW_ROOT_NODE, new NameableNameGenerator<BioSource>("biosource", "Biosource")); |
4740 |
05 Feb 09 |
nicklas |
52 |
} |
4740 |
05 Feb 09 |
nicklas |
53 |
|
4740 |
05 Feb 09 |
nicklas |
54 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the NodeLoader interface |
4740 |
05 Feb 09 |
nicklas |
56 |
------------------------------ |
4740 |
05 Feb 09 |
nicklas |
57 |
*/ |
4740 |
05 Feb 09 |
nicklas |
58 |
/** |
6043 |
03 Apr 12 |
nicklas |
Create forward-loading biosource nodes from a biomaterial list for the |
6043 |
03 Apr 12 |
nicklas |
member biosources. |
6043 |
03 Apr 12 |
nicklas |
@return The folder node for the biosources (or null if used with a list) |
6043 |
03 Apr 12 |
nicklas |
62 |
*/ |
6043 |
03 Apr 12 |
nicklas |
63 |
@Override |
6043 |
03 Apr 12 |
nicklas |
64 |
public Node createForwardNode(DbControl dc, OverviewContext context, Node parentNode) |
6043 |
03 Apr 12 |
nicklas |
65 |
{ |
6043 |
03 Apr 12 |
nicklas |
66 |
Node returnNode = null; |
6043 |
03 Apr 12 |
nicklas |
67 |
Item parentType = parentNode.getItemType(); |
6755 |
20 Feb 15 |
nicklas |
68 |
if (parentType == Item.ITEMLIST) |
6755 |
20 Feb 15 |
nicklas |
69 |
{ |
6755 |
20 Feb 15 |
nicklas |
70 |
ItemListLoader.loadMemberNodes(this, dc, context, parentNode); |
6755 |
20 Feb 15 |
nicklas |
71 |
} |
6043 |
03 Apr 12 |
nicklas |
72 |
return returnNode; |
6043 |
03 Apr 12 |
nicklas |
73 |
} |
6043 |
03 Apr 12 |
nicklas |
74 |
/** |
4740 |
05 Feb 09 |
nicklas |
Create a reverse-loading biosource node from a sample node. |
4740 |
05 Feb 09 |
nicklas |
@return A biosource node, which can be null if validation fails |
4740 |
05 Feb 09 |
nicklas |
77 |
*/ |
4740 |
05 Feb 09 |
nicklas |
78 |
@Override |
4740 |
05 Feb 09 |
nicklas |
79 |
public Node createReverseNode(DbControl dc, OverviewContext context, Node sampleNode) |
4740 |
05 Feb 09 |
nicklas |
80 |
{ |
4740 |
05 Feb 09 |
nicklas |
81 |
NodeFactory<BioSource> nf = getNodeFactory(dc, context); |
4740 |
05 Feb 09 |
nicklas |
82 |
BioSource bioSource = null; |
4740 |
05 Feb 09 |
nicklas |
83 |
boolean denied = false; |
4740 |
05 Feb 09 |
nicklas |
84 |
try |
4740 |
05 Feb 09 |
nicklas |
85 |
{ |
4740 |
05 Feb 09 |
nicklas |
86 |
Sample sample = (Sample)sampleNode.getItem(dc); |
5663 |
22 Jun 11 |
nicklas |
87 |
bioSource = (BioSource)sample.getParent(); |
4740 |
05 Feb 09 |
nicklas |
88 |
} |
4740 |
05 Feb 09 |
nicklas |
89 |
catch (PermissionDeniedException ex) |
4740 |
05 Feb 09 |
nicklas |
90 |
{ |
4740 |
05 Feb 09 |
nicklas |
91 |
denied = true; |
4740 |
05 Feb 09 |
nicklas |
92 |
} |
4740 |
05 Feb 09 |
nicklas |
93 |
Node bioSourceNode = createItemNode(nf, bioSource, bioSource, denied, |
4740 |
05 Feb 09 |
nicklas |
94 |
sampleNode, ChildNodeDirection.REVERSE); |
4740 |
05 Feb 09 |
nicklas |
95 |
return bioSourceNode; |
4740 |
05 Feb 09 |
nicklas |
96 |
} |
4740 |
05 Feb 09 |
nicklas |
97 |
// -------------------------------- |
4740 |
05 Feb 09 |
nicklas |
98 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the AbstractNodeLoader class |
4740 |
05 Feb 09 |
nicklas |
100 |
---------------------------------- |
4740 |
05 Feb 09 |
nicklas |
101 |
*/ |
4740 |
05 Feb 09 |
nicklas |
102 |
/** |
4740 |
05 Feb 09 |
nicklas |
Loads property nodes of an array design. |
4740 |
05 Feb 09 |
nicklas |
<ul> |
4740 |
05 Feb 09 |
nicklas |
<li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
</ul> |
4740 |
05 Feb 09 |
nicklas |
107 |
*/ |
4740 |
05 Feb 09 |
nicklas |
108 |
@Override |
4740 |
05 Feb 09 |
nicklas |
109 |
protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node bioSourceNode) |
4740 |
05 Feb 09 |
nicklas |
110 |
{ |
4740 |
05 Feb 09 |
nicklas |
111 |
getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, bioSourceNode); |
5500 |
18 Nov 10 |
nicklas |
112 |
getNodeLoader(context, Item.ANYTOANY).createPropertyNode(dc, context, bioSourceNode); |
4740 |
05 Feb 09 |
nicklas |
113 |
} |
4740 |
05 Feb 09 |
nicklas |
114 |
|
4740 |
05 Feb 09 |
nicklas |
115 |
/** |
4740 |
05 Feb 09 |
nicklas |
Loads the sample nodes that has been created from the given biosource node. |
4740 |
05 Feb 09 |
nicklas |
@see ArrayBatchLoader#createForwardNode(DbControl, OverviewContext, Node) |
4740 |
05 Feb 09 |
nicklas |
118 |
*/ |
4740 |
05 Feb 09 |
nicklas |
119 |
@Override |
4740 |
05 Feb 09 |
nicklas |
120 |
protected void loadForwardChildNodes(DbControl dc, OverviewContext context, Node bioSourceNode) |
4740 |
05 Feb 09 |
nicklas |
121 |
{ |
4740 |
05 Feb 09 |
nicklas |
122 |
getNodeLoader(context, Item.SAMPLE).createForwardNode(dc, context, bioSourceNode); |
4740 |
05 Feb 09 |
nicklas |
123 |
} |
5985 |
24 Feb 12 |
nicklas |
124 |
|
5985 |
24 Feb 12 |
nicklas |
125 |
/** |
5985 |
24 Feb 12 |
nicklas |
A biosource usually don't have any reverse child nodes. The exception is |
5985 |
24 Feb 12 |
nicklas |
child samples that have a subtype with the {@link ItemSubtype#getPushAnnotations()} flag set. |
5985 |
24 Feb 12 |
nicklas |
@since 3.1 |
5985 |
24 Feb 12 |
nicklas |
129 |
*/ |
5985 |
24 Feb 12 |
nicklas |
130 |
@Override |
5985 |
24 Feb 12 |
nicklas |
131 |
protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node bioSourceNode) |
5985 |
24 Feb 12 |
nicklas |
132 |
{ |
5985 |
24 Feb 12 |
nicklas |
133 |
if (bioSourceNode.getChildNodeDirection() == ChildNodeDirection.REVERSE) |
5985 |
24 Feb 12 |
nicklas |
134 |
{ |
5985 |
24 Feb 12 |
nicklas |
// Only if we are moving in the reverse direction (eg. not when the biosource is a root node) |
5985 |
24 Feb 12 |
nicklas |
136 |
getNodeLoader(context, Item.SAMPLE).createPropertyNode(dc, context, bioSourceNode); |
5985 |
24 Feb 12 |
nicklas |
137 |
} |
5985 |
24 Feb 12 |
nicklas |
138 |
} |
4740 |
05 Feb 09 |
nicklas |
139 |
// --------------------------------------- |
4740 |
05 Feb 09 |
nicklas |
140 |
|
4740 |
05 Feb 09 |
nicklas |
141 |
} |