org.opentox.toxotis.factory
Class FeatureFactory

java.lang.Object
  extended by org.opentox.toxotis.factory.FeatureFactory

public class FeatureFactory
extends Object

A factory-like class that provides methods for looking up features in remote databases through the OpenTox REST API.

Author:
Pantelis Sopasakis, Charalampos Chomenides

Constructor Summary
FeatureFactory()
           
 
Method Summary
static Feature createAndPublishFeature(MetaInfo metaInfo, String units, VRI featureService, AuthenticationToken token)
          Created and publishes online a new Feature given its title and source (acting as a reason for its creation).
static Feature createAndPublishFeature(String title, String units, ResourceValue hasSource, VRI fetureService, AuthenticationToken token)
          Created and publishes online a new Feature given its title and source (acting as a reason for its creation).
static Set<VRI> listAllFeatures(VRI featureService, int max, AuthenticationToken token)
          Lists all features available from a feature service providing also an authentication token.
static Set<VRI> listAllFeatures(VRI featureService, int page, int pagesize, AuthenticationToken token)
          Lists all features available from a feature service providing also an authentication token.
static Set<VRI> lookupSameAs(OntologicalClass echaEndpoint, AuthenticationToken token)
          Retrieve a collection of Feature URIs by querying a default Feature Service, that are same as a certain ECHA endpoint as these are formalized using the OpenTox ontology.
static Set<VRI> lookupSameAs(VRI service, OntologicalClass echaEndpoint, AuthenticationToken token)
          Retrieve a collection of Feature URIs that are same as a certain ECHA endpoint as these are formalized using the OpenTox ontology.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeatureFactory

public FeatureFactory()
Method Detail

lookupSameAs

public static Set<VRI> lookupSameAs(VRI service,
                                    OntologicalClass echaEndpoint,
                                    AuthenticationToken token)
                             throws ServiceInvocationException
Retrieve a collection of Feature URIs that are same as a certain ECHA endpoint as these are formalized using the OpenTox ontology. This ontology can be downloaded from the OpenTox repository for RDF files. Within ToxOtis, you can refer to the various ECHA end-points using the class OTEchaEndpoints .

Parameters:
service - URI of an OpenTox feature service. Feature service URI comply with the pattern http://someserver.com/feature/id which formally, in terms of regular expression matches the pattern .+/(?i)feature(s||)/([^/]+/$|[^/]+)$. If the URI is set to null then the Ontology Service is used.
echaEndpoint - An ECHA enpoint as an Ontological Class. You may obtain a list of some default endpoint classes from OTEchaEndpoints .
token - Auththentication token provided by the user to authenticate against the service in case it has restricted access.
Returns:
a Set of Feature URIs that are same as the ECHA endpoint provided.
Throws:
ServiceInvocationException

lookupSameAs

public static Set<VRI> lookupSameAs(OntologicalClass echaEndpoint,
                                    AuthenticationToken token)
                             throws ServiceInvocationException
Retrieve a collection of Feature URIs by querying a default Feature Service, that are same as a certain ECHA endpoint as these are formalized using the OpenTox ontology. This ontology can be downloaded from the OpenTox repository for RDF files. Within ToxOtis, you can refer to the various ECHA enpoitns using the class OTEchaEndpoints .

Parameters:
echaEndpoint - An ECHA enpoint as an Ontological Class. You may obtain a list of some default endpoint classes from OTEchaEndpoints .
token - Auththentication token provided by the user to authenticate against the service in case it has restricted access.
Returns:
a Set of Feature URIs that are same as the ECHA endpoint provided.
Throws:
ServiceInvocationException

listAllFeatures

public static Set<VRI> listAllFeatures(VRI featureService,
                                       int max,
                                       AuthenticationToken token)
                                throws ServiceInvocationException
Lists all features available from a feature service providing also an authentication token.

Parameters:
featureService - The URI of a feature service
max - The maximum number of feature URIs to be returned from the feature service. This is supported by the web services at apps.ideaconsult.net and ambit.uni-plovdiv.bg but is not part of the official API (version 1.1) so it might not be supported by other OpenTox feature services. if set to -1 the method returns all available features on the remote server. If the provided URI has already a directive for the maximum number of features using the URL query ?max={max}, it will be overridden.
token - An authentication token which can be obtained from the singleton class TokenPool that manages multiple logged in users.
Returns:
Set of all URIs available from the feature service
Throws:
ToxOtisException - In case a non-success HTTP status code is returned by the remote service, either due to authentication/authorization failure of due to other unexpected conditions (e.g. error 500 or 503).
ServiceInvocationException

listAllFeatures

public static Set<VRI> listAllFeatures(VRI featureService,
                                       int page,
                                       int pagesize,
                                       AuthenticationToken token)
                                throws ServiceInvocationException
Lists all features available from a feature service providing also an authentication token.

Parameters:
featureService - The URI of a feature service
page - When paging of results is supported, page stands fort the index of that page. If set to -1 it will have no effect on the URI and the request so all pages will be returned.
pagesize - Size of the page of results to be returned. If set to -1 it will have no effect on the URI and the request so all pages will be returned, i.e. all features contained in the remote database.
token - An authentication token which can be obtained from the singleton class TokenPool that manages multiple logged in users.
Returns:
Set of all URIs available from the feature service
Throws:
ToxOtisException - In case a non-success HTTP status code is returned by the remote service, either due to authentication/authorization failure of due to other unexpected conditions (e.g. error 500 or 503).
ServiceInvocationException

createAndPublishFeature

public static Feature createAndPublishFeature(String title,
                                              String units,
                                              ResourceValue hasSource,
                                              VRI fetureService,
                                              AuthenticationToken token)
                                       throws ServiceInvocationException
Created and publishes online a new Feature given its title and source (acting as a reason for its creation).

Parameters:
title - Title of the newly created feature
units - Units for the created feature
hasSource - An ot:hasSource reference for the created Feature
fetureService - Feature service URI to which the created feature should be posted
token - Authentication token used to authenticate and authorize the user to publish the feature
Returns:
The created feature with an updated URI. Use the method OTComponent.getUri() to obtain the URI of the newly created feature.
Throws:
ToxOtisException - In case the publication of the feature is not possible, the process is interrupted while waiting for its completion of other unexpected exceptional events related to the publication of the feature occur.
ServiceInvocationException

createAndPublishFeature

public static Feature createAndPublishFeature(MetaInfo metaInfo,
                                              String units,
                                              VRI featureService,
                                              AuthenticationToken token)
                                       throws ServiceInvocationException
Created and publishes online a new Feature given its title and source (acting as a reason for its creation).

Parameters:
metaInfo - Meta-information about the feature
units - Units for the created feature
featureService - Feature service URI to which the created feature should be posted
token - Authentication token used to authenticate and authorize the user to publish the feature
Returns:
The created feature with an updated URI. Use the method OTComponent.getUri() to obtain the URI of the newly created feature.
Throws:
ToxOtisException - In case the publication of the feature is not possible, the process is interrupted while waiting for its completion of other unexpected exceptional events related to the publication of the feature occur.
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.