source: trunk/www/my_base/projects/view_project.jsp @ 5939

Last change on this file since 5939 was 5939, checked in by Nicklas Nordborg, 11 years ago

References #1655: GUI improvements

View pages for:

  • File server
  • Projects
  • Permission templates
  • Physical, derived and raw bioassays
  • Experiments, bioassay set
  • Formulas
  • Reporters
  • Reporter lists
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 14.7 KB
Line 
1<%-- $Id: view_project.jsp 5939 2012-01-30 14:42:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@page import="net.sf.basedb.core.Subtypable"%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.BasicItem"
29  import="net.sf.basedb.core.Nameable"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.SystemItems"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Include"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.Project"
37  import="net.sf.basedb.core.User"
38  import="net.sf.basedb.core.Group"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.ItemResultList"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.RawDataType"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.clients.web.Base"
49  import="net.sf.basedb.clients.web.PermissionUtil"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.util.Values"
52  import="net.sf.basedb.util.formatter.Formatter"
53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
54  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
55  import="net.sf.basedb.clients.web.extensions.JspContext"
56  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
57  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
58  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
59  import="java.util.Date"
60  import="java.util.Map"
61  import="java.util.Set"
62  import="java.util.List"
63%>
64<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
67<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
68<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
69<%!
70  private static final Item itemType = Item.PROJECT;
71  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
72%>
73<%
74final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
75final String ID = sc.getId();
76final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
77final int itemId = cc.getId();
78final String tab = Values.getString(request.getParameter("tab"), "properties");
79final float scale = Base.getScale(sc);
80final DbControl dc = sc.newDbControl();
81try
82{
83  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
84  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
85
86  String title = null;
87  Project project = Project.getById(dc, itemId);
88 
89  final boolean usePermission = project.hasPermission(Permission.USE);
90  final boolean writePermission = project.hasPermission(Permission.WRITE);
91  final boolean deletePermission = project.hasPermission(Permission.DELETE);
92  final boolean setOwnerPermission = project.hasPermission(Permission.SET_OWNER);
93  final boolean isRemoved = project.isRemoved();
94  final boolean isUsed = isRemoved && project.isUsed();
95  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
96  final boolean isOwner = project.isOwner();
97  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, project);
98  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
99  %>
100  <base:page title="<%=title%>">
101  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
102    <ext:scripts context="<%=jspContext%>" />
103    <ext:stylesheets context="<%=jspContext%>" />
104    <script language="JavaScript">
105    function editItem()
106    {
107      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
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 deleteItemPermanently()
118    {
119      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
120    }
121    function itemDeleted()
122    {
123      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
124    }
125    function showUsingItems()
126    {
127      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
128    }
129    function setOwner()
130    {
131      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
132    }
133    function runPlugin(cmd)
134    {
135      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
136    }
137    function setToActive()
138    {
139      Main.openPopup('set_active.jsp?ID=<%=ID%>&project_id=<%=itemId%>', 'ActivateProject', 300, 140);
140    }
141    function viewItems()
142    {
143      location.href = 'items/index.jsp?ID=<%=ID%>&project_id=<%=itemId%>';
144    }
145    function switchTab(tabControlId, tabId)
146    {
147      if (tabId == 'items')
148      {
149        viewItems();
150      }
151      else
152      {
153        TabControl.setActiveTab(tabControlId, tabId);
154      }
155    }
156    </script>
157  </base:head>
158  <base:body>
159    <p:path><p:pathelement 
160      title="Projects" href="<%="index.jsp?ID="+ID%>" 
161      /><p:pathelement title="<%=HTML.encodeTags(project.getName())%>" 
162      /></p:path>
163   
164    <t:tabcontrol 
165      id="main" 
166      subclass="content mastertabcontrol" 
167      active="<%=tab%>" switch="switchTab">
168    <t:tab id="properties" title="Properties">
169      <div>
170      <table class="fullform bottomborder">
171      <tr>
172        <th class="itemstatus">
173          <base:icon 
174            image="deleted.gif"
175            onclick="deleteItemPermanently()"
176            tooltip="This item has been flagged for deletion. Click to delete it now."
177            enabled="<%=deletePermanentlyPermission %>"
178            visible="<%=isRemoved%>" 
179          />
180          <base:icon image="used.gif" 
181            onclick="showUsingItems()"
182            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
183            visible="<%=isRemoved && isUsed%>" />
184        </th>
185        <td style="padding: 0px;">
186          <tbl:toolbar subclass="bottomborder">
187            <tbl:button 
188              disabled="<%=writePermission ? false : true%>" 
189              image="edit.gif" 
190              onclick="editItem()" 
191              title="Edit&hellip;" 
192              tooltip="<%=writePermission ? "Edit this project" : "You do not have permission to edit this project"%>" 
193            />
194            <tbl:button 
195              disabled="<%=deletePermission ? false : true%>" 
196              image="delete.gif" 
197              onclick="deleteItem()" 
198              title="Delete"
199              visible="<%=!project.isRemoved()%>"
200              tooltip="<%=deletePermission ? "Delete this project" : "You do not have permission to delete this project"%>" 
201            />
202            <tbl:button 
203              disabled="<%=writePermission ? false : true%>" 
204              image="restore.gif" 
205              onclick="restoreItem()" 
206              title="Restore"
207              visible="<%=project.isRemoved()%>"
208              tooltip="<%=writePermission ? "Restore this project" : "You do not have permission to restore this project"%>" 
209            />
210            <tbl:button 
211              disabled="<%=setOwnerPermission ? false : true%>"
212              image="take_ownership.png"
213              onclick="setOwner()" 
214              title="Set owner&hellip;"
215              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
216            />
217            <tbl:button 
218              onclick="setToActive()" 
219              image="bullet.gif"
220              title="Set active"
221              tooltip="Set this project to the active project"
222            />
223            <tbl:button 
224              image="import.gif" 
225              onclick="runPlugin('ImportItem')" 
226              title="Import&hellip;" 
227              tooltip="Import data" 
228              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
229            />
230            <tbl:button 
231              image="export.gif" 
232              onclick="runPlugin('ExportItem')" 
233              title="Export&hellip;" 
234              tooltip="Export data" 
235              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
236            />
237            <tbl:button 
238              image="runplugin.gif" 
239              onclick="runPlugin('RunPlugin')" 
240              title="Run plugin&hellip;" 
241              tooltip="Run a plugin" 
242              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
243            />
244            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
245              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
246            <tbl:button
247              image="help.png"
248              onclick="<%="Main.openHelp('" + ID +"', 'project.view.properties')"%>"
249              title="Help&hellip;"
250              tooltip="Get help about this page"
251            />
252          </tbl:toolbar>
253        </td>
254      </tr>
255      <tr>
256        <th>Name</th>
257        <td><%=HTML.encodeTags(project.getName())%></td>
258      </tr>
259      <tr>
260        <th>Registered</th>
261        <td><%=dateFormatter.format(project.getEntryDate())%></td>
262      </tr>
263      <tr>
264        <th>Owner</th>
265        <td><base:propertyvalue item="<%=project%>" property="owner" /></td>
266      </tr>
267      <tr>
268        <th>Default permissions</th>
269        <td><base:propertyvalue item="<%=project%>" property="permissionTemplate" 
270          nulltext="<%=PermissionUtil.getFullPermissionNames(project.getAutoPermission())%>" /></td>
271      </tr>
272      <tr>
273        <th>Your permissions</th>
274        <td><%=PermissionUtil.getFullPermissionNames(project)%></td>
275      </tr>
276      <tr>
277        <th>Description</th>
278        <td><%=HTML.niceFormat(project.getDescription())%></td>
279      </tr>
280      </table>
281      <%
282      // Query to retrieve child groups
283      ItemQuery<Group> groupQuery = project.getGroups();
284      groupQuery.include(Include.ALL);
285      groupQuery.order(Orders.asc(Hql.property("name")));
286      ItemResultList<Group> groups = groupQuery.list(dc);
287     
288      // Query to retrieve user members
289      ItemQuery<User> userQuery = project.getUsers();
290      userQuery.include(Include.ALL);
291      userQuery.order(Orders.asc(Hql.property("name")));
292      ItemResultList<User> users = userQuery.list(dc);
293      int numMembers = groups.size() + users.size();
294      %>
295      <base:section
296        id="membersSection"
297        title="<%="Members (" + numMembers + ")"%>"
298        context="<%=cc%>"
299        >
300        <% 
301        if (numMembers == 0)
302        {
303          %>
304          <div class="messagecontainer note">
305          There are no members in this project
306          (or, you don't have permission to view them).
307          </div>
308          <%
309        }
310        else
311        {
312          %>
313          <tbl:table
314            id="members"
315            columns="all"
316            >
317            <tbl:columndef
318              id="type"
319              title="User/Group"
320            />
321            <tbl:columndef
322              id="name"
323              title="Name"
324            />
325            <tbl:columndef
326              id="permissions"
327              title="Permissions"
328            />
329            <tbl:data>
330            <tbl:headers>
331              <tbl:headerrow>
332                <tbl:columnheaders />
333              </tbl:headerrow>
334            </tbl:headers>
335            <tbl:rows>
336            <%         
337            for (Group group : groups)
338            {
339              Set<Permission> permissions = project.getPermissions(group);
340              %>
341              <tbl:row>
342                <tbl:cell column="type">Group</tbl:cell>
343                <tbl:cell column="name"><base:icon 
344                    image="deleted.gif" 
345                    tooltip="This item has been scheduled for deletion" 
346                    visible="<%=group.isRemoved()%>"
347                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
348                <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
349              </tbl:row>
350              <%
351            }
352            for (User user : users)
353            {
354              Set<Permission> permissions = project.getPermissions(user);
355              %>
356              <tbl:row>
357                <tbl:cell column="type">User</tbl:cell>
358                <tbl:cell column="name"><base:icon 
359                    image="deleted.gif" 
360                    tooltip="This item has been scheduled for deletion" 
361                    visible="<%=user.isRemoved()%>"
362                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
363                <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
364              </tbl:row>
365              <%
366            }
367            %>
368            </tbl:rows>
369          </tbl:data>
370        </tbl:table>
371        <%
372      }
373      %>
374      </base:section>
375      <%
376      List<BasicItem> defaultItems = project.getDefaultItems(dc);
377      %>
378      <base:section 
379        id="defaultSection" 
380        title="Default items"
381        context="<%=cc%>"
382        >
383        <%
384        if (defaultItems.size() == 0 && project.getDefaultRawDataType() == null)
385        {
386          %>
387          <div class="messagecontainer note">
388          There are no default items in this project
389          (or, you don't have permission to view them).
390          </div>
391          <%
392        }
393        else
394        {
395          %>
396          <tbl:table 
397            id="defaults"
398            columns="all"
399          >
400          <tbl:columndef
401            id="item"
402            title="Item"
403          />
404          <tbl:columndef
405            id="type"
406            title="Type"
407          />
408          <tbl:data>
409            <tbl:headers>
410              <tbl:headerrow>
411                <tbl:columnheaders />
412              </tbl:headerrow>
413            </tbl:headers>
414            <tbl:rows>     
415            <%
416            if (project.getDefaultRawDataType() != null)
417            {
418              %>
419              <tbl:row>
420                <tbl:cell column="item"><%=project.getDefaultRawDataType().getName()%></tbl:cell>
421                <tbl:cell column="type">Raw data type</tbl:cell>
422              </tbl:row>
423              <%
424            }
425            for (BasicItem item : defaultItems)
426            {
427              %>
428              <tbl:row>
429                <tbl:cell column="item"><base:propertyvalue item="<%=item%>" /></tbl:cell>
430                <tbl:cell column="type">
431                  <%
432                  if (item instanceof Subtypable)
433                  {
434                    %>
435                    <base:propertyvalue item="<%=item%>" property="itemSubtype" nulltext="" /> (<%=item.getType()%>)
436                    <%
437                  }
438                  else
439                  {
440                    %>
441                    <%=item.getType()%>
442                    <%
443                  }
444                  %>
445                </tbl:cell>
446              </tbl:row>
447              <%
448            }
449            %>
450            </tbl:rows>
451          </tbl:data>
452        </tbl:table>
453        <%
454      }
455      %>
456      </base:section>
457      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
458        <jsp:param name="ID" value="<%=ID%>" />
459        <jsp:param name="item_type" value="<%=itemType.name()%>" />
460        <jsp:param name="item_id" value="<%=itemId%>" />
461        <jsp:param name="title" value="Other items related to this project" />
462      </jsp:include>
463    </t:tab>
464     
465    <t:tab id="items" title="Items" tooltip="List all items in this project" />
466     
467    </t:tabcontrol>
468
469  </base:body>
470  </base:page>
471  <%
472  dc.commit();
473}
474finally
475{
476  if (dc != null) dc.close();
477}
478
479%>
Note: See TracBrowser for help on using the repository browser.