info.sswap.impl.empire.model
Class RRGImpl

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.RRGImpl
All Implemented Interfaces:
com.clarkparsia.empire.SupportsRdfId, RRG, SSWAPDocument, SSWAPModel, SSWAPProtocol, SourceModel

public abstract class RRGImpl
extends ProtocolImpl
implements RRG

Implementation of RRG interface

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 mutable
          A flag indicating whether this RRG is mutable.
private  java.util.Map<SSWAPNode,SSWAPNode> translatedNodes
           
 
Fields inherited from class info.sswap.impl.empire.model.SourceModelImpl
SSWAP_ONTOLOGY_URI
 
Constructor Summary
RRGImpl()
           
 
Method Summary
 void addImport(java.net.URI uri)
          Adds an import to the list of OWL imports of this model.
private  void assertMutable()
           
private  void copyDeclaredTypes(SSWAPObject srcObject, SSWAPObject dstObject)
          Copy types from one SSWAPObject onto another SSWAPObject
private  void copyObjectToObject(SSWAPObject src, SSWAPObject dst)
           
private  void copyObjectToSubject(SSWAPObject object, SSWAPSubject subject, SSWAPProtocol protocolDoc)
           
 SSWAPGraph createGraph()
          Creates a graph that will be associated with this SSWAPModel.
 SSWAPObject createObject()
          Creates an anonymous object (blank node) that will be associated with this SSWAPModel.
 SSWAPObject createObject(java.net.URI uri)
          Creates an object of the resource URI that will be associated with this SSWAPModel.
 SSWAPResource createResource(java.net.URI uri)
          Creates a new ResourceImpl in this protocol graph
 RIG createRIG(RDG rdg)
          Returns a new Resource Invocation Graph (RIG) based on the contents of this Resource Response Graph (RRG) suitable for the service represented by the Resource Description Graph (RRG).
private  java.util.Collection<SSWAPObject> createRIGObjects(RIG rig, java.util.Collection<SSWAPObject> templateObjects)
           
 RQG createRQG()
           
 SSWAPSubject createSubject()
          Creates an anonymous object (blank node) subject that will be associated with this SSWAPModel.
private  SSWAPSubject createSubject(SSWAPObject object, RIG rig, java.util.Map<java.net.URI,SSWAPSubject> subjectCache)
           
 SSWAPSubject createSubject(java.net.URI uri)
          Creates a subject of the resource URI that will be associated with this SSWAPModel.
private  java.util.Collection<SSWAPObject> getAllObjects()
           
private static java.util.Collection<SSWAPObject> getAllObjects(SSWAPGraph graph)
           
private  java.util.Collection<SSWAPSubject> getAllRIGSubjects(RIG rig)
           
 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)
protected  ProtocolImpl.MappingValidator<SSWAPObject> getObjectMappingValidator()
           
protected  java.util.Map<SSWAPNode,SSWAPNode> getTranslationMap()
          Gets the translation map for implementations of Protocol Graphs that support translation.
 boolean isMutable()
          Checks whether this object is mutable.
private  SSWAPSubject selectTemplateSubject(java.util.Collection<SSWAPSubject> subjects, SSWAPObject rrgObject)
           
(package private)  void setMutable(boolean mutable)
          Sets whether this object is mutable.
 void setNsPrefix(java.lang.String prefix, java.net.URI uri)
          Sets a namespace prefix that will be used in serialization of this model.
protected  boolean supportsTranslation()
          Checks whether the particular implementation of Protocol Graph supports translation of terms (e.g., RIG)
 void validateAgainstRDG(RDG rdg)
          In addition to the regular validation (provided by the superclass), it also performs computation of type triples for objects in RRG.
