org.opentox.toxotis.util.spiders
Class Tarantula<Result>

java.lang.Object
  extended by org.opentox.toxotis.util.spiders.Tarantula<Result>
Type Parameters:
Result - The expected result or parsed object from the method parse() in this class.
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
AlgorithmSpider, BibTeXSprider, CompoundSpider, ConformerSpider, DataEntrySpider, DatasetSpider, ErrorReportSpider, FeatureSpider, FeatureValueSpider, MetaInfoSpider, ModelSpider, ParameterSpider, TaskSpider

public abstract class Tarantula<Result>
extends Object
implements Closeable

A generic parser for OpenTox components.

Author:
Charalampos Chomenides, Pantelis Sopasakis

Field Summary
protected  com.hp.hpl.jena.ontology.OntModel model
          The data model which is used in the parsing procedure and also hold the base resource
protected  long parseTime
          Computational time needed for the parsing of the data model.
protected  long readRemoteTime
          Time in ms that was needed for the reading the data model from the remote location identified by the URI of the parsed entity.
protected  com.hp.hpl.jena.rdf.model.Resource resource
          The core resource that is to be parsed out of the datamodel into an OpenTox component object.
 
Constructor Summary
Tarantula()
           
Tarantula(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.ontology.OntModel model)
          Constructor of a generic parsing processor with a given data model and a base resource which is the target of the parsing processor.
 
Method Summary
protected  void assessHttpStatus(int status, VRI actionUri)
           
 void close()
          Closes the ontological model used by the Spider (if any) and releases all resources it holds.
 com.hp.hpl.jena.ontology.OntModel getOntModel()
          Returns the ontological model held by this parser.
protected  Set<OntologicalClass> getOntologicalTypes(com.hp.hpl.jena.rdf.model.Resource currentResource)
           
protected  Set<OntologicalClass> getOTATypes(com.hp.hpl.jena.rdf.model.Resource currentResource)
           
 long getParseTime()
          Get the time needed to parse the Ontological Model into an in-house component of ToxOtis.
 long getReadRemoteTime()
          Get the time needed to download the Ontological Model and cast it as an Ontological model (instance of com.hp.hpl.jena.ontology.OntModel).
abstract  Result parse()
          Parse the data model of an OpenTox entity and create an ToxOtis object according to the data content of the data model.
protected  Set<LiteralValue> retrievePropertyLiterals(com.hp.hpl.jena.rdf.model.Property prop)
           
protected  Set<ResourceValue> retrievePropertyNodes(com.hp.hpl.jena.rdf.model.Property prop)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resource

protected com.hp.hpl.jena.rdf.model.Resource resource
The core resource that is to be parsed out of the datamodel into an OpenTox component object.


model

protected com.hp.hpl.jena.ontology.OntModel model
The data model which is used in the parsing procedure and also hold the base resource


readRemoteTime

protected long readRemoteTime
Time in ms that was needed for the reading the data model from the remote location identified by the URI of the parsed entity.


parseTime

protected long parseTime
Computational time needed for the parsing of the data model. Does not include the time needed for the entity to be downloaded and/or converted into a datamodel (OntModel of Jena).

Constructor Detail

Tarantula

public Tarantula(com.hp.hpl.jena.rdf.model.Resource resource,
                 com.hp.hpl.jena.ontology.OntModel model)
Constructor of a generic parsing processor with a given data model and a base resource which is the target of the parsing processor.

Parameters:
resource - The base resource which is to the parsed by the method parse()
model -

Tarantula

public Tarantula()
Method Detail

parse

public abstract Result parse()
                      throws ServiceInvocationException
Parse the data model of an OpenTox entity and create an ToxOtis object according to the data content of the data model.

Returns:
The parsed object.
Throws:
ServiceInvocationException

retrievePropertyLiterals

protected Set<LiteralValue> retrievePropertyLiterals(com.hp.hpl.jena.rdf.model.Property prop)

retrievePropertyNodes

protected Set<ResourceValue> retrievePropertyNodes(com.hp.hpl.jena.rdf.model.Property prop)

getOTATypes

protected Set<OntologicalClass> getOTATypes(com.hp.hpl.jena.rdf.model.Resource currentResource)

getOntologicalTypes

protected Set<OntologicalClass> getOntologicalTypes(com.hp.hpl.jena.rdf.model.Resource currentResource)

close

public void close()
Closes the ontological model used by the Spider (if any) and releases all resources it holds. Closing the Spider is considered good practise and prefered comparing to leaving it to the finalizer.

Specified by:
close in interface Closeable

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel()
Returns the ontological model held by this parser.

Returns:
Ontological Model of the processed resource.

getParseTime

public long getParseTime()
Get the time needed to parse the Ontological Model into an in-house component of ToxOtis. This time does not include the time needed to download the Ontological Model from the remote location.

Returns:
Parsing time. The method will return -1 in case the method parse has not been invoked.

getReadRemoteTime

public long getReadRemoteTime()
Get the time needed to download the Ontological Model and cast it as an Ontological model (instance of com.hp.hpl.jena.ontology.OntModel).

Returns:
Download time plus the time needed by the method read(InputStream, String) in com.hp.hpl.jena.ontology.OntModel to convert the representation into an Ontological Model. The method returns -1 if the underlying Spider (subclass of Tarantula) was not properly initialized or the model was not loaded from a remote location.

assessHttpStatus

protected void assessHttpStatus(int status,
                                VRI actionUri)
                         throws ServiceInvocationException
Throws:
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.