Class AbstractCurationTask
- java.lang.Object
-
- org.dspace.curate.AbstractCurationTask
-
- All Implemented Interfaces:
CurationTask
- Direct Known Subclasses:
AbstractTranslator,BasicLinkChecker,BitstreamsIntoMetadata,CitationPage,ClamScan,MetadataWebService,NoOpCurationTask,ProfileFormats,PropertyParameterTestingTask,RegisterDOI,RequiredMetadata,WorkflowReportTest
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
Fields Modifier and Type Field Description protected CommunityServicecommunityServiceprotected ConfigurationServiceconfigurationServiceprotected Curatorcuratorprotected HandleServicehandleServiceprotected ItemServiceitemServiceprotected StringtaskId
-
Constructor Summary
Constructors Constructor Description AbstractCurationTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected DSpaceObjectdereference(Context ctx, String id)Returns a DSpaceObject for passed identifier, if it existsprotected voiddistribute(DSpaceObject dso)Distributes a task through a DSpace container - a convenience method for tasks declaring the@Distributiveproperty.voidinit(Curator curator, String taskId)Initialize task - parameters inform the task of it's invoking curator.abstract intperform(DSpaceObject dso)Perform the curation task upon passed DSOintperform(Context ctx, String id)Perform the curation task for passed idprotected voidperformItem(Item item)Performs task upon a single DSpace Item.protected voidperformObject(DSpaceObject dso)Performs task upon a single DSpaceObject.protected voidreport(String message)Sends message to the reporting streamprotected voidsetResult(String result)Assigns the result of the task performanceprotected String[]taskArrayProperty(String name)Returns task configuration Array property value for passed name, elsenullif no properties defined or no value for passed key.protected booleantaskBooleanProperty(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 inttaskIntProperty(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 longtaskLongProperty(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 StringtaskProperty(String name)Returns task configuration property value for passed name, elsenullif no properties defined or no value for passed key.
-
-
-
Field Detail
-
curator
protected Curator curator
-
taskId
protected String taskId
-
communityService
protected CommunityService communityService
-
itemService
protected ItemService itemService
-
handleService
protected HandleService handleService
-
configurationService
protected ConfigurationService configurationService
-
-
Method Detail
-
init
public void init(Curator curator, String taskId) throws IOException
Description copied from interface:CurationTaskInitialize 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:
initin interfaceCurationTask- Parameters:
curator- the Curator controlling this tasktaskId- identifier task should use in invoking services- Throws:
IOException- if error
-
perform
public abstract int perform(DSpaceObject dso) throws IOException
Description copied from interface:CurationTaskPerform the curation task upon passed DSO- Specified by:
performin interfaceCurationTask- Parameters:
dso- the DSpace object- Returns:
- status code
- Throws:
IOException- if error
-
distribute
protected void distribute(DSpaceObject dso) throws IOException
Distributes a task through a DSpace container - a convenience method for tasks declaring the@Distributiveproperty.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.
Individual tasks MUST override either the
performObjectmethod or theperformItemmethod to ensure the task is run on either all DSOs or just all Items, respectively.- Parameters:
dso- current DSpaceObject- Throws:
IOException- if IO error
-
performObject
protected void performObject(DSpaceObject dso) throws SQLException, IOException
Performs task upon a single DSpaceObject. Used in conjunction with thedistributemethod to run a single task across multiple DSpaceObjects.By default, this method just wraps a call to
performItemfor each Item Object.You should override this method if you want to use
distributeto run your task across multiple DSpace Objects.Either this method or
performItemshould be overridden ifdistributemethod is used.- Parameters:
dso- the DSpaceObject- Throws:
SQLException- if database errorIOException- if IO error
-
performItem
protected void performItem(Item item) throws SQLException, IOException
Performs task upon a single DSpace Item. Used in conjunction with thedistributemethod to run a single task across multiple Items.You should override this method if you want to use
distributeto run your task across multiple DSpace Items.Either this method or
performObjectshould be overridden ifdistributemethod is used.- Parameters:
item- the DSpace Item- Throws:
SQLException- if database errorIOException- if IO error
-
perform
public int perform(Context ctx, String id) throws IOException
Description copied from interface:CurationTaskPerform the curation task for passed id- Specified by:
performin interfaceCurationTask- Parameters:
ctx- DSpace context objectid- persistent ID for DSpace object- Returns:
- status code
- Throws:
IOException- if error
-
dereference
protected DSpaceObject dereference(Context ctx, String id) throws IOException
Returns a DSpaceObject for passed identifier, if it exists- Parameters:
ctx- DSpace contextid- canonical id of object- Returns:
- dso DSpace object, or null if no object with id exists
- Throws:
IOException- if IO error
-
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, elsenullif no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.- 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. If a taskID/Name is specified, prepend it on the configuration name.- Parameters:
name- the property namedefaultValue- 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. If a taskID/Name is specified, prepend it on the configuration name.- Parameters:
name- the property namedefaultValue- 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. If a taskID/Name is specified, prepend it on the configuration name.- Parameters:
name- the property namedefaultValue- value the default value- Returns:
- value the property value, or default
-
taskArrayProperty
protected String[] taskArrayProperty(String name)
Returns task configuration Array property value for passed name, elsenullif no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.- Parameters:
name- the property name- Returns:
- value the property value, or null
-
-