info.sswap.impl.empire
Class APIProviderImpl

java.lang.Object
  extended by info.sswap.impl.empire.APIProviderImpl
All Implemented Interfaces:
APIProvider

public class APIProviderImpl
extends java.lang.Object
implements APIProvider

Provides implementation of the API that is called by SSWAP factory class. This class is implemented as a singleton. Normal access to the instance is provided via the get() static method.

Author:
Blazej Bulka

Field Summary
private static APIProviderImpl instance
          The instance singleton instance of this class.
 
Constructor Summary
private APIProviderImpl()
          Private constructor (following singleton design pattern).
 
Method Summary
 com.hp.hpl.jena.rdf.model.Model asJenaModel(SSWAPModel model)
          Returns the representation of the given SSWAPModel using Jena interface
private  void clearIndividual(SSWAPIndividual individual)
           
protected
<T extends SSWAPDocument>
T
clone(T original, java.lang.Class<T> clazz)
           
 SSWAPElement copyElement(SSWAPDocument dstDocument, SSWAPElement element)
           
 RDG createCompositeService(java.net.URI serviceURI, java.lang.String name, java.lang.String description, java.net.URI providerURI, RDG firstService, RDG lastService)
           
<T extends SSWAPDocument>
T
createDocument(com.hp.hpl.jena.rdf.model.Model model, java.lang.Class<T> clazz)
           
<T extends SSWAPDocument>
T
createDocument(com.hp.hpl.jena.rdf.model.Model model, java.lang.Class<T> clazz, java.net.URI uri)
           
 PDG createPDG(java.net.URI providerURI, java.lang.String name, java.lang.String oneLineDescription)
          Creates a new PDG (Provider Description Graph).
 SSWAPProvider createProvider(java.net.URI uri)
          Gets an undereferenced SSWAPProvider implementation
 RDG createRDG(java.net.URI resourceURI, java.lang.String name, java.lang.String oneLineDescription, java.net.URI providerURI)
          Creates a new RDG object.
 SSWAPResource createResource(java.net.URI uri)
          Gets an undereferenced SSWAPResource implementation
 RQG createRQG(java.net.URI resourceURI)
          Creates a basic RQG from scratch.
 SSWAPDocument createSSWAPDocument(java.net.URI uri)
          Creates an empty SSWAPModel.
private  java.util.Collection<SSWAPObject> generateCompositeServiceObjects(RDG lastService, RDG result)
           
private  java.util.Collection<SSWAPSubject> generateCompositeServiceSubjects(RDG firstService, RDG lastService, RDG result)
           
 RQG generateRQG(RDG upstreamService, RDG downstreamService)
           
 RQG generateRQG(RDG upstreamService, RDG downstreamService, java.net.URI resultURI)
           
private  java.util.Collection<SSWAPObject> generateRQGObjects(RDG downstreamService, RQG rqg)
           
private  java.util.Collection<SSWAPSubject> generateRQGSubjects(RDG upstreamService, RDG downstreamService, RQG rqg)
           
static APIProviderImpl get()
          The getter method for the singleton instance.
 RIG getAsyncRIG(java.net.URI serviceURI, java.net.URI upstreamRRG)
           
 Cache getCache()
           
 SSWAPDocument getClosureDocument(SSWAPDocument document)
           
private
<S extends SSWAPDocument>
java.lang.Class<? extends SourceModelImpl>
getImplementationClass(java.lang.Class<S> interfaceClass)
          Gets the implementation of a specific SSWAPProtocol interface
 SSWAPDocument getInferredABox(SSWAPDocument document)
          Gets the document that contains the ABox of this document (including both inferred and asserted statements).
 SSWAPDocument getInferredDocument(SSWAPDocument document)
           
 SSWAPDocument getInferredTBox(SSWAPDocument document)
          Gets the document that contains the TBox of this document (including both inferred and asserted statements).
 java.util.Collection<java.lang.String> getInferredTypeURIs(SSWAPIndividual individual)
           
 PDG getPDG(java.net.URI uri)
          Gets an undereferenced PDG implementation.
 RDG getRDG(java.net.URI uri)
          Gets a dereferenced RDG implementation
<T extends SSWAPDocument>
T
getResourceGraph(java.io.InputStream is, java.lang.Class<T> clazz, java.net.URI uri)
          Creates a SSWAPDocument graph from its serialization in an input stream.
 RQG getRQG(java.io.InputStream is)
          Reads an RQG from an input stream.
<T extends SSWAPNode>
T
getUntranslatedNode(T translatedNode)
           
 RQG inputOnlyRQG(RQG rqg)
           
