All Versions
- DSpace 7.x (Current Release)
- DSpace 8.x (Unreleased)
- DSpace 6.x (EOL)
- DSpace 5.x (EOL)
- More Versions...
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
A task is just a java class that can contain arbitrary code, but it must have 2 properties:
...
If a task extends the AbstractCurationTask
class, that is the only method it needs to define.
Few assumptions are made by CS about what the 'outcome' of a task may be (if any) - it. could e.g. produce a report to a temporary file, it could modify DSpace content silently, etc. But the CS runtime does provide a few pieces of information whenever a task is performed:
This is returned to CS by any of a task's perform
methods. The complete list of values, defined in Curator
, is:
value | symbol | meaning |
---|---|---|
-3 | CURATE_NOTASK | CS could not find the requested task |
-2 | CURATE_UNSET | task did not return a status code because it has not yet run |
-1 | CURATE_ERROR | task could not be performed |
0 | CURATE_SUCCESS | task performed successfully |
1 | CURATE_FAIL | task performed, but failed |
2 | CURATE_SKIP | task not performed due to object not being eligible |
In the administrative UI, this code is translated into the word or phrase configured by the ui.statusmessages property (discussed in Curation System) for display.
The task may set a string indicating details of the outcome:
...
CS does not interpret or assign result strings; the task does it. A task may choose not to assign a result, but the "best practice" for tasks is to assign one whenever possible. Code which invokes Curator.getResult()
may use the result string for display or any other purpose.
For very fine-grained information, a task may write to a reporting stream. This stream is sent to standard out, so is only available when running a task from the command line. Unlike the result string, there is no limit to the amount of data that may be pushed to this stream.
Code Block | ||
---|---|---|
| ||
curator.report("Lorem ipsum dolor sit amet,\n"); curator.report("consectetur adipiscing elit,\n"); curator.report("sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"); |
The status code, and the result string are accessed (or set) by methods on the Curation object:
Code Block | ||
---|---|---|
| ||
Curator curator = new Curator(); curator.addTask("vscan").curate(coll); int status = curator.getStatus("vscan"); String result = curator.getResult("vscan"); |
Task code may configure itself using ConfigurationService in the normal manner, or by the use of "task properties". See Curation System - Task Properties for discussion of the issues for which task properties were invented. Any code which extends AbstractCurationTask has access to its configured task properties.
...
Code Block | ||
---|---|---|
| ||
public String taskProperty(String name); public int taskIntProperty(String name, int defaultValue); public long taskLongProperty(String name, long defaultValue); public boolean taskBooleanProperty(String name, boolean default); |
CS looks for, and will use, certain java annotations in the task Class definition that can help it invoke tasks more intelligently. An example may explain best. Since tasks operate on DSOs that can either be simple (Items) or containers (Collections, and Communities), there is a fundamental problem or ambiguity in how a task is invoked: if the DSO is a collection, should the CS invoke the task on each member of the collection, or does the task "know" how to do that itself? The decision is made by looking for the @Distributive annotation: if present, CS assumes that the task will manage the details, otherwise CS will walk the collection, and invoke the task on each member. The java class would be defined:
...
Only a few annotation types have been defined so far, but as the number of tasks grow, we can look for common behavior that can be signaled by annotation. For example, there is a @Mutative type: that tells CS that the task may alter (mutate) the object it is working on.
DSpace 1.8 introduced limited (and somewhat experimental) support for deploying and running tasks written in languages other than Java. Since version 6, Java has provided a standard way (API) to invoke so-called scripting or dynamic language code that runs on the java virtual machine (JVM). Scripted tasks are those written in a language accessible from this API. See Curation System - Scripted Tasks for information on configuring and running scripted tasks.
Scripted tasks must implement a slightly different interface than the CurationTask interface used for Java tasks. The appropriate interface for scripting tasks is ScriptedTask and has the following methods:
...
The difference is that ScriptedTask
has separate perform
methods for DSO and identifier. The reason for that is that some scripting languages (e.g. Ruby) don't support method overloading.
You may have noticed that the ScriptedTask
interface has both performDso()
and performId()
methods, but only performDso is ever called when curator is launched from command line.
...