mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Fix for DS-1110 : AbstractCurationTask.distribute() convenience method doesn't distribute across all DSpace Objects. Modify the 'distribute()' method to run across all objects. Create a new 'performObject()' method that can be used in conjunction with 'distribute()'. By default, 'performObject()' just wraps a call to existing 'performItem()' method.
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6925 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -52,27 +52,36 @@ public abstract class AbstractCurationTask implements CurationTask
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Distributes a task through a DSpace container - a convenience method
|
* Distributes a task through a DSpace container - a convenience method
|
||||||
* for tasks declaring the <code>@Distributive</code> property. Users must
|
* for tasks declaring the <code>@Distributive</code> property.
|
||||||
* override the 'performItem' invoked by this method.
|
* <P>
|
||||||
|
* This method invokes the 'performObject()' method on the current DSO, and
|
||||||
|
* then recursively invokes the 'performObject()' method on all DSOs contained
|
||||||
|
* within the current DSO. For example: if a Community is passed in, then
|
||||||
|
* 'performObject()' will be called on that Community object, as well as
|
||||||
|
* on all SubCommunities/Collections/Items contained in that Community.
|
||||||
|
* <P>
|
||||||
|
* Individual tasks MUST override either the <code>performObject</code> method or
|
||||||
|
* the <code>performItem</code> method to ensure the task is run on either all
|
||||||
|
* DSOs or just all Items, respectively.
|
||||||
*
|
*
|
||||||
* @param dso
|
* @param dso current DSpaceObject
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void distribute(DSpaceObject dso) throws IOException
|
protected void distribute(DSpaceObject dso) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//perform task on this current object
|
||||||
|
performObject(dso);
|
||||||
|
|
||||||
|
//next, we'll try to distribute to all child objects, based on container type
|
||||||
int type = dso.getType();
|
int type = dso.getType();
|
||||||
if (Constants.ITEM == type)
|
if (Constants.COLLECTION == type)
|
||||||
{
|
|
||||||
performItem((Item)dso);
|
|
||||||
}
|
|
||||||
else if (Constants.COLLECTION == type)
|
|
||||||
{
|
{
|
||||||
ItemIterator iter = ((Collection)dso).getItems();
|
ItemIterator iter = ((Collection)dso).getItems();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
performItem(iter.next());
|
performObject(iter.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Constants.COMMUNITY == type)
|
else if (Constants.COMMUNITY == type)
|
||||||
@@ -87,6 +96,14 @@ public abstract class AbstractCurationTask implements CurationTask
|
|||||||
distribute(coll);
|
distribute(coll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Constants.SITE == type)
|
||||||
|
{
|
||||||
|
Community[] topComm = Community.findAllTop(Curator.curationContext());
|
||||||
|
for (Community comm : topComm)
|
||||||
|
{
|
||||||
|
distribute(comm);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException sqlE)
|
catch (SQLException sqlE)
|
||||||
{
|
{
|
||||||
@@ -95,10 +112,45 @@ public abstract class AbstractCurationTask implements CurationTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs task upon an Item. Must be overridden if <code>distribute</code>
|
* Performs task upon a single DSpaceObject. Used in conjunction with the
|
||||||
* method is used.
|
* <code>distribute</code> method to run a single task across multiple DSpaceObjects.
|
||||||
|
* <P>
|
||||||
|
* By default, this method just wraps a call to <code>performItem</code>
|
||||||
|
* for each Item Object.
|
||||||
|
* <P>
|
||||||
|
* You should override this method if you want to use
|
||||||
|
* <code>distribute</code> to run your task across multiple DSpace Objects.
|
||||||
|
* <P>
|
||||||
|
* Either this method or <code>performItem</code> should be overridden if
|
||||||
|
* <code>distribute</code> method is used.
|
||||||
*
|
*
|
||||||
* @param item
|
* @param dso the DSpaceObject
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
protected void performObject(DSpaceObject dso) throws SQLException, IOException
|
||||||
|
{
|
||||||
|
// By default this method only performs tasks on Items
|
||||||
|
// (You should override this method if you want to perform task on all objects)
|
||||||
|
if(dso.getType()==Constants.ITEM)
|
||||||
|
{
|
||||||
|
performItem((Item)dso);
|
||||||
|
}
|
||||||
|
|
||||||
|
//no-op for all other types of DSpace Objects
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs task upon a single DSpace Item. Used in conjunction with the
|
||||||
|
* <code>distribute</code> method to run a single task across multiple Items.
|
||||||
|
* <P>
|
||||||
|
* You should override this method if you want to use
|
||||||
|
* <code>distribute</code> to run your task across multiple DSpace Items.
|
||||||
|
* <P>
|
||||||
|
* Either this method or <code>performObject</code> should be overridden if
|
||||||
|
* <code>distribute</code> method is used.
|
||||||
|
*
|
||||||
|
* @param item the DSpace Item
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user