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.DbControl; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.core.Experiment; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.core.Item; |
4740 |
05 Feb 09 |
nicklas |
27 |
import net.sf.basedb.core.ItemQuery; |
4740 |
05 Feb 09 |
nicklas |
28 |
import net.sf.basedb.core.ItemResultIterator; |
4740 |
05 Feb 09 |
nicklas |
29 |
import net.sf.basedb.core.RawBioAssay; |
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 experiments. An experiment is the |
4740 |
05 Feb 09 |
nicklas |
endpoint of the forward-direction. The reverse direction goes |
4740 |
05 Feb 09 |
nicklas |
to the {@link RawBioAssay}:s included in the experiment. |
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 ExperimentLoader |
4740 |
05 Feb 09 |
nicklas |
46 |
extends BasicItemNodeLoader<Experiment> |
4740 |
05 Feb 09 |
nicklas |
47 |
{ |
4740 |
05 Feb 09 |
nicklas |
48 |
public ExperimentLoader() |
4740 |
05 Feb 09 |
nicklas |
49 |
{ |
4740 |
05 Feb 09 |
nicklas |
50 |
super(Item.EXPERIMENT, ALLOW_ROOT_NODE, |
4740 |
05 Feb 09 |
nicklas |
51 |
new NameableNameGenerator<Experiment>("experiment", "Experiment")); |
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 |
/** |
4740 |
05 Feb 09 |
nicklas |
Create property-loading experiment nodes from a given rawbioassay node. |
4740 |
05 Feb 09 |
nicklas |
The returned node is a folder-type node containing item nodes for |
4740 |
05 Feb 09 |
nicklas |
each experiment were the raw bioassay is used. |
4740 |
05 Feb 09 |
nicklas |
@return The folder node for the experiments |
4740 |
05 Feb 09 |
nicklas |
63 |
*/ |
4740 |
05 Feb 09 |
nicklas |
64 |
@Override |
4740 |
05 Feb 09 |
nicklas |
65 |
public Node createForwardNode(DbControl dc, OverviewContext context, Node rawBioAssayNode) |
4740 |
05 Feb 09 |
nicklas |
66 |
{ |
4740 |
05 Feb 09 |
nicklas |
67 |
NodeFactory<Experiment> nf = getNodeFactory(dc, context); |
4740 |
05 Feb 09 |
nicklas |
68 |
Node folderNode = null; |
4740 |
05 Feb 09 |
nicklas |
69 |
RawBioAssay rba = (RawBioAssay)rawBioAssayNode.getItem(dc); |
4740 |
05 Feb 09 |
nicklas |
70 |
ItemQuery<Experiment> query = context.initQuery(rba.getExperiments(), "name"); |
4740 |
05 Feb 09 |
nicklas |
71 |
ItemResultIterator<Experiment> it = query.iterate(dc); |
4740 |
05 Feb 09 |
nicklas |
72 |
while (it.hasNext()) |
4740 |
05 Feb 09 |
nicklas |
73 |
{ |
4740 |
05 Feb 09 |
nicklas |
74 |
Experiment experiment = it.next(); |
4740 |
05 Feb 09 |
nicklas |
75 |
if (folderNode == null) |
4740 |
05 Feb 09 |
nicklas |
76 |
{ |
4740 |
05 Feb 09 |
nicklas |
77 |
folderNode = new Node("experiments", "Experiments", rawBioAssayNode, ChildNodeDirection.PROPERTY); |
4740 |
05 Feb 09 |
nicklas |
78 |
} |
4740 |
05 Feb 09 |
nicklas |
79 |
createItemNode(nf, experiment, experiment, false, folderNode, ChildNodeDirection.FORWARD); |
4740 |
05 Feb 09 |
nicklas |
80 |
} |
4740 |
05 Feb 09 |
nicklas |
81 |
postValidateFolder(nf, folderNode, rawBioAssayNode, false); |
4740 |
05 Feb 09 |
nicklas |
82 |
return folderNode; |
4740 |
05 Feb 09 |
nicklas |
83 |
} |
4740 |
05 Feb 09 |
nicklas |
84 |
// ------------------------------ |
4740 |
05 Feb 09 |
nicklas |
85 |
|
4740 |
05 Feb 09 |
nicklas |
86 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the AbstractNodeLoader class |
4740 |
05 Feb 09 |
nicklas |
88 |
---------------------------------- |
4740 |
05 Feb 09 |
nicklas |
89 |
*/ |
4740 |
05 Feb 09 |
nicklas |
90 |
/** |
4740 |
05 Feb 09 |
nicklas |
Load property nodes for an experiment: |
4740 |
05 Feb 09 |
nicklas |
<ul> |
4740 |
05 Feb 09 |
nicklas |
<li>Experimental factors: {@link ExperimentalFactorLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
5966 |
16 Feb 12 |
nicklas |
<li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
</ul> |
4740 |
05 Feb 09 |
nicklas |
96 |
*/ |
4740 |
05 Feb 09 |
nicklas |
97 |
@Override |
4740 |
05 Feb 09 |
nicklas |
98 |
protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node experimentNode) |
4740 |
05 Feb 09 |
nicklas |
99 |
{ |
4740 |
05 Feb 09 |
nicklas |
100 |
getNodeLoader(context, "EXPERIMENTAL.FACTOR").createPropertyNode(dc, context, experimentNode); |
5966 |
16 Feb 12 |
nicklas |
101 |
getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, experimentNode); |
5500 |
18 Nov 10 |
nicklas |
102 |
getNodeLoader(context, Item.ANYTOANY).createPropertyNode(dc, context, experimentNode); |
4740 |
05 Feb 09 |
nicklas |
103 |
} |
4740 |
05 Feb 09 |
nicklas |
104 |
|
4740 |
05 Feb 09 |
nicklas |
105 |
/** |
6959 |
01 Oct 15 |
nicklas |
Loads the root raw bioassay nodes that are part of this experiment |
4740 |
05 Feb 09 |
nicklas |
@see RawBioAssayLoader#createReverseNode(DbControl, OverviewContext, Node) |
4740 |
05 Feb 09 |
nicklas |
108 |
*/ |
4740 |
05 Feb 09 |
nicklas |
109 |
@Override |
4740 |
05 Feb 09 |
nicklas |
110 |
protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node experimentNode) |
4740 |
05 Feb 09 |
nicklas |
111 |
{ |
6959 |
01 Oct 15 |
nicklas |
112 |
getNodeLoader(context, Item.ROOTRAWBIOASSAY).createReverseNode(dc, context, experimentNode); |
4740 |
05 Feb 09 |
nicklas |
113 |
} |
4740 |
05 Feb 09 |
nicklas |
114 |
// -------------------------------- |
4740 |
05 Feb 09 |
nicklas |
115 |
} |