info.sswap.impl.empire.model
Class RIGImpl

java.lang.Object
  extended by info.sswap.impl.empire.model.ModelImpl
      extended by info.sswap.impl.empire.model.SourceModelImpl
          extended by info.sswap.impl.empire.model.ProtocolImpl
              extended by info.sswap.impl.empire.model.RIGImpl
All Implemented Interfaces:
com.clarkparsia.empire.SupportsRdfId, RIG, SSWAPDocument, SSWAPModel, SSWAPProtocol, SourceModel

public abstract class RIGImpl
extends ProtocolImpl
implements RIG

Implementation of RIG.

Author:
Blazej Bulka

Nested Class Summary
 
Nested classes/interfaces inherited from class info.sswap.impl.empire.model.ProtocolImpl
ProtocolImpl.DefaultMappingValidator<T extends SSWAPNode>, ProtocolImpl.MappingValidator<T>
 
Nested classes/interfaces inherited from interface com.clarkparsia.empire.SupportsRdfId
com.clarkparsia.empire.SupportsRdfId.BNodeKey, com.clarkparsia.empire.SupportsRdfId.RdfKey<T>, com.clarkparsia.empire.SupportsRdfId.URIKey
 
Field Summary
private  boolean clientSideTranslation
           
private  java.util.Collection<SSWAPGraph> matchingGraphs
           
private  RDG rdg
           
private  java.util.Map<SSWAPNode,SSWAPNode> translatedNodes
           
 
Fields inherited from class info.sswap.impl.empire.model.SourceModelImpl
SSWAP_ONTOLOGY_URI
 
Constructor Summary
RIGImpl()
           
 
Method Summary
private  HTTPAPIImpl.RRGResponse doInvoke(java.lang.Long timeout)
          Invokes the service with this RIG and the specified connect/read timeout (if provided).
 java.lang.String getGraphType()
          Gets the human readable name of the particular graph implementation (e.g., RDG, RQG, RIG, RRG) This method is mostly provided to generate meaningful messages in exceptions (rather than to include class name, which may not be familiar to most users)
 java.util.Collection<SSWAPGraph> getMatchingGraphs()
           
(package private)  RDG getRDG()
           
 RRG getRRG()
          Gets the RRG that can be used to create a response to the RIG.
 RRG getRRG(java.io.InputStream is)
          Creates an RRG based on the serialized RRG data (e.g., sent by a provider of the service in response to this RIG having been sent to the provider).
 SSWAPResource getTranslatedResource()
          Returns a read-only copy of the SSWAPResource with properties and types of this RIG translated into the vocabulary of the RDG.
 java.util.Collection<SSWAPSubject> getTranslatedSubjects()
          Returns a read-only copy of the SSWAPSubject from all matching SSWAPGraphs with properties and types of this RIG translated into the vocabulary of the RDG.
protected  java.util.Map<SSWAPNode,SSWAPNode> getTranslationMap()
          Gets the translation map for implementations of Protocol Graphs that support translation.
 HTTPAPIImpl.RRGResponse invoke()
          Invokes the service with this RIG, blocks until the service responds, and reads back the RRG.
 HTTPAPIImpl.RRGResponse invoke(long timeout)
          Invokes the service with this RIG, blocks until the service responds, and reads back the RRG
(package private)  void setClientSideTranslation(boolean clientSideTranslation)
           
protected  void setMatchingGraphs(java.util.Collection<SSWAPGraph> matchingGraphs)
           
(package private)  void setRDG(RDG rdg)
           
protected  boolean supportsTranslation()
          Checks whether the particular implementation of Protocol Graph supports translation of terms (e.g., RIG)
<T extends SSWAPNode>
T
translate(T node)
          Translates a SSWAPNode in this RIG to the vocabulary used by the RDG (the translation only makes sense for SSWAPResources and SSWAPSubjects; for all others the nodes are returned unmodified).
 
Methods inherited from class info.sswap.impl.empire.model.ProtocolImpl
anonymizeSSWAPNodes, closeWorld, createCopyObject, createGraph, createObject, createObject, createResource, createSubject, createSubject, dereference, doClosure, getGraph, getMappings, getObject, getObjectMappings, getObjectMappingValidator, getPattern, getProvider, getResource, getResourceMappingValidator, getResources, getSubject, getSubjectMappings, getSubjectMappingValidator, isMultiGraphs, isPattern, needsClosedWorldForValidation, needsDefaultParametersSet, serialize, uncloseWorld, validate, validate, validateAgainstRDG, validatesObjects, validatesResourceURIMatch
 
