source: trunk/www/common/anytoany/list_anytoany.jsp @ 3675

Last change on this file since 3675 was 3675, checked in by Jari Häkkinen, 14 years ago

Fixing copyright statements. Fixing svn properties.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 4.1 KB
Line 
1<%-- $Id: list_anytoany.jsp 3675 2007-08-16 14:16:43Z jari $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Nicklas Nordborg
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.Item"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.BasicItem"
33  import="net.sf.basedb.core.AnyToAny"
34  import="net.sf.basedb.core.Nameable"
35  import="net.sf.basedb.core.File"
36  import="net.sf.basedb.core.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.query.Orders"
40  import="net.sf.basedb.core.query.Hql"
41  import="net.sf.basedb.clients.web.Base"
42  import="net.sf.basedb.clients.web.util.HTML"
43  import="net.sf.basedb.util.Values"
44  import="java.util.List"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
48
49<%
50String root = request.getContextPath() + "/";
51final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
52final String ID = sc.getId();
53final Item itemType = Item.valueOf(request.getParameter("item_type"));
54final int itemId = Values.getInt(request.getParameter("item_id"));
55final float scale = Base.getScale(sc);
56final DbControl dc = sc.newDbControl();
57
58try
59{
60  final BasicItem item = itemType.getById(dc, itemId);
61  ItemQuery<AnyToAny> query = AnyToAny.getLinksFrom(item);
62  query.order(Orders.asc(Hql.property("name")));
63  ItemResultList<AnyToAny> links = query.list(dc);
64  %>
65
66  <base:page type="include">
67  <base:head />
68  <base:body>
69 
70    <%
71    if (links.getTotalCount() == 0)
72    {
73      %>
74      None.
75      <%
76    }
77    else
78    {
79      %>
80      <tbl:table
81        id="links"
82        clazz="itemlist"
83        columns="all"
84        >
85        <tbl:columndef 
86          id="name"
87          title="Name"
88        />
89        <tbl:columndef 
90          id="item"
91          title="Item"
92        />
93        <tbl:columndef 
94          id="description"
95          title="Description"
96        />
97        <tbl:data>
98          <tbl:columns>
99          </tbl:columns>
100          <tbl:rows>
101          <%
102          for (AnyToAny ata : links)
103          {
104            String name = HTML.encodeTags(ata.getName());
105            BasicItem to = null;
106            boolean readTo = true;
107            try
108            {
109              to = ata.getTo();
110            }
111            catch (PermissionDeniedException ex)
112            {
113              readTo = false;
114            }
115           
116            String toLink = "";
117            if (to instanceof File)
118            {
119              File toFile = (File)to;
120              toLink = Base.getLinkedFile(ID, toFile, false, true, true, root);
121            }
122            else if (to instanceof Nameable)
123            {
124              Nameable nameable = (Nameable)to;
125              toLink = Base.getLinkedName(ID, nameable, false, true);
126            }
127            else if (!readTo)
128            {
129              toLink = "<i>- denied -</i>";
130            }
131            else if (to == null)
132            {
133              toLink = "<i>- none -</i>";
134            }
135            else
136            {
137              toLink = Base.getLink(ID, to.toString(), to.getType(), to.getId(), true);
138            }
139            %>
140            <tbl:row>
141              <tbl:cell column="name"><%=Base.getLinkedName(ID, ata, false, true)%></tbl:cell>
142              <tbl:cell column="item"><%=toLink%></tbl:cell>
143              <tbl:cell column="description"><%=HTML.encodeTags(ata.getDescription())%></tbl:cell>
144            </tbl:row>
145            <%
146          }
147          %>
148          </tbl:rows>
149        </tbl:data>
150      </tbl:table>
151      <%
152    }
153    %>
154    <br>
155
156  </base:body>
157  </base:page>
158  <%
159}
160finally
161{
162  if (dc != null) dc.close();
163}
164
165%>
Note: See TracBrowser for help on using the repository browser.