protected  boolean validatesObjects()
           
 
Methods inherited from class info.sswap.impl.empire.model.ProtocolImpl
anonymizeSSWAPNodes, closeWorld, createCopyObject, dereference, doClosure, getGraph, getMappings, getObject, getObjectMappings, getPattern, getProvider, getResource, getResourceMappingValidator, getResources, getSubject, getSubjectMappings, getSubjectMappingValidator, isMultiGraphs, isPattern, needsClosedWorldForValidation, needsDefaultParametersSet, serialize, setMatchingGraphs, uncloseWorld, validate, validate, validatesResourceURIMatch
 
Methods inherited from class info.sswap.impl.empire.model.SourceModelImpl
addDependentModel, 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, 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
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
checkProfile, dereference, dereference, doClosure, getDocument, getImports, getInputStream, getNsPrefixMap, getReasoningService, getTypeSignature, getURI, isDereferenced, removeImport, removeNsPrefix, serialize, serialize, validate
 
Methods inherited from interface info.sswap.impl.empire.model.SourceModel
isDereferenced
 
Methods inherited from interface com.clarkparsia.empire.SupportsRdfId
getRdfId, setRdfId
 

Field Detail

mutable

private boolean mutable
A flag indicating whether this RRG is mutable. In general, RRGs should be immutable only on the client-side, and mutable on the server-side.


translatedNodes

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

RRGImpl

public RRGImpl()
Method Detail

assertMutable

private void assertMutable()

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

setMutable

void setMutable(boolean mutable)
Sets whether this object is mutable.

Parameters:
mutable - true, if the object should be mutable, false otherwise

isMutable

public boolean isMutable()
Checks whether this object is mutable.

Returns:
mutable true, if the object should be mutable, false otherwise

setNsPrefix

public void setNsPrefix(java.lang.String prefix,
                        java.net.URI uri)
Description copied from interface: SSWAPModel
Sets a namespace prefix that will be used in serialization of this model.

Specified by:
setNsPrefix in interface SSWAPModel
Specified by:
setNsPrefix in interface SourceModel
Overrides:
setNsPrefix in class SourceModelImpl
Parameters:
prefix - the prefix
uri - the corresponding URI

addImport

public void addImport(java.net.URI uri)
Description copied from class: ModelImpl
Adds an import to the list of OWL imports of this model. Adding a URI to the list of imports does not trigger the import itself (use doClosure()) for that purpose.

Specified by:
addImport in interface SSWAPModel
Specified by:
addImport in interface SourceModel
Overrides:
addImport in class SourceModelImpl
Parameters:
uri - the URI of the import to be added

createGraph

public SSWAPGraph createGraph()
Description copied from interface: SSWAPProtocol
Creates a graph that will be associated with this SSWAPModel.

Note: creating a graph does not assign it to the SSWAPResource; see SSWAPResource.setGraph(SSWAPGraph) variant methods to assign a graph to the resource.

Specified by:
createGraph in interface SSWAPProtocol
Overrides:
createGraph in class ProtocolImpl
Returns:
the new SSWAPGraph

createSubject

public SSWAPSubject createSubject()
Description copied from interface: SSWAPProtocol
Creates an anonymous object (blank node) subject that will be associated with this SSWAPModel.

Note: creating a subject does not assign it to a SSWAPGraph; see SSWAPGraph.setSubject(SSWAPSubject) and variant methods to assign a subject to a graph.

Specified by:
createSubject in interface SSWAPProtocol
Overrides:
createSubject in class ProtocolImpl
Returns:
the new SSWAPSubject

createSubject

public SSWAPSubject createSubject(java.net.URI uri)
Description copied from interface: SSWAPProtocol
Creates a subject of the resource URI that will be associated with this SSWAPModel. If uri is null it creates an anonymous subject (blank node).

Note: creating a subject does not assign it to a SSWAPGraph; see SSWAPGraph.setSubject(SSWAPSubject) and variant methods to assign a subject to a graph.

Specified by:
createSubject in interface SSWAPProtocol
Overrides:
createSubject in class ProtocolImpl
Parameters:
uri - URI of the resource
Returns:
the new SSWAPSubject

createObject

public SSWAPObject createObject()
Description copied from interface: SSWAPProtocol
Creates an anonymous object (blank node) that will be associated with this SSWAPModel.

