Use of SPARQL query to describe patterns is a natural choice - SPARQL is after all specifically a pattern-matching language. It is easy to construct generic SPARQL query describing HydrostaticTestPressure RDF sub-graph in two variants of the pattern - an option for a class and an option for an individual.
Code: Select all
@prefix rdl: <http://posccaesar.org/rdl/> .
@prefix tpl: <http://data.posccaesar.org/tpl/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dm: <http://rds.posccaesar.org/2008/02/OWL/ISO-15926-2_2003#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
SELECT ?hasPosessor ?hasPressure ?hasScale
WHERE { {?x1 a tpl:ClassOfParticipationDefinition ;
tpl:hasActivityType ?activity ;
tpl:hasParticipantType ?hasPossessor ;
tpl:hasParticipantRole rdl:RDS4398439 ; # TESTED
tpl:hasCardinalityOfActivity rdl:RDS4367382 ; # ZERO-TO-INF (faked ID)
tpl:hasCardinalityOfParticipant rdl:RDS2387482 . # EXACTLY ONE (faked ID)
?x2 a tpl:ClassOfParticipationDefinition ;
tpl:hasActivityType ?activity ;
tpl:hasParticipantType ?fluid ;
tpl:hasParticipantRole rdl:RDS13108820 ; # TEST FLUID
tpl:hasCardinalityOfActivity rdl:RDS4367382 ; # ZERO-TO-INF (faked ID)
tpl:hasCardinalityOfParticipant rdl:RDS2387482 . # EXACTLY ONE (faked ID)
?x3 a tpl:ClassOfIndividualHasIndirectPropertyWithValue ;
tpl:hasPossessorType ?fluid ;
tpl:hasIndirectPropertyType rdl:RDS361349 ; # HYDROSTATIC TEST PRESSURE
tpl:valPropertyValue ?hasPressure ;
tpl:hasScale ?hasScale .
?hasPossessor rdfs:subClassOf rdl:RDS430694 . # PRESSURE-RATED ARTEFACT
?hasScale a dm:Scale .
?activity rdfs:subClassOf rdl:RDS9706787 . # HYDROSTATIC TESTING
?fluid rdfs:subClassOf rdl:RDS5605044 . # UNION OF ALLOWABLE TEST FLUIDS (faked ID)
FILTER ( datatype(?hasPressure) = xsd:float ) . }
UNION
{?x1 a tpl:ParticipationOfIndividualInActivity ;
tpl:hasActivity ?activity ;
tpl:hasParticipant ?hasPossessor ;
tpl:hasParticipationType rdl:RDS43923435345 . # PARTICIPATION IN HYDROSTATIC TESTING AS TESTED (faked ID)
?x2 a tpl:ParticipationOfIndividualInActivity ;
tpl:hasActivity ?activity ;
tpl:hasParticipant ?fluid ;
tpl:hasParticipationType rdl:RDS142388242 . # PARTICIPATION IN HYDROSTATIC TESTING AS TEST FLUID (faked ID)
?x3 a tpl:IndividualHasIndirectPropertyWithValue ;
tpl:hasPossessor ?fluid ;
tpl:hasIndirectPropertyType rdl:RDS361349 ; # HYDROSTATIC TEST PRESSURE
tpl:valPropertyValue ?hasPressure ;
tpl:hasScale ?hasScale .
?hasPossessor a rdl:RDS430694 . # PRESSURE-RATED ARTEFACT
?hasScale a dm:Scale .
?activity a rdl:RDS9706787 . # HYDROSTATIC TESTING
?fluid a rdl:RDS5605044 . # UNION OF ALLOWABLE TEST FLUIDS (faked ID)
FILTER ( datatype(?hasPressure) = xsd:float ) . } }
It was not easy for me to select appropriate SPIN container to encapsulate SPARQL pattern description. Looks like SPIN requires strict determination - whether you will use SPIN rule to search for data, to verify data or to modify it. As we understand now, ISO 15926 patterns will be used for all these purposes simultaneously. Patterns can be used to construct RDF data from data in the native engineering applications, patterns can be used to search in RDF data to verify it or to write data to native engineering applications, and patterns can be used to search RDF data and replace it with other RDF data (for template lowering-lifting, for example). Such universal usage is broader then any specific containers available in SPIN.
Therefore I've tried to describe our intended SPARQL queries as SPIN Templates (http://spinrdf.org/spl.html#templates). This container allows description of pattern parameters, allows classification and labelling of patterns.
Obviously specialized software will be able to extract SPARQL pattern description from the container and use it for any of the purposes mentioned above. Whether a generic SPIN engine will make some sense out of this form - is an open question for me.
Hope SPIN experts will look at this, correct mistakes or show better solutions if available.
Code: Select all
@prefix rdl: <http://posccaesar.org/rdl/> .
@prefix tpl: <http://data.posccaesar.org/tpl/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dm: <http://rds.posccaesar.org/2008/02/OWL/ISO-15926-2_2003#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix spin: <http://spinrdf.org/spin#>.
@prefix sp: <http://spinrdf.org/sp#>.
@prefix spl: <http://spinrdf.org/spl#>.
@prefix ptrn: <http://data.posccaesar.org/ptrn/>.
ptrn:HydroTestPressureForClass a spin:SelectTemplate ;
rdfs:subClassOf ptrn:HydroTestPressure ;
rdfs:comment "For ?hasPossessor class members hydrostatic test pressure property equals ?hasPressure on ?hasScale scale" ;
rdfs:label "Hydrostatic test pressure (class)"^^xsd:string ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Tested entity (class)" ;
spl:predicate ptrn:hasPossessor ;
] ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Hydrostatic test pressure value" ;
spl:predicate ptrn:hasPressure ;
spl:valueType xsd:float
] ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Hydrostatic test pressure UOM" ;
spl:predicate ptrn:hasScale ;
spl:valueType dm:Scale
] ;
spin:labelTemplate "Hydrostatic test pressure for {?hasPossessor} is {?hasPressure} {?hasScale}"^^xsd:string ;
spin:body
[ a sp:Select ;
sp:text """
SELECT ?hasPosessor ?hasPressure ?hasScale
WHERE { ?x1 a tpl:ClassOfParticipationDefinition ;
tpl:hasActivityType ?activity ;
tpl:hasParticipantType ?hasPossessor ;
tpl:hasParticipantRole rdl:RDS4398439 ; # TESTED
tpl:hasCardinalityOfActivity rdl:RDS4367382 ; # ZERO-TO-INF (faked ID)
tpl:hasCardinalityOfParticipant rdl:RDS2387482 . # EXACTLY ONE (faked ID)
?x2 a tpl:ClassOfParticipationDefinition ;
tpl:hasActivityType ?activity ;
tpl:hasParticipantType ?fluid ;
tpl:hasParticipantRole rdl:RDS13108820 ; # TEST FLUID
tpl:hasCardinalityOfActivity rdl:RDS4367382 ; # ZERO-TO-INF (faked ID)
tpl:hasCardinalityOfParticipant rdl:RDS2387482 . # EXACTLY ONE (faked ID)
?x3 a tpl:ClassOfIndividualHasIndirectPropertyWithValue ;
tpl:hasPossessorType ?fluid ;
tpl:hasIndirectPropertyType rdl:RDS361349 ; # HYDROSTATIC TEST PRESSURE
tpl:valPropertyValue ?hasPressure ;
tpl:hasScale ?hasScale .
?hasPossessor rdfs:subClassOf rdl:RDS430694 . # PRESSURE-RATED ARTEFACT
?activity rdfs:subClassOf rdl:RDS9706787 . # HYDROSTATIC TESTING
?fluid rdfs:subClassOf rdl:RDS5605044 . # UNION OF ALLOWABLE TEST FLUIDS (faked ID) }
"""
] .
ptrn:HydroTestPressureForIndividual a spin:SelectTemplate ;
rdfs:subClassOf ptrn:HydroTestPressure ;
rdfs:comment "For ?hasPossessor object hydrostatic test pressure property equals ?hasPressure on ?hasScale scale" ;
rdfs:label "Hydrostatic test pressure (individual)"^^xsd:string ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Tested entity (individual)" ;
spl:predicate ptrn:hasPossessor ;
spl:valueType rdl:RDS430694 # PRESSURE-RATED ARTEFACT
] ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Hydrostatic test pressure value" ;
spl:predicate ptrn:hasPressure ;
spl:valueType xsd:float
] ;
spin:constraint
[ a spl:Argument ;
rdfs:comment "Hydrostatic test pressure UOM" ;
spl:predicate ptrn:hasScale ;
spl:valueType dm:Scale
] ;
spin:labelTemplate "Hydrostatic test pressure for {?hasPossessor} is {?hasPressure} {?hasScale}"^^xsd:string ;
spin:body
[ a sp:Select ;
sp:text """
SELECT ?hasPosessor ?hasPressure ?hasScale
WHERE { ?x1 a tpl:ParticipationOfIndividualInActivity ;
tpl:hasActivity ?activity ;
tpl:hasParticipant ?hasPossessor ;
tpl:hasParticipationType rdl:RDS43923435345 . # PARTICIPATION IN HYDROSTATIC TESTING AS TESTED (faked ID)
?x2 a tpl:ParticipationOfIndividualInActivity ;
tpl:hasActivity ?activity ;
tpl:hasParticipant ?fluid ;
tpl:hasParticipationType rdl:RDS142388242 . # PARTICIPATION IN HYDROSTATIC TESTING AS TEST FLUID (faked ID)
?x3 a tpl:IndividualHasIndirectPropertyWithValue ;
tpl:hasPossessor ?fluid ;
tpl:hasIndirectPropertyType rdl:RDS361349 ; # HYDROSTATIC TEST PRESSURE
tpl:valPropertyValue ?hasPressure ;
tpl:hasScale ?hasScale .
?activity a rdl:RDS9706787 . # HYDROSTATIC TESTING
?fluid a rdl:RDS5605044 . # UNION OF ALLOWABLE TEST FLUIDS (faked ID)
"""
] .