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

Last change on this file since 2978 was 2978, checked in by Nicklas Nordborg, 17 years ago

Added session="false" to all jsp pages so we no longer generate unneeded cookies

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