mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
SF Patch 1743188 Patch for Request #1145499 - Move Items
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2171 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -1979,6 +1979,66 @@ public class Item extends DSpaceObject
|
|||||||
replaceAllBitstreamPolicies(policies);
|
replaceAllBitstreamPolicies(policies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the item from one collection to another one
|
||||||
|
*
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void move (Collection from, Collection to) throws SQLException, AuthorizeException, IOException
|
||||||
|
{
|
||||||
|
if (isOwningCollection(from))
|
||||||
|
{
|
||||||
|
setOwningCollection(to);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
to.addItem(this);
|
||||||
|
from.removeItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the collections this item is not in.
|
||||||
|
*
|
||||||
|
* @return the collections this item is not in, if any.
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public Collection[] getCollectionsNotLinked() throws SQLException
|
||||||
|
{
|
||||||
|
Collection[] allCollections = Collection.findAll(ourContext);
|
||||||
|
Collection[] linkedCollections = getCollections();
|
||||||
|
Collection[] notLinkedCollections = new Collection[allCollections.length - linkedCollections.length];
|
||||||
|
|
||||||
|
if ((allCollections.length - linkedCollections.length) == 0)
|
||||||
|
{
|
||||||
|
return notLinkedCollections;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (Collection collection : allCollections)
|
||||||
|
{
|
||||||
|
boolean alreadyLinked = false;
|
||||||
|
|
||||||
|
for (Collection linkedCommunity : linkedCollections)
|
||||||
|
{
|
||||||
|
if (collection.getID() == linkedCommunity.getID())
|
||||||
|
{
|
||||||
|
alreadyLinked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!alreadyLinked)
|
||||||
|
{
|
||||||
|
notLinkedCollections[i++] = collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return notLinkedCollections;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return TRUE if context's user can edit item, false otherwise
|
* return TRUE if context's user can edit item, false otherwise
|
||||||
*
|
*
|
||||||
|
@@ -1070,6 +1070,7 @@ jsp.tools.edit-item-form.item = Item's Authori
|
|||||||
jsp.tools.edit-item-form.itemID = Item internal ID:
|
jsp.tools.edit-item-form.itemID = Item internal ID:
|
||||||
jsp.tools.edit-item-form.itempage = Item page:
|
jsp.tools.edit-item-form.itempage = Item page:
|
||||||
jsp.tools.edit-item-form.modified = Last modified:
|
jsp.tools.edit-item-form.modified = Last modified:
|
||||||
|
jsp.tools.edit-item-form.move-item.button = Move Item
|
||||||
jsp.tools.edit-item-form.msg = This item was withdrawn from DSpace
|
jsp.tools.edit-item-form.msg = This item was withdrawn from DSpace
|
||||||
jsp.tools.edit-item-form.na = N/A
|
jsp.tools.edit-item-form.na = N/A
|
||||||
jsp.tools.edit-item-form.note = PLEASE NOTE: These changes are not validated in any way. You are responsible for entering the data in the correct format. If you are not sure what the format is, please do NOT make changes.
|
jsp.tools.edit-item-form.note = PLEASE NOTE: These changes are not validated in any way. You are responsible for entering the data in the correct format. If you are not sure what the format is, please do NOT make changes.
|
||||||
@@ -1170,6 +1171,11 @@ jsp.tools.itemmap-main.info7 = Click on colle
|
|||||||
jsp.tools.itemmap-main.info8 = This collection has no items mapped into it.
|
jsp.tools.itemmap-main.info8 = This collection has no items mapped into it.
|
||||||
jsp.tools.itemmap-main.search.button = Search Authors
|
jsp.tools.itemmap-main.search.button = Search Authors
|
||||||
jsp.tools.itemmap-main.title = Item Mapper
|
jsp.tools.itemmap-main.title = Item Mapper
|
||||||
|
jsp.tools.move-item.button = Move
|
||||||
|
jsp.tools.move-item.collection.from.msg = Collection to move from
|
||||||
|
jsp.tools.move-item.collection.to.msg = Collection to move to
|
||||||
|
jsp.tools.move-item.item.name.msg = Name of the item to be moved
|
||||||
|
jsp.tools.move-item.title = Moving an item
|
||||||
jsp.tools.upload-bitstream.info = Select the bitstream to upload
|
jsp.tools.upload-bitstream.info = Select the bitstream to upload
|
||||||
jsp.tools.upload-bitstream.title = Upload Bitstream
|
jsp.tools.upload-bitstream.title = Upload Bitstream
|
||||||
jsp.tools.upload-bitstream.upload = Upload
|
jsp.tools.upload-bitstream.upload = Upload
|
||||||
|
@@ -105,6 +105,12 @@ public class EditItemServlet extends DSpaceServlet
|
|||||||
/** User reinstates a withdrawn item */
|
/** User reinstates a withdrawn item */
|
||||||
public static final int REINSTATE = 6;
|
public static final int REINSTATE = 6;
|
||||||
|
|
||||||
|
/** User starts the movement of an item */
|
||||||
|
public static final int START_MOVE_ITEM = 7;
|
||||||
|
|
||||||
|
/** User confirms the movement of the item */
|
||||||
|
public static final int CONFIRM_MOVE_ITEM = 8;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(EditCommunitiesServlet.class);
|
private static Logger log = Logger.getLogger(EditCommunitiesServlet.class);
|
||||||
|
|
||||||
@@ -268,6 +274,45 @@ public class EditItemServlet extends DSpaceServlet
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case START_MOVE_ITEM:
|
||||||
|
if (AuthorizeManager.isAdmin(context))
|
||||||
|
{
|
||||||
|
// Display move collection page with fields of collections and communities
|
||||||
|
Collection[] notLinkedCollections = item.getCollectionsNotLinked();
|
||||||
|
Collection[] linkedCollections = item.getCollections();
|
||||||
|
|
||||||
|
request.setAttribute("linkedCollections", linkedCollections);
|
||||||
|
request.setAttribute("notLinkedCollections", notLinkedCollections);
|
||||||
|
|
||||||
|
JSPManager.showJSP(request, response, "/tools/move-item.jsp");
|
||||||
|
} else {
|
||||||
|
throw new ServletException("You must be an administrator to move an item");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIRM_MOVE_ITEM:
|
||||||
|
if (AuthorizeManager.isAdmin(context))
|
||||||
|
{
|
||||||
|
Collection fromCollection = Collection.find(context, UIUtil.getIntParameter(request, "collection_from_id"));
|
||||||
|
Collection toCollection = Collection.find(context, UIUtil.getIntParameter(request, "collection_to_id"));
|
||||||
|
|
||||||
|
if (fromCollection == null || toCollection == null)
|
||||||
|
{
|
||||||
|
throw new ServletException("Missing or incorrect collection IDs for moving item");
|
||||||
|
}
|
||||||
|
|
||||||
|
item.move(fromCollection, toCollection);
|
||||||
|
|
||||||
|
showEditForm(context, request, response, item);
|
||||||
|
|
||||||
|
context.complete();
|
||||||
|
} else {
|
||||||
|
throw new ServletException("You must be an administrator to move an item");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// Erm... weird action value received.
|
// Erm... weird action value received.
|
||||||
|
@@ -73,6 +73,7 @@
|
|||||||
<%@ page import="org.dspace.content.DCValue" %>
|
<%@ page import="org.dspace.content.DCValue" %>
|
||||||
<%@ page import="org.dspace.content.Item" %>
|
<%@ page import="org.dspace.content.Item" %>
|
||||||
<%@ page import="org.dspace.core.ConfigurationManager" %>
|
<%@ page import="org.dspace.core.ConfigurationManager" %>
|
||||||
|
<%@ page import="org.dspace.eperson.EPerson" %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
Item item = (Item) request.getAttribute("item");
|
Item item = (Item) request.getAttribute("item");
|
||||||
@@ -80,6 +81,13 @@
|
|||||||
Collection[] collections = (Collection[]) request.getAttribute("collections");
|
Collection[] collections = (Collection[]) request.getAttribute("collections");
|
||||||
MetadataField[] dcTypes = (MetadataField[]) request.getAttribute("dc.types");
|
MetadataField[] dcTypes = (MetadataField[]) request.getAttribute("dc.types");
|
||||||
HashMap metadataFields = (HashMap) request.getAttribute("metadataFields");
|
HashMap metadataFields = (HashMap) request.getAttribute("metadataFields");
|
||||||
|
|
||||||
|
// Is anyone logged in?
|
||||||
|
EPerson user = (EPerson) request.getAttribute("dspace.current.user");
|
||||||
|
|
||||||
|
// Is the logged in user an admin
|
||||||
|
Boolean admin = (Boolean)request.getAttribute("is.admin");
|
||||||
|
boolean isAdmin = (admin == null ? false : admin.booleanValue());
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
||||||
@@ -140,6 +148,17 @@
|
|||||||
<%-- <input type="submit" name="submit" value="Delete (Expunge)..."> --%>
|
<%-- <input type="submit" name="submit" value="Delete (Expunge)..."> --%>
|
||||||
<input type="submit" name="submit" value="<fmt:message key="jsp.tools.edit-item-form.delete-w-confirm.button"/>"/>
|
<input type="submit" name="submit" value="<fmt:message key="jsp.tools.edit-item-form.delete-w-confirm.button"/>"/>
|
||||||
</form>
|
</form>
|
||||||
|
<%
|
||||||
|
if (isAdmin)
|
||||||
|
{
|
||||||
|
%> <form method="post" action="<%= request.getContextPath() %>/tools/edit-item">
|
||||||
|
<input type="hidden" name="item_id" value="<%= item.getID() %>" />
|
||||||
|
<input type="hidden" name="action" value="<%= EditItemServlet.START_MOVE_ITEM %>" />
|
||||||
|
<input type="submit" name="submit" value="<fmt:message key="jsp.tools.edit-item-form.move-item.button"/>"/>
|
||||||
|
</form>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
125
dspace-jspui/src/main/webapp/tools/move-item.jsp
Normal file
125
dspace-jspui/src/main/webapp/tools/move-item.jsp
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<%--
|
||||||
|
- move-item.jsp
|
||||||
|
-
|
||||||
|
- Version: $Revision$
|
||||||
|
-
|
||||||
|
- Date: $Date$
|
||||||
|
-
|
||||||
|
- Copyright (c) 2002, 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.
|
||||||
|
--%>
|
||||||
|
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||||
|
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
|
||||||
|
|
||||||
|
<%@ page import="org.dspace.content.Collection" %>
|
||||||
|
<%@ page import="org.dspace.content.DCValue" %>
|
||||||
|
<%@ page import="org.dspace.content.Item" %>
|
||||||
|
<%@ page import="org.dspace.app.webui.servlet.admin.EditItemServlet" %>
|
||||||
|
|
||||||
|
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
Collection [] notLinkedCollections = (Collection[] )request.getAttribute("notLinkedCollections");
|
||||||
|
Collection [] linkedCollections = (Collection[] )request.getAttribute("linkedCollections");
|
||||||
|
|
||||||
|
Item item = (Item)request.getAttribute("item");
|
||||||
|
%>
|
||||||
|
|
||||||
|
<dspace:layout titlekey="jsp.tools.move-item.title">
|
||||||
|
|
||||||
|
<form action="<%=request.getContextPath()%>/tools/edit-item" method="post">
|
||||||
|
|
||||||
|
<table class="miscTable" align="center">
|
||||||
|
<tr>
|
||||||
|
<td class="evenRowEvenCol" colspan="2">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="standard">
|
||||||
|
<small><strong><fmt:message key="jsp.tools.move-item.item.name.msg"/></strong></small>
|
||||||
|
</td>
|
||||||
|
<td class="standard">
|
||||||
|
<font color="#FF0000"><%=item.getMetadata("dc", "title", null, Item.ANY)[0].value%></font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="standard">
|
||||||
|
<small><strong><fmt:message key="jsp.tools.move-item.collection.from.msg"/></strong></small>
|
||||||
|
</td>
|
||||||
|
<td class="standard">
|
||||||
|
<select name="collection_from_id">
|
||||||
|
<%
|
||||||
|
for (int i = 0; i < linkedCollections.length; i++)
|
||||||
|
{
|
||||||
|
%>
|
||||||
|
<option value="<%= linkedCollections[i].getID() %>"><%= linkedCollections[i].getMetadata("name") %></option>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="standard">
|
||||||
|
<small><strong><fmt:message key="jsp.tools.move-item.collection.to.msg"/></strong></small>
|
||||||
|
</td>
|
||||||
|
<td class="standard">
|
||||||
|
<select name="collection_to_id">
|
||||||
|
<%
|
||||||
|
//Later on find a away to display in a tree format with the linked one disabled?
|
||||||
|
for (int i = 0; i < notLinkedCollections.length; i++)
|
||||||
|
{
|
||||||
|
%>
|
||||||
|
<option value="<%= notLinkedCollections[i].getID() %>"><%= notLinkedCollections[i].getMetadata("name") %></option>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="standard"></td>
|
||||||
|
<td class="standard">
|
||||||
|
<input type="submit" name="submit" value="<fmt:message key="jsp.tools.move-item.button"/>">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<input type="hidden" name="action" value="<%=EditItemServlet.CONFIRM_MOVE_ITEM%>" />
|
||||||
|
<input type="hidden" name="item_id" value="<%=item.getID() %>">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</dspace:layout>
|
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
(Flavio Botelho)
|
(Flavio Botelho)
|
||||||
- S.F. Patch 1764069 Replace "String" with "Integer" in PreparedStatement
|
- S.F. Patch 1764069 Replace "String" with "Integer" in PreparedStatement
|
||||||
Parameters where appropiate.
|
Parameters where appropriate.
|
||||||
|
- SF Patch 1743188 Patch for Request #1145499 - Move Items
|
||||||
|
|
||||||
(Mark Diggory)
|
(Mark Diggory)
|
||||||
- Guard against output invalid unqualified Dublin Core in OAIDCCrosswalk.
|
- Guard against output invalid unqualified Dublin Core in OAIDCCrosswalk.
|
||||||
|
Reference in New Issue
Block a user