info.sswap.impl.empire.model
Class ProtocolImpl

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
All Implemented Interfaces:
com.clarkparsia.empire.SupportsRdfId, SSWAPDocument, SSWAPModel, SSWAPProtocol, SourceModel
Direct Known Subclasses:
RDGImpl, RIGImpl, RQGImpl, RRGImpl

public abstract class ProtocolImpl
extends SourceModelImpl
implements SSWAPProtocol


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
<T extends SSWAPIndividual>
T
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
<T> java.util.Collection<T>
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
<T extends SSWAPIndividual>
java.util.Map<T,T>
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
<T extends SSWAPIndividual>
T
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
<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)
          Finds a mapping for a selected RDG individual.
private
<T extends SSWAPIndividual>
java.util.Map<T,T>
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.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.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

LOGGER

private static final org.apache.log4j.Logger LOGGER

resources

private java.util.List<ResourceImpl> resources

subjectMappings

private java.util.Map<SSWAPSubject,SSWAPSubject> subjectMappings
Contains mappings from subjects in this protocol graph onto subjects in RDG. (The keys are subjects in this protocol graph, and values are subjects in RDG.) One subject in RDG can have multiple subjects from this graph mapped onto it. This structure is uninitialized until validateAgainstRDG() is called.


objectMappings

private java.util.Map<SSWAPObject,SSWAPObject> objectMappings
Contains mappings from objects in this protocol graph onto objects in RDG. (The keys are objects in this protocol graph, and values are objects in RDG.) One object in RDG can have multiple objects from this graph mapped onto it. This structure is uninitialized until validateAgainstRDG() is called.

Constructor Detail

ProtocolImpl

public ProtocolImpl()
Method Detail

getGraph

public SSWAPGraph getGraph()

getObject

public SSWAPObject getObject()

getPattern

public MappingPattern getPattern()

getProvider

public SSWAPProvider getProvider()
Description copied from interface: SSWAPProtocol
Gets the SSWAP provider for this canonical graph (or more exactly the SSWAPProvider of the SSWAPResource in the file).

Specified by:
getProvider in interface SSWAPProtocol
Returns:
the SSWAPProvider object (may not be dereferenced)

getResources

java.util.Collection<ResourceImpl> getResources()

getResource

public SSWAPResource getResource()
Description copied from interface: SSWAPProtocol
Gets the SSWAPResource in the file

Specified by:
getResource in interface SSWAPProtocol
Returns:
gets the SSWAPResource defined in this file

createResource

public SSWAPResource createResource(java.net.URI resourceURI)
Creates a new ResourceImpl in this protocol graph

Parameters:
resourceURI - the URI of the resource to be created
Returns:
the created SSWAPResource

getSubject

public SSWAPSubject getSubject()

getMappings

public java.util.Map<SSWAPGraph,java.util.Collection<SSWAPSubject>> getMappings()
Description copied from interface: SSWAPProtocol
Gets a map from SSWAPGraphs to SSWAPSubjects

Specified by:
getMappings in interface SSWAPProtocol
Returns:
the map of SSWAPGraphs to a collection of SSWAPSubjects

isMultiGraphs

public boolean isMultiGraphs()
Description copied from interface: SSWAPProtocol
Checks whether this graph contains multiple SSWAPGraphs

Specified by:
isMultiGraphs in interface SSWAPProtocol
Returns:
true if it contains more than one SSWAPGraph

isPattern

public boolean isPattern(MappingPattern pattern)
Description copied from interface: SSWAPProtocol
Checks whether this graph contains the specific mapping of subjects to objects.

Specified by:
isPattern in interface SSWAPProtocol
Parameters:
pattern - the pattern to be checked
Returns:
true, if the graph contains that pattern

dereference

protected void dereference(ProtocolImpl otherGraph)
                    throws DataAccessException
Populates this graph (must not be dereferenced yet) with the contents of another graph. The implementation of this method serializes the other graph, and then dereferences this graph from the serialization of that other graph.

Parameters:
otherGraph - the source graph for the contents
Throws:
DataAccessException - in the unlikely case there is an I/O issue when populating the new graph with the contents of the old graph

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
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
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
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
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
Parameters:
uri - the URI of the object
Returns:
the new SSWAPObject

validate

public void validate()
              throws ValidationException
Description copied from interface: SSWAPModel
Verifies whether the underlying RDF data conforms to SSWAP syntax and requirements.

Specified by:
validate in interface SSWAPModel
Overrides:
validate in class SourceModelImpl
Throws:
ValidationException - if the data violates SSWAP syntax or requirements

validate

public void validate(boolean strict)
              throws ValidationException
