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

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

Fixes #498: Move Array batches on Array design view page

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 16.6 KB
Line 
1<%-- $Id: view_design.jsp 3608 2007-07-27 08:41:07Z 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    <div class="boxedbottom">
248      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(design)%></i></div>
249      <%
250      if (design.isRemoved() || design.isShared())
251      {
252        %>
253        <div class="itemstatus">
254          <base:icon image="deleted.gif" 
255            visible="<%=design.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
256          <base:icon image="shared.gif" 
257            visible="<%=design.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
258        </div>
259        <%
260      }
261      %>
262      <table class="form" cellspacing="0">
263      <tr>
264        <td class="prompt">Name</td>
265        <td><%=HTML.encodeTags(design.getName())%></td>
266      </tr>
267      <tr>
268        <td class="prompt">Affy chip</td>
269        <td><%=design.isAffyChip() ? "yes" : "no"%></td>
270      </tr>
271      <%
272      if (design.isAffyChip())
273      {
274        boolean readCurrentCdfFile = true;
275        File currentCdfFile = null; 
276        try
277        {
278          currentCdfFile = Affymetrix.getCdfFile(design);
279        }
280        catch (PermissionDeniedException ex)
281        {
282          readCurrentCdfFile = false;
283        }
284        %>
285        <tr>
286          <td class="prompt">CDF file</td>
287          <td>
288            <%=Base.getLinkedFile(ID, currentCdfFile, !readCurrentCdfFile, true, true, root)%>
289            <%
290            if (currentCdfFile != null)
291            {
292              try
293              {
294                PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.CdfFileReporterImporter");
295                %>
296                [<a href="javascript:verifyReporters()">verify reporters</a>]
297                <%
298              }
299              catch (Throwable t)
300              {}
301            }
302            %>
303          </td>
304        </tr>
305        <%
306      }
307      %>
308      <tr>
309        <td class="prompt">Features</td>
310        <td><%=design.hasFeatures() ? "yes (" + design.getNumFeatures(dc) + ")" : "no"%></td>
311      </tr>
312      <tr>
313        <td class="prompt">Owner</td>
314        <td><base:propertyvalue item="<%=design%>" property="owner" /></td>
315      </tr>
316      <tr>
317        <td class="prompt">Description</td>
318        <td><%=HTML.niceFormat(design.getDescription())%></td>
319      </tr>
320      </table>
321     
322      <%
323      ItemQuery<ArrayBatch> batchQuery = design.getArrayBatches();
324      batchQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
325      batchQuery.order(Orders.asc(Hql.property("name")));
326      ItemResultList<ArrayBatch> batches = batchQuery.list(dc);
327      if (batches.size() == 0)
328      {
329        %>
330        <h4>Array batches</h4>
331        No batches exists for this design
332        (or, you don't have permission to view them).
333        <%
334      }
335      else
336      {
337        %>
338        <h4 class="docked">Array batches</h4>
339        <tbl:table
340          id="batches"
341          clazz="itemlist"
342          columns="all"
343          >
344        <tbl:columndef 
345          id="name"
346          title="Name"
347        />
348        <tbl:columndef 
349          id="description"
350          title="Description"
351        />
352        <tbl:data>
353          <tbl:columns>
354          </tbl:columns>
355          <tbl:rows>
356          <%
357          for (ArrayBatch item : batches)
358          {
359            %>
360            <tbl:row>
361              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
362              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
363            </tbl:row>
364            <%
365          }
366          %>
367          </tbl:rows>
368        </tbl:data>
369        </tbl:table>
370        <%
371      }
372      %>
373     
374      <%
375      ItemQuery<ArrayDesignPlate> platesQuery = design.getArrayDesignPlates();
376      platesQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
377      platesQuery.order(Orders.asc(Hql.property("position")));
378      ItemResultList<ArrayDesignPlate> plates = platesQuery.list(dc);
379      if (plates.size() == 0)
380      {
381        %>
382        <h4>Plates</h4>
383        This array design isn't connected to any plates (or, you don't have permission to view them).
384        <%
385      }
386      else
387      {
388        %>
389        <h4 class="docked">Plates</h4>
390        <tbl:table
391          id="plates"
392          clazz="itemlist"
393          columns="all"
394          >
395        <tbl:columndef 
396          id="name"
397          title="Name"
398        />
399        <tbl:columndef 
400          id="position"
401          title="Position"
402        />
403        <tbl:columndef 
404          id="description"
405          title="Description"
406        />
407        <tbl:data>
408          <tbl:columns>
409          </tbl:columns>
410          <tbl:rows>
411          <%
412          for (ArrayDesignPlate item : plates)
413          {
414            Plate plate = null;
415            boolean readPlate = true;
416            try
417            {
418              plate = item.getPlate();
419            }
420            catch (PermissionDeniedException ex)
421            {
422              readPlate = false;
423            }
424            %>
425            <tbl:row>
426              <tbl:cell column="name"><%=Base.getLinkedName(ID, plate, !readPlate, true)%></tbl:cell>
427              <tbl:cell column="position"><%=item.getPosition()+1%></tbl:cell>
428              <tbl:cell column="description"><%=HTML.encodeTags(plate == null ? "" : plate.getDescription())%></tbl:cell>
429            </tbl:row>
430            <%
431          }
432          %>
433          </tbl:rows>
434        </tbl:data>
435        </tbl:table>
436        <%
437      }
438      %>
439     
440
441      <%
442      // Tables with users/groups/projects that this item is shared to
443      MultiPermissions mp = new MultiPermissions(Collections.singleton(design));
444      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
445      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
446      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
447     
448      if (users.hasNext() || groups.hasNext() || projects.hasNext())
449      {
450        %>
451        <h4 class="docked">Shared to</h4>
452        <tbl:table 
453          id="itemsSharedTo"
454          clazz="itemlist"
455          columns="all"
456        >
457          <tbl:columndef 
458            id="itemType"
459            title="Item type"
460          />
461          <tbl:columndef 
462            id="name"
463            title="Name"
464          />
465          <tbl:columndef 
466            id="permissions"
467            title="Permissions"
468          />
469          <tbl:data>
470            <tbl:columns>
471            </tbl:columns>
472            <tbl:rows>
473            <%
474            while(projects.hasNext())
475            {
476              Project project = projects.next();
477              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
478              %>     
479              <tbl:row>
480                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
481                <tbl:cell column="name"><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
482                <tbl:cell column="permissions">
483                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
484                </tbl:cell>
485              </tbl:row>
486              <%
487            }
488            while(groups.hasNext())
489            {
490              Group group = groups.next();
491              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
492              %>
493              <tbl:row>             
494                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
495                <tbl:cell column="name"><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
496                <tbl:cell column="permissions">
497                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
498                </tbl:cell>
499              </tbl:row>
500              <% 
501            }
502            while (users.hasNext())
503            {
504              User user = users.next();
505              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
506              %>
507              <tbl:row>             
508                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
509                <tbl:cell column="name"><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
510                <tbl:cell column="permissions">
511                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
512                </tbl:cell>
513              </tbl:row>
514              <%
515            }
516            %>
517            </tbl:rows>
518          </tbl:data>
519        </tbl:table>
520        <%
521      }
522      else
523      {
524        %>
525        <h4>Shared to</h4>
526        This array design is not shared
527        (or, you don't have permission to view the ones it is shared to).
528        <%
529      }
530      %>     
531     
532    </div>
533      </t:tab>
534     
535      <t:tab id="annotations" title="Annotations" >
536        <div class="boxed">
537        <jsp:include page="../../common/annotations/list_annotations.jsp">
538          <jsp:param name="item_type" value="<%=itemType.name()%>" />
539          <jsp:param name="item_id" value="<%=itemId%>" />
540          <jsp:param name="ID" value="<%=ID%>" />
541        </jsp:include>
542        </div>
543      </t:tab>
544     
545      <t:tab id="features" title="Features" visible="<%=design.hasFeatures() && !design.isAffyChip()%>"/>
546      </t:tabcontrol>
547
548  </base:body>
549  </base:page>
550  <%
551}
552finally
553{
554  if (dc != null) dc.close();
555}
556
557%>
Note: See TracBrowser for help on using the repository browser.