Note: creating an object does not assign it to a SSWAPSubject; see SSWAPSubject.addObject(SSWAPObject) variant methods to assign an object to a subject.

Specified by:
createObject in interface SSWAPProtocol
Overrides:
createObject in class ProtocolImpl
Returns:
the new SSWAPObject

createObject

public SSWAPObject createObject(java.net.URI uri)
Description copied from interface: SSWAPProtocol
Creates an object of the resource URI that will be associated with this SSWAPModel. If uri is null it creates an anonymous object (blank node).

Note: creating an object does not assign it to a SSWAPSubject; see SSWAPSubject.addObject(SSWAPObject) variant methods to assign an object to a subject.

Specified by:
createObject in interface SSWAPProtocol
Overrides:
createObject in class ProtocolImpl
Parameters:
uri - the URI of the object
Returns:
the new SSWAPObject

createResource

public SSWAPResource createResource(java.net.URI uri)
Description copied from class: ProtocolImpl
Creates a new ResourceImpl in this protocol graph

Overrides:
createResource in class ProtocolImpl
Parameters:
uri - the URI of the resource to be created
Returns:
the created SSWAPResource

createSubject

private SSWAPSubject createSubject(SSWAPObject object,
                                   RIG rig,
                                   java.util.Map<java.net.URI,SSWAPSubject> subjectCache)

selectTemplateSubject

private SSWAPSubject selectTemplateSubject(java.util.Collection<SSWAPSubject> subjects,
                                           SSWAPObject rrgObject)

createRIGObjects

private java.util.Collection<SSWAPObject> createRIGObjects(RIG rig,
                                                           java.util.Collection<SSWAPObject> templateObjects)

getAllObjects

private java.util.Collection<SSWAPObject> getAllObjects()

getAllRIGSubjects

private java.util.Collection<SSWAPSubject> getAllRIGSubjects(RIG rig)

createRIG

public RIG createRIG(RDG rdg)
              throws DataAccessException
Description copied from interface: RRG
Returns a new Resource Invocation Graph (RIG) based on the contents of this Resource Response Graph (RRG) suitable for the service represented by the Resource Description Graph (RRG). This allows the output of one service to become the input to another service. Conversion involves transferring the SSWAPObjects of the RRG into SSWAPSubjects of the RIG and updating the SSWAPResource.

Specified by:
createRIG in interface RRG
Parameters:
rdg - service for which to create the RIG
Returns:
RIG suitable for invocation
Throws:
DataAccessException - on inability to create a pre-transformed RIG for the RDG

getAllObjects

private static java.util.Collection<SSWAPObject> getAllObjects(SSWAPGraph graph)

copyObjectToObject

private void copyObjectToObject(SSWAPObject src,
                                SSWAPObject dst)

copyObjectToSubject

private void copyObjectToSubject(SSWAPObject object,
                                 SSWAPSubject subject,
                                 SSWAPProtocol protocolDoc)

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

validateAgainstRDG

public void validateAgainstRDG(RDG rdg)
                        throws ValidationException
In addition to the regular validation (provided by the superclass), it also performs computation of type triples for objects in RRG.

Overrides:
validateAgainstRDG in class ProtocolImpl
Parameters:
rdg - RDG against which to validate
Throws:
ValidationException - if validation fails

copyDeclaredTypes

private void copyDeclaredTypes(SSWAPObject srcObject,
                               SSWAPObject dstObject)
Copy types from one SSWAPObject onto another SSWAPObject

Parameters:
srcObject - source object
dstObject - destination object

createRQG

public RQG createRQG()
Specified by:
createRQG in interface RRG

validatesObjects

protected boolean validatesObjects()
Overrides:
validatesObjects in class ProtocolImpl

getObjectMappingValidator

protected ProtocolImpl.MappingValidator<SSWAPObject> getObjectMappingValidator()
Overrides:
getObjectMappingValidator in class ProtocolImpl


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