5651 |
08 Jun 11 |
nicklas |
1 |
/** |
5651 |
08 Jun 11 |
nicklas |
$Id$ |
5651 |
08 Jun 11 |
nicklas |
3 |
|
5651 |
08 Jun 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5651 |
08 Jun 11 |
nicklas |
5 |
|
5651 |
08 Jun 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5651 |
08 Jun 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5651 |
08 Jun 11 |
nicklas |
8 |
|
5651 |
08 Jun 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5651 |
08 Jun 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5651 |
08 Jun 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5651 |
08 Jun 11 |
nicklas |
of the License, or (at your option) any later version. |
5651 |
08 Jun 11 |
nicklas |
13 |
|
5651 |
08 Jun 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5651 |
08 Jun 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5651 |
08 Jun 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5651 |
08 Jun 11 |
nicklas |
GNU General Public License for more details. |
5651 |
08 Jun 11 |
nicklas |
18 |
|
5651 |
08 Jun 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5651 |
08 Jun 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5651 |
08 Jun 11 |
nicklas |
21 |
*/ |
5651 |
08 Jun 11 |
nicklas |
22 |
package net.sf.basedb.util.overview.loader; |
5651 |
08 Jun 11 |
nicklas |
23 |
|
5651 |
08 Jun 11 |
nicklas |
24 |
import net.sf.basedb.core.BasicItem; |
5651 |
08 Jun 11 |
nicklas |
25 |
import net.sf.basedb.core.DbControl; |
5651 |
08 Jun 11 |
nicklas |
26 |
import net.sf.basedb.core.Extract; |
5651 |
08 Jun 11 |
nicklas |
27 |
import net.sf.basedb.core.Item; |
5651 |
08 Jun 11 |
nicklas |
28 |
import net.sf.basedb.core.PermissionDeniedException; |
5651 |
08 Jun 11 |
nicklas |
29 |
import net.sf.basedb.core.Tag; |
5651 |
08 Jun 11 |
nicklas |
30 |
import net.sf.basedb.util.overview.Node; |
5651 |
08 Jun 11 |
nicklas |
31 |
import net.sf.basedb.util.overview.OverviewContext; |
5651 |
08 Jun 11 |
nicklas |
32 |
import net.sf.basedb.util.overview.Validator; |
5651 |
08 Jun 11 |
nicklas |
33 |
import net.sf.basedb.util.overview.node.ChildNodeDirection; |
5651 |
08 Jun 11 |
nicklas |
34 |
import net.sf.basedb.util.overview.node.NameableNameGenerator; |
5651 |
08 Jun 11 |
nicklas |
35 |
import net.sf.basedb.util.overview.node.NodeFactory; |
5651 |
08 Jun 11 |
nicklas |
36 |
|
5651 |
08 Jun 11 |
nicklas |
37 |
/** |
5651 |
08 Jun 11 |
nicklas |
Node loader implementation for tags. Tag nodes are loaded as |
5651 |
08 Jun 11 |
nicklas |
end-point property nodes with no children. It can't be a root |
5651 |
08 Jun 11 |
nicklas |
node or a forward/reverse-loading node. |
5651 |
08 Jun 11 |
nicklas |
<p> |
5651 |
08 Jun 11 |
nicklas |
Validations: |
5651 |
08 Jun 11 |
nicklas |
<ul> |
5651 |
08 Jun 11 |
nicklas |
<li>Incorrect tag type: {@link Validator#INCORRECT_TAGTYPE} |
5651 |
08 Jun 11 |
nicklas |
</ul> |
5651 |
08 Jun 11 |
nicklas |
46 |
|
5651 |
08 Jun 11 |
nicklas |
@author Nicklas |
5651 |
08 Jun 11 |
nicklas |
@since 3.0 |
5651 |
08 Jun 11 |
nicklas |
@base.modified $Date$ |
5651 |
08 Jun 11 |
nicklas |
50 |
*/ |
5651 |
08 Jun 11 |
nicklas |
51 |
public class TagLoader |
5651 |
08 Jun 11 |
nicklas |
52 |
extends BasicItemNodeLoader<Tag> |
5651 |
08 Jun 11 |
nicklas |
53 |
{ |
5651 |
08 Jun 11 |
nicklas |
54 |
|
5651 |
08 Jun 11 |
nicklas |
55 |
public TagLoader() |
5651 |
08 Jun 11 |
nicklas |
56 |
{ |
5651 |
08 Jun 11 |
nicklas |
57 |
super(Item.TAG, DENY_ROOT_NODE, |
5651 |
08 Jun 11 |
nicklas |
58 |
new NameableNameGenerator<Tag>("tag", "Tag")); |
5651 |
08 Jun 11 |
nicklas |
59 |
} |
5651 |
08 Jun 11 |
nicklas |
60 |
|
5651 |
08 Jun 11 |
nicklas |
61 |
/* |
5651 |
08 Jun 11 |
nicklas |
From the NodeLoader interface |
5651 |
08 Jun 11 |
nicklas |
63 |
------------------------------ |
5651 |
08 Jun 11 |
nicklas |
64 |
*/ |
5651 |
08 Jun 11 |
nicklas |
65 |
@Override |
5651 |
08 Jun 11 |
nicklas |
66 |
public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode) |
5651 |
08 Jun 11 |
nicklas |
67 |
{ |
5651 |
08 Jun 11 |
nicklas |
68 |
Tag tag = null; |
5651 |
08 Jun 11 |
nicklas |
69 |
boolean denied = false; |
5651 |
08 Jun 11 |
nicklas |
70 |
try |
5651 |
08 Jun 11 |
nicklas |
71 |
{ |
6870 |
16 Apr 15 |
nicklas |
72 |
BasicItem parentItem = parentNode.getItem(dc); |
5651 |
08 Jun 11 |
nicklas |
73 |
if (parentItem instanceof Extract) |
5651 |
08 Jun 11 |
nicklas |
74 |
{ |
5651 |
08 Jun 11 |
nicklas |
75 |
tag = ((Extract)parentItem).getTag(); |
5651 |
08 Jun 11 |
nicklas |
76 |
} |
5651 |
08 Jun 11 |
nicklas |
// If there are other items with a tag |
5651 |
08 Jun 11 |
nicklas |
// we should add more cases here |
5651 |
08 Jun 11 |
nicklas |
79 |
} |
5651 |
08 Jun 11 |
nicklas |
80 |
catch (PermissionDeniedException ex) |
5651 |
08 Jun 11 |
nicklas |
81 |
{ |
5651 |
08 Jun 11 |
nicklas |
82 |
denied = true; |
5651 |
08 Jun 11 |
nicklas |
83 |
} |
5651 |
08 Jun 11 |
nicklas |
84 |
|
5651 |
08 Jun 11 |
nicklas |
85 |
NodeFactory<Tag> nf = getNodeFactory(dc, context); |
6335 |
21 Oct 13 |
olle |
86 |
Node tagNode = createItemNode(nf, tag, tag, denied, |
6335 |
21 Oct 13 |
olle |
87 |
parentNode, ChildNodeDirection.PROPERTY); |
6335 |
21 Oct 13 |
olle |
88 |
return tagNode; |
5651 |
08 Jun 11 |
nicklas |
89 |
} |
5651 |
08 Jun 11 |
nicklas |
90 |
// ----------------------------------- |
6335 |
21 Oct 13 |
olle |
91 |
/* |
6335 |
21 Oct 13 |
olle |
From the AbstractNodeLoader class |
6335 |
21 Oct 13 |
olle |
93 |
---------------------------------- |
6335 |
21 Oct 13 |
olle |
94 |
*/ |
6335 |
21 Oct 13 |
olle |
95 |
/** |
6335 |
21 Oct 13 |
olle |
Loads annotations and tag parameters for the given tag node. |
6335 |
21 Oct 13 |
olle |
@see RawBioAssayLoader#createForwardNode(DbControl, OverviewContext, Node) |
6335 |
21 Oct 13 |
olle |
98 |
*/ |
6335 |
21 Oct 13 |
olle |
99 |
@Override |
6335 |
21 Oct 13 |
olle |
100 |
protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node tagNode) |
6335 |
21 Oct 13 |
olle |
101 |
{ |
6335 |
21 Oct 13 |
olle |
102 |
getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, tagNode); |
6335 |
21 Oct 13 |
olle |
103 |
} |
6335 |
21 Oct 13 |
olle |
104 |
// ------------------------------------- |
5651 |
08 Jun 11 |
nicklas |
105 |
} |