Methods inherited from class info.sswap.impl.empire.model.SourceModelImpl
addDependentModel, addImport, checkProfile, createAnonymousDatatype, createAnonymousRestrictionType, createAnonymousType, createIndividual, createIndividual, createIntersectionOf, createList, createLiteral, createTypedLiteral, createUnionOf, dereference, dereference, dereference, equals, getClosedWorldModel, getClosureModel, getDatatype, getDependentModel, getDependentModel, getDependentModels, getEntityManager, getImports, getInferredABox, getInferredTBox, getIntersectionType, getMaxClosureBytes, getMaxClosureThreads, getMaxClosureTime, getModel, getModelResolver, getNsPrefixMap, getPredicate, getReasoningService, getType, hashCode, hasJenaModel, isClosureEnabled, isOwlDlRequired, isValueValidationEnabled, newIndividual, newIndividual, persist, refresh, removeDependentModel, removeImport, removeNsPrefix, resetReasoningService, serialize, setClosureEnabled, setClosureModel, setEntityManager, setMaxClosureBytes, setMaxClosureThreads, setMaxClosureTime, setModel, setNsPrefix, setOwlDlRequired, setValueValidationEnabled
 
Methods inherited from class info.sswap.impl.empire.model.ModelImpl
assertModel, assertSourceModel, getAllDependentObjects, getDependentObject, getDocument, getExpressivity, getInputStream, getSourceModel, getTypeSignature, getURI, hasSourceModel, hasSourceModelWithEntityManager, isDereferenced, rdfIdEquals, rdfIdHashCode, refreshSiblings, setDereferenced, setSourceModel, setURI
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.sswap.api.model.SSWAPProtocol
createGraph, createObject, createObject, createSubject, createSubject, getMappings, getProvider, getResource, isMultiGraphs, isPattern
 
Methods inherited from interface info.sswap.api.model.SSWAPDocument
createAnonymousDatatype, createAnonymousType, createIndividual, createIndividual, createIntersectionOf, createList, createLiteral, createTypedLiteral, createUnionOf, getDatatype, getPredicate, getType, newIndividual, newIndividual
 
Methods inherited from interface info.sswap.api.model.SSWAPModel
addImport, checkProfile, dereference, dereference, doClosure, getDocument, getImports, getInputStream, getNsPrefixMap, getReasoningService, getTypeSignature, getURI, isDereferenced, removeImport, removeNsPrefix, serialize, serialize, setNsPrefix, validate
 
Methods inherited from interface info.sswap.impl.empire.model.SourceModel
isDereferenced
 
Methods inherited from interface com.clarkparsia.empire.SupportsRdfId
getRdfId, setRdfId
 

Field Detail

rdg

private RDG rdg

translatedNodes

private java.util.Map<SSWAPNode,SSWAPNode> translatedNodes

matchingGraphs

private java.util.Collection<SSWAPGraph> matchingGraphs

clientSideTranslation

private boolean clientSideTranslation
Constructor Detail

RIGImpl

public RIGImpl()
Method Detail

getMatchingGraphs

public java.util.Collection<SSWAPGraph> getMatchingGraphs()

setMatchingGraphs

protected void setMatchingGraphs(java.util.Collection<SSWAPGraph> matchingGraphs)
Overrides:
setMatchingGraphs in class ProtocolImpl

getRRG

public RRG getRRG()
           throws DataAccessException,
                  ValidationException
Description copied from interface: RIG
Gets the RRG that can be used to create a response to the RIG. This method need not be called by clients (creators of the RIG), but is called by providers after they have mutated an incoming RIG so as to create a response. This method enforces that the RIG--as a putative RRG--is validated against the contract of the RDG. Additionally, if the RIG is OWL DL, the RRG must also be OWL DL.

Specified by:
getRRG in interface RIG
Returns:
the RRG for the RIG.
Throws:
DataAccessException - if an error should occur while accessing the data in the RIG to create the RRG
ValidationException - if the RRG is not valid with respect to the RIG invoking the service

getRRG

public RRG getRRG(java.io.InputStream is)
           throws DataAccessException
Description copied from interface: RIG
Creates an RRG based on the serialized RRG data (e.g., sent by a provider of the service in response to this RIG having been sent to the provider).

Specified by:
getRRG in interface RIG
Parameters:
is - the input stream from which the serialized RRG data can be read
Returns:
the created RRG
Throws:
DataAccessException - if an error should occur while reading the data (either an I/O error or problem parsing the data)

getRDG

RDG getRDG()

setRDG

void setRDG(RDG rdg)

setClientSideTranslation

void setClientSideTranslation(boolean clientSideTranslation)

supportsTranslation

protected boolean supportsTranslation()
Description copied from class: ProtocolImpl
Checks whether the particular implementation of Protocol Graph supports translation of terms (e.g., RIG)

