source: trunk/www/admin/platforms/list_platforms.jsp @ 7943

Last change on this file since 7943 was 7943, checked in by Nicklas Nordborg, 23 months ago

Merged BASE 3.18.1 to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.5 KB
Line 
1<%-- $Id:list_platforms.jsp 3820 2007-10-12 10:03:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2007 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  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.Platform"
30  import="net.sf.basedb.core.PlatformVariant"
31  import="net.sf.basedb.core.RawDataType"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.Include"
34  import="net.sf.basedb.core.Type"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.ItemResultList"
37  import="net.sf.basedb.core.ItemContext"
38  import="net.sf.basedb.core.Permission"
39  import="net.sf.basedb.core.PluginDefinition"
40  import="net.sf.basedb.core.query.Orders"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.core.query.Expressions"
43  import="net.sf.basedb.core.query.Restrictions"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.util.Enumeration"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.ModeInfo"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.util.formatter.Formatter"
52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
53  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
54  import="net.sf.basedb.clients.web.extensions.JspContext"
55  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
56  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
57  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
58  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
59  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
60  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
61  import="net.sf.basedb.util.Values"
62  import="java.util.List"
63  import="java.util.Map"
64  import="java.util.Date"
65%>
66<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
67<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
68<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
69<%!
70  private static final Item itemType = Item.PLATFORM;
71  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
72%>
73<%
74final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
75final String ID = sc.getId();
76final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
77final boolean writePermission = sc.hasPermission(Permission.WRITE, itemType);
78final boolean deletePermission = sc.hasPermission(Permission.DELETE, itemType);
79final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
80
81final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
82final String callback = request.getParameter("callback");
83final String title = mode.generateTitle("platform", "platforms");
84final DbControl dc = sc.newDbControl();
85ItemResultIterator<Platform> platforms = null;
86try
87{
88  // Query for variants of a platform
89  final ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery();
90  variantQuery.include(cc.getInclude());
91  variantQuery.restrict(Restrictions.eq(Hql.property("platform"), Expressions.parameter("platform")));
92  variantQuery.order(Orders.asc(Hql.property("name"))); 
93  final boolean createVariantPermission = sc.hasPermission(Permission.CREATE, Item.PLATFORMVARIANT); 
94
95  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
96  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
97  try
98  {
99    final ItemQuery<Platform> query = Base.getConfiguredQuery(dc, cc, jspContext, true, Platform.getQuery(), mode);
100    platforms = query.iterate(dc);
101  }
102  catch (Throwable t)
103  {
104    cc.setMessage(t.getMessage());
105  }
106  int numListed = 0;
107  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
108  ExtensionsInvoker<ListColumnAction<Platform,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
109  %>
110  <base:page title="<%=title==null ? "Platforms" : title%>" type="<%=mode.getPageType()%>" id="list-page">
111  <base:head scripts="table.js,~platforms.js" styles="table.css,toolbar.css">
112    <ext:scripts context="<%=jspContext%>" />
113    <ext:stylesheets context="<%=jspContext%>" />
114  </base:head>
115 
116  <base:body>
117    <h1><%=title==null ? "Platforms" : title%></h1>
118    <div class="content">
119    <tbl:table 
120      id="platforms" 
121      columns="<%=cc.getSetting("columns")%>"
122      sortby="<%=cc.getSortProperty()%>" 
123      direction="<%=cc.getSortDirection()%>"
124      action="index.jsp"
125      sc="<%=sc%>"
126      item="<%=itemType%>"
127      filterrows="<%=cc.getFilterRows()%>"
128      subclass="fulltable"
129      stickyheaders="name"
130      >
131      <tbl:hidden 
132        name="mode" 
133        value="<%=mode.getName()%>" 
134      />
135      <tbl:hidden 
136        name="callback" 
137        value="<%=callback%>" 
138        skip="<%=callback == null%>" 
139      />
140      <tbl:columndef 
141        id="name"
142        property="name"
143        datatype="string"
144        title="Name"
145        sortable="true" 
146        filterable="true"
147        exportable="true"
148        show="always" 
149      />
150      <tbl:columndef 
151        id="id"
152        clazz="uniquecol"
153        property="id"
154        datatype="int"
155        title="ID"
156        sortable="true"
157        filterable="true"
158        exportable="true"
159      />
160      <tbl:columndef 
161        id="externalId"
162        clazz="uniquecol"
163        property="externalId"
164        datatype="string"
165        title="External ID"
166        sortable="true"
167        filterable="true"
168        exportable="true"
169      />
170      <tbl:columndef 
171        id="fileOnly"
172        property="fileOnly"
173        datatype="boolean"
174        title="File-only"
175        sortable="true"
176        filterable="true"
177        exportable="true"
178      />
179      <tbl:columndef 
180        id="rawDataType"
181        property="rawDataType"
182        datatype="string"
183        title="Raw data type"
184        sortable="true"
185        filterable="true"
186        exportable="true"
187      />
188      <tbl:columndef 
189        id="channels"
190        property="channels"
191        datatype="int"
192        title="Channels"
193        sortable="true"
194        filterable="true"
195        exportable="true"
196      />
197      <tbl:columndef
198        id="variants"
199        title="Variants"
200        property="&variants(name)"
201        datatype="string"
202        filterable="true"
203        exportable="true"
204      />
205      <tbl:columndef 
206        id="description"
207        property="description"
208        datatype="string"
209        title="Description" 
210        sortable="true" 
211        filterable="true" 
212        exportable="true"
213      />
214      <tbl:columndef 
215        id="xt-columns" 
216        extensions="<%=columnsInvoker%>" 
217        jspcontext="<%=jspContext%>" 
218      />
219      <div class="panelgroup bg-filled-50 bottomborder">
220        <tbl:toolbar
221          subclass="bottomborder"
222          visible="<%=mode.hasToolbar()%>"
223          >
224          <tbl:button 
225            id="btnNewItem"
226            disabled="<%=!createPermission%>" 
227            image="new.png" 
228            title="New&hellip;" 
229            tooltip="<%=createPermission ? "Create platforms" : "You do not have permission to create platforms"%>" 
230          />
231          <tbl:button 
232            id="btnDeleteItems"
233            disabled="<%=!deletePermission%>" 
234            image="delete.png" 
235            title="Delete" 
236            tooltip="<%=deletePermission ? "Delete the selected items" : "You do not have permission to delete platforms" %>" 
237          />
238          <tbl:button 
239            id="btnRestoreItems"
240            disabled="<%=!writePermission%>" 
241            image="restore.png" 
242            title="Restore" 
243            tooltip="<%=writePermission ? "Restore the selected (deleted) items" : "You do not have permission to edit platforms" %>" 
244          />
245          <tbl:button 
246            id="btnColumns"
247            image="columns.png" 
248            title="Columns&hellip;" 
249            tooltip="Show, hide and re-order columns" 
250          />
251          <tbl:button 
252            id="btnImport"
253            data-plugin-type="IMPORT"
254            image="import.png" 
255            title="Import&hellip;" 
256            tooltip="Import data" 
257            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
258          />
259          <tbl:button 
260            id="btnExport"
261            data-plugin-type="EXPORT"
262            image="export.png" 
263            title="Export&hellip;" 
264            tooltip="Export data" 
265            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
266          />
267          <tbl:button 
268            id="btnRunPlugin"
269            data-plugin-type="OTHER"
270            image="runplugin.png" 
271            title="Run plugin&hellip;" 
272            tooltip="Run a plugin" 
273            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
274          />
275          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
276            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
277        </tbl:toolbar>
278        <tbl:panel>
279          <tbl:presetselector />
280          <tbl:navigator
281            page="<%=cc.getPage()%>" 
282            rowsperpage="<%=cc.getRowsPerPage()%>" 
283            totalrows="<%=platforms == null ? 0 : platforms.getTotalCount()%>" 
284            visible="<%=mode.hasNavigator()%>"
285          />
286        </tbl:panel>
287      </div>
288      <tbl:data>
289        <tbl:headers>
290          <tbl:headerrow>
291            <tbl:header clazz="row-index bg-filled-100" />
292            <tbl:columnheaders />
293          </tbl:headerrow>
294          <%
295          int numFilters = cc.getNumPropertyFilters();
296          int numRows = cc.getFilterRows();
297          for (int filterNo = 0; filterNo < numRows; filterNo++)
298          {
299            boolean lastRow = filterNo == numRows-1;
300            %>
301            <tbl:headerrow>
302              <tbl:header subclass="row-index bg-filled-100">
303                <div class="index-<%=mode.getName()%>">
304                  <div class="index"></div>
305                  <div class="check">
306                    <base:icon 
307                      subclass="link table-check"
308                      image="check_uncheck.png" 
309                      tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)" 
310                      visible="<%=lastRow && mode.hasCheck()%>"
311                    />
312                  </div>
313                  <div class="icons">
314                    <base:icon
315                      subclass="link table-filter-row-action"
316                      image="add.png"
317                      tooltip="Add extra filter row"
318                      visible="<%=lastRow%>"
319                    /><base:icon
320                      subclass="link table-filter-row-action"
321                      image="remove.png"
322                      tooltip="Remove this filter row"
323                      visible="<%=numRows > 1 || numFilters > 0 %>"
324                      data-remove-row="<%=filterNo%>"
325                    />
326                  </div>
327                </div>
328              </tbl:header>
329              <tbl:propertyfilter row="<%=filterNo%>" />
330            </tbl:headerrow>
331            <%
332          }
333          %>
334          <tbl:columnsubtitles />
335        </tbl:headers>
336        <tbl:rows>
337          <%
338          if (cc.getMessage() != null)
339          {
340            %>
341            <tbl:panel subclass="bg-filled-50">
342              <div class="messagecontainer error"><%=cc.getMessage()%></div>
343            </tbl:panel>
344            <%
345            cc.setMessage(null);
346          }
347          int index = cc.getPage()*cc.getRowsPerPage();
348          int selectedItemId = cc.getId();
349          if (platforms != null)
350          {           
351            while (platforms.hasNext())
352            {
353              Platform item = platforms.next();
354              RawDataType rdt = item.getRawDataType();
355              int itemId = item.getId();
356              String name = HTML.encodeTags(item.getName());
357              String tooltip = mode.isSelectionMode() ? 
358                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : ""); 
359             
360              index++;
361              numListed++;
362              %>
363              <tbl:row>
364                <tbl:header clazz="row-index bg-filled-100">
365                  <div class="index-<%=mode.getName()%>">
366                    <div class="index <%=index>999?"index-smaller":""%>"><%=index%></div>
367                    <div class="check">
368                      <base:input
369                        type="checkbox" 
370                        name="<%=itemId%>" 
371                        value="<%=itemId%>" 
372                        title="<%=name%>" 
373                        checked="<%=cc.getSelected().contains(itemId)%>"
374                        visible="<%=mode.hasCheck()%>"
375                      />
376                      <base:input 
377                        type="radio" 
378                        name="item_id" 
379                        value="<%=itemId%>" 
380                        title="<%=name%>" 
381                        checked="<%=selectedItemId == itemId%>"
382                        visible="<%=mode.hasRadio()%>"
383                      />
384                    </div>
385                    <div class="icons">
386                      <base:icon 
387                        image="deleted.png"
388                        id="<%="delete."+itemId %>"
389                        subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
390                        data-item-id="<%=itemId%>"
391                        tooltip="This item has been scheduled for deletion" 
392                        visible="<%=item.isRemoved()%>"
393                      />
394                    </div>
395                  </div>
396                </tbl:header>
397                <tbl:cell column="name"><div 
398                  class="link table-item"
399                  data-item-id="<%=itemId%>"
400                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
401                  tabindex="0"
402                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
403                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
404                <tbl:cell column="externalId"><%=item.getExternalId()%></tbl:cell>
405                <tbl:cell column="fileOnly"><%=item.isFileOnly() ? "yes" : "no"%></tbl:cell>
406                <tbl:cell column="channels"><%=rdt == null ? "N/A" : rdt.getChannels()%></tbl:cell>
407                <tbl:cell column="rawDataType">
408                  <%=item.isFileOnly() ? "N/A" : (rdt == null ? "<i>- any -</i>" : rdt.getName())%>
409                </tbl:cell>
410                <tbl:cell column="variants">
411                  <%
412                  variantQuery.setParameter("platform", itemId, Type.INT);
413                  try
414                  {
415                    String separator = "";
416                    for (PlatformVariant v : variantQuery.list(dc))
417                    {
418                      out.write(separator);
419                      if (mode.hasPropertyLink())
420                      {
421                        out.write(Base.getLinkedName(ID, v, false, mode.hasEditLink()));
422                      }
423                      else
424                      {
425                        out.write(HTML.encodeTags(v.getName()));
426                      }
427                      separator = ", ";
428                    }
429                  }
430                  catch (Throwable t)
431                  {
432                    %>
433                    <div class="error"><%=t.getMessage()%></div>
434                    <%
435                  }
436                  %>
437                  <base:icon
438                    id="<%="new-variant."+itemId %>"
439                    image="add.png" 
440                    subclass="auto-init"
441                    data-auto-init="new-variant"
442                    data-item-id="<%=itemId %>"
443                    tooltip="Create new variant" 
444                    visible="<%=mode.hasEditLink() && createVariantPermission %>"
445                  />
446                </tbl:cell>
447                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
448                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
449                  <tbl:cell column="xt-columns" />
450                </tbl:xt-cells>
451              </tbl:row>
452              <%
453              }
454            }
455          if (numListed == 0)
456          {
457            %>
458            <tbl:panel subclass="bg-filled-50">
459              <div class="messagecontainer note">
460              <%=platforms == null || platforms.getTotalCount() == 0 ? "No platforms were found" : "No platforms on this page. Please select another page!" %>
461              </div>
462            </tbl:panel>
463            <%
464          }
465          %>
466          </tbl:rows>
467      </tbl:data>
468    </tbl:table>
469    </div>
470   
471    <base:buttongroup subclass="dialogbuttons">
472      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
473      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
474      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
475    </base:buttongroup>
476   
477  </base:body>
478  </base:page>
479  <%
480}
481finally
482{
483  if (platforms != null) platforms.close();
484  if (dc != null) dc.close();
485}
486%>
Note: See TracBrowser for help on using the repository browser.