source: trunk/www/lims/arrayslides/list_slides.jsp @ 6690

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

References #1906: Display inherited annotations in list views

Implemented this for samples, extracts physical bioassays, derived bioassays and array (slide/batch/desing) list views

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 19.1 KB
Line 
1<%-- $Id: list_slides.jsp 6690 2015-01-21 12:25:49Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.PhysicalBioAssay"
31  import="net.sf.basedb.core.ArraySlide"
32  import="net.sf.basedb.core.AnnotationType"
33  import="net.sf.basedb.core.AnnotationSet"
34  import="net.sf.basedb.core.Annotation"
35  import="net.sf.basedb.core.ItemQuery"
36  import="net.sf.basedb.core.Include"
37  import="net.sf.basedb.core.ItemResultIterator"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.ItemContext"
40  import="net.sf.basedb.core.Nameable"
41  import="net.sf.basedb.core.Permission"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.query.Hql"
44  import="net.sf.basedb.core.query.Restrictions"
45  import="net.sf.basedb.core.query.Expressions"
46  import="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.core.snapshot.AnnotationLoaderUtil"
49  import="net.sf.basedb.core.snapshot.AnnotationTypeFilter"
50  import="net.sf.basedb.core.snapshot.AnnotationSnapshot"
51  import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot"
52  import="net.sf.basedb.core.snapshot.SnapshotManager"
53  import="net.sf.basedb.util.Enumeration"
54  import="net.sf.basedb.util.ShareableUtil"
55  import="net.sf.basedb.clients.web.Base"
56  import="net.sf.basedb.clients.web.ModeInfo"
57  import="net.sf.basedb.clients.web.PermissionUtil"
58  import="net.sf.basedb.clients.web.util.HTML"
59  import="net.sf.basedb.util.Values"
60  import="net.sf.basedb.util.formatter.Formatter"
61  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
62  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
63  import="net.sf.basedb.clients.web.extensions.JspContext"
64  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
65  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
66  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
67  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
68  import="java.util.Date"
69  import="java.util.Iterator"
70  import="java.util.List"
71  import="java.util.Map"
72  import="java.util.ArrayList"
73%>
74<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
75<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
76<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
77<%!
78  private static final Item itemType = Item.ARRAYSLIDE;
79  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
80%>
81<%
82final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
83final String ID = sc.getId();
84final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
85final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
86
87final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
88final String callback = request.getParameter("callback");
89final String title = mode.generateTitle("array slide", "array slides");
90final DbControl dc = sc.newDbControl();
91ItemResultIterator<ArraySlide> slides = null;
92List<AnnotationLoaderUtil> annotationLoaders = new ArrayList<AnnotationLoaderUtil>();
93try
94{
95  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
96  ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
97  SnapshotManager manager = new SnapshotManager();
98  for (AnnotationType at : annotationTypeQuery.list(dc))
99  {
100    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
101  }
102  annotationTypeQuery = Base.getInheritedAnnotationColumns(cc.getSetting("columns"));
103  for (AnnotationType at : annotationTypeQuery.list(dc))
104  {
105    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at, false, true));
106  }
107
108  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
109  try
110  {
111    final ItemQuery<ArraySlide> query = Base.getConfiguredQuery(dc, cc, true, ArraySlide.getQuery(), mode);
112    slides = query.iterate(dc);
113  }
114  catch (Throwable t)
115  {
116    cc.setMessage(t.getMessage());
117    t.printStackTrace();
118  }
119  int numListed = 0;
120  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
121  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
122  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
123  %>
124  <base:page title="<%=title==null ? "Array slides" : title%>" type="<%=mode.getPageType()%>" id="list-page">
125  <base:head scripts="table.js,~slides.js" styles="table.css,toolbar.css">
126    <ext:scripts context="<%=jspContext%>" />
127    <ext:stylesheets context="<%=jspContext%>" />
128  </base:head>
129 
130  <base:body>
131    <h1><%=title==null ? "Array slides" : title%></h1>
132    <div class="content">
133    <tbl:table 
134      id="slides" 
135      columns="<%=cc.getSetting("columns")%>"
136      sortby="<%=cc.getSortProperty()%>" 
137      direction="<%=cc.getSortDirection()%>"
138      action="index.jsp"
139      sc="<%=sc%>"
140      item="<%=itemType%>"
141      subclass="fulltable"
142      data-inherited-annotations="true"
143      >
144      <tbl:hidden 
145        name="mode" 
146        value="<%=mode.getName()%>" 
147      />
148      <tbl:hidden 
149        name="callback" 
150        value="<%=callback%>" 
151        skip="<%=callback == null%>" 
152      />
153      <tbl:columndef 
154        id="name"
155        property="name"
156        datatype="string"
157        title="Name"
158        sortable="true" 
159        filterable="true"
160        exportable="true"
161        show="always" 
162      />
163      <tbl:columndef 
164        id="id"
165        clazz="uniquecol"
166        property="id"
167        datatype="int"
168        title="ID"
169        sortable="true"
170        filterable="true"
171        exportable="true"
172      />
173      <tbl:columndef 
174        id="entryDate"
175        property="entryDate"
176        datatype="date"
177        title="Registered"
178        sortable="true" 
179        filterable="true"
180        exportable="true"
181        formatter="<%=dateFormatter%>"
182      />
183      <tbl:columndef 
184        id="arrayBatch"
185        property="arrayBatch.name"
186        datatype="string"
187        title="Array batch"
188        sortable="true" 
189        filterable="true"
190        exportable="true"
191      />
192      <tbl:columndef 
193        id="arrayDesign"
194        property="arrayBatch.arrayDesign.name"
195        datatype="string"
196        title="Array design"
197        sortable="true" 
198        filterable="true"
199        exportable="true"
200      />
201      <tbl:columndef 
202        id="physicalBioAssay"
203        property="physicalBioAssay.name"
204        datatype="string"
205        title="Physical bioassay"
206        sortable="true" 
207        filterable="true"
208        exportable="true"
209      />
210      <tbl:columndef 
211        id="barcode"
212        property="barcode"
213        datatype="string"
214        title="Barcode"
215        sortable="true" 
216        filterable="true"
217        exportable="true"
218      />
219      <tbl:columndef 
220        id="destroyed"
221        property="destroyed"
222        datatype="boolean"
223        title="Destroyed"
224        sortable="true" 
225        filterable="true"
226        exportable="true"
227      />
228      <tbl:columndef 
229        id="batchIndex"
230        property="batchIndex"
231        datatype="int"
232        title="Batch index"
233        sortable="true" 
234        filterable="true"
235        exportable="true"
236      />
237      <tbl:columndef 
238        id="owner"
239        property="owner.name"
240        datatype="string"
241        title="Owner"
242        sortable="true" 
243        filterable="true"
244        exportable="true"
245      />
246      <tbl:columndef 
247        id="description"
248        property="description"
249        datatype="string"
250        title="Description" 
251        sortable="true" 
252        filterable="true" 
253        exportable="true"
254      />     
255      <%
256      for (AnnotationLoaderUtil loader : annotationLoaders)
257      {
258        AnnotationType at = loader.getAnnotationType();
259        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
260        Enumeration<String, String> annotationEnum = null;
261        if (at.isEnumeration())
262        {
263          annotationEnum = new Enumeration<String, String>();
264          List<?> values = at.getValues();
265          for (Object value : values)
266          {
267            String encoded = formatter.format(value);
268            annotationEnum.add(encoded, encoded);
269          }
270        }
271        %>
272        <tbl:columndef 
273          id="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+at.getId()%>"
274          title="<%=HTML.encodeTags(at.getName())+(loader.isSearchingInheritedAnnotations() ? " [I]" : " [A]")%>" 
275          property="<%=(loader.isSearchingInheritedAnnotations() ? "##" : "#")+at.getId()%>"
276          annotation="true"
277          datatype="<%=at.getValueType().getStringValue()%>"
278          enumeration="<%=annotationEnum%>"
279          smartenum="<%=at.getDisplayAsList() %>"
280          sortable="<%=at.getMultiplicity() == 1 && !loader.isSearchingInheritedAnnotations()%>" 
281          filterable="true" 
282          exportable="true"
283          formatter="<%=formatter%>"
284          unit="<%=at.getDefaultUnit()%>"
285        />
286        <%
287      }
288      %>
289      <tbl:columndef
290        id="permission"
291        title="Permission"
292      />
293      <tbl:columndef
294        id="sharedTo"
295        title="Shared to"
296        filterable="true"
297        filterproperty="!sharedTo.name"
298        datatype="string"
299      />
300      <tbl:columndef 
301        id="xt-columns" 
302        extensions="<%=columnsInvoker%>" 
303        jspcontext="<%=jspContext%>" 
304      />
305      <div class="panelgroup bg-filled-50 bottomborder">
306        <tbl:toolbar
307          subclass="bottomborder"
308          visible="<%=mode.hasToolbar()%>"
309          >
310          <tbl:button 
311            id="btnNewItem"
312            disabled="<%=!createPermission%>" 
313            image="new.png" 
314            title="New&hellip;" 
315            tooltip="<%=createPermission ? "Create new array slide" : "You do not have permission to create array slides"%>" 
316          />
317          <tbl:button
318            id="btnNewItemsWizard"
319            disabled="<%=!createPermission%>"
320            image="new_wizard.png"
321            title="Create multiple&hellip;"
322            tooltip="<%=createPermission ? "Create multiple new array slides using a wizard" : "You do not have permission to create array slides"%>" 
323          />
324          <tbl:button 
325            id="btnDeleteItems"
326            image="delete.png"
327            title="Delete" 
328            tooltip="Delete the selected items" 
329          />
330          <tbl:button 
331            id="btnRestoreItems"
332            image="restore.png"
333            title="Restore" 
334            tooltip="Restore the selected (deleted) items"
335          />
336          <tbl:button 
337            id="btnShareItems"
338            image="share.png"
339            title="Share&hellip;" 
340            tooltip="Share the selected items"
341          />
342          <tbl:button 
343            id="btnSetOwner"
344            image="take_ownership.png"
345            title="Set owner&hellip;"
346            tooltip="Change owner of the selected items"
347          />
348          <tbl:button 
349            id="btnColumns"
350            image="columns.png" 
351            title="Columns&hellip;" 
352            tooltip="Show, hide and re-order columns" 
353          />
354          <tbl:button 
355            id="btnImport"
356            data-plugin-type="IMPORT"
357            image="import.png" 
358            title="Import&hellip;" 
359            tooltip="Import data" 
360            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
361          />
362          <tbl:button 
363            id="btnExport"
364            data-plugin-type="EXPORT"
365            image="export.png" 
366            title="Export&hellip;" 
367            tooltip="Export data" 
368            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
369          />
370          <tbl:button 
371            id="btnRunPlugin"
372            data-plugin-type="OTHER"
373            image="runplugin.png" 
374            title="Run plugin&hellip;" 
375            tooltip="Run a plugin" 
376            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
377          />
378          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
379            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
380        </tbl:toolbar>
381        <tbl:panel>
382          <tbl:presetselector />
383          <tbl:navigator
384            page="<%=cc.getPage()%>" 
385            rowsperpage="<%=cc.getRowsPerPage()%>" 
386            totalrows="<%=slides == null ? 0 : slides.getTotalCount()%>" 
387            visible="<%=mode.hasNavigator()%>"
388          />
389        </tbl:panel>
390      </div>
391      <tbl:data>
392        <tbl:headers>
393          <tbl:headerrow>
394            <tbl:header colspan="3" />
395            <tbl:columnheaders />
396          </tbl:headerrow>
397          <tbl:headerrow>
398            <tbl:header subclass="index" />
399            <tbl:header 
400              subclass="check" 
401              visible="<%=mode.hasCheck()%>"
402              ><base:icon 
403                id="check.uncheck"
404                image="check_uncheck.png" 
405                tooltip="Check/uncheck all" 
406                 
407              /></tbl:header>
408            <tbl:header 
409              subclass="check" 
410              visible="<%=mode.hasRadio()%>"
411              />
412            <tbl:header 
413              subclass="icons" 
414              visible="<%=mode.hasIcons()%>"
415              />
416            <tbl:propertyfilter />
417          </tbl:headerrow>
418        </tbl:headers>
419        <tbl:rows>
420          <%
421          if (cc.getMessage() != null)
422          {
423            %>
424            <tbl:panel subclass="bg-filled-50">
425              <div class="messagecontainer error"><%=cc.getMessage()%></div>
426            </tbl:panel>
427            <%
428            cc.setMessage(null);
429          }
430          int index = cc.getPage()*cc.getRowsPerPage();
431          int selectedItemId = cc.getId();
432          if (slides != null)
433          {
434            while (slides.hasNext())
435            {
436              ArraySlide item = slides.next();
437              int itemId = item.getId();
438             
439             
440              boolean deletePermission = item.hasPermission(Permission.DELETE);
441              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
442              boolean writePermission = item.hasPermission(Permission.WRITE);
443              String tooltip = mode.isSelectionMode() ? 
444                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
445              String name = HTML.encodeTags(item.getName());
446              index++;
447              numListed++;
448              %>
449              <tbl:row>
450                <tbl:header 
451                  clazz="index"
452                  ><%=index%></tbl:header>
453                <tbl:header 
454                  clazz="check" 
455                  visible="<%=mode.hasCheck()%>"
456                  ><input 
457                    type="checkbox" 
458                    name="<%=itemId%>" 
459                    value="<%=itemId%>" 
460                    title="<%=name%>" 
461                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
462                  ></tbl:header>
463                <tbl:header 
464                  clazz="check" 
465                  visible="<%=mode.hasRadio()%>"
466                  ><input 
467                    type="radio" 
468                    name="item_id" 
469                    value="<%=itemId%>" 
470                    title="<%=name%>" 
471                    <%=selectedItemId == itemId ? "checked" : ""%>
472                  ></tbl:header>
473                <tbl:header 
474                  clazz="icons" 
475                  visible="<%=mode.hasIcons()%>"
476                  ><base:icon 
477                    image="deleted.png"
478                    id="<%="delete."+itemId %>"
479                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
480                    data-item-id="<%=itemId%>"
481                    tooltip="This item has been scheduled for deletion" 
482                    visible="<%=item.isRemoved()%>"
483                  /><base:icon 
484                    image="shared.png" 
485                    id="<%="share."+itemId %>"
486                    subclass="<%=sharePermission ? "table-share-item" : null %>"
487                    data-item-id="<%=itemId%>"
488                    tooltip="This item is shared to other users, groups and/or projects" 
489                    visible="<%=item.isShared()%>"
490                  />&nbsp;</tbl:header>
491                <tbl:cell column="name"><div
492                  class="link table-item"
493                  data-item-id="<%=itemId%>"
494                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
495                  tabindex="0"
496                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
497                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
498                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
499                <tbl:cell column="arrayBatch"
500                  ><base:propertyvalue 
501                    item="<%=item%>" 
502                    property="arrayBatch"
503                    enableEditLink="<%=mode.hasEditLink()%>" 
504                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
505                  /></tbl:cell>
506                <tbl:cell column="arrayDesign"
507                  ><base:propertyvalue 
508                    item="<%=item%>" 
509                    property="arrayBatch.arrayDesign"
510                    enableEditLink="<%=mode.hasEditLink()%>" 
511                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
512                  /></tbl:cell>
513                <tbl:cell column="physicalBioAssay"
514                  ><base:propertyvalue 
515                    item="<%=item%>" 
516                    property="physicalBioAssay"
517                    enableEditLink="<%=mode.hasEditLink()%>" 
518                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
519                  /></tbl:cell>
520                <tbl:cell column="barcode"><%=HTML.encodeTags(item.getBarcode())%></tbl:cell>
521                <tbl:cell column="batchIndex"><%=item.getBatchIndex()%></tbl:cell>
522                <tbl:cell column="destroyed"><%=item.isDestroyed()%></tbl:cell>
523                <tbl:cell column="owner"
524                  ><base:propertyvalue 
525                    item="<%=item%>" 
526                    property="owner"
527                    enableEditLink="<%=mode.hasEditLink()%>" 
528                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
529                  /></tbl:cell>
530                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>               
531                <%
532                if (item.isAnnotated())
533                {
534                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
535                  for (AnnotationLoaderUtil loader : annotationLoaders)
536                  {
537                    if (loader.find(snapshot))
538                    {
539                      %>
540                      <tbl:cell 
541                        column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
542                        ><tbl:cellvalue 
543                          list="<%=loader.getValues()%>"
544                          suffix="<%=loader.getUnitSymbol()%>"
545                      /></tbl:cell>
546                      <%
547                    }
548                  }
549                }
550                %>
551                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
552                <tbl:cell column="sharedTo">
553                  <%
554                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
555                  while(sharees.hasNext())
556                  {
557                    Nameable n = sharees.next();
558                    if (mode.hasPropertyLink())
559                    {
560                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
561                    }
562                    else
563                    {
564                      out.write(HTML.encodeTags(n.getName()));
565                    }
566                    out.write(sharees.hasNext() ? ", " : "");
567                  }
568                  %>
569                </tbl:cell>
570                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
571                  <tbl:cell column="xt-columns" />
572                </tbl:xt-cells>
573              </tbl:row>
574              <%
575              }
576            }
577          if (numListed == 0)
578          {
579            %>
580            <tbl:panel subclass="bg-filled-50">
581              <div class="messagecontainer note">
582              <%=slides == null || slides.getTotalCount() == 0 ? "No array slides were found" : "No array slides on this page. Please select another page!" %>
583              </div>
584            </tbl:panel>
585            <%
586          }
587          %>
588        </tbl:rows>
589      </tbl:data>
590    </tbl:table>
591    </div>
592   
593    <base:buttongroup subclass="dialogbuttons">
594      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
595      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
596      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
597    </base:buttongroup>
598   
599  </base:body>
600  </base:page>
601  <%
602}
603finally
604{
605  if (slides != null) slides.close();
606  if (dc != null) dc.close();
607}
608%>
Note: See TracBrowser for help on using the repository browser.