source: trunk/www/lims/arraydesigns/view_design.jsp @ 3610

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

References #360: Make subsections on view pages hideable

Infrastructure is now in place. See below for examples.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 16.8 KB
Line 
1<%-- $Id: view_design.jsp 3610 2007-07-27 12:53:11Z 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.SystemItems"
31  import="net.sf.basedb.core.Group"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.ItemResultIterator"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.AnnotationType"
37  import="net.sf.basedb.core.AnnotationSet"
38  import="net.sf.basedb.core.ArrayDesign"
39  import="net.sf.basedb.core.ArrayBatch"
40  import="net.sf.basedb.core.Affymetrix"
41  import="net.sf.basedb.core.File"
42  import="net.sf.basedb.core.ArrayDesignPlate"
43  import="net.sf.basedb.core.Plate"
44  import="net.sf.basedb.core.User"
45  import="net.sf.basedb.core.ItemQuery"
46  import="net.sf.basedb.core.Include"
47  import="net.sf.basedb.core.ItemResultList"
48  import="net.sf.basedb.core.MultiPermissions"
49  import="net.sf.basedb.core.PermissionDeniedException"
50  import="net.sf.basedb.core.PluginDefinition"
51  import="net.sf.basedb.core.plugin.GuiContext"
52  import="net.sf.basedb.core.plugin.Plugin"
53  import="net.sf.basedb.core.Project"
54  import="net.sf.basedb.core.query.Orders"
55  import="net.sf.basedb.core.query.Hql"
56  import="net.sf.basedb.clients.web.Base"
57  import="net.sf.basedb.clients.web.PermissionUtil"
58  import="net.sf.basedb.clients.web.util.HTML"
59  import="net.sf.basedb.util.Values"
60  import="java.util.Collections"
61  import="java.util.Date"
62  import="java.util.Map"
63  import="java.util.Set"
64  import="java.util.List"
65%>
66<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
67<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
68<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
69<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
70<%!
71  private static final Item itemType = Item.ARRAYDESIGN;
72  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
73%>
74<%
75final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
76final String ID = sc.getId();
77final String root = request.getContextPath()+"/";
78final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
79final int itemId = cc.getId();
80final String tab = Values.getString(request.getParameter("tab"), "properties");
81final float scale = Base.getScale(sc);
82final DbControl dc = sc.newDbControl();
83try
84{
85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
86
87  String title = null;
88  ArrayDesign design = ArrayDesign.getById(dc, itemId);
89 
90  final boolean usePermission = design.hasPermission(Permission.USE);
91  final boolean writePermission = design.hasPermission(Permission.WRITE);
92  final boolean deletePermission = design.hasPermission(Permission.DELETE);
93  final boolean sharePermission = design.hasPermission(Permission.SET_PERMISSION);
94  final boolean setOwnerPermission = design.hasPermission(Permission.SET_OWNER);
95  final boolean isOwner = design.isOwner();
96  %>
97
98  <base:page title="<%=title%>">
99  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
100    <script language="JavaScript">
101    function editItem()
102    {
103      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
104    }
105    function shareItem()
106    {
107      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareArrayDesign', 500, 400);
108    }
109    function deleteItem()
110    {
111      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
112    }
113    function restoreItem()
114    {
115      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
116    }
117    function takeOwnership()
118    {
119      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
120      {
121        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
122      }
123    }
124    function runPlugin(cmd)
125    {
126      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
127    }
128    function viewFeatures()
129    {
130      location.href = 'features/index.jsp?ID=<%=ID%>&arraydesign_id=<%=itemId%>';
131    }
132    function managePlates()
133    {
134      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ManagePlates&item_id=<%=itemId%>', 'ManagePlates', 600, 400);
135    }
136    function switchTab(tabControlId, tabId)
137    {
138      if (tabId == 'features')
139      {
140        viewFeatures();
141      }
142      else
143      {
144        TabControl.setActiveTab(tabControlId, tabId);
145      }
146    }
147    function newBatch()
148    {
149      Main.viewOrEditItem('<%=ID%>', 'ARRAYBATCH', 0, true, '&arraydesign_id=<%=itemId%>');
150    }
151    function verifyReporters()
152    {
153      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=VerifyReporters&item_id=<%=itemId%>', 'VerifyReporters', 740, 540);
154    }
155    </script>
156  </base:head>
157  <base:body>
158    <p>
159    <p:path>
160      <p:pathelement title="Array designs" href="<%="index.jsp?ID="+ID%>" />
161      <p:pathelement title="<%=HTML.encodeTags(design.getName())%>" />
162    </p:path>
163   
164    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
165    <t:tab id="properties" title="Properties">
166    <tbl:toolbar
167      >
168      <tbl:button 
169        disabled="<%=writePermission ? false : true%>" 
170        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
171        onclick="editItem()" 
172        title="Edit&hellip;" 
173        tooltip="<%=writePermission ? "Edit this array design" : "You do not have permission to edit this array design"%>" 
174      />
175      <tbl:button 
176        disabled="<%=deletePermission ? false : true%>" 
177        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
178        onclick="deleteItem()" 
179        title="Delete"
180        visible="<%=!design.isRemoved()%>"
181        tooltip="<%=deletePermission ? "Delete this array design" : "You do not have permission to delete this array design"%>" 
182      />
183      <tbl:button 
184        disabled="<%=writePermission ? false : true%>" 
185        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
186        onclick="restoreItem()" 
187        title="Restore"
188        visible="<%=design.isRemoved()%>"
189        tooltip="<%=writePermission ? "Restore this array design" : "You do not have permission to restore this array design"%>" 
190      />
191      <tbl:button 
192        disabled="<%=sharePermission ? false : true%>"
193        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
194        onclick="shareItem()" 
195        title="Share&hellip;" 
196        tooltip="<%=sharePermission ? "Share this array design to other user, groups and projects" : "You do not have permission to share this array design"%>"
197      />
198      <tbl:button 
199        disabled="<%=setOwnerPermission ? false : true%>"
200        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
201        onclick="takeOwnership()" 
202        title="Take ownership&hellip;"
203        visible="<%=!isOwner%>"
204        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
205      />
206      <tbl:button
207        image="add.png"
208        onclick="newBatch()"
209        title="New batch&hellip;"
210        tooltip="Create a new array batch with this design"
211        visible="<%=sc.hasPermission(Permission.CREATE, Item.ARRAYBATCH) && usePermission%>"
212      />
213      <tbl:button 
214        image="import.gif" 
215        onclick="runPlugin('ImportItem')" 
216        title="Import&hellip;" 
217        tooltip="Import data" 
218        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
219      />
220      <tbl:button 
221        image="export.gif" 
222        onclick="runPlugin('ExportItem')" 
223        title="Export&hellip;" 
224        tooltip="Export data" 
225        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
226      />
227      <tbl:button 
228        image="runplugin.gif" 
229        onclick="runPlugin('RunPlugin')" 
230        title="Run plugin&hellip;" 
231        tooltip="Run a plugin" 
232        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
233      />
234      <tbl:button 
235        onclick="managePlates()"
236        title="Manage plates&hellip;"
237        tooltip="Attach / detach plates to this array design"
238        visible="<%=writePermission && !design.hasFeatures() && !design.isAffyChip()%>"
239      />
240      <tbl:button
241        image="help.gif"
242        onclick="<%="Main.openHelp('" + ID +"', 'arraydesign.view.properties')"%>"
243        title="Help&hellip;"
244        tooltip="Get help about this page"
245      />
246      </tbl:toolbar>
247     
248    <div class="boxedbottom">
249      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(design)%></i></div>
250      <%
251      if (design.isRemoved() || design.isShared())
252      {
253        %>
254        <div class="itemstatus">
255          <base:icon image="deleted.gif" 
256            visible="<%=design.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
257          <base:icon image="shared.gif" 
258            visible="<%=design.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
259        </div>
260        <%
261      }
262      %>
263      <table class="form" cellspacing="0">
264      <tr>
265        <td class="prompt">Name</td>
266        <td><%=HTML.encodeTags(design.getName())%></td>
267      </tr>
268      <tr>
269        <td class="prompt">Affy chip</td>
270        <td><%=design.isAffyChip() ? "yes" : "no"%></td>
271      </tr>
272      <%
273      if (design.isAffyChip())
274      {
275        boolean readCurrentCdfFile = true;
276        File currentCdfFile = null; 
277        try
278        {
279          currentCdfFile = Affymetrix.getCdfFile(design);
280        }
281        catch (PermissionDeniedException ex)
282        {
283          readCurrentCdfFile = false;
284        }
285        %>
286        <tr>
287          <td class="prompt">CDF file</td>
288          <td>
289            <%=Base.getLinkedFile(ID, currentCdfFile, !readCurrentCdfFile, true, true, root)%>
290            <%
291            if (currentCdfFile != null)
292            {
293              try
294              {
295                PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.CdfFileReporterImporter");
296                %>
297                [<a href="javascript:verifyReporters()">verify reporters</a>]
298                <%
299              }
300              catch (Throwable t)
301              {}
302            }
303            %>
304          </td>
305        </tr>
306        <%
307      }
308      %>
309      <tr>
310        <td class="prompt">Features</td>
311        <td><%=design.hasFeatures() ? "yes (" + design.getNumFeatures(dc) + ")" : "no"%></td>
312      </tr>
313      <tr>
314        <td class="prompt">Owner</td>
315        <td><base:propertyvalue item="<%=design%>" property="owner" /></td>
316      </tr>
317      <tr>
318        <td class="prompt">Description</td>
319        <td><%=HTML.niceFormat(design.getDescription())%></td>
320      </tr>
321      </table>
322     
323      <%
324      ItemQuery<ArrayBatch> batchQuery = design.getArrayBatches();
325      batchQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
326      batchQuery.order(Orders.asc(Hql.property("name")));
327      ItemResultList<ArrayBatch> batches = batchQuery.list(dc);
328      if (batches.size() == 0)
329      {
330        %>
331        <h4>Array batches</h4>
332        No batches exists for this design
333        (or, you don't have permission to view them).
334        <%
335      }
336      else
337      {
338        %>
339        <base:section 
340          id="batches" 
341          title="<%="Array batches (" + batches.size() +")"%>"
342          context="<%=cc%>">
343        <tbl:table
344          id="batches"
345          clazz="itemlist"
346          columns="all"
347          >
348        <tbl:columndef 
349          id="name"
350          title="Name"
351        />
352        <tbl:columndef 
353          id="description"
354          title="Description"
355        />
356        <tbl:data>
357          <tbl:columns>
358          </tbl:columns>
359          <tbl:rows>
360          <%
361          for (ArrayBatch item : batches)
362          {
363            %>
364            <tbl:row>
365              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
366              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
367            </tbl:row>
368            <%
369          }
370          %>
371          </tbl:rows>
372        </tbl:data>
373        </tbl:table>
374        </base:section>
375        <%
376      }
377      %>
378     
379      <%
380      ItemQuery<ArrayDesignPlate> platesQuery = design.getArrayDesignPlates();
381      platesQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
382      platesQuery.order(Orders.asc(Hql.property("position")));
383      ItemResultList<ArrayDesignPlate> plates = platesQuery.list(dc);
384      if (plates.size() == 0)
385      {
386        %>
387        <h4>Plates</h4>
388        This array design isn't connected to any plates (or, you don't have permission to view them).
389        <%
390      }
391      else
392      {
393        %>
394        <base:section 
395          id="plates" 
396          title="<%="Plates (" + plates.size() +")"%>" 
397          context="<%=cc%>">
398        <tbl:table
399          id="plates"
400          clazz="itemlist"
401          columns="all"
402          >
403        <tbl:columndef 
404          id="name"
405          title="Name"
406        />
407        <tbl:columndef 
408          id="position"
409          title="Position"
410        />
411        <tbl:columndef 
412          id="description"
413          title="Description"
414        />
415        <tbl:data>
416          <tbl:columns>
417          </tbl:columns>
418          <tbl:rows>
419          <%
420          for (ArrayDesignPlate item : plates)
421          {
422            Plate plate = null;
423            boolean readPlate = true;
424            try
425            {
426              plate = item.getPlate();
427            }
428            catch (PermissionDeniedException ex)
429            {
430              readPlate = false;
431            }
432            %>
433            <tbl:row>
434              <tbl:cell column="name"><%=Base.getLinkedName(ID, plate, !readPlate, true)%></tbl:cell>
435              <tbl:cell column="position"><%=item.getPosition()+1%></tbl:cell>
436              <tbl:cell column="description"><%=HTML.encodeTags(plate == null ? "" : plate.getDescription())%></tbl:cell>
437            </tbl:row>
438            <%
439          }
440          %>
441          </tbl:rows>
442        </tbl:data>
443        </tbl:table>
444        </base:section>
445        <%
446      }
447      %>
448     
449
450      <%
451      // Tables with users/groups/projects that this item is shared to
452      MultiPermissions mp = new MultiPermissions(Collections.singleton(design));
453      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
454      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
455      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
456     
457      if (users.hasNext() || groups.hasNext() || projects.hasNext())
458      {
459        %>
460        <base:section 
461          id="sharedTo" 
462          title="Shared to"
463          context="<%=cc%>">
464        <tbl:table 
465          id="itemsSharedTo"
466          clazz="itemlist"
467          columns="all"
468        >
469          <tbl:columndef 
470            id="itemType"
471            title="Item type"
472          />
473          <tbl:columndef 
474            id="name"
475            title="Name"
476          />
477          <tbl:columndef 
478            id="permissions"
479            title="Permissions"
480          />
481          <tbl:data>
482            <tbl:columns>
483            </tbl:columns>
484            <tbl:rows>
485            <%
486            while(projects.hasNext())
487            {
488              Project project = projects.next();
489              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
490              %>     
491              <tbl:row>
492                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
493                <tbl:cell column="name"><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
494                <tbl:cell column="permissions">
495                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
496                </tbl:cell>
497              </tbl:row>
498              <%
499            }
500            while(groups.hasNext())
501            {
502              Group group = groups.next();
503              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
504              %>
505              <tbl:row>             
506                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
507                <tbl:cell column="name"><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
508                <tbl:cell column="permissions">
509                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
510                </tbl:cell>
511              </tbl:row>
512              <% 
513            }
514            while (users.hasNext())
515            {
516              User user = users.next();
517              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
518              %>
519              <tbl:row>             
520                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
521                <tbl:cell column="name"><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
522                <tbl:cell column="permissions">
523                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
524                </tbl:cell>
525              </tbl:row>
526              <%
527            }
528            %>
529            </tbl:rows>
530          </tbl:data>
531        </tbl:table>
532        </base:section>
533        <%
534      }
535      else
536      {
537        %>
538        <h4>Shared to</h4>
539        This array design is not shared
540        (or, you don't have permission to view the ones it is shared to).
541        <%
542      }
543      %>     
544     
545    </div>
546      </t:tab>
547     
548      <t:tab id="annotations" title="Annotations" >
549        <div class="boxed">
550        <jsp:include page="../../common/annotations/list_annotations.jsp">
551          <jsp:param name="item_type" value="<%=itemType.name()%>" />
552          <jsp:param name="item_id" value="<%=itemId%>" />
553          <jsp:param name="ID" value="<%=ID%>" />
554        </jsp:include>
555        </div>
556      </t:tab>
557     
558      <t:tab id="features" title="Features" visible="<%=design.hasFeatures() && !design.isAffyChip()%>"/>
559      </t:tabcontrol>
560
561  </base:body>
562  </base:page>
563  <%
564}
565finally
566{
567  if (dc != null) dc.close();
568}
569
570%>
Note: See TracBrowser for help on using the repository browser.