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.AnnotationType; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.core.DbControl; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.core.Experiment; |
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.util.overview.OverviewContext; |
4740 |
05 Feb 09 |
nicklas |
30 |
import net.sf.basedb.util.overview.node.ChildNodeDirection; |
4740 |
05 Feb 09 |
nicklas |
31 |
import net.sf.basedb.util.overview.node.NameableNameGenerator; |
4740 |
05 Feb 09 |
nicklas |
32 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
33 |
import net.sf.basedb.util.overview.node.NodeFactory; |
4740 |
05 Feb 09 |
nicklas |
34 |
|
4740 |
05 Feb 09 |
nicklas |
35 |
/** |
4740 |
05 Feb 09 |
nicklas |
Node loader implementation for experimental factors. The |
4740 |
05 Feb 09 |
nicklas |
annotation types used as experimental factors are loaded |
4740 |
05 Feb 09 |
nicklas |
as property-type child nodes of an experiment. |
4740 |
05 Feb 09 |
nicklas |
39 |
|
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 |
43 |
*/ |
4740 |
05 Feb 09 |
nicklas |
44 |
public class ExperimentalFactorLoader |
4740 |
05 Feb 09 |
nicklas |
45 |
extends BasicItemNodeLoader<AnnotationType> |
4740 |
05 Feb 09 |
nicklas |
46 |
{ |
4740 |
05 Feb 09 |
nicklas |
47 |
|
4740 |
05 Feb 09 |
nicklas |
48 |
public ExperimentalFactorLoader() |
4740 |
05 Feb 09 |
nicklas |
49 |
{ |
4740 |
05 Feb 09 |
nicklas |
50 |
super("EXPERIMENTAL.FACTOR", DENY_ROOT_NODE, |
4740 |
05 Feb 09 |
nicklas |
51 |
new NameableNameGenerator<AnnotationType>("factor", "Experimental factor")); |
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 |
@Override |
4740 |
05 Feb 09 |
nicklas |
59 |
public Node createPropertyNode(DbControl dc, OverviewContext context, Node experimentNode) |
4740 |
05 Feb 09 |
nicklas |
60 |
{ |
4740 |
05 Feb 09 |
nicklas |
61 |
NodeFactory<AnnotationType> nf = getNodeFactory(dc, context); |
4740 |
05 Feb 09 |
nicklas |
62 |
Node folderNode = null; |
4740 |
05 Feb 09 |
nicklas |
63 |
|
4740 |
05 Feb 09 |
nicklas |
// Load all experimental factors for the given experiment |
4740 |
05 Feb 09 |
nicklas |
65 |
Experiment experiment = (Experiment)experimentNode.getItem(dc); |
4740 |
05 Feb 09 |
nicklas |
66 |
ItemQuery<AnnotationType> query = context.initQuery(experiment.getExperimentalFactors(), "name"); |
4740 |
05 Feb 09 |
nicklas |
67 |
ItemResultIterator<AnnotationType> it = query.iterate(dc); |
4740 |
05 Feb 09 |
nicklas |
68 |
while (it.hasNext()) |
4740 |
05 Feb 09 |
nicklas |
69 |
{ |
4740 |
05 Feb 09 |
nicklas |
70 |
AnnotationType factor = it.next(); |
4740 |
05 Feb 09 |
nicklas |
71 |
if (folderNode == null) |
4740 |
05 Feb 09 |
nicklas |
72 |
{ |
4740 |
05 Feb 09 |
nicklas |
73 |
folderNode = new Node("factors", "Experimental factors", experimentNode); |
4740 |
05 Feb 09 |
nicklas |
74 |
} |
4740 |
05 Feb 09 |
nicklas |
75 |
createItemNode(nf, factor, null, false, folderNode, ChildNodeDirection.NONE); |
4740 |
05 Feb 09 |
nicklas |
76 |
} |
4740 |
05 Feb 09 |
nicklas |
77 |
postValidateFolder(nf, folderNode, experimentNode, false); |
4740 |
05 Feb 09 |
nicklas |
78 |
return folderNode; |
4740 |
05 Feb 09 |
nicklas |
79 |
} |
4740 |
05 Feb 09 |
nicklas |
80 |
// ----------------------------------- |
4740 |
05 Feb 09 |
nicklas |
81 |
} |