source: trunk/www/views/itemlists/view_list.jsp @ 6769

Last change on this file since 6769 was 6769, checked in by Nicklas Nordborg, 8 years ago

References #1325: Lists of items

Improved code for printing out the synchronization filter on the information page. Instead of jus using the PropertyFilter.toString() method a PropertyFilterFormatter is used. This makes some cosmetic changes as well as loading names of annotation types, etc. which are used instead of the ID values.

File size: 13.2 KB
Line 
1<%-- $Id$
2  ------------------------------------------------------------------
3  Copyright (C) 2015 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.SystemItems"
28  import="net.sf.basedb.core.Group"
29  import="net.sf.basedb.core.Include"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.RawDataType"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.ItemList"
37  import="net.sf.basedb.core.SyncFilter"
38  import="net.sf.basedb.core.MultiPermissions"
39  import="net.sf.basedb.core.User"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.PluginDefinition"
42  import="net.sf.basedb.core.plugin.GuiContext"
43  import="net.sf.basedb.core.plugin.Plugin"
44  import="net.sf.basedb.core.Project"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.query.Hql"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
49  import="net.sf.basedb.clients.web.PermissionUtil"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.util.Values"
52  import="net.sf.basedb.util.formatter.Formatter"
53  import="net.sf.basedb.util.formatter.PropertyFilterFormatter"
54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
55  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
56  import="net.sf.basedb.clients.web.extensions.JspContext"
57  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
58  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
59  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
60  import="java.util.Collections"
61  import="java.util.Map"
62  import="java.util.Set"
63  import="java.util.Date"
64%>
65<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
66<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
67<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
68<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
69<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
70<%!
71  private static final Item itemType = Item.ITEMLIST;
72  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
73%>
74<%
75final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
76final String ID = sc.getId();
77final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
78final int itemId = cc.getId();
79final String tab = Values.getStringOrNull(request.getParameter("tab"));
80final float scale = Base.getScale(sc);
81final DbControl dc = sc.newDbControl();
82try
83{
84  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
85
86  String title = null;
87  ItemList list = ItemList.getById(dc, itemId);
88 
89  final boolean writePermission = list.hasPermission(Permission.WRITE);
90  final boolean deletePermission = list.hasPermission(Permission.DELETE);
91  final boolean sharePermission = list.hasPermission(Permission.SET_PERMISSION);
92  final boolean usePermission = list.hasPermission(Permission.USE);
93  final boolean setOwnerPermission = list.hasPermission(Permission.SET_OWNER);
94  final boolean isRemoved = list.isRemoved();
95  final boolean isUsed = isRemoved && list.isUsed();
96  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
97  final boolean isOwner = list.isOwner();
98  Formatter<Date> timeFormatter = FormatterFactory.getDateTimeFormatter(sc);
99  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
100  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, list);
101  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
102  %>
103  <base:page title="<%=title%>" id="view-page">
104  <base:head scripts="table.js,tabcontrol-2.js,~lists.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
105    <ext:scripts context="<%=jspContext%>" />
106    <ext:stylesheets context="<%=jspContext%>" />
107  </base:head>
108  <base:body>
109    <p:path><p:pathelement 
110      title="Item lists" href="<%="index.jsp?ID="+ID%>" 
111      /><p:pathelement title="<%=HTML.encodeTags(list.getName())%>"
112      /></p:path>
113    <div id="page-data" data-item-id="<%=itemId%>"></div>
114   
115    <t:tabcontrol 
116      id="main" 
117      subclass="content mastertabcontrol"
118      active="<%=tab%>">
119    <t:tab id="properties" title="Properties">
120      <div>
121      <table class="fullform bottomborder">
122      <tr>
123        <th class="itemstatus">
124          <base:icon 
125            image="shared.png" 
126            visible="<%=list.isShared()%>"
127            tooltip="This item is shared to other users, groups and/or projects"
128          />
129          <base:icon 
130            id="btnDeletePermanently"
131            image="deleted.png"
132            tooltip="This item has been flagged for deletion. Click to delete it now."
133            enabled="<%=deletePermanentlyPermission %>"
134            visible="<%=isRemoved%>" 
135          />
136          <base:icon 
137            id="btnUsingItems"
138            image="used.png" 
139            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
140            visible="<%=isRemoved && isUsed%>" />
141        </th>
142        <td style="padding: 0px;">
143          <tbl:toolbar subclass="bottomborder bg-filled-50">
144            <tbl:button 
145              id="btnEdit"
146              disabled="<%=!writePermission%>" 
147              image="edit.png" 
148              title="Edit&hellip;" 
149              tooltip="<%=writePermission ? "Edit this list" : "You do not have permission to edit this list"%>" 
150            />
151            <tbl:button 
152              id="btnDelete"
153              disabled="<%=!deletePermission%>" 
154              image="delete.png" 
155              title="Delete"
156              visible="<%=!list.isRemoved()%>"
157              tooltip="<%=deletePermission ? "Delete this list" : "You do not have permission to delete this list"%>" 
158            />
159            <tbl:button 
160              id="btnRestore"
161              disabled="<%=!writePermission%>" 
162              image="restore.png" 
163              title="Restore"
164              visible="<%=list.isRemoved()%>"
165              tooltip="<%=writePermission ? "Restore this list" : "You do not have permission to restore this list"%>" 
166            />
167            <tbl:button 
168              id="btnShare"
169              disabled="<%=!sharePermission%>"
170              image="share.png"
171              title="Share&hellip;" 
172              tooltip="<%=sharePermission ? "Share this list to other user, groups and projects" : "You do not have permission to share this list"%>"
173            />
174            <tbl:button 
175              id="btnSetOwner"
176              disabled="<%=!setOwnerPermission%>"
177              image="take_ownership.png"
178              title="Set owner&hellip;"
179              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
180            />
181            <tbl:button
182              id="btnMergeUnion"
183              data-merge-type="union"
184              visible="<%=writePermission%>"
185              image="set_operations/union_small.png"
186              title="Union&hellip;"
187              tooltip="Add items from other lists to this list"
188            />
189            <tbl:button
190              id="btnMergeIntersection"
191              data-merge-type="intersection"
192              visible="<%=writePermission%>"
193              image="set_operations/intersection_small.png"
194              title="Intersection&hellip;"
195              tooltip="Keep only items that are present in other lists"
196            />
197            <tbl:button
198              id="btnMergeComplement"
199              data-merge-type="complement"
200              visible="<%=writePermission%>"
201              image="set_operations/complement_small.png"
202              title="Complement&hellip;"
203              tooltip="Remove items found in other lists from this list"
204            />
205            <tbl:button 
206              id="btnImport"
207              image="import.png" 
208              data-plugin-type="IMPORT" 
209              title="Import&hellip;" 
210              tooltip="Import data" 
211              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
212            />
213            <tbl:button 
214              id="btnExport"
215              image="export.png"
216              data-plugin-type="EXPORT" 
217              title="Export&hellip;" 
218              tooltip="Export data" 
219              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
220            />
221            <tbl:button 
222              id="btnRunPlugin"
223              image="runplugin.png" 
224              data-plugin-type="OTHER" 
225              title="Run plugin&hellip;" 
226              tooltip="Run a plugin" 
227              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
228            />
229            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
230              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
231            <tbl:button
232              image="help.png"
233              subclass="auto-init"
234              data-auto-init="help"
235              data-help-id="itemlist.view.properties"
236              title="Help&hellip;"
237              tooltip="Get help about this page"
238            /> 
239          </tbl:toolbar>
240        </td>
241      </tr>
242      <tr>
243        <th>Name</th>
244        <td><%=HTML.encodeTags(list.getName())%></td>
245      </tr>
246      <tr>
247        <th>Member type</th>
248        <td><%=list.getMemberType()%>
249          <%
250          if (list.getMemberType() != Item.RAWBIOASSAY)
251          {
252            %>
253            (<base:propertyvalue item="<%=list%>" property="itemSubtype" nulltext="<i>any</i>"/>)
254            <%
255          }
256          else
257          {
258            RawDataType rdt = list.getRawDataType();
259            %>
260            (<%=rdt != null ? HTML.encodeTags(rdt.getName()) : "<i>any</i>"%>)
261            <%
262          }
263          %>
264        </td>
265      </tr>
266      <tr>
267        <th>Size</th>
268        <td><%=list.getSize()%></td>
269      </tr>
270      <tr style="vertical-align: top;">
271        <th>Sync filter</th>
272        <td>
273          <%
274          if (list.hasSyncFilter())
275          {
276            SyncFilter syncFilter = list.getSyncFilter();
277            StringBuilder sb = new StringBuilder();
278            for (int filterRow = 0; filterRow < syncFilter.getFilterRows(); filterRow++)
279            {
280              sb.append(filterRow > 0 ? "\nOR " : "");
281              sb.append(Values.getString(syncFilter.getPropertyFilters(filterRow), "\n   AND ", true, new PropertyFilterFormatter(dc, dateFormatter)));
282            }
283            %>
284            Yes (last sync: <%=timeFormatter.format(list.getSyncDate()) %>) [<a href="index.jsp?ID=<%=ID%>&item_id=<%=itemId%>&cmd=ReSyncFilter">Re-sync</a>]<br>
285            <pre style="margin: 5px;"><%=HTML.encodeTags(sb.toString())%></pre>
286            <%
287          }
288          else
289          {
290            %>
291            No
292            <%
293          }
294          %>
295        </td>
296      </tr>
297      <tr>
298        <th>External ID</th>
299        <td><%=HTML.encodeTags(list.getExternalId())%></td>
300      </tr>
301      <tr>
302        <th>Owner</th>
303        <td><base:propertyvalue item="<%=list%>" property="owner"/></td>
304      </tr>
305      <tr>
306        <th>Permissions</th>
307        <td><%=PermissionUtil.getFullPermissionNames(list)%></td>
308      </tr>
309      <tr>
310        <th>Description</th>
311        <td><%=HTML.niceFormat(list.getDescription())%></td>
312      </tr>
313      </table>
314      </div>
315
316      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
317        <jsp:param name="ID" value="<%=ID%>" />
318        <jsp:param name="item_type" value="<%=itemType.name()%>" />
319        <jsp:param name="item_id" value="<%=itemId%>" />
320        <jsp:param name="title" value="Other items related to this list" />
321      </jsp:include>
322      <jsp:include page="../../common/share/list_share.jsp">
323        <jsp:param name="ID" value="<%=ID%>" />
324        <jsp:param name="item_type" value="<%=itemType.name()%>" />
325        <jsp:param name="item_id" value="<%=itemId%>" />
326        <jsp:param name="title" value="Shared to" />
327      </jsp:include>
328    </t:tab>
329    <t:tab id="annotations" title="Annotations" 
330      tooltip="View annotation values" clazz="white">
331      <jsp:include page="../../common/annotations/list_frameset.jsp">
332        <jsp:param name="item_type" value="<%=itemType.name()%>" />
333        <jsp:param name="item_id" value="<%=itemId%>" />
334        <jsp:param name="ID" value="<%=ID%>" />
335      </jsp:include>
336    </t:tab>
337    <t:tab id="members" title="Members" />
338    <t:tab id="overview" title="Overview" 
339      tooltip="Display a tree overview of related items"
340      visible="<%=list.getMemberType() != Item.FILE%>">
341      <jsp:include page="../../common/overview/overview.jsp">
342        <jsp:param name="item_type" value="<%=itemType.name()%>" />
343        <jsp:param name="item_id" value="<%=itemId%>" />
344        <jsp:param name="ID" value="<%=ID%>" />
345      </jsp:include>
346    </t:tab>     
347    <t:tab id="history" title="Change history" 
348      tooltip="Displays a log of all modifications made to this item"
349      visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
350      <jsp:include page="../../common/history/frameset.jsp">
351        <jsp:param name="item_type" value="<%=itemType.name()%>" />
352        <jsp:param name="item_id" value="<%=itemId%>" />
353        <jsp:param name="ID" value="<%=ID%>" />
354      </jsp:include>
355    </t:tab>     
356    </t:tabcontrol>
357
358  </base:body>
359  </base:page>
360  <%
361}
362finally
363{
364  if (dc != null) dc.close();
365}
366
367%>
Note: See TracBrowser for help on using the repository browser.