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 |
|
7303 |
01 Mar 17 |
nicklas |
25 |
import java.util.Collections; |
7302 |
01 Mar 17 |
nicklas |
26 |
import java.util.HashSet; |
7302 |
01 Mar 17 |
nicklas |
27 |
import java.util.List; |
7302 |
01 Mar 17 |
nicklas |
28 |
import java.util.Set; |
7302 |
01 Mar 17 |
nicklas |
29 |
|
4740 |
05 Feb 09 |
nicklas |
30 |
import net.sf.basedb.core.DbControl; |
5652 |
10 Jun 11 |
nicklas |
31 |
import net.sf.basedb.core.DerivedBioAssay; |
4740 |
05 Feb 09 |
nicklas |
32 |
import net.sf.basedb.core.Experiment; |
5641 |
25 May 11 |
nicklas |
33 |
import net.sf.basedb.core.Extract; |
5748 |
19 Sep 11 |
nicklas |
34 |
import net.sf.basedb.core.PermissionDeniedException; |
4740 |
05 Feb 09 |
nicklas |
35 |
import net.sf.basedb.core.Item; |
4740 |
05 Feb 09 |
nicklas |
36 |
import net.sf.basedb.core.ItemQuery; |
4740 |
05 Feb 09 |
nicklas |
37 |
import net.sf.basedb.core.ItemResultIterator; |
4740 |
05 Feb 09 |
nicklas |
38 |
import net.sf.basedb.core.RawBioAssay; |
7302 |
01 Mar 17 |
nicklas |
39 |
import net.sf.basedb.core.Type; |
7302 |
01 Mar 17 |
nicklas |
40 |
import net.sf.basedb.core.query.Expressions; |
4740 |
05 Feb 09 |
nicklas |
41 |
import net.sf.basedb.core.query.Hql; |
4740 |
05 Feb 09 |
nicklas |
42 |
import net.sf.basedb.core.query.Restrictions; |
7302 |
01 Mar 17 |
nicklas |
43 |
import net.sf.basedb.util.listable.ExtractToParentExtractTransformer; |
7302 |
01 Mar 17 |
nicklas |
44 |
import net.sf.basedb.util.listable.SourceItemTransformer; |
7302 |
01 Mar 17 |
nicklas |
45 |
import net.sf.basedb.util.listable.TransformContext; |
4740 |
05 Feb 09 |
nicklas |
46 |
import net.sf.basedb.util.overview.Node; |
5748 |
19 Sep 11 |
nicklas |
47 |
import net.sf.basedb.util.overview.NodeAttribute; |
4740 |
05 Feb 09 |
nicklas |
48 |
import net.sf.basedb.util.overview.OverviewContext; |
7494 |
04 Jun 18 |
nicklas |
49 |
import net.sf.basedb.util.overview.filter.BasicItemFilter; |
4740 |
05 Feb 09 |
nicklas |
50 |
import net.sf.basedb.util.overview.filter.ItemTypeFilter; |
4740 |
05 Feb 09 |
nicklas |
51 |
import net.sf.basedb.util.overview.node.ChildNodeDirection; |
4740 |
05 Feb 09 |
nicklas |
52 |
import net.sf.basedb.util.overview.node.NameableNameGenerator; |
4740 |
05 Feb 09 |
nicklas |
53 |
import net.sf.basedb.util.overview.node.NodeFactory; |
4740 |
05 Feb 09 |
nicklas |
54 |
|
4740 |
05 Feb 09 |
nicklas |
55 |
/** |
4740 |
05 Feb 09 |
nicklas |
Node loader implementation for raw bioassays. The forward-loading |
5652 |
10 Jun 11 |
nicklas |
direction goes from {@link DerivedBioAssay}:s -> {@link RawBioAssay}:s -> |
4740 |
05 Feb 09 |
nicklas |
{@link Experiment}:s. The reverse-loading direction is the opposite |
4740 |
05 Feb 09 |
nicklas |
direction. |
4740 |
05 Feb 09 |
nicklas |
60 |
|
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 |
64 |
*/ |
4740 |
05 Feb 09 |
nicklas |
65 |
public class RawBioAssayLoader |
4740 |
05 Feb 09 |
nicklas |
66 |
extends BasicItemNodeLoader<RawBioAssay> |
4740 |
05 Feb 09 |
nicklas |
67 |
{ |
4740 |
05 Feb 09 |
nicklas |
68 |
public RawBioAssayLoader() |
4740 |
05 Feb 09 |
nicklas |
69 |
{ |
4740 |
05 Feb 09 |
nicklas |
70 |
super(Item.RAWBIOASSAY, ALLOW_ROOT_NODE, |
4740 |
05 Feb 09 |
nicklas |
71 |
new NameableNameGenerator<RawBioAssay>("rawbioassay", "Raw bioassay")); |
4740 |
05 Feb 09 |
nicklas |
72 |
} |
4740 |
05 Feb 09 |
nicklas |
73 |
|
4740 |
05 Feb 09 |
nicklas |
74 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the NodeLoader interface |
4740 |
05 Feb 09 |
nicklas |
76 |
------------------------------ |
4740 |
05 Feb 09 |
nicklas |
77 |
*/ |
5748 |
19 Sep 11 |
nicklas |
78 |
@Override |
5748 |
19 Sep 11 |
nicklas |
79 |
public Node createRootNode(DbControl dc, OverviewContext context, RawBioAssay item) |
5748 |
19 Sep 11 |
nicklas |
80 |
{ |
5748 |
19 Sep 11 |
nicklas |
81 |
Node node = super.createRootNode(dc, context, item); |
5748 |
19 Sep 11 |
nicklas |
82 |
try |
5748 |
19 Sep 11 |
nicklas |
83 |
{ |
5748 |
19 Sep 11 |
nicklas |
84 |
Extract extract = item.getParentExtract(); |
5748 |
19 Sep 11 |
nicklas |
85 |
if (extract != null) node.setAttribute(NodeAttribute.EXTRACT, extract); |
5748 |
19 Sep 11 |
nicklas |
86 |
} |
5748 |
19 Sep 11 |
nicklas |
87 |
catch (PermissionDeniedException ex) |
5748 |
19 Sep 11 |
nicklas |
88 |
{} |
5748 |
19 Sep 11 |
nicklas |
89 |
return node; |
5748 |
19 Sep 11 |
nicklas |
90 |
} |
4740 |
05 Feb 09 |
nicklas |
91 |
/** |
5748 |
19 Sep 11 |
nicklas |
Create forward-loading raw bioassay nodes from a given parent derived bioassay or |
5748 |
19 Sep 11 |
nicklas |
extract node. The returned node is a folder-type node containing item nodes for |
5748 |
19 Sep 11 |
nicklas |
each raw bioassay. If the parent item is an extract only raw bioassays which doesn't |
5748 |
19 Sep 11 |
nicklas |
have a parent derived bioassay are loaded. |
4740 |
05 Feb 09 |
nicklas |
@return The folder node for the raw bioassays |
4740 |
05 Feb 09 |
nicklas |
97 |
*/ |
4740 |
05 Feb 09 |
nicklas |
98 |
@Override |
5748 |
19 Sep 11 |
nicklas |
99 |
public Node createForwardNode(DbControl dc, OverviewContext context, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
100 |
{ |
5748 |
19 Sep 11 |
nicklas |
101 |
Node returnNode = null; |
5748 |
19 Sep 11 |
nicklas |
102 |
Item parentType = parentNode.getItemType(); |
5748 |
19 Sep 11 |
nicklas |
103 |
if (parentType == Item.DERIVEDBIOASSAY) |
4740 |
05 Feb 09 |
nicklas |
104 |
{ |
5748 |
19 Sep 11 |
nicklas |
105 |
returnNode = createForwardNode((DerivedBioAssay)parentNode.getItem(dc), dc, context, parentNode); |
4740 |
05 Feb 09 |
nicklas |
106 |
} |
5748 |
19 Sep 11 |
nicklas |
107 |
else if (parentType == Item.EXTRACT) |
4740 |
05 Feb 09 |
nicklas |
108 |
{ |
5748 |
19 Sep 11 |
nicklas |
109 |
returnNode = createForwardNode((Extract)parentNode.getItem(dc), dc, context, parentNode); |
4740 |
05 Feb 09 |
nicklas |
110 |
} |
6755 |
20 Feb 15 |
nicklas |
111 |
else if (parentType == Item.ITEMLIST) |
6755 |
20 Feb 15 |
nicklas |
112 |
{ |
6755 |
20 Feb 15 |
nicklas |
113 |
ItemListLoader.loadMemberNodes(this, dc, context, parentNode); |
6755 |
20 Feb 15 |
nicklas |
114 |
} |
5748 |
19 Sep 11 |
nicklas |
115 |
return returnNode; |
4740 |
05 Feb 09 |
nicklas |
116 |
} |
4740 |
05 Feb 09 |
nicklas |
117 |
|
4740 |
05 Feb 09 |
nicklas |
118 |
/** |
4740 |
05 Feb 09 |
nicklas |
Create a reverse-loading raw bioassay nodes from a given experiment node. |
4740 |
05 Feb 09 |
nicklas |
The returned node is a folder-type node containing nodes for each raw |
4740 |
05 Feb 09 |
nicklas |
bioassay is part of the experiment. |
4740 |
05 Feb 09 |
nicklas |
@return The folder node for the raw bioassays |
4740 |
05 Feb 09 |
nicklas |
123 |
*/ |
4740 |
05 Feb 09 |
nicklas |
124 |
@Override |
4740 |
05 Feb 09 |
nicklas |
125 |
public Node createReverseNode(DbControl dc, OverviewContext context, Node experimentNode) |
4740 |
05 Feb 09 |
nicklas |
126 |
{ |
4740 |
05 Feb 09 |
nicklas |
127 |
NodeFactory<RawBioAssay> nf = getNodeFactory(dc, context); |
4740 |
05 Feb 09 |
nicklas |
128 |
Node folderNode = null; |
4740 |
05 Feb 09 |
nicklas |
129 |
Experiment experiment = (Experiment)experimentNode.getItem(dc); |
4740 |
05 Feb 09 |
nicklas |
130 |
ItemQuery<RawBioAssay> query = context.initQuery(experiment.getRawBioAssays(), "name"); |
4740 |
05 Feb 09 |
nicklas |
131 |
ItemResultIterator<RawBioAssay> it = query.iterate(dc); |
4740 |
05 Feb 09 |
nicklas |
132 |
while (it.hasNext()) |
4740 |
05 Feb 09 |
nicklas |
133 |
{ |
4740 |
05 Feb 09 |
nicklas |
134 |
RawBioAssay rba = it.next(); |
4740 |
05 Feb 09 |
nicklas |
135 |
if (folderNode == null) |
4740 |
05 Feb 09 |
nicklas |
136 |
{ |
4740 |
05 Feb 09 |
nicklas |
137 |
folderNode = new Node("rawbioassays", "Raw bioassays", experimentNode, ChildNodeDirection.REVERSE); |
4740 |
05 Feb 09 |
nicklas |
138 |
} |
5748 |
19 Sep 11 |
nicklas |
139 |
Node rawNode = createItemNode(nf, rba, rba, false, folderNode, ChildNodeDirection.REVERSE); |
5748 |
19 Sep 11 |
nicklas |
140 |
try |
5748 |
19 Sep 11 |
nicklas |
141 |
{ |
5748 |
19 Sep 11 |
nicklas |
// We must set the EXTRACT attribute so that upstream loaders |
5748 |
19 Sep 11 |
nicklas |
// follow the correct path when reaching the biomaterials section |
5748 |
19 Sep 11 |
nicklas |
144 |
rawNode.setAttribute(NodeAttribute.EXTRACT, rba.getParentExtract()); |
5748 |
19 Sep 11 |
nicklas |
145 |
} |
5748 |
19 Sep 11 |
nicklas |
146 |
catch (PermissionDeniedException ex) |
5748 |
19 Sep 11 |
nicklas |
147 |
{} |
4740 |
05 Feb 09 |
nicklas |
148 |
} |
4740 |
05 Feb 09 |
nicklas |
149 |
postValidateFolder(nf, folderNode, experimentNode, false); |
4740 |
05 Feb 09 |
nicklas |
150 |
return folderNode; |
4740 |
05 Feb 09 |
nicklas |
151 |
} |
4740 |
05 Feb 09 |
nicklas |
152 |
// ------------------------------ |
4740 |
05 Feb 09 |
nicklas |
153 |
|
4740 |
05 Feb 09 |
nicklas |
154 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the AbstractNodeLoader class |
4740 |
05 Feb 09 |
nicklas |
156 |
---------------------------------- |
4740 |
05 Feb 09 |
nicklas |
157 |
*/ |
4740 |
05 Feb 09 |
nicklas |
158 |
/** |
4740 |
05 Feb 09 |
nicklas |
Load property nodes for a raw bioassay: |
4740 |
05 Feb 09 |
nicklas |
<ul> |
4740 |
05 Feb 09 |
nicklas |
<li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
<li>Data files: {@link DataFileLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
<li>Platform: {@link PlatformLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
<li>Protocol: {@link ProtocolLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
<li>Software: {@link SoftwareLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
<li>Array design: {@link ArrayDesignLoader#createPropertyNode(DbControl, OverviewContext, Node)} |
4740 |
05 Feb 09 |
nicklas |
</ul> |
4740 |
05 Feb 09 |
nicklas |
168 |
*/ |
4740 |
05 Feb 09 |
nicklas |
169 |
@Override |
4740 |
05 Feb 09 |
nicklas |
170 |
protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode) |
4740 |
05 Feb 09 |
nicklas |
171 |
{ |
7494 |
04 Jun 18 |
nicklas |
172 |
Extract e = getExtract((RawBioAssay)rawBioAssayNode.getItem()); |
7494 |
04 Jun 18 |
nicklas |
173 |
if (e == null || rawBioAssayNode.getFirstParent(new BasicItemFilter(e)) == null) |
7494 |
04 Jun 18 |
nicklas |
174 |
{ |
7494 |
04 Jun 18 |
nicklas |
// Only load the extract if it is not already a parent node |
7494 |
04 Jun 18 |
nicklas |
176 |
getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode); |
7494 |
04 Jun 18 |
nicklas |
177 |
} |
4740 |
05 Feb 09 |
nicklas |
178 |
getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, rawBioAssayNode); |
5652 |
10 Jun 11 |
nicklas |
179 |
getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
180 |
getNodeLoader(context, Item.PLATFORM).createPropertyNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
181 |
getNodeLoader(context, Item.ARRAYDESIGN).createPropertyNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
182 |
getNodeLoader(context, Item.PROTOCOL).createPropertyNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
183 |
getNodeLoader(context, Item.SOFTWARE).createPropertyNode(dc, context, rawBioAssayNode); |
5500 |
18 Nov 10 |
nicklas |
184 |
getNodeLoader(context, Item.ANYTOANY).createPropertyNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
185 |
} |
4740 |
05 Feb 09 |
nicklas |
186 |
/** |
4740 |
05 Feb 09 |
nicklas |
Loads all experiment nodes where the given raw bioassay is used. |
4740 |
05 Feb 09 |
nicklas |
@see ExperimentLoader#createForwardNode(DbControl, OverviewContext, Node) |
4740 |
05 Feb 09 |
nicklas |
189 |
*/ |
4740 |
05 Feb 09 |
nicklas |
190 |
@Override |
4740 |
05 Feb 09 |
nicklas |
191 |
protected void loadForwardChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode) |
4740 |
05 Feb 09 |
nicklas |
192 |
{ |
4740 |
05 Feb 09 |
nicklas |
193 |
getNodeLoader(context, Item.EXPERIMENT).createForwardNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
194 |
} |
4740 |
05 Feb 09 |
nicklas |
195 |
/** |
5652 |
10 Jun 11 |
nicklas |
Loads the derived bioassay node that this raw bioassay is created from. |
5652 |
10 Jun 11 |
nicklas |
@see DerivedBioAssayLoader#createReverseNode(DbControl, OverviewContext, Node) |
4740 |
05 Feb 09 |
nicklas |
198 |
*/ |
4740 |
05 Feb 09 |
nicklas |
199 |
@Override |
4740 |
05 Feb 09 |
nicklas |
200 |
protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode) |
4740 |
05 Feb 09 |
nicklas |
201 |
{ |
5652 |
10 Jun 11 |
nicklas |
202 |
getNodeLoader(context, Item.DERIVEDBIOASSAY).createReverseNode(dc, context, rawBioAssayNode); |
4740 |
05 Feb 09 |
nicklas |
203 |
} |
4740 |
05 Feb 09 |
nicklas |
204 |
// -------------------------------- |
4740 |
05 Feb 09 |
nicklas |
205 |
|
5748 |
19 Sep 11 |
nicklas |
206 |
private Node createForwardNode(DerivedBioAssay bioAssay, DbControl dc, OverviewContext context, Node bioAssayNode) |
5748 |
19 Sep 11 |
nicklas |
207 |
{ |
5748 |
19 Sep 11 |
nicklas |
208 |
NodeFactory<RawBioAssay> nf = getNodeFactory(dc, context); |
5748 |
19 Sep 11 |
nicklas |
209 |
Node folderNode = null; |
5748 |
19 Sep 11 |
nicklas |
210 |
ItemQuery<RawBioAssay> query = context.initQuery(bioAssay.getRawBioAssays(), "name"); |
5748 |
19 Sep 11 |
nicklas |
211 |
|
7302 |
01 Mar 17 |
nicklas |
// We should only load derived bioassays that has a null extract or an |
7302 |
01 Mar 17 |
nicklas |
// extract that is found in the parent chain |
7303 |
01 Mar 17 |
nicklas |
214 |
Set<Integer> extractIds = getExtractChain(dc, bioAssayNode); |
7302 |
01 Mar 17 |
nicklas |
215 |
if (extractIds.size() > 0) |
5748 |
19 Sep 11 |
nicklas |
216 |
{ |
7302 |
01 Mar 17 |
nicklas |
217 |
query.restrict( |
7302 |
01 Mar 17 |
nicklas |
218 |
Restrictions.or( |
7302 |
01 Mar 17 |
nicklas |
219 |
Restrictions.eq(Hql.property("parentExtract"), null), |
7302 |
01 Mar 17 |
nicklas |
220 |
Restrictions.in(Hql.property("parentExtract"), Expressions.parameter("extracts")) |
7302 |
01 Mar 17 |
nicklas |
221 |
)); |
7303 |
01 Mar 17 |
nicklas |
222 |
query.setParameter("extracts", extractIds, Type.INT); |
5748 |
19 Sep 11 |
nicklas |
223 |
} |
7302 |
01 Mar 17 |
nicklas |
224 |
|
5748 |
19 Sep 11 |
nicklas |
225 |
ItemResultIterator<RawBioAssay> it = query.iterate(dc); |
5748 |
19 Sep 11 |
nicklas |
226 |
while (it.hasNext()) |
5748 |
19 Sep 11 |
nicklas |
227 |
{ |
5748 |
19 Sep 11 |
nicklas |
228 |
RawBioAssay rba = it.next(); |
5748 |
19 Sep 11 |
nicklas |
229 |
if (folderNode == null) |
5748 |
19 Sep 11 |
nicklas |
230 |
{ |
5748 |
19 Sep 11 |
nicklas |
231 |
folderNode = new Node("rawbioassays", "Raw bioassays", bioAssayNode, ChildNodeDirection.FORWARD); |
5748 |
19 Sep 11 |
nicklas |
232 |
} |
5748 |
19 Sep 11 |
nicklas |
233 |
createItemNode(nf, rba, rba, false, folderNode, ChildNodeDirection.FORWARD); |
5748 |
19 Sep 11 |
nicklas |
234 |
} |
5748 |
19 Sep 11 |
nicklas |
235 |
postValidateFolder(nf, folderNode, bioAssayNode, false); |
5748 |
19 Sep 11 |
nicklas |
236 |
return folderNode; |
5748 |
19 Sep 11 |
nicklas |
237 |
} |
5748 |
19 Sep 11 |
nicklas |
238 |
|
5748 |
19 Sep 11 |
nicklas |
239 |
private Node createForwardNode(Extract extract, DbControl dc, OverviewContext context, Node extractNode) |
5748 |
19 Sep 11 |
nicklas |
240 |
{ |
5748 |
19 Sep 11 |
nicklas |
241 |
NodeFactory<RawBioAssay> nf = getNodeFactory(dc, context); |
5748 |
19 Sep 11 |
nicklas |
242 |
Node folderNode = null; |
7494 |
04 Jun 18 |
nicklas |
// Load raw bioassays linked to the 'extract' if: |
7494 |
04 Jun 18 |
nicklas |
// they have no parent bioassay OR |
7494 |
04 Jun 18 |
nicklas |
// the parent bioassay has no parent extract OR |
7494 |
04 Jun 18 |
nicklas |
// the parent bioassay has a different parent extract |
5748 |
19 Sep 11 |
nicklas |
247 |
ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
5748 |
19 Sep 11 |
nicklas |
248 |
query.restrict(Restrictions.eq(Hql.property("parentExtract"), Hql.entity(extract))); |
7494 |
04 Jun 18 |
nicklas |
249 |
query.join(Hql.leftJoin("parentBioAssay", "parent")); |
7494 |
04 Jun 18 |
nicklas |
250 |
query.join(Hql.leftJoin("parent", "extract", "parentExtract", null, false)); |
7494 |
04 Jun 18 |
nicklas |
251 |
query.restrict( |
7494 |
04 Jun 18 |
nicklas |
252 |
Restrictions.or( |
7494 |
04 Jun 18 |
nicklas |
253 |
Restrictions.eq(Hql.alias("parent"), null), |
7494 |
04 Jun 18 |
nicklas |
254 |
Restrictions.eq(Hql.alias("parentExtract"), null), |
7494 |
04 Jun 18 |
nicklas |
255 |
Restrictions.neq(Hql.alias("parentExtract"), Hql.entity(extract)) |
7494 |
04 Jun 18 |
nicklas |
256 |
)); |
5748 |
19 Sep 11 |
nicklas |
257 |
context.initQuery(query, "name"); |
5748 |
19 Sep 11 |
nicklas |
258 |
ItemResultIterator<RawBioAssay> it = query.iterate(dc); |
5748 |
19 Sep 11 |
nicklas |
259 |
while (it.hasNext()) |
5748 |
19 Sep 11 |
nicklas |
260 |
{ |
5748 |
19 Sep 11 |
nicklas |
261 |
RawBioAssay rba = it.next(); |
5748 |
19 Sep 11 |
nicklas |
262 |
if (folderNode == null) |
5748 |
19 Sep 11 |
nicklas |
263 |
{ |
5748 |
19 Sep 11 |
nicklas |
264 |
folderNode = new Node("rawbioassays", "Raw bioassays", extractNode, ChildNodeDirection.FORWARD); |
5748 |
19 Sep 11 |
nicklas |
265 |
} |
5748 |
19 Sep 11 |
nicklas |
266 |
createItemNode(nf, rba, rba, false, folderNode, ChildNodeDirection.FORWARD); |
5748 |
19 Sep 11 |
nicklas |
267 |
} |
5748 |
19 Sep 11 |
nicklas |
268 |
postValidateFolder(nf, folderNode, extractNode, false); |
5748 |
19 Sep 11 |
nicklas |
269 |
return folderNode; |
5748 |
19 Sep 11 |
nicklas |
270 |
} |
5748 |
19 Sep 11 |
nicklas |
271 |
|
7494 |
04 Jun 18 |
nicklas |
272 |
/** |
7494 |
04 Jun 18 |
nicklas |
Get the extract that is associated with the current raw bioassay |
7494 |
04 Jun 18 |
nicklas |
@return The extract or null if none was found |
7494 |
04 Jun 18 |
nicklas |
275 |
*/ |
7494 |
04 Jun 18 |
nicklas |
276 |
private Extract getExtract(RawBioAssay bioAssay) |
7494 |
04 Jun 18 |
nicklas |
277 |
{ |
7494 |
04 Jun 18 |
nicklas |
278 |
Extract extract = null; |
7494 |
04 Jun 18 |
nicklas |
279 |
try |
7494 |
04 Jun 18 |
nicklas |
280 |
{ |
7494 |
04 Jun 18 |
nicklas |
281 |
extract = bioAssay.getParentExtract(); |
7494 |
04 Jun 18 |
nicklas |
282 |
} |
7494 |
04 Jun 18 |
nicklas |
283 |
catch (PermissionDeniedException ex) |
7494 |
04 Jun 18 |
nicklas |
284 |
{} |
7494 |
04 Jun 18 |
nicklas |
285 |
return extract; |
7494 |
04 Jun 18 |
nicklas |
286 |
} |
7494 |
04 Jun 18 |
nicklas |
287 |
|
7303 |
01 Mar 17 |
nicklas |
288 |
private Set<Integer> getExtractChain(DbControl dc, Node node) |
7302 |
01 Mar 17 |
nicklas |
289 |
{ |
7302 |
01 Mar 17 |
nicklas |
290 |
List<Node> extractNodes = node.findAll(new ItemTypeFilter(Item.EXTRACT)); |
7302 |
01 Mar 17 |
nicklas |
291 |
Set<Integer> extractIds = new HashSet<Integer>(extractNodes.size()); |
7302 |
01 Mar 17 |
nicklas |
292 |
for (Node n : extractNodes) |
7302 |
01 Mar 17 |
nicklas |
293 |
{ |
7302 |
01 Mar 17 |
nicklas |
294 |
extractIds.add(n.getItem().getId()); |
7303 |
01 Mar 17 |
nicklas |
295 |
if (n.getParent() == null) |
7303 |
01 Mar 17 |
nicklas |
296 |
{ |
7303 |
01 Mar 17 |
nicklas |
// We have reach the root node, continue to load parent extracts from here |
7303 |
01 Mar 17 |
nicklas |
298 |
SourceItemTransformer transformer = new ExtractToParentExtractTransformer(true); |
7303 |
01 Mar 17 |
nicklas |
299 |
extractIds.addAll(transformer.transform(new TransformContext(dc), Collections.singleton(n.getItem().getId()))); |
7303 |
01 Mar 17 |
nicklas |
300 |
|
7303 |
01 Mar 17 |
nicklas |
301 |
} |
7302 |
01 Mar 17 |
nicklas |
302 |
} |
7302 |
01 Mar 17 |
nicklas |
303 |
return extractIds; |
7302 |
01 Mar 17 |
nicklas |
304 |
} |
7302 |
01 Mar 17 |
nicklas |
305 |
|
4740 |
05 Feb 09 |
nicklas |
306 |
} |