Note: This validation must be done before E4
None ranges min-max values in price specifications are include in others
One offering (gr:Offering) can include more than one price specification. Prices specifications can include price intervals using the gr:hasMinCurrencyValue - gr:hasMaxCurrencyValue properties. Care must be taken that price ranges in price specifications for the same offering do not overlapp to each other.
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix toy: <http://www.heppnetz.de/ontologies/examples/toy#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://www.heppnetz.de/ontologies/examples/gr> rdf:type owl:Ontology ;
owl:imports <http://www.heppnetz.de/ontologies/examples/toy> ,
<http://purl.org/goodrelations/v1> .
<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> rdf:type gr:Offering .
<http://www.heppnetz.de/ontologies/examples/gr#UnitPriceSpecification_1> rdf:type gr:UnitPriceSpecification ;
gr:hasMinCurrencyValue "300.0"^^<http://www.w3.org/2001/XMLSchema#float> ;
gr:hasMaxCurrencyValue "450.0"^^<http://www.w3.org/2001/XMLSchema#float> .
<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> gr:hasPriceSpecification
<http://www.heppnetz.de/ontologies/examples/gr#UnitPriceSpecification_1> .
<http://www.heppnetz.de/ontologies/examples/gr#UnitPriceSpecification_2> rdf:type gr:UnitPriceSpecification ;
gr:hasMinCurrencyValue "100.0"^^<http://www.w3.org/2001/XMLSchema#float> ;
gr:hasMaxCurrencyValue "400.0"^^<http://www.w3.org/2001/XMLSchema#float> .
<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> gr:hasPriceSpecification
<http://www.heppnetz.de/ontologies/examples/gr#UnitPriceSpecification_2> .
<http://www.heppnetz.de/ontologies/examples/gr#DeliveryChargeSpecification_1> rdf:type gr:DeliveryChargeSpecification ;
gr:hasMinCurrencyValue "100.0"^^<http://www.w3.org/2001/XMLSchema#float> ;
gr:hasMaxCurrencyValue "400.0"^^<http://www.w3.org/2001/XMLSchema#float> .
<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> gr:hasPriceSpecification
<http://www.heppnetz.de/ontologies/examples/gr#DeliveryChargeSpecification_1> .
PREFIX gr:<http://purl.org/goodrelations/v1#>
#domain: Offering, objectProperty: hasPriceSpecification, range: PriceSpecification
#domain: PriceSpecification, dataProperties: hasMinCurrencyValue, hasMaxCurrencyValue, range: float
SELECT DISTINCT ?offering
WHERE {
{#PriceSpecification
#Get prices
?offering gr:hasPriceSpecification ?priceSpec .
?priceSpec a gr:PriceSpecification .
?priceSpec gr:hasMinCurrencyValue ?min .
?priceSpec gr:hasMaxCurrencyValue ?max .
# Get the prices for each ?offering again
?offering gr:hasPriceSpecification ?priceSpec1 .
?priceSpec1 a gr:PriceSpecification .
?priceSpec1 gr:hasMinCurrencyValue ?min1 .
?priceSpec1 gr:hasMaxCurrencyValue ?max1 .
# Filter same priceSpec (no sense to compare to itself)
FILTER ( ?priceSpec != ?priceSpec1 )
# Test for overlapping ranges
FILTER (
( ( ?min <= ?max1 ) && ( ?max1 <= ?max ) ) ||
( ( ?min <= ?min1 ) && ( ?min1 <= ?max ) )
)
} UNION {#UnitPriceSpecification
#Get prices
?offering gr:hasPriceSpecification ?priceSpec .
?priceSpec a gr:UnitPriceSpecification .
?priceSpec gr:hasMinCurrencyValue ?min .
?priceSpec gr:hasMaxCurrencyValue ?max .
# Get the prices for each ?offering again
?offering gr:hasPriceSpecification ?priceSpec1 .
?priceSpec1 a gr:UnitPriceSpecification .
?priceSpec1 gr:hasMinCurrencyValue ?min1 .
?priceSpec1 gr:hasMaxCurrencyValue ?max1 .
# Filter same priceSpec (no sense to compare to itself)
FILTER ( ?priceSpec != ?priceSpec1 )
# Test for overlapping ranges
FILTER (
( ( ?min <= ?max1 ) && ( ?max1 <= ?max ) ) ||
( ( ?min <= ?min1 ) && ( ?min1 <= ?max ) )
)
} UNION {#DeliveryChargeSpecification
#Get prices
?offering gr:hasPriceSpecification ?priceSpec .
?priceSpec a gr:DeliveryChargeSpecification .
?priceSpec gr:hasMinCurrencyValue ?min .
?priceSpec gr:hasMaxCurrencyValue ?max .
# Get the prices for each ?offering again
?offering gr:hasPriceSpecification ?priceSpec1 .
?priceSpec1 a gr:DeliveryChargeSpecification .
?priceSpec1 gr:hasMinCurrencyValue ?min1 .
?priceSpec1 gr:hasMaxCurrencyValue ?max1 .
# Filter same priceSpec (no sense to compare to itself)
FILTER ( ?priceSpec != ?priceSpec1 )
# Test for overlapping ranges
FILTER (
( ( ?min <= ?max1 ) && ( ?max1 <= ?max ) ) ||
( ( ?min <= ?min1 ) && ( ?min1 <= ?max ) )
)
} UNION {#PaymentChargeSpecification
#Get prices
?offering gr:hasPriceSpecification ?priceSpec .
?priceSpec a gr:PaymentChargeSpecification .
?priceSpec gr:hasMinCurrencyValue ?min .
?priceSpec gr:hasMaxCurrencyValue ?max .
# Get the prices for each ?offering again
?offering gr:hasPriceSpecification ?priceSpec1 .
?priceSpec1 a gr:PaymentChargeSpecification .
?priceSpec1 gr:hasMinCurrencyValue ?min1 .
?priceSpec1 gr:hasMaxCurrencyValue ?max1 .
# Filter same priceSpec (no sense to compare to itself)
FILTER ( ?priceSpec != ?priceSpec1 )
# Test for overlapping ranges
FILTER (
( ( ?min <= ?max1 ) && ( ?max1 <= ?max ) ) ||
( ( ?min <= ?min1 ) && ( ?min1 <= ?max ) )
)
}
}
ORDER BY ?offering