private static boolean isEmptyObject(SSWAPObject object)
           
private static boolean isEmptySubject(SSWAPSubject subject)
           
 boolean isUnrestricted(RQG rqg)
           
 RQG outputOnlyRQG(RQG rqg)
           
 void setClosureEnabled(SSWAPDocument document, boolean enabled)
           
 void setExplanationSyntax(java.lang.String explanationSyntax)
           
 void setMaxClosureBytes(SSWAPModel model, long byteLimit)
          Sets a model-specific byte limit to retrieve the closure
 void setMaxClosureThreads(SSWAPModel model, int threads)
          Sets a model-specific limit on the number of threads used to retrieve the closure
 void setMaxClosureTime(SSWAPModel model, long timeLimit)
          Sets a model-specific time limit to retrieve the closure
 void setValueValidation(SSWAPDocument document, boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static final APIProviderImpl instance
The instance singleton instance of this class.

Constructor Detail

APIProviderImpl

private APIProviderImpl()
Private constructor (following singleton design pattern).

Method Detail

get

public static APIProviderImpl get()
The getter method for the singleton instance.

Returns:
the instance of the implementation

getPDG

public PDG getPDG(java.net.URI uri)
           throws DataAccessException
Description copied from interface: APIProvider
Gets an undereferenced PDG implementation.

Specified by:
getPDG in interface APIProvider
Parameters:
uri - URI of the PDG
Returns:
the implementation of the PDG
Throws:
DataAccessException

createProvider

public SSWAPProvider createProvider(java.net.URI uri)
                             throws DataAccessException
Description copied from interface: APIProvider
Gets an undereferenced SSWAPProvider implementation

Specified by:
createProvider in interface APIProvider
Parameters:
uri - URI of the provider
Returns:
the implementation of the SSWAPProvider
Throws:
DataAccessException

getRDG

public RDG getRDG(java.net.URI uri)
           throws DataAccessException
Description copied from interface: APIProvider
Gets a dereferenced RDG implementation

Specified by:
getRDG in interface APIProvider
Parameters:
uri - URI of the RDG
Returns:
the implementation of the RDG
Throws:
DataAccessException - if an error should occur while trying to access RDG's data

createResource

public SSWAPResource createResource(java.net.URI uri)
                             throws DataAccessException
Description copied from interface: APIProvider
Gets an undereferenced SSWAPResource implementation

Specified by:
createResource in interface APIProvider
Parameters:
uri - URI of the Resource
Returns:
the implementation of the resource
Throws:
DataAccessException

createRDG

public RDG createRDG(java.net.URI resourceURI,
                     java.lang.String name,
                     java.lang.String oneLineDescription,
                     java.net.URI providerURI)
              throws DataAccessException
Description copied from interface: APIProvider
Creates a new RDG object.

Specified by:
createRDG in interface APIProvider
Parameters:
resourceURI - the URI of the SSWAP Resource (and the RDG itself)
name - the name of the service described in this RDG
oneLineDescription - a short description of the RDG
providerURI - an URI of the provider of this service
Returns:
the created RDG
Throws:
DataAccessException

getRQG

public RQG getRQG(java.io.InputStream is)
           throws DataAccessException
Description copied from interface: APIProvider
Reads an RQG from an input stream.

Specified by:
getRQG in interface APIProvider
Parameters:
is - the input stream containing the representation of the RQG
Returns:
the RQG
Throws:
DataAccessException

createRQG

public RQG createRQG(java.net.URI resourceURI)
              throws DataAccessException
Description copied from interface: APIProvider
Creates a basic RQG from scratch. The created RQG contains only SSWAPResource.

Specified by:
createRQG in interface APIProvider
Parameters:
resourceURI - the URI of the resource in the RQG; may be null for anonymous resources
Returns:
the RQG with a SSWAPResource
Throws:
DataAccessException

createSSWAPDocument

public SSWAPDocument createSSWAPDocument(java.net.URI uri)
                                  throws DataAccessException
Description copied from interface: APIProvider
Creates an empty SSWAPModel. This method can be used to contain other SSWAPModels if it is undesirable to create a full SSWAPCanonicalGraph or a PDG.

Specified by:
createSSWAPDocument in interface APIProvider
Parameters:
uri - the URI of the SSWAP model
Returns:
an empty SSWAP model
Throws:
DataAccessException

createPDG

public PDG createPDG(java.net.URI providerURI,
                     java.lang.String name,
                     java.lang.String oneLineDescription)
              throws DataAccessException
Description copied from interface: APIProvider
Creates a new PDG (Provider Description Graph).

Specified by:
createPDG in interface APIProvider
Parameters:
providerURI - the URI of the SSWAP Provider (and the PDG itself)
name - the name of the provider described in this PDG
oneLineDescription - the one line description of the provider
Returns:
newly created PDG
Throws:
DataAccessException

getImplementationClass

private <S extends SSWAPDocument> java.lang.Class<? extends SourceModelImpl> getImplementationClass(java.lang.Class<S> interfaceClass)
Gets the implementation of a specific SSWAPProtocol interface

Type Parameters:
S - the interface
Parameters:
interfaceClass - the interface class
Returns:
the class of the implementation

getResourceGraph

public <T extends SSWAPDocument> T getResourceGraph(java.io.InputStream is,
                                                    java.lang.Class<T> clazz,
                                                    java.net.URI uri)
                                         throws DataAccessException
Description copied from interface: APIProvider
Creates a SSWAPDocument graph from its serialization in an input stream.

Specified by:
getResourceGraph in interface APIProvider
Type Parameters:
T - the template parameter that specifies the type of SSWAPDocument graph to be created (e.g., RDG, RIG, etc.).
Parameters:
is - the input stream from which the contents of the graph should be read
clazz - the Java Class object that identifies the type of SSWAPDocument graph (and provides the instantiation for the template parameter; e.g., RDG.class, RIG.class, etc.)
uri - the URI to dereference to obtain the graph
Returns:
the created SSWAPDocument graph
Throws:
DataAccessException - on parsing or other data error

asJenaModel

public com.hp.hpl.jena.rdf.model.Model asJenaModel(SSWAPModel model)
                                            throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Returns the representation of the given SSWAPModel using Jena interface

Specified by:
asJenaModel in interface APIProvider
Parameters:
model - the SSWAPModel
Returns:
Jena model that contains the representation of this document
Throws:
java.lang.UnsupportedOperationException - if the specified provider does not support this feature

getInferredABox

public SSWAPDocument getInferredABox(SSWAPDocument document)
                              throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Gets the document that contains the ABox of this document (including both inferred and asserted statements).

Specified by:
getInferredABox in interface APIProvider
Parameters:
document - source SSWAPDocument
Returns:
the document with the ABox
Throws:
java.lang.UnsupportedOperationException - if the specified provider does not support this feature

getInferredTBox

public SSWAPDocument getInferredTBox(SSWAPDocument document)
                              throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Gets the document that contains the TBox of this document (including both inferred and asserted statements).

Specified by:
getInferredTBox in interface APIProvider
Parameters:
document - source SSWAPDocument
Returns:
the document with the TBox
Throws:
java.lang.UnsupportedOperationException - if the specified provider does not support this feature

setMaxClosureBytes

public void setMaxClosureBytes(SSWAPModel model,
                               long byteLimit)
                        throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Sets a model-specific byte limit to retrieve the closure

Specified by:
setMaxClosureBytes in interface APIProvider
Parameters:
model - the model for which the limit should be set
byteLimit - the maximum number of bytes to retrieve the closure, or -1 to remove any previous model-specific limit (a system-wide limit will be used for this model)
Throws:
java.lang.UnsupportedOperationException - if the operation is not supported by this API Implementation

setMaxClosureThreads

public void setMaxClosureThreads(SSWAPModel model,
                                 int threads)
                          throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Sets a model-specific limit on the number of threads used to retrieve the closure

Specified by:
setMaxClosureThreads in interface APIProvider
Parameters:
model - the model for which the limit should be set
threads - the number of threads, or -1 to remove any previous model-specific limit (a system-wide limit will be used for this model)
Throws:
java.lang.UnsupportedOperationException - if the operation is not supported by this API Implementation

setMaxClosureTime

public void setMaxClosureTime(SSWAPModel model,
                              long timeLimit)
                       throws java.lang.UnsupportedOperationException
Description copied from interface: APIProvider
Sets a model-specific time limit to retrieve the closure

Specified by:
setMaxClosureTime in interface APIProvider
Parameters:
model - the model for which the limit should be set
timeLimit - the maximum number of milliseconds to retrieve the closure, or -1 to remove any previous model-specific limit (a system-wide limit will be used for this model)
Throws:
java.lang.UnsupportedOperationException - if the operation is not supported by this API Implementation

createDocument

public <T extends SSWAPDocument> T createDocument(com.hp.hpl.jena.rdf.model.Model model,
                                                  java.lang.Class<T> clazz)
                                       throws java.lang.UnsupportedOperationException
Specified by:
createDocument in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

createDocument

public <T extends SSWAPDocument> T createDocument(com.hp.hpl.jena.rdf.model.Model model,
                                                  java.lang.Class<T> clazz,
                                                  java.net.URI uri)
                                       throws java.lang.UnsupportedOperationException
Specified by:
createDocument in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

getClosureDocument

public SSWAPDocument getClosureDocument(SSWAPDocument document)
                                 throws java.lang.UnsupportedOperationException
Specified by:
getClosureDocument in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

getInferredDocument

public SSWAPDocument getInferredDocument(SSWAPDocument document)
                                  throws java.lang.UnsupportedOperationException
Specified by:
getInferredDocument in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

setExplanationSyntax

public void setExplanationSyntax(java.lang.String explanationSyntax)
                          throws java.lang.UnsupportedOperationException
Specified by:
setExplanationSyntax in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

generateRQG

public RQG generateRQG(RDG upstreamService,
                       RDG downstreamService)
                throws java.lang.UnsupportedOperationException
Specified by:
generateRQG in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

generateRQG

public RQG generateRQG(RDG upstreamService,
                       RDG downstreamService,
                       java.net.URI resultURI)
                throws java.lang.UnsupportedOperationException
Specified by:
generateRQG in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

generateRQGSubjects

private java.util.Collection<SSWAPSubject> generateRQGSubjects(RDG upstreamService,
                                                               RDG downstreamService,
                                                               RQG rqg)

generateRQGObjects

private java.util.Collection<SSWAPObject> generateRQGObjects(RDG downstreamService,
                                                             RQG rqg)

getAsyncRIG

public RIG getAsyncRIG(java.net.URI serviceURI,
                       java.net.URI upstreamRRG)
                throws DataAccessException
Specified by:
getAsyncRIG in interface APIProvider
Throws:
DataAccessException

copyElement

public SSWAPElement copyElement(SSWAPDocument dstDocument,
                                SSWAPElement element)
                         throws java.lang.UnsupportedOperationException
Specified by:
copyElement in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

getCache

public Cache getCache()
Specified by:
getCache in interface APIProvider

setValueValidation

public void setValueValidation(SSWAPDocument document,
                               boolean enabled)
                        throws java.lang.UnsupportedOperationException
Specified by:
setValueValidation in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

setClosureEnabled

public void setClosureEnabled(SSWAPDocument document,
                              boolean enabled)
                       throws java.lang.UnsupportedOperationException
Specified by:
setClosureEnabled in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

getInferredTypeURIs

public java.util.Collection<java.lang.String> getInferredTypeURIs(SSWAPIndividual individual)
                                                           throws java.lang.UnsupportedOperationException
Specified by:
getInferredTypeURIs in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

createCompositeService

public RDG createCompositeService(java.net.URI serviceURI,
                                  java.lang.String name,
                                  java.lang.String description,
                                  java.net.URI providerURI,
                                  RDG firstService,
                                  RDG lastService)
                           throws java.lang.UnsupportedOperationException
Specified by:
createCompositeService in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

generateCompositeServiceSubjects

private java.util.Collection<SSWAPSubject> generateCompositeServiceSubjects(RDG firstService,
                                                                            RDG lastService,
                                                                            RDG result)

generateCompositeServiceObjects

private java.util.Collection<SSWAPObject> generateCompositeServiceObjects(RDG lastService,
                                                                          RDG result)

clone

protected <T extends SSWAPDocument> T clone(T original,
                                            java.lang.Class<T> clazz)

clearIndividual

private void clearIndividual(SSWAPIndividual individual)

inputOnlyRQG

public RQG inputOnlyRQG(RQG rqg)
                 throws java.lang.UnsupportedOperationException
Specified by:
inputOnlyRQG in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

outputOnlyRQG

public RQG outputOnlyRQG(RQG rqg)
                  throws java.lang.UnsupportedOperationException
Specified by:
outputOnlyRQG in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

isUnrestricted

public boolean isUnrestricted(RQG rqg)
                       throws java.lang.UnsupportedOperationException
Specified by:
isUnrestricted in interface APIProvider
Throws:
java.lang.UnsupportedOperationException

isEmptySubject

private static boolean isEmptySubject(SSWAPSubject subject)

isEmptyObject

private static boolean isEmptyObject(SSWAPObject object)

getUntranslatedNode

public <T extends SSWAPNode> T getUntranslatedNode(T translatedNode)
                                        throws java.lang.UnsupportedOperationException
Specified by:
getUntranslatedNode in interface APIProvider
Throws:
java.lang.UnsupportedOperationException


Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.