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

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

Fixes #788: Select project default platforms / variant

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.2 KB
Line 
1<%-- $Id: view_project.jsp 3847 2007-10-17 05:52:56Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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 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.BasicItem"
30  import="net.sf.basedb.core.Nameable"
31  import="net.sf.basedb.core.DbControl"
32  import="net.sf.basedb.core.SystemItems"
33  import="net.sf.basedb.core.Item"
34  import="net.sf.basedb.core.ItemContext"
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="java.util.Date"
53  import="java.util.Map"
54  import="java.util.Set"
55  import="java.util.List"
56%>
57<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
58<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
59<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
60<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
61<%!
62  private static final Item itemType = Item.PROJECT;
63  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
64%>
65<%
66final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
67final String ID = sc.getId();
68final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
69final int itemId = cc.getId();
70final String tab = Values.getString(request.getParameter("tab"), "properties");
71final float scale = Base.getScale(sc);
72final DbControl dc = sc.newDbControl();
73try
74{
75  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
76
77  String title = null;
78  Project project = Project.getById(dc, itemId);
79 
80  final boolean usePermission = project.hasPermission(Permission.USE);
81  final boolean writePermission = project.hasPermission(Permission.WRITE);
82  final boolean deletePermission = project.hasPermission(Permission.DELETE);
83  final boolean setOwnerPermission = project.hasPermission(Permission.SET_OWNER);
84  final boolean isOwner = project.isOwner();
85  %>
86
87  <base:page title="<%=title%>">
88  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
89    <script language="JavaScript">
90    function editItem()
91    {
92      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
93    }
94    function deleteItem()
95    {
96      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
97    }
98    function restoreItem()
99    {
100      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
101    }
102    function takeOwnership()
103    {
104      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
105      {
106        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
107      }
108    }
109    function runPlugin(cmd)
110    {
111      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
112    }
113    function setToActive()
114    {
115      Main.openPopup('set_active.jsp?ID=<%=ID%>&project_id=<%=itemId%>', 'ActivateProject', 300, 140);
116    }
117    function viewItems()
118    {
119      location.href = 'items/index.jsp?ID=<%=ID%>&project_id=<%=itemId%>';
120    }
121    function switchTab(tabControlId, tabId)
122    {
123      if (tabId == 'items')
124      {
125        viewItems();
126      }
127      else
128      {
129        TabControl.setActiveTab(tabControlId, tabId);
130      }
131    }
132    </script>
133  </base:head>
134  <base:body>
135    <p>
136    <p:path>
137      <p:pathelement title="Projects" href="<%="index.jsp?ID="+ID%>" />
138      <p:pathelement title="<%=HTML.encodeTags(project.getName())%>" />
139    </p:path>
140   
141    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
142    <t:tab id="properties" title="Properties">
143
144    <tbl:toolbar
145      >
146      <tbl:button 
147        disabled="<%=writePermission ? false : true%>" 
148        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
149        onclick="editItem()" 
150        title="Edit&hellip;" 
151        tooltip="<%=writePermission ? "Edit this project" : "You do not have permission to edit this project"%>" 
152      />
153      <tbl:button 
154        disabled="<%=deletePermission ? false : true%>" 
155        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
156        onclick="deleteItem()" 
157        title="Delete"
158        visible="<%=!project.isRemoved()%>"
159        tooltip="<%=deletePermission ? "Delete this project" : "You do not have permission to delete this project"%>" 
160      />
161      <tbl:button 
162        disabled="<%=writePermission ? false : true%>" 
163        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
164        onclick="restoreItem()" 
165        title="Restore"
166        visible="<%=project.isRemoved()%>"
167        tooltip="<%=writePermission ? "Restore this project" : "You do not have permission to restore this project"%>" 
168      />
169      <tbl:button 
170        disabled="<%=setOwnerPermission ? false : true%>"
171        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
172        onclick="takeOwnership()" 
173        title="Take ownership&hellip;"
174        visible="<%=!isOwner%>"
175        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
176      />
177      <tbl:button 
178        onclick="setToActive()" 
179        image="bullet.gif"
180        title="Set active"
181        tooltip="Set this project to the active project"
182      />
183      <tbl:button 
184        image="import.gif" 
185        onclick="runPlugin('ImportItem')" 
186        title="Import&hellip;" 
187        tooltip="Import data" 
188        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
189      />
190      <tbl:button 
191        image="export.gif" 
192        onclick="runPlugin('ExportItem')" 
193        title="Export&hellip;" 
194        tooltip="Export data" 
195        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
196      />
197      <tbl:button 
198        image="runplugin.gif" 
199        onclick="runPlugin('RunPlugin')" 
200        title="Run plugin&hellip;" 
201        tooltip="Run a plugin" 
202        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
203      />
204      <tbl:button
205        image="help.gif"
206        onclick="<%="Main.openHelp('" + ID +"', 'project.view.properties')"%>"
207        title="Help&hellip;"
208        tooltip="Get help about this page"
209      />
210      </tbl:toolbar>
211    <div class="boxedbottom">
212      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(project)%></i></div>
213      <%
214      if (project.isRemoved())
215      {
216        %>
217        <div class="itemstatus">
218          <base:icon image="deleted.gif" 
219            visible="<%=project.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
220        </div>
221        <%
222      }
223      %>
224      <table class="form" cellspacing=0>
225      <tr>
226        <td class="prompt">Name</td>
227        <td><%=HTML.encodeTags(project.getName())%></td>
228      </tr>
229      <tr>
230        <td class="prompt">Owner</td>
231        <td><base:propertyvalue item="<%=project%>" property="owner" /></td>
232      </tr>
233      <tr>
234        <td class="prompt">Description</td>
235        <td><%=HTML.niceFormat(project.getDescription())%></td>
236      </tr>
237      </table>
238     
239      <h4 class="docked">Members</h4>
240     
241      <tbl:table
242        id="members"
243        clazz="itemlist"
244        columns="all"
245        >
246        <tbl:columndef
247          id="type"
248          title="User/Group"
249        />
250        <tbl:columndef
251          id="name"
252          title="Name"
253        />
254        <tbl:columndef
255          id="permissions"
256          title="Permissions"
257        />
258        <tbl:data>
259          <tbl:columns />
260          <tbl:rows>
261          <%
262          // Query to retrieve child groups
263          ItemQuery<Group> groupQuery = project.getGroups();
264          groupQuery.order(Orders.asc(Hql.property("name")));
265          ItemResultList<Group> groups = groupQuery.list(dc);
266          for (Group group : groups)
267          {
268            Set<Permission> permissions = project.getPermissions(group);
269            %>
270            <tbl:row>
271              <tbl:cell column="type">Group</tbl:cell>
272              <tbl:cell column="name"><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
273              <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
274            </tbl:row>
275            <%
276          }
277     
278          // Query to retrieve user members
279          ItemQuery<User> userQuery = project.getUsers();
280          userQuery.order(Orders.asc(Hql.property("name")));
281          ItemResultList<User> users = userQuery.list(dc);
282          for (User user : users)
283          {
284            Set<Permission> permissions = project.getPermissions(user);
285            %>
286            <tbl:row>
287              <tbl:cell column="type">User</tbl:cell>
288              <tbl:cell column="name"><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
289              <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
290            </tbl:row>
291            <%
292          }
293          %>
294          </tbl:rows>
295        </tbl:data>
296      </tbl:table>
297     
298      <h4 class="docked">Defaults</h4>     
299      <tbl:table 
300        id="defaults"
301        clazz="itemlist"
302        columns="all"
303      >
304      <tbl:columndef
305        id="setting"
306        title="Setting"
307      />
308      <tbl:columndef
309        id="value"
310        title="Value"
311      />
312      <tbl:data>
313        <tbl:columns />
314          <tbl:rows>     
315          <%   
316          // Check each Default if it has any value
317          for (Project.Default d : Project.Default.values())
318          {
319            boolean readDefaultValue = true;
320            String defaultName = d.getShortName();
321            String value = null;
322            if (d.getItemType() != null)
323            {
324              BasicItem item = null;
325              try
326              {
327                item = project.getDefaultItem(dc, d); 
328                if (item != null)
329                {
330                  value = item instanceof Nameable ? Base.getLinkedName(ID, (Nameable)item, false, true) : item.toString();
331                }
332              }
333              catch (PermissionDeniedException ex)
334              {
335                readDefaultValue = false;
336                value = "<i>- denied -</i>";
337              }             
338            }
339            else if (d.equals(Project.Default.RAW_DATA_TYPE))
340            {
341              RawDataType rdt = project.getDefaultRawDataType();
342              value = rdt != null ? rdt.getName() : null;
343            }
344            if (value != null)
345            {
346              %>
347              <tbl:row>
348                <tbl:cell column="setting"><%=defaultName%></tbl:cell>
349                <tbl:cell column="value"><%=value%></tbl:cell>
350              </tbl:row>
351              <%
352            }
353          }
354          %>
355          </tbl:rows>
356        </tbl:data>
357      </tbl:table>     
358    </div>
359      </t:tab>
360     
361      <t:tab id="items" title="Items" tooltip="List all items in this project" />
362     
363      </t:tabcontrol>
364
365  </base:body>
366  </base:page>
367  <%
368}
369finally
370{
371  if (dc != null) dc.close();
372}
373
374%>
Note: See TracBrowser for help on using the repository browser.