org.opentox.toxotis.core.component
Class Task

java.lang.Object
  extended by org.opentox.toxotis.core.OTComponent<T>
      extended by org.opentox.toxotis.core.OTOnlineResource<Task>
          extended by org.opentox.toxotis.core.component.Task
All Implemented Interfaces:
Serializable, IHTMLSupport, IOnlineResource, IOTComponent, IStAXWritable

public class Task
extends OTOnlineResource<Task>
implements IHTMLSupport

An asynchronous job running on a remote service. Tasks are resources provided to the client to be able to monitor the progress of a job running on a server.

Author:
Pantelis Sopasakis, Charalampos Chomenides
See Also:
Serialized Form

Nested Class Summary
static class Task.Status
          Status of the task revealing information about the asynchronous job with which the task is related and runs on a server.
 
Field Summary
 
Fields inherited from class org.opentox.toxotis.core.OTOnlineResource
XSD_DATATYPE_LINKS
 
Fields inherited from class org.opentox.toxotis.core.OTComponent
meta, RDF_ABOUT, RDF_RDF, RDF_RESOURCE, RDF_TYPE
 
Constructor Summary
Task()
           
Task(VRI uri)
           
 
Method Summary
 com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
          The OpenTox component as an individual.
 User getCreatedBy()
          Retrieve the user which created the task.
 Long getDuration()
          The duration of the task, that is the overall time since its execution started, not including the time it was queued.
 ErrorReport getErrorReport()
           
 float getHttpStatus()
           
 float getPercentageCompleted()
          Get the percentage of completion of a running task.
 VRI getResultUri()
           
 Task.Status getStatus()
          The status of the task as an element of the enumeration Task.Status.
 HTMLContainer inHtml()
          Create an HTML container for the online resource.
protected  Task loadFromRemote(VRI uri, AuthenticationToken token)
          Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T.
 Task setCreatedBy(User createdBy)
           
 Task setDuration(Long duration)
          Setter method for the duration of the task in milliseconds.
 Task setErrorReport(ErrorReport errorReport)
           
 Task setHttpStatus(float httpStatus)
           
 Task setPercentageCompleted(float percentageCompleted)
           
 Task setResultUri(VRI resultUri)
           
 Task setStatus(Task.Status status)
          ParameterValue the status of a task.
 String toString()
           
 void writeRdf(XMLStreamWriter writer)
          Due to the large size of some objects like datasets, it is advisable to use this method for serializing large objects to RDF/XML rather than the method OntModel#write(OutputStream).
 
Methods inherited from class org.opentox.toxotis.core.OTOnlineResource
download, download, download, download, downloadImage, loadFromRemote, loadFromRemote
 
Methods inherited from class org.opentox.toxotis.core.OTComponent
addOntologicalClasses, asOntModel, endRdfWriter, equals, getMeta, getOntologicalClasses, getUri, hashCode, initRdfWriter, isEnabled, setEnabled, setMeta, setOntologicalClasses, setUri, writeAnnotationProperty, writeClass, writeDatatypeProperty, writeMetaDataProperties, writeObjectProperty, writeRdf, writeRdf, writeSuperClassRelationships
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opentox.toxotis.core.IOTComponent
addOntologicalClasses, asOntModel, getMeta, getOntologicalClasses, getUri, isEnabled, setEnabled, setMeta, setOntologicalClasses
 

Constructor Detail

Task

public Task()

Task

public Task(VRI uri)
Method Detail

loadFromRemote

protected Task loadFromRemote(VRI uri,
                              AuthenticationToken token)
                       throws ServiceInvocationException
Description copied from class: OTOnlineResource
Loads an OpenTox component from a remote location identified by its uri and parses it into an instance of T. This method is protected and should be implemented by all subclasses of OTOnlineResource. The method is invoked by its public counterpart OTOnlineResource.loadFromRemote(org.opentox.toxotis.util.aa.AuthenticationToken) which accesses the remote location providing an authentication token.

Specified by:
loadFromRemote in class OTOnlineResource<Task>
Parameters:
uri - Identifier of the location from where the component should be downloaded and parsed
token - Token provided
Returns:
Parsed instance of the component.
Throws:
ServiceInvocationException

writeRdf

public void writeRdf(XMLStreamWriter writer)
              throws XMLStreamException
Description copied from interface: IStAXWritable
Due to the large size of some objects like datasets, it is advisable to use this method for serializing large objects to RDF/XML rather than the method OntModel#write(OutputStream). In the case of Datasets, it has been shown that this method performs much faster (about 7,5 times faster on a dataset of 21 features and 1000 compounds).

Specified by:
writeRdf in interface IStAXWritable
Parameters:
writer - XML Stream Writer used for the serialization of the dataset object.
Throws:
XMLStreamException - In case the serialization is not possible due to syntax errors.

inHtml

public HTMLContainer inHtml()
Description copied from interface: IHTMLSupport
Create an HTML container for the online resource.

Specified by:
inHtml in interface IHTMLSupport
Returns:
HTMLContainer which can be used to create an HTML representation for the component.

getDuration

public Long getDuration()
The duration of the task, that is the overall time since its execution started, not including the time it was queued.

Returns:
The duration of the task in millisenconds or 0 if no duration is assigned.

setDuration

public Task setDuration(Long duration)
Setter method for the duration of the task in milliseconds. The time during which the task was in a queue should not be included in the execution duration.

Parameters:
duration - The duration of the task in milliseconds
Returns:
The current updated modifiable Task object.

getCreatedBy

public User getCreatedBy()
Retrieve the user which created the task.

Returns:
Creator of the task or null if not available.

setCreatedBy

public Task setCreatedBy(User createdBy)

getStatus

public Task.Status getStatus()
The status of the task as an element of the enumeration Task.Status. A task can either be RUNNING, COMPLETED, CANCELLED and ERROR.

Returns:
The status of the task.

setStatus

public Task setStatus(Task.Status status)
ParameterValue the status of a task.

Parameters:
status - The new value for the status of the task.

getPercentageCompleted

public float getPercentageCompleted()
Get the percentage of completion of a running task.

Returns:
Percentage of completion as a number in the range [0, 100].

setPercentageCompleted

public Task setPercentageCompleted(float percentageCompleted)

getResultUri

public VRI getResultUri()

setResultUri

public Task setResultUri(VRI resultUri)

getErrorReport

public ErrorReport getErrorReport()

setErrorReport

public Task setErrorReport(ErrorReport errorReport)

getHttpStatus

public float getHttpStatus()

setHttpStatus

public Task setHttpStatus(float httpStatus)

asIndividual

public com.hp.hpl.jena.ontology.Individual asIndividual(com.hp.hpl.jena.ontology.OntModel model)
Description copied from interface: IOTComponent
The OpenTox component as an individual.

Specified by:
asIndividual in interface IOTComponent
Parameters:
model - The ontological model to which the individual belongs.
Returns:
The OpenTox component as an individual of a data model.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011-2012 OpenTox. All Rights Reserved.