source: trunk/www/views/experiments/bioassaysets/analysis_tree.jsp @ 3580

Last change on this file since 3580 was 3580, checked in by Nicklas Nordborg, 16 years ago

Fixes #690: Not allowed to read Extra value type

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 29.2 KB
Line 
1<%-- $Id: analysis_tree.jsp 3580 2007-07-20 06:02:00Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.BasicItem"
33  import="net.sf.basedb.core.Experiment"
34  import="net.sf.basedb.core.BioAssaySet"
35  import="net.sf.basedb.core.Transformation"
36  import="net.sf.basedb.core.ExtraValue"
37  import="net.sf.basedb.core.ExtraValueType"
38  import="net.sf.basedb.core.AnnotationSet"
39  import="net.sf.basedb.core.AnnotationType"
40  import="net.sf.basedb.core.Job"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.Nameable"
43  import="net.sf.basedb.core.ItemResultIterator"
44  import="net.sf.basedb.core.ItemResultList"
45  import="net.sf.basedb.core.Permission"
46  import="net.sf.basedb.core.PluginDefinition"
47  import="net.sf.basedb.core.PermissionDeniedException"
48  import="net.sf.basedb.core.query.Restrictions"
49  import="net.sf.basedb.core.query.Expressions"
50  import="net.sf.basedb.core.query.Orders"
51  import="net.sf.basedb.core.query.Hql"
52  import="net.sf.basedb.core.query.Restrictions"
53  import="net.sf.basedb.core.plugin.GuiContext"
54  import="net.sf.basedb.core.plugin.Plugin"
55  import="net.sf.basedb.util.Tree"
56  import="net.sf.basedb.util.Enumeration"
57  import="net.sf.basedb.clients.web.Base"
58  import="net.sf.basedb.clients.web.ModeInfo"
59  import="net.sf.basedb.clients.web.util.HTML"
60  import="net.sf.basedb.util.Values"
61  import="net.sf.basedb.util.formatter.Formatter"
62  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
63  import="java.util.Date"
64  import="java.util.List"
65  import="java.util.ArrayList"
66  import="java.util.LinkedList"
67  import="java.util.Map"
68  import="java.util.HashMap"
69  import="java.util.Iterator"
70  import="java.util.Collection"
71%>
72<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
73<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
74<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
75<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
76<%!
77  private static final Item itemType = Item.BIOASSAYSET;
78  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
79%>
80<%!
81
82private static void addToTree(Tree<BasicItem> tree, BioAssaySet bas)
83{
84  if (!tree.contains(bas))
85  {
86    Transformation transformation = bas.getTransformation();
87    Tree.Entry<BasicItem> parent = tree.getEntry(transformation);
88    if (parent == null) 
89    {
90      addToTree(tree, transformation);
91      parent = tree.getEntry(transformation);
92    }
93    Tree.Entry<BasicItem> basEntry = parent.addChild(bas);
94    for (ExtraValue xv : bas.getExtraValues().list(bas.getDbControl())) 
95    {
96      basEntry.addChild(xv);
97    }
98  }
99}
100
101private static void addToTree(Tree<BasicItem> tree, Transformation transformation)
102{
103  if (!tree.contains(transformation))
104  {
105    BioAssaySet source = transformation.getSource();
106    Tree.Entry<BasicItem> parent = tree.getEntry(source);
107    if (parent == null) 
108    {
109      addToTree(tree, source);
110      parent = tree.getEntry(source);
111    }
112    parent.addChild(transformation);
113  }
114}
115
116private static Tree<BasicItem> getAnalysisTree(DbControl dc, ItemQuery<BioAssaySet> bioAssaySetQuery, ItemQuery<Transformation> transformationQuery)
117{
118  Tree<BasicItem> tree = new Tree<BasicItem>(null);
119  ItemResultList<BioAssaySet> allBioAssaySets = bioAssaySetQuery.list(dc);
120  List<Integer> ids = new ArrayList<Integer>(allBioAssaySets.size());
121 
122  for (BioAssaySet bas : allBioAssaySets)
123  {
124    addToTree(tree, bas);
125    ids.add(bas.getId());
126  }
127 
128  transformationQuery.restrict(
129    Restrictions.in(
130      Hql.property("source.id"), 
131      Expressions.parameter("bioAssaySets", ids)
132    )
133  );
134  ItemResultList<Transformation> allTransformations = transformationQuery.list(dc);
135  for (Transformation t: allTransformations)
136  {
137    addToTree(tree, t);
138  }
139  return tree;
140}
141String generateTree(Tree<BasicItem> tree, BasicItem root, BasicItem parentItem, Collection<String> closed)
142{
143  StringBuilder sb = new StringBuilder();
144  Tree.Entry<BasicItem> parentEntry = tree.getEntry(parentItem);
145  if (parentEntry == null) return "";
146 
147  if (root != null && root == parentItem)
148  {
149    appendNode(sb, root, null, true);
150  }
151 
152  List<Tree.Entry<BasicItem>> children = parentEntry.getChildren();
153  if (children != null)
154  {
155    for (Tree.Entry<BasicItem> child : children)
156    {
157      BasicItem node = child.getNode();
158      String var = node.getType().name() + "_" + node.getId();
159      appendNode(sb, node, parentItem, (closed == null || !closed.contains(var)) && child.getNumChildren() > 0);
160      sb.append(generateTree(tree, root, node, closed));
161    }
162  }
163  return sb.toString();
164}
165
166void appendNode(StringBuilder sb, BasicItem node, BasicItem parentItem, boolean open)
167{
168  int id = node.getId();
169  String var = node.getType().name() + "_" + id;
170  String name = "";
171 
172  Item nodeType = node.getType();
173  String folderIcon = "";
174  if (nodeType == Item.BIOASSAYSET)
175  {
176    folderIcon = "BioAssaySet";
177    name = ((BioAssaySet)node).getName();
178  } 
179  else if (nodeType == Item.TRANSFORMATION)
180  {
181    folderIcon = "Transformation";
182    name = ((Transformation)node).getName();
183  } 
184  else if (nodeType == Item.EXTRAVALUE) 
185  {
186    folderIcon = "ExtraValue";
187    try
188    {
189      name = ((ExtraValue)node).getExtraValueType().getName();
190    }
191    catch (PermissionDeniedException ex)
192    {
193      name = ((ExtraValue)node).getValueType().toString();
194    }
195  }
196  sb.append("var ").append(var);
197  if (parentItem == null)
198  {
199    sb.append(" = JoustMenu.addMenuItem(-1");
200  }
201  else
202  {
203    String rootVar = parentItem.getType().name() + "_" + parentItem.getId();
204    sb.append(" = JoustMenu.addChildItem(").append(rootVar); 
205  }
206  sb.append(",'").append(folderIcon).append("'");
207  sb.append(",'").append(HTML.javaScriptEncode(name)).append("'");
208  sb.append(", null, '', '").append(var).append("');\n");
209  if (open)
210  {
211    sb.append("JoustMenu.menuItems[").append(var).append("].isOpen = true;\n");
212  }
213}
214%>
215<%
216final int experimentId = Values.getInt(request.getParameter("experiment_id"));
217final int bioAssaySetId = Values.getInt(request.getParameter("item_id"));
218final int transformationId = Values.getInt(request.getParameter("transformation_id"));
219final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
220final String ID = sc.getId();
221final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
222final ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION);
223final ItemContext xvc = sc.getCurrentContext(Item.EXTRAVALUE);
224
225final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
226final String callback = request.getParameter("callback");
227final String title = mode.generateTitle("bioassay set", "bioassay sets");
228final DbControl dc = sc.newDbControl();
229Tree<BasicItem> analysisTree = null;
230ItemResultList<AnnotationType> annotationTypes = null;
231try
232{
233  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
234  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
235  final Experiment experiment = Experiment.getById(dc, experimentId);
236  final BasicItem root = transformationId == 0 ? 
237      (bioAssaySetId == 0 ? null : BioAssaySet.getById(dc, bioAssaySetId))
238      : Transformation.getById(dc, transformationId);
239  final boolean createPermission = experiment.hasPermission(Permission.USE);
240  final boolean deletePermission = createPermission;
241  final boolean writePermission = createPermission;
242
243  final ItemQuery<BioAssaySet> query = Base.getConfiguredQuery(cc, true, experiment.getBioAssaySets(), mode);
244  final ItemQuery<Transformation> transformationQuery = experiment.getTransformations();
245  transformationQuery.include(cc.getInclude());
246  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
247  annotationTypes = annotationTypeQuery.list(dc);
248  try
249  {
250    analysisTree = getAnalysisTree(dc, query, transformationQuery);
251  }
252  catch (Throwable t)
253  {
254    cc.setMessage(t.getMessage());
255  }
256  // Contains the ID:s of the bioassaysets that are closed in the tree
257  Collection<String> closed = (Collection<String>)cc.getObject("closed");
258  int numListed = 0;
259  %>
260  <base:page type="include">
261  <base:body>
262    <script language="JavaScript">
263    var submitPage = '<%=transformationId != 0 ? "../bioassaysets/index.jsp" : "index.jsp"%>';
264    var formId = 'bioAssaySets';
265    function newItem()
266    {
267      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 740, 540);
268    }
269    function editBioAssaySet(itemId)
270    {
271      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
272    }
273    function viewBioAssaySet(itemId)
274    {
275      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
276    }
277    function bioAssaySetOnClick(evt, itemId)
278    {
279      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewBioAssaySet, editBioAssaySet, returnSelected);
280    }
281    function viewTransformation(itemId)
282    {
283      Main.viewOrEditItem('<%=ID%>', 'TRANSFORMATION', itemId, false);
284    }
285    function editTransformation(itemId)
286    {
287      Main.viewOrEditItem('<%=ID%>', 'TRANSFORMATION', itemId, true);
288    }
289    function transformationOnClick(evt, itemId)
290    {
291      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewTransformation, editTransformation, returnSelected);
292    }
293    function viewExtraValue(itemId)
294    {
295      Main.viewOrEditItem('<%=ID%>', 'EXTRAVALUE', itemId, false);
296    }
297    function editExtraValue(itemId)
298    {
299      Main.viewOrEditItem('<%=ID%>', 'EXTRAVALUE', itemId, true);
300    }
301    function extraValueOnClick(evt, itemId)
302    {
303      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewExtraValue, editExtraValue, returnSelected);
304    }
305    function deleteItems()
306    {
307      var frm = document.forms[formId];
308      if (Forms.numChecked(frm) == 0)
309      {
310        alert('Please select at least one item in the list');
311        return;
312      }
313      if (Forms.numChecked(frm, /^X:/) > 0)
314      {
315        if (!confirm('Extra values are deleted immediately and cannot be restored. Do you want to continue?'))
316        {
317          return;
318        }
319      }
320      frm.action = submitPage;
321      frm.cmd.value = 'DeleteItems';
322      frm.submit();
323    }
324    function restoreItems()
325    {
326      var frm = document.forms[formId];
327      if (Forms.numChecked(frm) == 0)
328      {
329        alert('Please select at least one item in the list');
330        return;
331      }
332      frm.action = submitPage;
333      frm.cmd.value = 'RestoreItems';
334      frm.submit();
335    }
336    function configureColumns()
337    {
338      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
339    }
340    function runPlugin(cmd)
341    {
342      Table.submitToPopup(formId, cmd, 740, 540);
343    }
344    function filter(itemId)
345    {
346      Main.openPopup('../bioassaysets/index.jsp?ID=<%=ID%>&cmd=NewFilteredBioAssaySet&experiment_id=<%=experimentId%>&item_id='+itemId, 'FilterBioAssaySet', 740, 540);
347    }
348    function openPlotTool(itemId)
349    {
350      Main.openPopup('../plotter/index.jsp?ID=<%=ID%>&bioassayset_id='+itemId, 'Plotter', 1000, 700);
351    }
352    function openExperimentExplorer(itemId)
353    {
354      location.href = '../explorer/view/index.jsp?ID=<%=ID%>&bioassayset_id='+itemId;
355    }
356    function launchMeV(itemId)
357    {
358      location.href = '../../../plugins/org/tigr/microarray/mev/launch_mev.jsp?ID=<%=ID%>&bioassayset_id='+itemId;
359    }
360    function runAnalysisPlugin(itemId)
361    {
362      Main.openPopup('../bioassaysets/index.jsp?ID=<%=ID%>&cmd=RunAnalysisPlugin&experiment_id=<%=experimentId%>&item_id='+itemId, 'RunPlugin', 740, 540);
363    }
364    function runExportPlugin(itemId)
365    {
366      Main.openPopup('../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ExportItem&experiment_id=<%=experimentId%>&item_id='+itemId, 'Export', 740, 540);
367    }
368    function copyJob(jobId)
369    {
370      var url = '../../../common/plugin/index.jsp?ID=<%=ID%>';
371      url += '&cmd=CopyJob&job_id='+jobId;
372      url += '&item_type=BIOASSAYSET&context_type=LIST'
373      Main.openPopup(url, 'CopyJob', 740, 540);
374    }
375    function returnSelected()
376    {
377      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
378      window.close();
379    }
380    function presetOnChange()
381    {
382      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
383    }
384    function initTree()
385    {
386      var bigDir = getRoot()+'images/joust/big/';
387      IconStore.init(bigDir, 18, 22);
388      IconStore.addIcon('BioAssaySet', bigDir + 'bioassayset.gif', 18, 22);
389      IconStore.addIcon('Transformation', bigDir + 'transformation.gif', 18, 22);
390      IconStore.addIcon('Filter', bigDir + 'filter.gif', 18, 22);
391      IconStore.addIcon('ExtraValue', bigDir + 'extravalue.gif', 18, 22);
392
393      JoustMenu.toggle = function(menuItemIndex)
394      {
395        var menuItem = this.menuItems[menuItemIndex];
396        if (!menuItem) return;
397        // Switch the open/closed status and hide or show the children
398        menuItem.isOpen = !menuItem.isOpen;
399        if (menuItem.isOpen)
400        {
401          this.showChildren(menuItemIndex);
402          var frm = document.forms[formId];
403          frm.closed.value = frm.closed.value.replace(','+menuItem.externalId+',', ',');
404        }
405        else
406        {
407          this.hideChildren(menuItemIndex);
408          var frm = document.forms[formId];
409          frm.closed.value += menuItem.externalId+',';
410        }
411        // alert(document.forms[formId].closed.value);
412        this.updateIconsAndText(menuItemIndex);
413      }
414     
415      JoustMenu.drawMenuItems = function(firstIndex, indentString)
416      {
417        var menuItem = this.menuItems[firstIndex];
418        while (menuItem)
419        {
420          var html = menuItem.draw(indentString);
421          var padIcon = IconStore.getIcon(menuItem.noOutlineIcon == true ? null : menuItem.nextItemIndex == -1 ? 'iconBlank' : 'iconLine');
422          var padHtml = padIcon == null ? '' : padIcon.getImgTag();
423         
424          var menuDiv = document.getElementById('tree.'+menuItem.externalId);
425          menuDiv.innerHTML = html;
426         
427          if (menuItem.firstChildIndex != -1)
428          {
429            this.drawMenuItems(menuItem.firstChildIndex, indentString+padHtml);
430          }
431          if (!menuItem.isOpen)
432          {
433            this.hideChildren(menuItem.index);
434          }
435          menuItem = this.menuItems[menuItem.nextItemIndex];
436        }
437        return '';
438      }
439
440      JoustMenu.hideChildren = function(menuItemIndex)
441      {
442        var menuItem = this.menuItems[menuItemIndex];
443        if (menuItem)
444        {
445          var firstChildIndex = menuItem.firstChildIndex;
446          var child = this.menuItems[firstChildIndex];
447          while (child)
448          {
449            var e = document.getElementById('row.'+child.externalId);
450            e.style.display = 'none';
451            this.hideChildren(child.index);
452            child = this.menuItems[child.nextItemIndex];
453          }
454        }
455      }
456     
457      JoustMenu.showChildren = function(menuItemIndex)
458      {
459        var menuItem = this.menuItems[menuItemIndex];
460        if (menuItem)
461        {
462          var firstChildIndex = menuItem.firstChildIndex;
463          var child = this.menuItems[firstChildIndex];
464          while (child)
465          {
466            var e = document.getElementById('row.'+child.externalId);
467            e.style.display = Browser.isIE ? 'block' : 'table-row';
468            if (child.isOpen)
469            {
470              this.showChildren(child.index);
471            }
472            child = this.menuItems[child.nextItemIndex];
473          }
474        }
475      }
476
477      <%=analysisTree == null ? "" : generateTree(analysisTree, root, root, closed)%>
478      JoustMenu.draw('joust');
479     
480    }
481    </script>
482 
483
484    <%
485    if (cc.getMessage() != null)
486    {
487      %>
488      <div class="error"><%=cc.getMessage()%></div>
489      <%
490      cc.setMessage(null);
491    }
492    %>
493    <tbl:table 
494      id="bioAssaySets" 
495      clazz="itemlist" 
496      columns="<%=cc.getSetting("columns")%>"
497      sortby="<%=cc.getSortProperty()%>" 
498      direction="<%=cc.getSortDirection()%>"
499      title="<%=title%>"
500      action="<%=transformationId != 0 ? "../bioassaysets/index.jsp" : "index.jsp"%>"
501      sc="<%=sc%>"
502      item="<%=itemType%>"
503      >
504      <tbl:hidden 
505        name="mode" 
506        value="<%=mode.getName()%>" 
507      />
508      <tbl:hidden 
509        name="experiment_id" 
510        value="<%=String.valueOf(experimentId)%>" 
511      />
512      <tbl:hidden 
513        name="item_id" 
514        value="<%=String.valueOf(bioAssaySetId)%>"
515        skip="<%=bioAssaySetId == 0%>"
516      />
517      <tbl:hidden 
518        name="transformation_id" 
519        value="<%=String.valueOf(transformationId)%>"
520        skip="<%=transformationId == 0%>"
521      />
522      <tbl:hidden 
523        name="callback" 
524        value="<%=callback%>" 
525        skip="<%=callback == null%>" 
526      />
527      <tbl:hidden
528        name="closed"
529        value="<%=closed == null ? "," : ","+Values.getString(closed, ",", true)+","%>"
530      />
531      <tbl:columndef 
532        id="name"
533        property="name"
534        datatype="string"
535        title="Name"
536        sortable="true" 
537        filterable="true"
538        exportable="true"
539        show="always" 
540      />
541      <tbl:columndef 
542        id="spots"
543        property="numSpots"
544        datatype="int"
545        title="Spots/Values"
546        sortable="true" 
547        filterable="true"
548        exportable="true"
549      />
550      <tbl:columndef 
551        id="reporters"
552        property="numReporters"
553        datatype="int"
554        title="Reporters"
555        sortable="true" 
556        filterable="true"
557        exportable="true"
558      />
559      <tbl:columndef 
560        id="date"
561        property="transformation.job.ended"
562        datatype="string"
563        title="Date"
564        sortable="true" 
565        filterable="true"
566        exportable="true"
567      />
568      <tbl:columndef 
569        id="plugin"
570        property="transformation.job.pluginDefinition.name"
571        datatype="string"
572        title="Plugin"
573        sortable="true" 
574        filterable="true"
575        exportable="true"
576      />
577      <tbl:columndef 
578        id="description"
579        property="description"
580        datatype="string"
581        title="Description" 
582        sortable="true" 
583        filterable="true" 
584        exportable="true"
585      />
586      <%
587      for (AnnotationType at : annotationTypes)
588      {
589        Enumeration<String, String> annotationEnum = null;
590        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
591        if (at.isEnumeration())
592        {
593          annotationEnum = new Enumeration<String, String>();
594          List<?> values = at.getValues();
595          for (Object value : values)
596          {
597            String encoded = formatter.format(value);
598            annotationEnum.add(encoded, encoded);
599          }
600        }
601        %>
602        <tbl:columndef 
603          id="<%="at"+at.getId()%>"
604          title="<%=HTML.encodeTags(at.getName())+" [A]"%>" 
605          property="<%="#"+at.getId()%>"
606          annotation="true"
607          datatype="<%=at.getValueType().getStringValue()%>"
608          enumeration="<%=annotationEnum%>"
609          sortable="false" 
610          filterable="true" 
611          exportable="true"
612          formatter="<%=formatter%>"
613        />
614        <%
615      }
616      %>
617      <tbl:columndef 
618        id="tools"
619        title="Tools" 
620      />
621
622      <tbl:toolbar
623        visible="<%=mode.hasToolbar()%>"
624        >
625        <tbl:button 
626          disabled="<%=createPermission ? false : true%>" 
627          image="<%=createPermission ? "new.gif" : "new_disabled.gif"%>" 
628          onclick="newItem()" 
629          title="New root bioassay set&hellip;" 
630          tooltip="<%=createPermission ? "Create a new root bioassay set" : "You do not have permission to create bioassay sets"%>" 
631          visible="<%=root == null && pluginCount.containsKey(Plugin.MainType.INTENSITY)%>"
632        />
633        <tbl:button 
634          disabled="<%=deletePermission ? false : true%>" 
635          image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
636          title="Delete"
637          onclick="deleteItems()" 
638          tooltip="<%=deletePermission ? "Delete the selected items" : "You do not have permission to delete items"%>" 
639        />
640        <tbl:button 
641          disabled="<%=writePermission ? false : true%>" 
642          image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
643          onclick="restoreItems()" 
644          title="Restore"
645          tooltip="<%=writePermission ? "Restore the selected (deleted) items" : "You do not have permission to restore items"%>" 
646        />
647        <tbl:button 
648          image="columns.gif" 
649          onclick="configureColumns()" 
650          title="Columns&hellip;" 
651          tooltip="Show, hide and re-order columns" 
652        />
653        <tbl:button 
654          image="import.gif" 
655          onclick="runPlugin('ImportItems')" 
656          title="Import&hellip;" 
657          tooltip="Import data" 
658          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
659        />
660        <tbl:button 
661          image="export.gif" 
662          onclick="runPlugin('ExportItems')" 
663          title="Export&hellip;" 
664          tooltip="Export data" 
665          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
666        />
667        <tbl:button 
668          image="runplugin.gif" 
669          onclick="runPlugin('RunListPlugin')" 
670          title="Run plugin&hellip;" 
671          tooltip="Run a plugin" 
672          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
673        />
674      </tbl:toolbar>
675      <tbl:data>
676        <tbl:columns>
677        <tbl:presetselector 
678          clazz="columnheader"
679          colspan="3"
680          onchange="presetOnChange()"
681        />
682        </tbl:columns>
683        <tr>
684          <tbl:header 
685            clazz="index"
686            >&nbsp;</tbl:header>
687          <tbl:header 
688            clazz="check" 
689            visible="<%=mode.hasCheck()%>"
690            ><base:icon 
691              image="check_uncheck.gif" 
692              tooltip="Check/uncheck all" 
693              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
694            /></tbl:header>
695          <tbl:header 
696            clazz="check" 
697            visible="<%=mode.hasRadio()%>"
698            />
699          <tbl:header 
700            clazz="icons" 
701            visible="<%=mode.hasIcons()%>"
702            >&nbsp;</tbl:header>
703          <tbl:propertyfilter />
704        </tr>
705   
706          <tbl:rows>
707          <%
708          int index = cc.getPage()*cc.getRowsPerPage();
709          int selectedItemId = cc.getId();
710          if (analysisTree != null)
711          {           
712            Iterator<Tree.Entry<BasicItem>> baas = analysisTree.entryIterator(root);
713            while (baas.hasNext())
714            {
715              Tree.Entry<BasicItem> entry = baas.next();
716              BasicItem item = entry.getNode();
717              if (item != null)
718              {
719                int level = entry.getDepth() - 1;
720                int itemId = item.getId();
721                String joustId = item.getType().name() + "_" + itemId;
722                String name = "";
723                String description = "";
724                String tooltip = mode.isSelectionMode() ?
725                    "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
726                boolean removed = false;
727                Transformation t = null;
728                BioAssaySet bas = null;
729                ExtraValue xv = null;
730                PluginDefinition plugin = null;
731                Job job = null;
732                String prefix = "";
733                ItemContext ccc = null;
734                String view = "";
735                String onClick = "";
736                Item itemType = item.getType();
737                if (itemType == Item.TRANSFORMATION)
738                {
739                  t = (Transformation)item;
740                  removed = t.isRemoved();
741                  prefix = "T:";
742                  ccc = tc;
743                  onClick = "transformationOnClick";
744                  name = HTML.encodeTags(t.getName());
745                  description = HTML.encodeTags(t.getDescription());
746                  try
747                  {
748                    job = t.getJob();
749                    plugin = job.getPluginDefinition();
750                  }
751                  catch (Throwable ex)
752                  {}
753                }
754                else if (itemType == Item.BIOASSAYSET)
755                {
756                  bas = (BioAssaySet)item;
757                  removed = bas.isRemoved();
758                  ccc = cc;
759                  onClick = "bioAssaySetOnClick";
760                  name = HTML.encodeTags(bas.getName());
761                  description = HTML.encodeTags(bas.getDescription());
762                }
763                else if (itemType == Item.EXTRAVALUE)
764                {
765                  xv = (ExtraValue)item;
766                  prefix = "X:";
767                  removed = false;
768                  ccc = xvc;
769                  onClick = "extraValueOnClick";
770                  try
771                  {
772                    ExtraValueType xvType = xv.getExtraValueType();
773                    name = HTML.encodeTags(xvType.getName());
774                    description = HTML.encodeTags(xvType.getDescription());
775                  }
776                  catch (PermissionDeniedException ex)
777                  {
778                    name = xv.getValueType().toString();
779                    description = "";
780                  }
781                  try
782                  {
783                    job = xv.getJob();
784                    plugin = job.getPluginDefinition();
785                  }
786                  catch (Throwable ex)
787                  {}
788                }
789               
790                index++;
791                numListed++;
792
793                %>
794                <tbl:row
795                  id="<%="row."+joustId%>"
796                  >
797                  <tbl:header 
798                    clazz="index"
799                    ><%=index%></tbl:header>
800                  <tbl:header 
801                    clazz="check" 
802                    visible="<%=mode.hasCheck()%>"
803                    ><input 
804                        type="checkbox" 
805                        name="<%=prefix+itemId%>" 
806                        value="<%=itemId%>" 
807                        title="<%=name%>" 
808                        <%=ccc.getSelected().contains(itemId) ? "checked" : ""%>
809                      ></tbl:header>
810                  <tbl:header 
811                    clazz="check" 
812                    visible="<%=mode.hasRadio()%>"
813                    ><input 
814                        type="radio" 
815                        name="item_id" 
816                        value="<%=itemId%>" 
817                        title="<%=name%>" 
818                        <%=selectedItemId == itemId ? "checked" : ""%>
819                      ></tbl:header>
820                  <tbl:header 
821                    clazz="icons" 
822                    visible="<%=mode.hasIcons()%>"
823                    ><base:icon 
824                      image="deleted.gif" 
825                      tooltip="This item has been scheduled for deletion" 
826                      visible="<%=removed%>"
827                    />&nbsp;</tbl:header>
828                 
829                  <tbl:cell clazz="joustcell" column="name">
830                    <div id="tree.<%=joustId%>" class="link" 
831                      onclick="<%=onClick%>(<%=writePermission ? "event" : null%>, <%=itemId%>)" 
832                      title="<%=tooltip%>"><%=name%>
833                    </div>
834                  </tbl:cell>
835                  <%
836                  if (t != null)
837                  {
838                    %>
839                    <tbl:cell column="spots">&nbsp;</tbl:cell>
840                    <tbl:cell column="reporters">&nbsp;</tbl:cell>
841                    <tbl:cell column="tools">
842                      <nobr>
843                      <%
844                      if (createPermission && job != null && plugin != null && plugin.isInteractive())
845                      {
846                        %>
847                        <a href="javascript:copyJob(<%=job.getId()%>)" 
848                          title="Copy this transformation"><img 
849                          src="../../../images/copy.gif" border="0"></a>
850                        <%
851                      }
852                      %>
853                      </nobr>
854                    </tbl:cell>
855                    <%
856                  }
857                  if (bas != null)
858                  {
859                    %>
860                    <tbl:cell column="spots"><%=bas.getNumSpots()%></tbl:cell>
861                    <tbl:cell column="reporters"><%=bas.getNumReporters()%></tbl:cell>
862                    <tbl:cell column="date">&nbsp;</tbl:cell>
863                    <tbl:cell column="plugin">&nbsp;</tbl:cell>
864                    <%
865                    AnnotationSet as = bas.isAnnotated() ? bas.getAnnotationSet() : null;
866                    if (as != null)
867                    {
868                      for (AnnotationType at : annotationTypes)
869                      {
870                        if (as.hasAnnotation(at))
871                        {
872                          %>
873                          <tbl:cell column="<%="at"+at.getId()%>"
874                            ><tbl:cellvalue 
875                            list="<%=as.getAnnotation(at).getValues()%>" 
876                          /></tbl:cell>
877                          <%
878                        }
879                      }
880                    }
881                    %>
882                    <tbl:cell column="tools">
883                      <nobr>
884                      <a href="javascript:openPlotTool(<%=itemId%>)" 
885                        title="A simple plot tool"><img 
886                        src="../../../images/plotter.gif" border="0"></a>
887                      <a href="javascript:openExperimentExplorer(<%=itemId%>)"
888                        title="Experiment explorer"><img
889                        src="../../../images/explorer.png" border="0"></a>
890                      <a href="javascript:launchMeV(<%=itemId%>)"
891                        title="MeV: MultiExperiment Viewer"><img
892                        src="../../../images/tm4.png" border="0"></a>
893                      <a href="javascript:runExportPlugin(<%=itemId%>)"
894                        title="Export data"><img 
895                        src="../../../images/export.gif" border="0"></a>
896                      <%
897                      if (createPermission)
898                      {
899                        %>
900                        <a href="javascript:filter(<%=itemId%>)" 
901                          title="Create a filtered bioassay set"><img 
902                          src="../../../images/filter.gif" border="0"></a>
903                        <a href="javascript:runAnalysisPlugin(<%=itemId%>)" title="Run an analysis plugin"><img 
904                          src="../../../images/runplugin.gif" border="0"></a>
905                        <%
906                      }
907                      %>
908                      </nobr>
909                    </tbl:cell>
910                    <%
911                  }
912                  if (xv != null)
913                  {
914                    %>
915                    <tbl:cell column="spots"><%=xv.getNumValues()%></tbl:cell>
916                    <tbl:cell column="reporters">&nbsp;</tbl:cell>
917                    <tbl:cell column="tools">
918                      <nobr>
919                      <%
920                      if (createPermission && job != null && plugin != null && plugin.isInteractive())
921                      {
922                        %>
923                        <a href="javascript:copyJob(<%=job.getId()%>)" 
924                          title="Copy this extra value"><img 
925                          src="../../../images/copy.gif" border="0"></a>
926                        <%
927                      }
928                      %>
929                      </nobr>
930                    </tbl:cell>
931                    <%
932                  }
933                  %>
934                  <tbl:cell column="date"><%=job == null ? "" : dateTimeFormatter.format(job.getEnded())%></tbl:cell>
935                  <tbl:cell column="plugin"><%=plugin == null ? "" : Base.getLinkedName(ID, plugin, false, true)%></tbl:cell>
936                  <tbl:cell column="description"><%=description%></tbl:cell>
937                </tbl:row>
938                <%
939              }
940            }
941          }
942          %>
943          </tbl:rows>
944        </tbl:data>
945      <%
946      if (numListed == 0)
947      {
948        %>
949        <tbl:panel>No bioassay sets or transformations were found.</tbl:panel>
950        <%
951      }
952      %>
953    </tbl:table>
954
955
956    <script language="JavaScript">
957    initTree();
958    </script>
959  </base:body>
960  </base:page>
961  <%
962}
963finally
964{
965  if (dc != null) dc.close();
966}
967%>
Note: See TracBrowser for help on using the repository browser.