PREFIX gesli: <https://gesli.example/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?brandName ?productName ?transportMode ?transportSubMode
       ?serviceForm ?routeType ?originLocation ?destinationLocation ?transitPortName
       ?supplierName ?platformSupplierType ?offeringCode ?offeringChannel ?agencyLevel
       ?capacityCommitment ?bookingSuccessRate ?spaceReleaseSuccessRate
       ?quoteNo ?supplierCostAmount ?currency ?validFrom ?validTo
       ?scheduleCode ?documentCutoffTime ?estimatedDepartureTime ?estimatedArrivalTime
WHERE {
  ?quote a gesli:SupplierQuote ;
         gesli:quoteNo ?quoteNo ;
         gesli:quotedForOffering ?offering ;
         gesli:supplierCostAmount ?supplierCostAmount ;
         gesli:currency ?currency .

  ?offering a gesli:SupplierProductOffering ;
            gesli:offeringCode ?offeringCode ;
            gesli:offeredBySupplier ?supplier ;
            gesli:offeringProduct ?product .

  ?supplier rdfs:label ?supplierName .
  ?product gesli:productName ?productName ;
           gesli:transportMode ?transportMode ;
           gesli:transportSubMode ?transportSubMode ;
           gesli:serviceForm ?serviceForm ;
           gesli:routeType ?routeType ;
           gesli:originLocation ?originLocation ;
           gesli:destinationLocation ?destinationLocation .

  OPTIONAL {
    ?product gesli:hasServiceBrand ?brand .
    ?brand gesli:brandName ?brandName .
  }
  OPTIONAL { ?supplier gesli:platformSupplierType ?platformSupplierType . }
  OPTIONAL { ?offering gesli:offeringChannel ?offeringChannel . }
  OPTIONAL { ?offering gesli:agencyLevel ?agencyLevel . }
  OPTIONAL { ?offering gesli:capacityCommitment ?capacityCommitment . }
  OPTIONAL { ?offering gesli:bookingSuccessRate ?bookingSuccessRate . }
  OPTIONAL { ?offering gesli:spaceReleaseSuccessRate ?spaceReleaseSuccessRate . }
  OPTIONAL { ?product gesli:transitPortName ?transitPortName . }
  OPTIONAL { ?quote gesli:validFrom ?validFrom . }
  OPTIONAL { ?quote gesli:validTo ?validTo . }
  OPTIONAL {
    ?quote gesli:quoteAppliesToSchedule ?schedule .
    ?schedule gesli:scheduleCode ?scheduleCode .
    OPTIONAL { ?schedule gesli:documentCutoffTime ?documentCutoffTime . }
    OPTIONAL { ?schedule gesli:estimatedDepartureTime ?estimatedDepartureTime . }
    OPTIONAL { ?schedule gesli:estimatedArrivalTime ?estimatedArrivalTime . }
  }
}
ORDER BY ?productName ?supplierName ?quoteNo
