7851 |
14 Oct 20 |
nicklas |
1 |
<%-- $Id: save_preset.jsp 6607 2014-11-19 14:52:20Z nicklas $ |
7851 |
14 Oct 20 |
nicklas |
2 |
------------------------------------------------------------------ |
7851 |
14 Oct 20 |
nicklas |
Copyright (C) 2020 Nicklas Nordborg |
7851 |
14 Oct 20 |
nicklas |
4 |
|
7851 |
14 Oct 20 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
7851 |
14 Oct 20 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
7851 |
14 Oct 20 |
nicklas |
7 |
|
7851 |
14 Oct 20 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
7851 |
14 Oct 20 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
7851 |
14 Oct 20 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
7851 |
14 Oct 20 |
nicklas |
11 |
of the License, or (at your option) any later version. |
7851 |
14 Oct 20 |
nicklas |
12 |
|
7851 |
14 Oct 20 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
7851 |
14 Oct 20 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7851 |
14 Oct 20 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7851 |
14 Oct 20 |
nicklas |
16 |
GNU General Public License for more details. |
7851 |
14 Oct 20 |
nicklas |
17 |
|
7851 |
14 Oct 20 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
7851 |
14 Oct 20 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7851 |
14 Oct 20 |
nicklas |
20 |
------------------------------------------------------------------ |
7851 |
14 Oct 20 |
nicklas |
21 |
|
7851 |
14 Oct 20 |
nicklas |
22 |
--%> |
7851 |
14 Oct 20 |
nicklas |
23 |
<%@ page pageEncoding="UTF-8" session="false" |
7853 |
19 Oct 20 |
nicklas |
24 |
import="net.sf.basedb.core.AnyToAny" |
7853 |
19 Oct 20 |
nicklas |
25 |
import="net.sf.basedb.core.DbControl" |
7851 |
14 Oct 20 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
7851 |
14 Oct 20 |
nicklas |
27 |
import="net.sf.basedb.core.Item" |
7853 |
19 Oct 20 |
nicklas |
28 |
import="net.sf.basedb.core.ItemQuery" |
7852 |
16 Oct 20 |
nicklas |
29 |
import="net.sf.basedb.core.ItemContext" |
7853 |
19 Oct 20 |
nicklas |
30 |
import="net.sf.basedb.core.Metadata" |
7853 |
19 Oct 20 |
nicklas |
31 |
import="net.sf.basedb.util.AnyToAnyLinkStatistics" |
7851 |
14 Oct 20 |
nicklas |
32 |
import="net.sf.basedb.clients.web.Base" |
7851 |
14 Oct 20 |
nicklas |
33 |
import="net.sf.basedb.clients.web.util.HTML" |
7851 |
14 Oct 20 |
nicklas |
34 |
import="net.sf.basedb.util.Values" |
7852 |
16 Oct 20 |
nicklas |
35 |
import="java.util.Arrays" |
7851 |
14 Oct 20 |
nicklas |
36 |
import="java.util.List" |
7851 |
14 Oct 20 |
nicklas |
37 |
%> |
7851 |
14 Oct 20 |
nicklas |
38 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
7851 |
14 Oct 20 |
nicklas |
39 |
<% |
7851 |
14 Oct 20 |
nicklas |
40 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
7851 |
14 Oct 20 |
nicklas |
41 |
final String ID = sc.getId(); |
7851 |
14 Oct 20 |
nicklas |
42 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
7853 |
19 Oct 20 |
nicklas |
43 |
final String subContext = Values.getString(request.getParameter("subcontext"), ""); |
7852 |
16 Oct 20 |
nicklas |
44 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, Item.ANYTOANY, null, null); |
7954 |
12 May 21 |
nicklas |
45 |
final DbControl dc = sc.newDbControl(":Add linked item column"); |
7853 |
19 Oct 20 |
nicklas |
46 |
try |
7853 |
19 Oct 20 |
nicklas |
47 |
{ |
7853 |
19 Oct 20 |
nicklas |
48 |
ItemQuery<?> statQuery = itemType.getQuery(); |
7853 |
19 Oct 20 |
nicklas |
49 |
ItemContext ccList = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null); |
7853 |
19 Oct 20 |
nicklas |
50 |
ccList.configureQuery(dc, statQuery, true); |
7853 |
19 Oct 20 |
nicklas |
51 |
statQuery.setMaxResults(-1); |
7853 |
19 Oct 20 |
nicklas |
52 |
statQuery.setFirstResult(0); |
7853 |
19 Oct 20 |
nicklas |
53 |
final List<AnyToAnyLinkStatistics> stats = AnyToAny.getExistingLinkStatistics(dc, statQuery, new AnyToAnyLinkStatistics.Options()); |
7853 |
19 Oct 20 |
nicklas |
54 |
%> |
7853 |
19 Oct 20 |
nicklas |
55 |
<base:page type="popup" title="Add linked item column"> |
7853 |
19 Oct 20 |
nicklas |
56 |
<base:head scripts="~add_linkeditem_column.js" /> |
7853 |
19 Oct 20 |
nicklas |
57 |
<base:body> |
7853 |
19 Oct 20 |
nicklas |
58 |
<h1>Add linked item column <base:help helpid="columns.configure.add_linkeditem_column" /></h1> |
7851 |
14 Oct 20 |
nicklas |
59 |
|
7853 |
19 Oct 20 |
nicklas |
60 |
<form name="linkedItems" method="post"> |
7853 |
19 Oct 20 |
nicklas |
61 |
<input type="hidden" name="ID" value="<%=ID%>"> |
7853 |
19 Oct 20 |
nicklas |
62 |
<input type="hidden" name="item_type" value="<%=itemType.name()%>"> |
7853 |
19 Oct 20 |
nicklas |
63 |
|
7853 |
19 Oct 20 |
nicklas |
64 |
<div class="content"> |
7853 |
19 Oct 20 |
nicklas |
65 |
<table class="fullform input100 bottomborder"> |
7874 |
22 Oct 20 |
nicklas |
66 |
<% |
7874 |
22 Oct 20 |
nicklas |
67 |
if (stats.size() > 0) |
7874 |
22 Oct 20 |
nicklas |
68 |
{ |
7874 |
22 Oct 20 |
nicklas |
69 |
%> |
7874 |
22 Oct 20 |
nicklas |
70 |
<tr> |
7874 |
22 Oct 20 |
nicklas |
71 |
<th></th> |
7874 |
22 Oct 20 |
nicklas |
72 |
<td> |
7874 |
22 Oct 20 |
nicklas |
73 |
<select name="presets" id="presets" style="width: 25em;"> |
7874 |
22 Oct 20 |
nicklas |
74 |
<option value="">- presets - |
7874 |
22 Oct 20 |
nicklas |
75 |
<% |
7874 |
22 Oct 20 |
nicklas |
76 |
for (AnyToAnyLinkStatistics stat : stats) |
7874 |
22 Oct 20 |
nicklas |
77 |
{ |
7874 |
22 Oct 20 |
nicklas |
78 |
String name = HTML.encodeTags(stat.getLinkName()); |
7874 |
22 Oct 20 |
nicklas |
79 |
String targetType = stat.getTargetType().name(); |
7874 |
22 Oct 20 |
nicklas |
80 |
%> |
7874 |
22 Oct 20 |
nicklas |
81 |
<option data-linkname="<%=name%>" data-targettype="<%=targetType%>"><%=name%> [<%=targetType%>] |
7874 |
22 Oct 20 |
nicklas |
82 |
<% |
7874 |
22 Oct 20 |
nicklas |
83 |
} |
7853 |
19 Oct 20 |
nicklas |
84 |
%> |
7874 |
22 Oct 20 |
nicklas |
85 |
</select> |
7874 |
22 Oct 20 |
nicklas |
86 |
</td> |
7874 |
22 Oct 20 |
nicklas |
87 |
</tr> |
7874 |
22 Oct 20 |
nicklas |
88 |
<% |
7874 |
22 Oct 20 |
nicklas |
89 |
} |
7874 |
22 Oct 20 |
nicklas |
90 |
%> |
7853 |
19 Oct 20 |
nicklas |
91 |
<tr> |
7853 |
19 Oct 20 |
nicklas |
92 |
<th style="border-top-width: 0;">Link name</th> |
7853 |
19 Oct 20 |
nicklas |
93 |
<td> |
7853 |
19 Oct 20 |
nicklas |
94 |
<input class="text required auto-init" data-auto-init="focus" |
7853 |
19 Oct 20 |
nicklas |
95 |
type="text" name="linkName" id="linkName" style="width: 25em;"> |
7853 |
19 Oct 20 |
nicklas |
96 |
</td> |
7853 |
19 Oct 20 |
nicklas |
97 |
</tr> |
7853 |
19 Oct 20 |
nicklas |
98 |
<tr> |
7853 |
19 Oct 20 |
nicklas |
99 |
<th>Target item type</th> |
7853 |
19 Oct 20 |
nicklas |
100 |
<td> |
7853 |
19 Oct 20 |
nicklas |
101 |
<select name="targetItemType" id="targetItemType" style="min-width: 25em;"> |
7853 |
19 Oct 20 |
nicklas |
102 |
<option value="">- any - |
7852 |
16 Oct 20 |
nicklas |
103 |
<% |
7853 |
19 Oct 20 |
nicklas |
104 |
List<String> recentTypes = cc.getRecent("toTypes"); |
7853 |
19 Oct 20 |
nicklas |
105 |
if (recentTypes.size() == 0) |
7851 |
14 Oct 20 |
nicklas |
106 |
{ |
7853 |
19 Oct 20 |
nicklas |
107 |
recentTypes = Arrays.asList("FILE"); |
7853 |
19 Oct 20 |
nicklas |
108 |
} |
7853 |
19 Oct 20 |
nicklas |
109 |
%> |
7853 |
19 Oct 20 |
nicklas |
110 |
<option value="0" disabled class="recentheader">- recently used - |
7853 |
19 Oct 20 |
nicklas |
111 |
<% |
7853 |
19 Oct 20 |
nicklas |
112 |
for (String r : recentTypes) |
7853 |
19 Oct 20 |
nicklas |
113 |
{ |
7851 |
14 Oct 20 |
nicklas |
114 |
%> |
7853 |
19 Oct 20 |
nicklas |
115 |
<option value="<%=r%>"><%=r%> |
7851 |
14 Oct 20 |
nicklas |
116 |
<% |
7851 |
14 Oct 20 |
nicklas |
117 |
} |
7853 |
19 Oct 20 |
nicklas |
118 |
%> |
7853 |
19 Oct 20 |
nicklas |
119 |
<option value="0" disabled class="recentheader">- all - |
7853 |
19 Oct 20 |
nicklas |
120 |
<% |
7853 |
19 Oct 20 |
nicklas |
121 |
for (Item targetItem : Metadata.getNameableItems()) |
7853 |
19 Oct 20 |
nicklas |
122 |
{ |
7853 |
19 Oct 20 |
nicklas |
123 |
if (targetItem.getDefinedPermissions() != null) |
7853 |
19 Oct 20 |
nicklas |
124 |
{ |
7853 |
19 Oct 20 |
nicklas |
125 |
%> |
7853 |
19 Oct 20 |
nicklas |
126 |
<option value="<%=targetItem.name() %>"><%=targetItem.name() %> |
7853 |
19 Oct 20 |
nicklas |
127 |
<% |
7853 |
19 Oct 20 |
nicklas |
128 |
} |
7853 |
19 Oct 20 |
nicklas |
129 |
} |
7853 |
19 Oct 20 |
nicklas |
130 |
%> |
7853 |
19 Oct 20 |
nicklas |
131 |
</select> |
7853 |
19 Oct 20 |
nicklas |
132 |
</td> |
7853 |
19 Oct 20 |
nicklas |
133 |
</tr> |
7853 |
19 Oct 20 |
nicklas |
134 |
<tr class="dynamic"> |
7853 |
19 Oct 20 |
nicklas |
135 |
<th></th> |
7853 |
19 Oct 20 |
nicklas |
136 |
<td><div id="added-column-msg" class="messagecontainer note" style="display:none; margin: 0.5em 0;"></div></td> |
7853 |
19 Oct 20 |
nicklas |
137 |
</tr> |
7853 |
19 Oct 20 |
nicklas |
138 |
</table> |
7853 |
19 Oct 20 |
nicklas |
139 |
</div> |
7853 |
19 Oct 20 |
nicklas |
140 |
</form> |
7853 |
19 Oct 20 |
nicklas |
141 |
|
7853 |
19 Oct 20 |
nicklas |
142 |
<base:buttongroup subclass="dialogbuttons"> |
7853 |
19 Oct 20 |
nicklas |
143 |
<base:button id="btnAdd" title="Add" /> |
7853 |
19 Oct 20 |
nicklas |
144 |
<base:button id="close" title="Close" /> |
7853 |
19 Oct 20 |
nicklas |
145 |
</base:buttongroup> |
7853 |
19 Oct 20 |
nicklas |
146 |
|
7853 |
19 Oct 20 |
nicklas |
147 |
</base:body> |
7853 |
19 Oct 20 |
nicklas |
148 |
</base:page> |
7853 |
19 Oct 20 |
nicklas |
149 |
<% |
7853 |
19 Oct 20 |
nicklas |
150 |
} |
7853 |
19 Oct 20 |
nicklas |
151 |
finally |
7853 |
19 Oct 20 |
nicklas |
152 |
{ |
7853 |
19 Oct 20 |
nicklas |
153 |
if (dc != null) dc.close(); |
7853 |
19 Oct 20 |
nicklas |
154 |
} |
7853 |
19 Oct 20 |
nicklas |
155 |
%> |
7851 |
14 Oct 20 |
nicklas |
156 |
|
7851 |
14 Oct 20 |
nicklas |
157 |
|