Overrides:
validate in class SourceModelImpl
Throws:
ValidationException

anonymizeSSWAPNodes

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. This method is typically used when reasoning is needed when using information from multiple documents (e.g., Protocol graph and RDG), and when it is necessary to treat corresponding objects from these documents as different individuals. For example, sswap:Resources frequently have their own URIs, which are identical in RDG/RIG/RRG, and this will cause the reasoner to treat all these resources as being the same individual; in the cases when these individuals differ (e.g., sswap:inputURI is different), this may lead to undesired effects (e.g., inconsistent ontology).

Returns:
a copy of this Protocol document but with all SSWAPNodes turned into blank nodes.

supportsTranslation

protected boolean supportsTranslation()
Checks whether the particular implementation of Protocol Graph supports translation of terms (e.g., RIG)

Returns:
true if the implementation supports translation of terms, false otherwise

validatesObjects

protected boolean validatesObjects()

needsDefaultParametersSet

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). Most protocol types require values of default parameters.

Returns:
true if this object requires default values of parameters

validatesResourceURIMatch

protected boolean validatesResourceURIMatch()

getTranslationMap

protected java.util.Map<SSWAPNode,SSWAPNode> getTranslationMap()
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)

Returns:
a map whose keys are the individuals from this graph, and the values are translated individuals

setMatchingGraphs

protected void setMatchingGraphs(java.util.Collection<SSWAPGraph> matchingGraphs)

getGraphType

public 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)

Returns:
the name of this protocol graph implementation

needsClosedWorldForValidation

protected boolean needsClosedWorldForValidation()

closeWorld

public void closeWorld()

uncloseWorld

public void uncloseWorld()

validateAgainstRDG

void validateAgainstRDG(RDG rdg)
                  throws ValidationException
Validates this Protocol message against an RDG.

Parameters:
rdg - the RDG against which the protocol graph should be validated
Throws:
ValidationException - if validation fails

validateGraph

private void validateGraph(SSWAPGraph protocolGraph,
                           java.util.Collection<SSWAPGraph> rdgGraphs,
                           ReasoningServiceImpl reasoningService)
                    throws ValidationException
Throws:
ValidationException

validateMappedObjects

private void validateMappedObjects(ReasoningServiceImpl reasoningService,
                                   java.util.Map<SSWAPObject,SSWAPObject> mappedObjects)
                            throws ValidationException
Throws:
ValidationException

getSubjectMappings

protected java.util.Map<SSWAPSubject,SSWAPSubject> getSubjectMappings()
Gets the computed subject mappings during the recent validateAgainstRDG() invocation.

Returns:
a map where keys are subjects in this graph and values are subjects in RDG (value may be null, if there is no mapping)

getObjectMappings

protected java.util.Map<SSWAPObject,SSWAPObject> getObjectMappings()
Gets the computed object mappings during the recent validateAgainstRDG() invocation.

Returns:
a map where keys are objects in this graph and values are objects in RDG (value may be null, if there is no mapping)

mapIndividuals

private <T extends SSWAPIndividual> java.util.Map<T,T> 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. Since it is expected that individuals in the RDG express a requirement for the Protocol graph, every individual in the RDG needs to have at least one individual mapped from the Protocol graph (required mapping). If it is not possible to compute such a required mapping, this method will return null (to indicate failure). Once every individual in RDG has an associated individual in Protocol graph associated with it, this method will attempt to find mapping for any other remaining individuals in Protocol graph (if any; this is optional mapping). Because of the optional mapping, it is possible that an individual in RDG will have more than one individual in the Protocol graph mapped onto it. Similarly, it is possible that an individual in the Protocol Graph may not have a corresponding element in RDG.

Type Parameters:
T - the type of individuals being mapped (e.g., SSWAPSubject)
Parameters:
protocolIndividuals - the individuals in the Protocol Graph to be mapped
rdgIndividuals - the individuals in RDG to be mapped
individualMapper - an object that can decide whether an individual from Protocol Graph is a valid mapping for the individual from RDG
Returns:
a map whose keys are individuals in Protocol Graph, and the values are individuals in RDG (a value may be null, if there is no mapping for that particular Protocol graph individual). The map returned may be null, if it was not possible to establish the required mappings

requiredMappings

