source: trunk/www/biomaterials/bioplatetypes/list_platetypes.jsp @ 5641

Last change on this file since 5641 was 5641, checked in by Nicklas Nordborg, 12 years ago

References #1153: Handling short read transcript sequence data

Removed LabeledExtract and related classes. Extract takes it place in most situations, including a temporary link to hybridizations. All tests programs pass and the web client is more or less working. The next step is to replace Hybridization with PhysicalBioAssay.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 14.1 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2010 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.BioPlateType"
30  import="net.sf.basedb.core.ItemQuery"
31  import="net.sf.basedb.core.Include"
32  import="net.sf.basedb.core.Type"
33  import="net.sf.basedb.core.BioWell"
34  import="net.sf.basedb.core.ItemResultIterator"
35  import="net.sf.basedb.core.ItemResultList"
36  import="net.sf.basedb.core.ItemContext"
37  import="net.sf.basedb.core.Permission"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.query.Restrictions"
41  import="net.sf.basedb.core.query.Expressions"
42  import="net.sf.basedb.core.query.Orders"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.util.Enumeration"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.ModeInfo"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.Values"
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.ToolbarUtil"
57  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
58  import="java.util.Date"
59  import="java.util.List"
60  import="java.util.Map"
61%>
62<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
63<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
64<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
65<%!
66  private static final Item itemType = Item.BIOPLATETYPE;
67  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
68 
69  private static Enumeration<String, String> bioMaterialTypes = new Enumeration<String, String>();
70  static
71  {
72    bioMaterialTypes.add("", "-any-");
73    bioMaterialTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString());
74    bioMaterialTypes.add(Integer.toString(Item.EXTRACT.getValue()), Item.EXTRACT.toString());
75  }
76  private static Enumeration<String, String> lockModes = new Enumeration<String, String>();
77  static
78  {
79    for (BioWell.LockMode lm : BioWell.LockMode.values())
80    {
81      lockModes.add(Integer.toString(lm.getValue()), lm.toString());
82    }
83  }
84 
85%>
86<%
87final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
88final String ID = sc.getId();
89final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
90final boolean deletePermission = sc.hasPermission(Permission.DELETE, itemType);
91final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
92
93final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
94final String callback = request.getParameter("callback");
95final String title = mode.generateTitle("bio plate type", "bio plate types");
96final DbControl dc = sc.newDbControl();
97ItemResultIterator<BioPlateType> bioPlateTypes = null;
98try
99{
100  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
101  try
102  {
103    final ItemQuery<BioPlateType> query = Base.getConfiguredQuery(dc, cc, true, BioPlateType.getQuery(), mode);
104    bioPlateTypes = query.iterate(dc);
105  }
106  catch (Throwable t)
107  {
108    cc.setMessage(t.getMessage());
109  }
110  int numListed = 0;
111  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
112  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
113  %>
114  <base:page title="<%=title==null ? "Bio plate types" : title%>" type="<%=mode.getPageType()%>">
115  <base:head scripts="menu.js,table.js" styles="menu.css,table.css">
116    <ext:scripts context="<%=jspContext%>" />
117    <ext:stylesheets context="<%=jspContext%>" />
118    <script language="JavaScript">
119    var submitPage = 'index.jsp';
120    var formId = 'bioPlateTypes';
121    function newItem()
122    {
123      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true);
124    }
125    function editItem(itemId)
126    {
127      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
128    }
129    function viewItem(itemId)
130    {
131      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
132    }
133    function itemOnClick(evt, itemId)
134    {
135      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected);
136    }
137    function deleteItems()
138    {
139      var frm = document.forms[formId];
140      if (Forms.numChecked(frm) == 0)
141      {
142        alert('Please select at least one item in the list');
143        return;
144      }
145      frm.action = submitPage;
146      frm.cmd.value = 'DeleteItems';
147      frm.submit();
148    }
149    function restoreItems()
150    {
151      var frm = document.forms[formId];
152      if (Forms.numChecked(frm) == 0)
153      {
154        alert('Please select at least one item in the list');
155        return;
156      }
157      frm.action = submitPage;
158      frm.cmd.value = 'RestoreItems';
159      frm.submit();
160    }
161    function deleteItemPermanently(itemId)
162    {
163      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', itemId);
164    }
165    function configureColumns()
166    {
167      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
168    }
169    function runPlugin(cmd)
170    {
171      Table.submitToPopup(formId, cmd, 740, 540);
172    }
173    function returnSelected()
174    {
175      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
176      window.close();
177    }
178    function presetOnChange()
179    {
180      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
181    }
182    </script>
183  </base:head>
184 
185  <base:body>
186    <%
187    if (cc.getMessage() != null)
188    {
189      %>
190      <div class="error"><%=cc.getMessage()%></div>
191      <%
192      cc.setMessage(null);
193    }
194    %>
195    <tbl:table 
196      id="bioPlateTypes" 
197      clazz="itemlist" 
198      columns="<%=cc.getSetting("columns")%>"
199      sortby="<%=cc.getSortProperty()%>" 
200      direction="<%=cc.getSortDirection()%>"
201      title="<%=title%>"
202      action="index.jsp"
203      sc="<%=sc%>"
204      item="<%=itemType%>"
205      >
206      <tbl:hidden 
207        name="mode" 
208        value="<%=mode.getName()%>" 
209      />
210      <tbl:hidden 
211        name="callback" 
212        value="<%=callback%>" 
213        skip="<%=callback == null%>" 
214      />
215      <tbl:columndef 
216        id="name"
217        property="name"
218        datatype="string"
219        title="Name"
220        sortable="true" 
221        filterable="true"
222        exportable="true"
223        show="always" 
224      />
225      <tbl:columndef 
226        id="id"
227        clazz="uniquecol"
228        property="id"
229        datatype="int"
230        title="ID"
231        sortable="true"
232        filterable="true"
233        exportable="true"
234      />
235      <tbl:columndef
236        id="bioMaterialType"
237        property="bioMaterialType"
238        title="Biomaterial type"
239        datatype="int"
240        sortable="true" 
241        filterable="true" 
242        exportable="true"
243        enumeration="<%=bioMaterialTypes%>"
244      />
245      <tbl:columndef
246        id="lockMode"
247        property="lockMode"
248        title="Well lock mode"
249        datatype="int"
250        sortable="true" 
251        filterable="true" 
252        exportable="true"
253        enumeration="<%=lockModes%>"
254      />
255      <tbl:columndef 
256        id="description"
257        property="description"
258        datatype="string"
259        title="Description" 
260        sortable="true" 
261        filterable="true" 
262        exportable="true"
263      />
264      <tbl:toolbar
265        visible="<%=mode.hasToolbar()%>"
266        >
267        <tbl:button 
268          disabled="<%=createPermission ? false : true%>" 
269          image="<%=createPermission ? "new.gif" : "new_disabled.gif"%>" 
270          onclick="newItem()" 
271          title="New&hellip;" 
272          tooltip="<%=createPermission ? "Create new bio plate type" : "You do not have permission to create bio plate types"%>" 
273        />
274        <tbl:button 
275          image="delete.gif"
276          onclick="deleteItems()" 
277          title="Delete" 
278          tooltip="Delete the selected items" 
279        />
280        <tbl:button 
281          image="restore.gif"
282          onclick="restoreItems()" 
283          title="Restore" 
284          tooltip="Restore the selected (deleted) items"
285        />
286        <tbl:button 
287          image="columns.gif" 
288          onclick="configureColumns()" 
289          title="Columns&hellip;" 
290          tooltip="Show, hide and re-order columns" 
291        />
292        <tbl:button 
293          image="import.gif" 
294          onclick="runPlugin('ImportItems')" 
295          title="Import&hellip;" 
296          tooltip="Import data" 
297          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
298        />
299        <tbl:button 
300          image="export.gif" 
301          onclick="runPlugin('ExportItems')" 
302          title="Export&hellip;" 
303          tooltip="Export data" 
304          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
305        />
306        <tbl:button 
307          image="runplugin.gif" 
308          onclick="runPlugin('RunListPlugin')" 
309          title="Run plugin&hellip;" 
310          tooltip="Run a plugin" 
311          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
312        />
313        <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
314          wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
315      </tbl:toolbar>
316      <tbl:navigator
317        page="<%=cc.getPage()%>" 
318        rowsperpage="<%=cc.getRowsPerPage()%>" 
319        totalrows="<%=bioPlateTypes == null ? 0 : bioPlateTypes.getTotalCount()%>" 
320        visible="<%=mode.hasNavigator()%>"
321      />
322      <tbl:data>
323        <tbl:columns>
324        <tbl:presetselector 
325          clazz="columnheader"
326          colspan="3"
327          onchange="presetOnChange()"
328        />
329        </tbl:columns>
330
331        <tr>
332          <tbl:header 
333            clazz="index"
334            >&nbsp;</tbl:header>
335          <tbl:header 
336            clazz="check" 
337            visible="<%=mode.hasCheck()%>"
338            ><base:icon 
339              image="check_uncheck.gif" 
340              tooltip="Check/uncheck all" 
341              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
342            /></tbl:header>
343          <tbl:header 
344            clazz="check" 
345            visible="<%=mode.hasRadio()%>"
346            >&nbsp;</tbl:header>
347          <tbl:header 
348            clazz="icons" 
349            visible="<%=mode.hasIcons()%>"
350            >&nbsp;</tbl:header>
351          <tbl:propertyfilter />
352        </tr>
353         
354          <tbl:rows>
355          <%
356          int index = cc.getPage()*cc.getRowsPerPage();
357          int selectedItemId = cc.getId();
358          if (bioPlateTypes != null)
359          {           
360            while (bioPlateTypes.hasNext())
361            {
362              BioPlateType item = bioPlateTypes.next();
363              int itemId = item.getId();
364              String name = HTML.encodeTags(item.getName());
365              boolean usePermission = item.hasPermission(Permission.USE);
366              boolean writePermission = item.hasPermission(Permission.WRITE);
367              String deletePermanently = "deleteItemPermanently("+itemId+")";
368              String tooltip = mode.isSelectionMode() ? 
369                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
370              index++;
371              numListed++;
372              %>
373              <tbl:row>
374                <tbl:header 
375                  clazz="index"
376                  ><%=index%></tbl:header>
377                <tbl:header 
378                  clazz="check" 
379                  visible="<%=mode.hasCheck()%>"
380                  ><input 
381                    type="checkbox" 
382                    name="<%=itemId%>" 
383                    value="<%=itemId%>" 
384                    title="<%=name%>" 
385                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
386                  ></tbl:header>
387                <tbl:header 
388                  clazz="check" 
389                  visible="<%=mode.hasRadio()%>"
390                  ><input 
391                    type="radio" 
392                    name="item_id" 
393                    value="<%=itemId%>" 
394                    title="<%=name%>" 
395                    <%=selectedItemId == itemId ? "checked" : ""%>
396                  ></tbl:header>
397                <tbl:header 
398                  clazz="icons" 
399                  visible="<%=mode.hasIcons()%>"
400                  ><base:icon 
401                    image="<%=deletePermission ? "deleted.gif" : "deleted_disabled.gif"%>"
402                    onclick="<%=deletePermission ? deletePermanently : null%>"
403                    tooltip="This item has been scheduled for deletion" 
404                    visible="<%=item.isRemoved()%>"
405                  />&nbsp;</tbl:header>
406                <tbl:cell column="name"><div class="link" 
407                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 
408                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
409                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
410                <tbl:cell column="bioMaterialType"><%=item.getBioMaterialType() == null ? "<i>- any -</i>" : item.getBioMaterialType().toString() %></tbl:cell>
411                <tbl:cell column="lockMode"><%=item.getLockMode()%></tbl:cell>
412                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
413              </tbl:row>
414              <%
415              }
416            }
417          %>
418          </tbl:rows>
419      </tbl:data>
420      <%
421      if (numListed == 0)
422      {
423        %>
424        <tbl:panel><%=bioPlateTypes == null || bioPlateTypes.getTotalCount() == 0 ? "No bio plate types were found" : "No bio plate types on this page. Please select another page!" %></tbl:panel>
425        <%
426      }
427      else
428      {
429        %>
430        <tbl:navigator
431          page="<%=cc.getPage()%>" 
432          rowsperpage="<%=cc.getRowsPerPage()%>" 
433          totalrows="<%=bioPlateTypes == null ? 0 : bioPlateTypes.getTotalCount()%>" 
434          visible="<%=mode.hasNavigator()%>"
435          locked="true"
436        />
437        <%
438      }
439      %>
440    </tbl:table>
441    <base:buttongroup align="center" clazz="fixedatbottom">
442      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
443      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
444      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
445    </base:buttongroup>
446    <br><br><br>
447  </base:body>
448  </base:page>
449  <%
450}
451finally
452{
453  if (bioPlateTypes != null) bioPlateTypes.close();
454  if (dc != null) dc.close();
455}
456%>
Note: See TracBrowser for help on using the repository browser.