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

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

Fixes #1611: Checkbox enabled lists for enumerated annotations

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