Overrides:
supportsTranslation in class ProtocolImpl
Returns:
true if the implementation supports translation of terms, false otherwise

getTranslationMap

protected java.util.Map<SSWAPNode,SSWAPNode> getTranslationMap()
Description copied from class: ProtocolImpl
Gets the translation map for implementations of Protocol Graphs that support translation. The translation map maps a resource from this graph onto its translated counterpart. The map returned by this method is modifiable (validateAgainstRDG() method will attempt to store the mappings)

Overrides:
getTranslationMap in class ProtocolImpl
Returns:
a map whose keys are the individuals from this graph, and the values are translated individuals

translate

public <T extends SSWAPNode> T translate(T node)
Description copied from interface: RIG
Translates a SSWAPNode in this RIG to the vocabulary used by the RDG (the translation only makes sense for SSWAPResources and SSWAPSubjects; for all others the nodes are returned unmodified). The translated node contains only properties that are described in the RDG (this includes using the name of a superproperty, if the RIG used a subproperty with respect to the RDG), and types defined in the RDG.

Specified by:
translate in interface RIG
Parameters:
node - the node that must belong to this RIG
Returns:
a translated node, or null if the node does not belong to this RIG

invoke

public HTTPAPIImpl.RRGResponse invoke()
Description copied from interface: RIG
Invokes the service with this RIG, blocks until the service responds, and reads back the RRG.

Specified by:
invoke in interface RIG
Returns:
the returned RRG, if available, and response information from the invocation call

invoke

public HTTPAPIImpl.RRGResponse invoke(long timeout)
Description copied from interface: RIG
Invokes the service with this RIG, blocks until the service responds, and reads back the RRG

Specified by:
invoke in interface RIG
Parameters:
timeout - connect and read timeout in milliseconds; if communication with the service should stall for more than the specified time the call will be interrupted and the returned RRGResponse will contain the error code.
Returns:
the returned RRG, if available, and response information from the invocation call

doInvoke

private HTTPAPIImpl.RRGResponse doInvoke(java.lang.Long timeout)
Invokes the service with this RIG and the specified connect/read timeout (if provided). Always returns a RRGResonse object, even on failure. Inspection of the response contains information on failure. Response exception objects are generated according to: IOException if an I/O error occurred while communicating with the service. DataAccessException if the RRG returned by the response was not syntactically valid ValidationException if the RRG returned by the response was not semantically valid.

Parameters:
timeout - connect/read timeout in milliseconds (may be null; in such a case the default timeout will be used as specified in Config's info.sswap.impl.empire.model.RIG_INVOCATION_TIMEOUT parameter).
Returns:
RRGResponse if an HTTP response was received

getGraphType

public java.lang.String getGraphType()
Description copied from class: ProtocolImpl
Gets the human readable name of the particular graph implementation (e.g., RDG, RQG, RIG, RRG) This method is mostly provided to generate meaningful messages in exceptions (rather than to include class name, which may not be familiar to most users)

Specified by:
getGraphType in class ProtocolImpl
Returns:
the name of this protocol graph implementation

getTranslatedResource

public SSWAPResource getTranslatedResource()
Description copied from interface: RIG
Returns a read-only copy of the SSWAPResource with properties and types of this RIG translated into the vocabulary of the RDG.

The translated resource contains only properties that are described in the RDG (this includes using the name of a super-property, if the RIG used a subproperty with respect to the RDG), and types defined in the RDG.

Given the translated copy returned by the method, use ExtensionAPI.getUntranslatedNode(SSWAPNode) to retrieve this source individual.

Specified by:
getTranslatedResource in interface RIG
Returns:
a translated resource
See Also:
ExtensionAPI.getUntranslatedNode(SSWAPNode)

getTranslatedSubjects

public java.util.Collection<SSWAPSubject> getTranslatedSubjects()
Description copied from interface: RIG
Returns a read-only copy of the SSWAPSubject from all matching SSWAPGraphs with properties and types of this RIG translated into the vocabulary of the RDG. The translated subjects contain only properties that are described in the RDG (this includes using the name of a super-property, if the RIG used a subproperty with respect to the RDG ), and types defined in the RDG.

The special case of SSWAPSubject.addObject(SSWAPObject) and its set() variants are not read-only and changes the underlying SSWAPSubject.

Given the translated copy returned by the method, use ExtensionAPI.getUntranslatedNode(SSWAPNode) to retrieve this source individual.

Specified by:
getTranslatedSubjects in interface RIG
Returns:
a collection of translated subjects
See Also:
ExtensionAPI.getUntranslatedNode(SSWAPNode)


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