1 | <%-- $Id $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2020 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | |
---|
22 | @author Nicklas |
---|
23 | --%> |
---|
24 | <%@ page pageEncoding="UTF-8" session="false" |
---|
25 | import="net.sf.basedb.core.SessionControl" |
---|
26 | import="net.sf.basedb.core.DbControl" |
---|
27 | import="net.sf.basedb.core.Item" |
---|
28 | import="net.sf.basedb.core.ItemQuery" |
---|
29 | import="net.sf.basedb.core.ItemContext" |
---|
30 | import="net.sf.basedb.core.ItemResultList" |
---|
31 | import="net.sf.basedb.core.ItemList" |
---|
32 | import="net.sf.basedb.core.RawDataType" |
---|
33 | import="net.sf.basedb.core.query.Orders" |
---|
34 | import="net.sf.basedb.core.query.Hql" |
---|
35 | import="net.sf.basedb.core.query.Expressions" |
---|
36 | import="net.sf.basedb.core.query.Restrictions" |
---|
37 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
38 | import="net.sf.basedb.util.Values" |
---|
39 | import="net.sf.basedb.util.formatter.Formatter" |
---|
40 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
41 | import="net.sf.basedb.clients.web.Base" |
---|
42 | import="net.sf.basedb.clients.web.util.HTML" |
---|
43 | import="java.util.Date" |
---|
44 | import="java.util.List" |
---|
45 | %> |
---|
46 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
47 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
48 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
49 | <% |
---|
50 | String root = request.getContextPath() + "/"; |
---|
51 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
52 | final String ID = sc.getId(); |
---|
53 | final Item itemType = Item.valueOf(request.getParameter("item_type")); |
---|
54 | final int itemId = Values.getInt(request.getParameter("item_id")); |
---|
55 | final float scale = Base.getScale(sc); |
---|
56 | final DbControl dc = sc.newDbControl(); |
---|
57 | final ItemContext cc = sc.getCurrentContext(itemType); |
---|
58 | String title = Values.getString(request.getParameter("title"), "Related items"); |
---|
59 | |
---|
60 | try |
---|
61 | { |
---|
62 | Formatter<Date> timeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
63 | |
---|
64 | final ItemQuery<ItemList> listQuery = ItemList.getQuery(); |
---|
65 | listQuery.setIncludes(cc.getInclude()); |
---|
66 | listQuery.join(Hql.innerJoin("members", "m")); |
---|
67 | listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue()))); |
---|
68 | listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.integer(itemId))); |
---|
69 | listQuery.order(Orders.asc(Hql.property("name"))); |
---|
70 | |
---|
71 | ItemResultList<ItemList> lists = listQuery.list(dc); |
---|
72 | long count = lists.getTotalCount(); |
---|
73 | %> |
---|
74 | <base:page type="include"> |
---|
75 | <base:body> |
---|
76 | <base:section |
---|
77 | id="itemlists" |
---|
78 | title="<%=title + " (" + (count) +")"%>" |
---|
79 | context="<%=cc%>" |
---|
80 | > |
---|
81 | <% |
---|
82 | if (count == 0) |
---|
83 | { |
---|
84 | %> |
---|
85 | <div class="messagecontainer note"> |
---|
86 | This <%=itemType.toString().toLowerCase() %> is not member in |
---|
87 | any list (or, you don't have permission to view them). |
---|
88 | </div> |
---|
89 | <% |
---|
90 | } |
---|
91 | else |
---|
92 | { |
---|
93 | %> |
---|
94 | <tbl:table |
---|
95 | id="links" |
---|
96 | columns="all" |
---|
97 | > |
---|
98 | <tbl:columndef |
---|
99 | id="name" |
---|
100 | title="List" |
---|
101 | /> |
---|
102 | <tbl:columndef |
---|
103 | id="memberType" |
---|
104 | title="Member type" |
---|
105 | /> |
---|
106 | <tbl:columndef |
---|
107 | id="lastSync" |
---|
108 | title="Last sync" |
---|
109 | /> |
---|
110 | <tbl:columndef |
---|
111 | id="size" |
---|
112 | title="Size" |
---|
113 | /> |
---|
114 | <tbl:columndef |
---|
115 | id="description" |
---|
116 | title="Description" |
---|
117 | /> |
---|
118 | <tbl:data> |
---|
119 | <tbl:headers> |
---|
120 | <tbl:headerrow> |
---|
121 | <tbl:columnheaders /> |
---|
122 | </tbl:headerrow> |
---|
123 | </tbl:headers> |
---|
124 | <tbl:rows> |
---|
125 | <% |
---|
126 | for (ItemList list : lists) |
---|
127 | { |
---|
128 | %> |
---|
129 | <tbl:row> |
---|
130 | <tbl:cell column="name"><base:icon |
---|
131 | image="deleted.png" |
---|
132 | tooltip="This item has been scheduled for deletion" |
---|
133 | visible="<%=list.isRemoved()%>" |
---|
134 | /><%=Base.getLinkedName(ID, list, false, true)%></tbl:cell> |
---|
135 | <tbl:cell column="memberType"> |
---|
136 | <% |
---|
137 | if (itemType != Item.RAWBIOASSAY) |
---|
138 | { |
---|
139 | %> |
---|
140 | <base:propertyvalue item="<%=list%>" property="itemSubtype" nulltext="<i>any</i>"/> |
---|
141 | <% |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | RawDataType rdt = list.getRawDataType(); |
---|
146 | %> |
---|
147 | (<%=rdt != null ? HTML.encodeTags(rdt.getName()) : "<i>any</i>"%>) |
---|
148 | <% |
---|
149 | } |
---|
150 | %> |
---|
151 | </tbl:cell> |
---|
152 | <tbl:cell column="lastSync"> |
---|
153 | <%=list.getSyncDate() == null ? "<i>never</i>" : timeFormatter.format(list.getSyncDate())%> |
---|
154 | </tbl:cell> |
---|
155 | <tbl:cell column="size"><%=list.getSize() %></tbl:cell> |
---|
156 | <tbl:cell column="description"><%=HTML.niceFormat(list.getDescription())%></tbl:cell> |
---|
157 | </tbl:row> |
---|
158 | <% |
---|
159 | } |
---|
160 | %> |
---|
161 | </tbl:rows> |
---|
162 | </tbl:data> |
---|
163 | </tbl:table> |
---|
164 | <% |
---|
165 | } |
---|
166 | %> |
---|
167 | </base:section> |
---|
168 | </base:body> |
---|
169 | </base:page> |
---|
170 | <% |
---|
171 | } |
---|
172 | finally |
---|
173 | { |
---|
174 | if (dc != null) dc.close(); |
---|
175 | } |
---|
176 | |
---|
177 | %> |
---|