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

Last change on this file since 4187 was 4187, checked in by Nicklas Nordborg, 15 years ago

Merged extensions branch into trunk

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