Make Packager restore item mappings to non-owning Collections

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5397 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Mark Wood
2010-10-06 14:46:30 +00:00
parent 99c1f44c68
commit ba50e4fa87
2 changed files with 47 additions and 1 deletions

View File

@@ -1034,6 +1034,22 @@ public class Item extends DSpaceObject
modified = true;
}
/**
* See whether this Item is contained by a given Collection.
* @param collection
* @return true if {@code collection} contains this Item.
* @throws SQLException
*/
public boolean isIn(Collection collection) throws SQLException
{
TableRow tr = DatabaseManager.querySingle(ourContext,
"SELECT COUNT(*) AS count" +
" FROM collection2item" +
" WHERE collection_id = ? AND item_id = ?",
collection.getID(), itemRow.getIntColumn("item_id"));
return tr.getLongColumn("count") > 0;
}
/**
* Get the collections this item is in. The order is indeterminate.
*