|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.impl.empire.model.ModelImpl
info.sswap.impl.empire.model.SourceModelImpl
info.sswap.impl.empire.model.ProtocolImpl
public abstract class ProtocolImpl
Nested Class Summary | |
---|---|
class |
ProtocolImpl.DefaultMappingValidator<T extends SSWAPNode>
|
static interface |
ProtocolImpl.MappingValidator<T>
Performs a check whether an individual from ProtocolGraph can correspond to another individual from RDG. |
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 static org.apache.log4j.Logger |
LOGGER
|
private java.util.Map<SSWAPObject,SSWAPObject> |
objectMappings
Contains mappings from objects in this protocol graph onto objects in RDG. |
private java.util.List<ResourceImpl> |
resources
|
private java.util.Map<SSWAPSubject,SSWAPSubject> |
subjectMappings
Contains mappings from subjects in this protocol graph onto subjects in RDG. |
Fields inherited from class info.sswap.impl.empire.model.SourceModelImpl |
---|
SSWAP_ONTOLOGY_URI |
Constructor Summary | |
---|---|
ProtocolImpl()
|
Method Summary | ||
---|---|---|
protected ProtocolImpl |
anonymizeSSWAPNodes()
Generates a copy of this Protocol document, where all SSWAPNodes (i.e., nodes with special meaning to SSWAP Protocol; e.g., sswap:Resource) have been converted into BNodes. |
|
void |
closeWorld()
|
|
private void |
copyNonTranslatedProperties(SSWAPIndividual translatedIndividual,
SSWAPIndividual nonTranslatedIndividual,
SSWAPIndividual rdgIndividual)
Copies the properties that were not translated for a Protocol graph node but they are both mentioned in RDG (default property), and the original (untranslated) Protocol graph node. |
|
private void |
copyPropertyValues(java.net.URI dstPropertyURI,
SSWAPIndividual dstIndividual,
java.net.URI srcPropertyURI,
SSWAPIndividual srcOriginal)
Performs a deep copy of all values for the given property from the specified individual to this individual. |
|
protected
|
createCopyObject(T original,
java.net.URI copyURI)
|
|
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 resourceURI)
Creates a new ResourceImpl in this protocol graph |
|
SSWAPSubject |
createSubject()
Creates an anonymous object (blank node) subject that will be associated with this SSWAPModel. |
|
SSWAPSubject |
createSubject(java.net.URI uri)
Creates a subject of the resource URI that will be associated with this SSWAPModel. |
|
protected void |
dereference(ProtocolImpl otherGraph)
Populates this graph (must not be dereferenced yet) with the contents of another graph. |
|
int |
doClosure()
Computes closure for this model. |
|
private static
|
filter(java.util.Collection<T> newCollection,
java.util.Collection<T> oldCollection,
T filteredElement)
A convenience method that filters a specified element from the collection: i.e., it adds items to a new collection without the specified element |
|
private static SSWAPProperty |
getCorrespondingRDGProperty(SSWAPProperty protocolProperty,
java.util.Collection<SSWAPProperty> rdgProperties)
Returns the corresponding property in the RDG individual for the specified Protocol graph property. |
|
SSWAPGraph |
getGraph()
|
|
abstract 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.Map<SSWAPGraph,java.util.Collection<SSWAPSubject>> |
getMappings()
Gets a map from SSWAPGraphs to SSWAPSubjects |
|
SSWAPObject |
getObject()
|
|
protected java.util.Map<SSWAPObject,SSWAPObject> |
getObjectMappings()
Gets the computed object mappings during the recent validateAgainstRDG() invocation. |
|
protected ProtocolImpl.MappingValidator<SSWAPObject> |
getObjectMappingValidator()
|
|
MappingPattern |
getPattern()
|
|
SSWAPProvider |
getProvider()
Gets the SSWAP provider for this canonical graph (or more exactly the SSWAPProvider of the SSWAPResource in the file). |
|
SSWAPResource |
getResource()
Gets the SSWAPResource in the file |
|
protected ProtocolImpl.MappingValidator<SSWAPResource> |
getResourceMappingValidator()
|
|
(package private) java.util.Collection<ResourceImpl> |
getResources()
|
|
SSWAPSubject |
getSubject()
|
|
protected java.util.Map<SSWAPSubject,SSWAPSubject> |
getSubjectMappings()
Gets the computed subject mappings during the recent validateAgainstRDG() invocation. |
|
protected ProtocolImpl.MappingValidator<SSWAPSubject> |
getSubjectMappingValidator()
|
|
protected java.util.Map<SSWAPNode,SSWAPNode> |
getTranslationMap()
Gets the translation map for implementations of Protocol Graphs that support translation. |
|
boolean |
isMultiGraphs()
Checks whether this graph contains multiple SSWAPGraphs |
|
boolean |
isPattern(MappingPattern pattern)
Checks whether this graph contains the specific mapping of subjects to objects. |
|
private
|
mapIndividuals(java.util.Collection<T> protocolIndividuals,
java.util.Collection<T> rdgIndividuals,
ProtocolImpl.MappingValidator<T> individualMapper)
Attempts to map individuals from this Protocol graph onto their corresponding individuals from RDG. |
|
protected boolean |
needsClosedWorldForValidation()
|
|
protected boolean |
needsDefaultParametersSet()
Returns information whether this object needs default values of parameters set during validation against RDG (i.e., default values for sswap:Resource or sswap:Subject). |
|
private
|
optionalMapping(T protocolIndividual,
java.util.Collection<T> rdgIndividuals,
ProtocolImpl.MappingValidator<T> individualMapper)
Finds an optional mapping between a single Protocol graph individual and an RDG individual (which may be already involved in some mapping; for optional mappings this is allowed). |
|
private
|
requiredMapping(T rdgIndividual,
java.util.Collection<T> remainingRdgIndividuals,
java.util.Collection<T> protocolIndividuals,
ProtocolImpl.MappingValidator<T> individualMapper)
Finds a mapping for a selected RDG individual. |
|
private
|
requiredMappings(java.util.Collection<T> rdgIndividuals,
java.util.Collection<T> protocolIndividuals,
ProtocolImpl.MappingValidator<T> individualMapper)
Computes required mappings from RDG individuals to individuals in this protocol graph. |
|
void |
serialize(java.io.OutputStream os,
RDFRepresentation rdfRepresentation,
boolean commentedOutput)
Serializes the contents of this object to the specified stream. |
|
protected void |
setMatchingGraphs(java.util.Collection<SSWAPGraph> matchingGraphs)
|
|
protected boolean |
supportsTranslation()
Checks whether the particular implementation of Protocol Graph supports translation of terms (e.g., RIG) |
|
void |
uncloseWorld()
|
|
void |
validate()
Verifies whether the underlying RDF data conforms to SSWAP syntax and requirements. |
|
void |
validate(boolean strict)
|
|
(package private) void |
validateAgainstRDG(RDG rdg)
Validates this Protocol message against an RDG. |
|
private void |
validateGraph(SSWAPGraph protocolGraph,
java.util.Collection<SSWAPGraph> rdgGraphs,
ReasoningServiceImpl reasoningService)
|
|
private void |
validateMappedObjects(ReasoningServiceImpl reasoningService,
java.util.Map<SSWAPObject,SSWAPObject> mappedObjects)
|
|
protected boolean |
validatesObjects()
|
|
protected boolean |
validatesResourceURIMatch()
|
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.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, getDocument, getImports, getInputStream, getNsPrefixMap, getReasoningService, getTypeSignature, getURI, isDereferenced, removeImport, removeNsPrefix, serialize, setNsPrefix |
Methods inherited from interface info.sswap.impl.empire.model.SourceModel |
---|
isDereferenced |
Methods inherited from interface com.clarkparsia.empire.SupportsRdfId |
---|
getRdfId, setRdfId |
Field Detail |
---|
private static final org.apache.log4j.Logger LOGGER
private java.util.List<ResourceImpl> resources
private java.util.Map<SSWAPSubject,SSWAPSubject> subjectMappings
private java.util.Map<SSWAPObject,SSWAPObject> objectMappings
Constructor Detail |
---|
public ProtocolImpl()
Method Detail |
---|
public SSWAPGraph getGraph()
public SSWAPObject getObject()
public MappingPattern getPattern()
public SSWAPProvider getProvider()
SSWAPProtocol
getProvider
in interface SSWAPProtocol
java.util.Collection<ResourceImpl> getResources()
public SSWAPResource getResource()
SSWAPProtocol
getResource
in interface SSWAPProtocol
public SSWAPResource createResource(java.net.URI resourceURI)
resourceURI
- the URI of the resource to be created
public SSWAPSubject getSubject()
public java.util.Map<SSWAPGraph,java.util.Collection<SSWAPSubject>> getMappings()
SSWAPProtocol
getMappings
in interface SSWAPProtocol
public boolean isMultiGraphs()
SSWAPProtocol
isMultiGraphs
in interface SSWAPProtocol
public boolean isPattern(MappingPattern pattern)
SSWAPProtocol
isPattern
in interface SSWAPProtocol
pattern
- the pattern to be checked
protected void dereference(ProtocolImpl otherGraph) throws DataAccessException
otherGraph
- the source graph for the contents
DataAccessException
- in the unlikely case there is an I/O issue when populating the new graph with the contents of the old graphpublic SSWAPGraph createGraph()
SSWAPProtocol
Note: creating a graph does not assign it to the
SSWAPResource
; see
SSWAPResource.setGraph(SSWAPGraph)
variant methods to assign a
graph to the resource.
createGraph
in interface SSWAPProtocol
public SSWAPSubject createSubject()
SSWAPProtocol
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.
createSubject
in interface SSWAPProtocol
public SSWAPSubject createSubject(java.net.URI uri)
SSWAPProtocol
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.
createSubject
in interface SSWAPProtocol
uri
- URI of the resource
public SSWAPObject createObject()
SSWAPProtocol
Note: creating an object does not assign it to a
SSWAPSubject
; see
SSWAPSubject.addObject(SSWAPObject)
variant methods to assign an
object to a subject.
createObject
in interface SSWAPProtocol
public SSWAPObject createObject(java.net.URI uri)
SSWAPProtocol
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.
createObject
in interface SSWAPProtocol
uri
- the URI of the object
public void validate() throws ValidationException
SSWAPModel
validate
in interface SSWAPModel
validate
in class SourceModelImpl
ValidationException
- if the data violates SSWAP syntax or requirementspublic void validate(boolean strict) throws ValidationException
validate
in class SourceModelImpl
ValidationException
protected ProtocolImpl anonymizeSSWAPNodes()
protected boolean supportsTranslation()
protected boolean validatesObjects()
protected boolean needsDefaultParametersSet()
protected boolean validatesResourceURIMatch()
protected java.util.Map<SSWAPNode,SSWAPNode> getTranslationMap()
protected void setMatchingGraphs(java.util.Collection<SSWAPGraph> matchingGraphs)
public abstract java.lang.String getGraphType()
protected boolean needsClosedWorldForValidation()
public void closeWorld()
public void uncloseWorld()
void validateAgainstRDG(RDG rdg) throws ValidationException
rdg
- the RDG against which the protocol graph should be validated
ValidationException
- if validation failsprivate void validateGraph(SSWAPGraph protocolGraph, java.util.Collection<SSWAPGraph> rdgGraphs, ReasoningServiceImpl reasoningService) throws ValidationException
ValidationException
private void validateMappedObjects(ReasoningServiceImpl reasoningService, java.util.Map<SSWAPObject,SSWAPObject> mappedObjects) throws ValidationException
ValidationException
protected java.util.Map<SSWAPSubject,SSWAPSubject> getSubjectMappings()
protected java.util.Map<SSWAPObject,SSWAPObject> getObjectMappings()
private <T extends SSWAPIndividual> java.util.Map<T,T> mapIndividuals(java.util.Collection<T> protocolIndividuals, java.util.Collection<T> rdgIndividuals, ProtocolImpl.MappingValidator<T> individualMapper)
T
- the type of individuals being mapped (e.g., SSWAPSubject)protocolIndividuals
- the individuals in the Protocol Graph to be mappedrdgIndividuals
- the individuals in RDG to be mappedindividualMapper
- an object that can decide whether an individual from Protocol Graph is a valid mapping for the individual from RDG
private <T extends SSWAPIndividual> java.util.Map<T,T> requiredMappings(java.util.Collection<T> rdgIndividuals, java.util.Collection<T> protocolIndividuals, ProtocolImpl.MappingValidator<T> individualMapper)
T
- rdgIndividuals
- the RDG individualsprotocolIndividuals
- the Protocol individualsindividualMapper
- an object that can decide whether an individual in RDG can be mapped onto a particular individual in the protocol graph
private <T extends SSWAPIndividual> java.util.Map<T,T> requiredMapping(T rdgIndividual, java.util.Collection<T> remainingRdgIndividuals, java.util.Collection<T> protocolIndividuals, ProtocolImpl.MappingValidator<T> individualMapper)
T
- rdgIndividual
- the selected rdgIndividualremainingRdgIndividuals
- the remaining RDG individuals for which mappings still have to be foundprotocolIndividuals
- individuals in this protocol graph which have not yet been used in a mappingindividualMapper
- an object that can decide whether an individual in RDG can be mapped onto a particular individual in the protocol graph
private <T extends SSWAPIndividual> T optionalMapping(T protocolIndividual, java.util.Collection<T> rdgIndividuals, ProtocolImpl.MappingValidator<T> individualMapper)
T
- protocolIndividual
- the Protocol graph individual for which the mapping should be foundrdgIndividuals
- candidate RDG individualsindividualMapper
- an object that can decide whether an individual in RDG can be mapped onto a particular individual in this protocol graph
private static <T> java.util.Collection<T> filter(java.util.Collection<T> newCollection, java.util.Collection<T> oldCollection, T filteredElement)
T
- the type of objects in the collectionsnewCollection
- the collection to which the non-filtered items are to be addedoldCollection
- the collections that contains elements to be filteredfilteredElement
- the element to be filtered
private void copyNonTranslatedProperties(SSWAPIndividual translatedIndividual, SSWAPIndividual nonTranslatedIndividual, SSWAPIndividual rdgIndividual)
nonTranslatedIndividual
- the node in the protocol graph (before translation)rdgIndividual
- the corresponding node in RDGprivate void copyPropertyValues(java.net.URI dstPropertyURI, SSWAPIndividual dstIndividual, java.net.URI srcPropertyURI, SSWAPIndividual srcOriginal)
dstPropertyURI
- the URI of the property in this (destination) individual to where the values should be copiedsrcPropertyURI
- the URI of the property in the source individualsrcOriginal
- the object from which the values should be copiedprivate static SSWAPProperty getCorrespondingRDGProperty(SSWAPProperty protocolProperty, java.util.Collection<SSWAPProperty> rdgProperties)
protocolProperty
- Protocol graph propertyrdgProperties
- all properties mentioned in the RDG individual
public void serialize(java.io.OutputStream os, RDFRepresentation rdfRepresentation, boolean commentedOutput)
SSWAPModel
serialize
in interface SSWAPModel
serialize
in interface SourceModel
serialize
in class SourceModelImpl
os
- output streamrdfRepresentation
- the representation, in which the contents should be written (e.g., RDF/XML).commentedOutput
- true, if the output should contain comments about various standard sections of an RDG (valid only for
RDF/XML)protected ProtocolImpl.MappingValidator<SSWAPResource> getResourceMappingValidator()
protected ProtocolImpl.MappingValidator<SSWAPSubject> getSubjectMappingValidator()
protected ProtocolImpl.MappingValidator<SSWAPObject> getObjectMappingValidator()
public int doClosure()
SourceModelImpl
doClosure
in interface SSWAPModel
doClosure
in interface SourceModel
doClosure
in class SourceModelImpl
protected <T extends SSWAPIndividual> T createCopyObject(T original, java.net.URI copyURI)
createCopyObject
in class SourceModelImpl
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |