mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
- Items by author view added.
- Browse UI code updated to use array forms of BrowseInfo methods. git-svn-id: http://scm.dspace.org/svn/repo/trunk@198 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -91,6 +91,11 @@
|
||||
<servlet-class>org.dspace.app.webui.servlet.DisplayItemServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>items-by-author</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.ItemsByAuthorServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>location</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.LocationServlet</servlet-class>
|
||||
@@ -130,6 +135,11 @@
|
||||
<url-pattern>/item/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>items-by-author</servlet-name>
|
||||
<url-pattern>/items-by-author</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>location</servlet-name>
|
||||
<url-pattern>/communities/*</url-pattern>
|
||||
|
@@ -162,15 +162,14 @@
|
||||
<%
|
||||
// Row: toggles between Odd and Even
|
||||
String row = "odd";
|
||||
List results = browseInfo.getResults();
|
||||
String[] results = browseInfo.getStringResults();
|
||||
|
||||
for (int i = 0; i < results.size(); i++)
|
||||
for (int i = 0; i < results.length; i++)
|
||||
{
|
||||
String name = (String) results.get(i);
|
||||
%>
|
||||
<tr>
|
||||
<td class="<%= highlight && i==browseInfo.getOffset() ? "highlight" : row %>RowOddCol">
|
||||
<A HREF="items-by-author?author=<%= URLEncoder.encode(name) %>"><%= name %></A>
|
||||
<A HREF="items-by-author?author=<%= URLEncoder.encode(results[i]) %>"><%= results[i] %></A>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
|
136
dspace/jsp/browse/items-by-author.jsp
Normal file
136
dspace/jsp/browse/items-by-author.jsp
Normal file
@@ -0,0 +1,136 @@
|
||||
<%--
|
||||
- items_by_author.jsp
|
||||
-
|
||||
- Version: $Revision$
|
||||
-
|
||||
- Date: $Date$
|
||||
-
|
||||
- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
||||
- Institute of Technology. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions are
|
||||
- met:
|
||||
-
|
||||
- - Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
-
|
||||
- - Redistributions in binary form must reproduce the above copyright
|
||||
- notice, this list of conditions and the following disclaimer in the
|
||||
- documentation and/or other materials provided with the distribution.
|
||||
-
|
||||
- - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
- Massachusetts Institute of Technology nor the names of their
|
||||
- contributors may be used to endorse or promote products derived from
|
||||
- this software without specific prior written permission.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
- DAMAGE.
|
||||
--%>
|
||||
|
||||
|
||||
<%--
|
||||
- Display items by a particular author
|
||||
-
|
||||
- Attributes to pass in:
|
||||
-
|
||||
- community - pass in if the scope of the browse is a community, or
|
||||
- a collection within this community
|
||||
- collection - pass in if the scope of the browse is a collection
|
||||
- browse.info - the BrowseInfo containing the items to display
|
||||
- handles - String[] of Handles corresponding to the browse results
|
||||
- author - The name of the author
|
||||
- sort.by.date - Boolean. if true, we're sorting by date, otherwise by
|
||||
- title.
|
||||
--%>
|
||||
|
||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
|
||||
<%@ page import="org.dspace.browse.BrowseInfo" %>
|
||||
<%@ page import="org.dspace.content.Community" %>
|
||||
<%@ page import="org.dspace.content.Collection" %>
|
||||
<%@ page import="org.dspace.content.Item" %>
|
||||
|
||||
<%
|
||||
Collection collection = (Collection) request.getAttribute("collection");
|
||||
Community community = (Community) request.getAttribute("community");
|
||||
BrowseInfo browseInfo = (BrowseInfo) request.getAttribute("browse.info" );
|
||||
String[] handles = (String[]) request.getAttribute("handles");
|
||||
String author = (String) request.getAttribute("author");
|
||||
boolean orderByTitle = ((Boolean) request.getAttribute("order.by.title")).booleanValue();
|
||||
|
||||
|
||||
// Description of what the user is actually browsing
|
||||
String scopeName = "All of DSpace";
|
||||
if (collection != null)
|
||||
{
|
||||
scopeName = collection.getMetadata("name");
|
||||
}
|
||||
else if (community != null)
|
||||
{
|
||||
scopeName = community.getMetadata("name");
|
||||
}
|
||||
|
||||
String pageTitle = "Items for Author " + author;
|
||||
%>
|
||||
|
||||
<dspace:layout title="<%= pageTitle %>">
|
||||
|
||||
<H2>Items for Author <%= author %> in <%= scopeName %></H2>
|
||||
|
||||
<%-- Sorting controls --%>
|
||||
<table border=0 cellpadding=10 align=center>
|
||||
<tr>
|
||||
<td colspan=2 align=center class=standard>
|
||||
<a href="browse-author?point=<%= URLEncoder.encode(author) %>">Return to Browse by Author</A>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=standard>
|
||||
<%
|
||||
if (orderByTitle)
|
||||
{
|
||||
%>
|
||||
<strong>Sorting by Title</strong>
|
||||
</td>
|
||||
<td class=standard>
|
||||
<a href="items-by-author?author=<%= URLEncoder.encode(author) %>&order=date">Sort by Date</a>
|
||||
<%
|
||||
}
|
||||
else
|
||||
{
|
||||
%>
|
||||
<a href="items-by-author?author=<%= URLEncoder.encode(author) %>&order=title">Sort by Title</a>
|
||||
</td>
|
||||
<td class=standard>
|
||||
<strong>Sorting by Date</strong>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<P align=center>Showing <%= browseInfo.getResultCount() %> items.</P>
|
||||
|
||||
|
||||
<%-- The items --%>
|
||||
<%
|
||||
String emphColumn = (orderByTitle ? "title" : "date");
|
||||
%>
|
||||
<dspace:itemlist items="<%= browseInfo.getItemResults() %>" handles="<%= handles %>" emphcolumn="<%= emphColumn %>" />
|
||||
|
||||
|
||||
</dspace:layout>
|
@@ -236,7 +236,7 @@
|
||||
highlightAttribute = String.valueOf(browseInfo.getOffset());
|
||||
}
|
||||
%>
|
||||
<dspace:itemlist items="<%= browseInfo.getResults() %>" handles="<%= handles %>" emphcolumn="date" highlightrow="<%= highlightAttribute %>" />
|
||||
<dspace:itemlist items="<%= browseInfo.getItemResults() %>" handles="<%= handles %>" emphcolumn="date" highlightrow="<%= highlightAttribute %>" />
|
||||
|
||||
|
||||
<%-- Previous page/Next page --%>
|
||||
|
@@ -165,7 +165,7 @@
|
||||
highlightAttribute = String.valueOf(browseInfo.getOffset());
|
||||
}
|
||||
%>
|
||||
<dspace:itemlist items="<%= browseInfo.getResults() %>" handles="<%= handles %>" emphcolumn="title" highlightrow="<%= highlightAttribute %>" />
|
||||
<dspace:itemlist items="<%= browseInfo.getItemResults() %>" handles="<%= handles %>" emphcolumn="title" highlightrow="<%= highlightAttribute %>" />
|
||||
|
||||
|
||||
<%-- Previous page/Next page --%>
|
||||
|
@@ -72,7 +72,7 @@ public class ItemListTag extends TagSupport
|
||||
private String[] handles;
|
||||
|
||||
/** Row to highlight, -1 for no row */
|
||||
private int highlightRow;
|
||||
private int highlightRow = -1;
|
||||
|
||||
/** Column to emphasise - null, "title" or "date" */
|
||||
private String emphColumn;
|
||||
@@ -100,6 +100,7 @@ public class ItemListTag extends TagSupport
|
||||
|
||||
try
|
||||
{
|
||||
System.err.println("HIGHLIGHT ROW: " + highlightRow);
|
||||
out.println("<table align=center class=\"miscTable\">");
|
||||
|
||||
// Row: toggles between Odd and Even
|
||||
@@ -204,9 +205,9 @@ public class ItemListTag extends TagSupport
|
||||
*
|
||||
* @return the items
|
||||
*/
|
||||
public List getItems()
|
||||
public Item[] getItems()
|
||||
{
|
||||
return Arrays.asList(items);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +216,9 @@ public class ItemListTag extends TagSupport
|
||||
*
|
||||
* @param itemsIn the items
|
||||
*/
|
||||
public void setItems(List itemsIn)
|
||||
public void setItems(Item[] itemsIn)
|
||||
{
|
||||
items = new Item[itemsIn.size()];
|
||||
items = (Item[]) itemsIn.toArray(items);
|
||||
items = itemsIn;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,9 @@ public class ItemListTag extends TagSupport
|
||||
*/
|
||||
public void setHighlightrow(String highlightRowIn)
|
||||
{
|
||||
if (highlightRowIn == null)
|
||||
System.err.println("HIGHLIGHT ROW IN: " + highlightRowIn);
|
||||
|
||||
if (highlightRowIn == null || highlightRowIn.equals(""))
|
||||
{
|
||||
highlightRow = -1;
|
||||
}
|
||||
@@ -300,4 +302,13 @@ public class ItemListTag extends TagSupport
|
||||
{
|
||||
emphColumn = emphColumnIn;
|
||||
}
|
||||
|
||||
|
||||
public void release()
|
||||
{
|
||||
highlightRow = -1;
|
||||
emphColumn = null;
|
||||
items = null;
|
||||
handles = null;
|
||||
}
|
||||
}
|
||||
|
@@ -338,9 +338,6 @@ public class BrowseServlet extends DSpaceServlet
|
||||
browseInfo = Browse.getItemsByTitle(scope);
|
||||
}
|
||||
|
||||
List results = browseInfo.getResults();
|
||||
|
||||
|
||||
// Write log entry
|
||||
String what = "title";
|
||||
if (browseAuthors)
|
||||
@@ -354,10 +351,10 @@ public class BrowseServlet extends DSpaceServlet
|
||||
|
||||
log.info(LogManager.getHeader(context,
|
||||
"browse_" + what,
|
||||
logInfo + ",results=" + results.size()));
|
||||
logInfo + ",results=" + browseInfo.getResultCount()));
|
||||
|
||||
|
||||
if (results.size() == 0)
|
||||
if (browseInfo.getResultCount() == 0)
|
||||
{
|
||||
// No results!
|
||||
request.setAttribute("community", community);
|
||||
@@ -371,12 +368,12 @@ public class BrowseServlet extends DSpaceServlet
|
||||
// out the Handles for the items
|
||||
if (browseDates || browseTitles)
|
||||
{
|
||||
String[] handles = new String[results.size()];
|
||||
Item[] items = browseInfo.getItemResults();
|
||||
String[] handles = new String[items.length];
|
||||
|
||||
for (int i = 0; i < results.size(); i++)
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
Item item = (Item) results.get(i);
|
||||
handles[i] = HandleManager.findHandle(context, item);
|
||||
handles[i] = HandleManager.findHandle(context, items[i]);
|
||||
}
|
||||
|
||||
request.setAttribute("handles", handles);
|
||||
@@ -395,11 +392,11 @@ public class BrowseServlet extends DSpaceServlet
|
||||
|
||||
if (browseAuthors)
|
||||
{
|
||||
s = (String) results.get(0);
|
||||
s = (browseInfo.getStringResults())[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
Item firstItem = (Item) results.get(0);
|
||||
Item firstItem = (browseInfo.getItemResults())[0];
|
||||
s = HandleManager.findHandle(context, firstItem);
|
||||
}
|
||||
|
||||
@@ -417,11 +414,13 @@ public class BrowseServlet extends DSpaceServlet
|
||||
|
||||
if (browseAuthors)
|
||||
{
|
||||
s = (String) results.get(results.size() - 1);
|
||||
String[] authors = browseInfo.getStringResults();
|
||||
s = authors[authors.length - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
Item lastItem = (Item) results.get(results.size() - 1);
|
||||
Item[] items = browseInfo.getItemResults();
|
||||
Item lastItem = items[items.length - 1];
|
||||
s = HandleManager.findHandle(context, lastItem);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* BrowseItemsByAuthorServlet.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
package org.dspace.app.webui.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.browse.Browse;
|
||||
import org.dspace.browse.BrowseInfo;
|
||||
import org.dspace.browse.BrowseScope;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.handle.HandleManager;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Displays the items with a particular author.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ItemsByAuthorServlet extends DSpaceServlet
|
||||
{
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(ItemsByAuthorServlet.class);
|
||||
|
||||
|
||||
protected void doDSGet(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
// We will resolve the HTTP request parameters into a scope
|
||||
BrowseScope scope = new BrowseScope(context);
|
||||
|
||||
// Get log information
|
||||
String logInfo = "";
|
||||
|
||||
// Get the HTTP parameters
|
||||
String author = request.getParameter("author");
|
||||
String order = request.getParameter("order");
|
||||
|
||||
// How should we order the items?
|
||||
boolean orderByTitle;
|
||||
|
||||
if (order != null && order.equalsIgnoreCase("title"))
|
||||
{
|
||||
orderByTitle = true;
|
||||
logInfo = "order=title";
|
||||
}
|
||||
else
|
||||
{
|
||||
orderByTitle = false;
|
||||
logInfo = "order=date";
|
||||
}
|
||||
|
||||
// Get the community or collection scope
|
||||
Community community = UIUtil.getCommunityLocation(request);
|
||||
Collection collection = UIUtil.getCollectionLocation(request);
|
||||
|
||||
if (collection != null)
|
||||
{
|
||||
logInfo = logInfo + ",collection_id=" + collection.getID();
|
||||
scope.setScope(collection);
|
||||
}
|
||||
else if (community != null)
|
||||
{
|
||||
logInfo = logInfo + ",community_id=" + community.getID();
|
||||
scope.setScope(community);
|
||||
}
|
||||
|
||||
|
||||
// Do the browse
|
||||
scope.setFocus(author);
|
||||
BrowseInfo browseInfo = Browse.getItemsByAuthor(scope, orderByTitle);
|
||||
|
||||
log.info(LogManager.getHeader(context,
|
||||
"items_by_author",
|
||||
logInfo + ",result_count=" + browseInfo.getResultCount()));
|
||||
|
||||
|
||||
// Get the Handles
|
||||
Item[] results = browseInfo.getItemResults();
|
||||
String[] handles = new String[results.length];
|
||||
|
||||
for (int i = 0; i < results.length; i++)
|
||||
{
|
||||
handles[i] = HandleManager.findHandle(context, results[i]);
|
||||
}
|
||||
|
||||
|
||||
// Display the JSP
|
||||
request.setAttribute("community", community);
|
||||
request.setAttribute("collection", collection);
|
||||
request.setAttribute("author", author);
|
||||
request.setAttribute("order.by.title", new Boolean(orderByTitle));
|
||||
request.setAttribute("browse.info", browseInfo);
|
||||
request.setAttribute("handles", handles);
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/items-by-author.jsp");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user