org.dspace.curate
Class AbstractCurationTask

java.lang.Object
  extended by org.dspace.curate.AbstractCurationTask
All Implemented Interfaces:
CurationTask
Direct Known Subclasses:
AbstractTranslator, BasicLinkChecker, BitstreamsIntoMetadata, ClamScan, NoOpCurationTask, ProfileFormats, RequiredMetadata

public abstract class AbstractCurationTask
extends Object
implements CurationTask

AbstractCurationTask encapsulates a few common patterns of task use, resources, and convenience methods.

Author:
richardrodgers

Field Summary
protected  Curator curator
           
protected  String taskId
           
 
Constructor Summary
AbstractCurationTask()
           
 
Method Summary
protected  DSpaceObject dereference(Context ctx, String id)
          Returns a DSpaceObject for passed identifier, if it exists
protected  void distribute(DSpaceObject dso)
          Distributes a task through a DSpace container - a convenience method for tasks declaring the @Distributive property.
 void init(Curator curator, String taskId)
          Initialize task - parameters inform the task of it's invoking curator.
 int perform(Context ctx, String id)
          Perform the curation task for passed id
abstract  int perform(DSpaceObject dso)
          Perform the curation task upon passed DSO
protected  void performItem(Item item)
          Performs task upon an Item.
protected  void report(String message)
          Sends message to the reporting stream
protected  void setResult(String result)
          Assigns the result of the task performance
protected  boolean taskBooleanProperty(String name, boolean defaultValue)
          Returns task configuration boolean property value for passed name, else passed default value if no properties defined or no value for passed key.
protected  int taskIntProperty(String name, int defaultValue)
          Returns task configuration integer property value for passed name, else passed default value if no properties defined or no value for passed key.
protected  long taskLongProperty(String name, long defaultValue)
          Returns task configuration long property value for passed name, else passed default value if no properties defined or no value for passed key.
protected  String taskProperty(String name)
          Returns task configuration property value for passed name, else null if no properties defined or no value for passed key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curator

protected Curator curator

taskId

protected String taskId
Constructor Detail

AbstractCurationTask

public AbstractCurationTask()
Method Detail

init

public void init(Curator curator,
                 String taskId)
          throws IOException
Description copied from interface: CurationTask
Initialize task - parameters inform the task of it's invoking curator. Since the curator can provide services to the task, this represents curation DI.

Specified by:
init in interface CurationTask
Parameters:
curator - the Curator controlling this task
taskId - identifier task should use in invoking services
Throws:
IOException

perform

public abstract int perform(DSpaceObject dso)
                     throws IOException
Description copied from interface: CurationTask
Perform the curation task upon passed DSO

Specified by:
perform in interface CurationTask
Parameters:
dso - the DSpace object
Returns:
status code
Throws:
IOException

distribute

protected void distribute(DSpaceObject dso)
                   throws IOException
Distributes a task through a DSpace container - a convenience method for tasks declaring the @Distributive property. Users must override the 'performItem' invoked by this method.

Parameters:
dso -
Throws:
IOException

performItem

protected void performItem(Item item)
                    throws SQLException,
                           IOException
Performs task upon an Item. Must be overridden if distribute method is used.

Parameters:
item -
Throws:
SQLException
IOException

perform

public int perform(Context ctx,
                   String id)
            throws IOException
Description copied from interface: CurationTask
Perform the curation task for passed id

Specified by:
perform in interface CurationTask
Parameters:
ctx - DSpace context object
id - persistent ID for DSpace object
Returns:
status code
Throws:
IOException

dereference

protected DSpaceObject dereference(Context ctx,
                                   String id)
                            throws IOException
Returns a DSpaceObject for passed identifier, if it exists

Parameters:
ctx - DSpace context
id - canonical id of object
Returns:
dso DSpace object, or null if no object with id exists
Throws:
IOException

report

protected void report(String message)
Sends message to the reporting stream

Parameters:
message - the message to stream

setResult

protected void setResult(String result)
Assigns the result of the task performance

Parameters:
result - the result string

taskProperty

protected String taskProperty(String name)
Returns task configuration property value for passed name, else null if no properties defined or no value for passed key.

Parameters:
name - the property name
Returns:
value the property value, or null

taskIntProperty

protected int taskIntProperty(String name,
                              int defaultValue)
Returns task configuration integer property value for passed name, else passed default value if no properties defined or no value for passed key.

Parameters:
name - the property name
defaultValue - value the default value
Returns:
value the property value, or default value

taskLongProperty

protected long taskLongProperty(String name,
                                long defaultValue)
Returns task configuration long property value for passed name, else passed default value if no properties defined or no value for passed key.

Parameters:
name - the property name
defaultValue - value the default value
Returns:
value the property value, or default

taskBooleanProperty

protected boolean taskBooleanProperty(String name,
                                      boolean defaultValue)
Returns task configuration boolean property value for passed name, else passed default value if no properties defined or no value for passed key.

Parameters:
name - the property name
defaultValue - value the default value
Returns:
value the property value, or default


Copyright © 2011 DuraSpace. All Rights Reserved.