GRValidator Implemented E13

Error 13

E13: Check that if a price specification is attached, not more than one BusinessFunction is used.

Validator Tool: Step # 20

Error Message

When price specifications exist, only one Business Function is allowed.

Potential Problem

One offering can specify more than one price specification. Care must be taken that only one gr:hasBusinessFunction is specified when there are more than one price specification for the same offer becausevery likely, the price asked for two business functions is not the same.

Examples of Wrong Data

@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 ;
    gr:hasBusinessFunction "" .
<http://www.heppnetz.de/ontologies/examples/gr#BusinessFunction_1> rdf:type rdf:Statement ;
    rdf:subject <http://www.heppnetz.de/ontologies/examples/gr#Offering_1> ;
    rdf:predicate gr:hasBusinessFunction ;
    rdf:object "" .
<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> gr:hasBusinessFunction "" .
<http://www.heppnetz.de/ontologies/examples/gr#BusinessFunction_2> rdf:type rdf:Statement ;
    rdf:subject <http://www.heppnetz.de/ontologies/examples/gr#Offering_1> ;
    rdf:predicate gr:hasBusinessFunction ;
    rdf:object "" .
<http://www.heppnetz.de/ontologies/examples/gr#UnitPriceSpecification_1> rdf:type gr:UnitPriceSpecification ;
    gr:hasCurrency "COP"^^<http://www.w3.org/2001/XMLSchema#string> ;
    gr:hasCurrencyValue "550.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:hasCurrency "COP"^^<http://www.w3.org/2001/XMLSchema#string> ;
    gr:hasCurrencyValue "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_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> .

SPARQL Query

PREFIX gr:<http://purl.org/goodrelations/v1#>

SELECT ?object
WHERE
{
# At least one PS, then only one hasBusinessFunction --> count = 1 is OK, check count != 1
  {
    ?object a gr:Offering .
    ?object gr:hasPriceSpecification ?priceSpec .
    FILTER (1 != (
      SELECT count(?hasBusinessFunction)
      WHERE {
          ?object gr:hasBusinessFunction ?hasBusinessFunction
      }
    ))
  }
}