private <T extends SSWAPIndividual> java.util.Map<T,T> 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. Since an individual in the Protocol graph can be potentially mapped to multiple corresponding individuals in the RDG, in order to compute a full mapping (involving all individuals in RDG), backtracking may be necessary, as well multiple proper solutions may be possible. This method returns the first full mapping. While this method uses a brute-force search of all possible mappings, the typical amounts of subjects or objects in the RDG tend to be fairly small (is that true?). If this is too slow, three solutions are possible: since many calls share the parts of the solution caching/memoization may be possible; a more advanced Constraint Satisfaction Solver may also be useful; and more intelligent techniques for backtracking may also be useful) This method calls requiredMapping() method, which in turn recursively calls this method. First, this method picks the first element from the remaining rdg individuals, and calls requiredMapping(), so that it finds a mapping (an individual in the protocol graph) for that rdg individual. After a potential mapping is found, requiredMapping() calls requiredMappings() to find the mappings for the remaining individuals. If at any step a mapping cannot be produced, a null map is returned, and the methods backtrack to the next potential mapping.

Type Parameters:
T -
Parameters:
rdgIndividuals - the RDG individuals
protocolIndividuals - the Protocol individuals
individualMapper - an object that can decide whether an individual in RDG can be mapped onto a particular individual in the protocol graph
Returns:
a map whose keys are RDG individuals, and the values are Protocol graph individuals

requiredMapping

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)
Finds a mapping for a selected RDG individual. This method is a second step in the recursive backtracking algorithm for finding a mapping. See the comment for requiredMappings() (the first step).

Type Parameters:
T -
Parameters:
rdgIndividual - the selected rdgIndividual
remainingRdgIndividuals - the remaining RDG individuals for which mappings still have to be found
protocolIndividuals - individuals in this protocol graph which have not yet been used in a mapping
individualMapper - an object that can decide whether an individual in RDG can be mapped onto a particular individual in the protocol graph
Returns:
a map whose keys are RDG individuals, and the values are individuals in this protocol graph

optionalMapping

private <T extends SSWAPIndividual> T 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).

Type Parameters:
T -
Parameters:
protocolIndividual - the Protocol graph individual for which the mapping should be found
rdgIndividuals - candidate RDG individuals
individualMapper - an object that can decide whether an individual in RDG can be mapped onto a particular individual in this protocol graph
Returns:
an individual from RDG that can be mapped onto the given protocol graph individual, null if there are no RDG individuals that can be mapped

filter

private static <T> java.util.Collection<T> 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

Type Parameters:
T - the type of objects in the collections
Parameters:
newCollection - the collection to which the non-filtered items are to be added
oldCollection - the collections that contains elements to be filtered
filteredElement - the element to be filtered
Returns:
the newCollection (i.e., the copy of oldCollection but without any occurrences of filteredElement)

copyNonTranslatedProperties

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. Such properties are typically not translated because they were not defined in subject's type, but they were still mentioned in RDG. This method should be invoked on the translated individual (e.g., SSWAPSubject).

Parameters:
nonTranslatedIndividual - the node in the protocol graph (before translation)
rdgIndividual - the corresponding node in RDG

copyPropertyValues

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.

Parameters:
dstPropertyURI - the URI of the property in this (destination) individual to where the values should be copied
srcPropertyURI - the URI of the property in the source individual
srcOriginal - the object from which the values should be copied

getCorrespondingRDGProperty

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. A corresponding property is a property that is a super-property of the given property.

Parameters:
protocolProperty - Protocol graph property
rdgProperties - all properties mentioned in the RDG individual
Returns:
the property that is corresponding to the given Protocol graph property or null, if there is no such property

serialize

public void serialize(java.io.OutputStream os,
                      RDFRepresentation rdfRepresentation,
                      boolean commentedOutput)
Description copied from interface: SSWAPModel
Serializes the contents of this object to the specified stream.

Specified by:
serialize in interface SSWAPModel
Specified by:
serialize in interface SourceModel
Overrides:
serialize in class SourceModelImpl
Parameters:
os - output stream
rdfRepresentation - 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)

getResourceMappingValidator

protected ProtocolImpl.MappingValidator<SSWAPResource> getResourceMappingValidator()

getSubjectMappingValidator

protected ProtocolImpl.MappingValidator<SSWAPSubject> getSubjectMappingValidator()

getObjectMappingValidator

protected ProtocolImpl.MappingValidator<SSWAPObject> getObjectMappingValidator()

doClosure

public int doClosure()
Description copied from class: SourceModelImpl
Computes closure for this model.

Specified by:
doClosure in interface SSWAPModel
Specified by:
doClosure in interface SourceModel
Overrides:
doClosure in class SourceModelImpl
Returns:
the degree of the closure computed.

createCopyObject

protected <T extends SSWAPIndividual> T createCopyObject(T original,
                                                         java.net.URI copyURI)
Overrides:
createCopyObject in class SourceModelImpl


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