PREFIX foaf:
PREFIX dct:
PREFIX schema:
PREFIX xsd:
CONSTRUCT
{
GRAPH ?graph
{
?graph dct:title ?orderID ;
foaf:primaryTopic ?order ;
foaf:topic ?orderDelivery, ?deliveryAddress .
?order a schema:Order ;
schema:identifier ?orderID ;
dct:title ?orderID ;
schema:customer ?customer ;
schema:broker ?employee ;
schema:orderDate ?orderDate ;
schema:orderDelivery ?orderDelivery .
?orderDelivery a schema:ParcelDelivery ;
foaf:page ?graph ;
schema:expectedArrivalUntil ?requiredDate ;
# ?shippedDate ;
schema:deliveryAddress ?deliveryAddress ;
schema:provider ?shipper .
?deliveryAddress a schema:PostalAddress ;
foaf:page ?graph ;
schema:addressCountry ?shipCountry ;
schema:addressLocality ?shipCity ;
schema:postalCode ?shipPostalCode ;
schema:streetAddress ?shipAddress ;
schema:location ?deliveryLocation ;
schema:addressRegion ?shipRegion .
}
}
WHERE
{
?order_row <#orderID> ?orderID ;
<#customerID> ?customerID ;
<#employeeID> ?employeeID ;
<#orderDate> ?orderDateString ;
<#requiredDate> ?requiredDateString ;
<#shipVia> ?shipVia ;
<#freight> ?freightString ;
<#shipName> ?shipName ;
<#shipAddress> ?shipAddress ;
<#shipCity> ?shipCity ;
<#shipPostalCode> ?shipPostalCode ;
<#shipCountry> ?shipCountry .
OPTIONAL {
?order_row <#shippedDate> ?shippedDateString
BIND(strdt(?shippedDateString, xsd:date) AS ?shippedDate)
}
OPTIONAL {
?order_row <#shipRegion> ?shipRegion
}
BIND(uri(concat(str($base), "orders/")) AS ?container)
BIND(uri(concat(str(?container), encode_for_uri(?orderID), "/")) AS ?graph)
BIND(uri(concat(str(?graph), "#this")) AS ?order)
BIND(uri(concat(str(?graph), "#delivery")) AS ?orderDelivery)
BIND(uri(concat(str(?graph), "#delivery-address")) AS ?deliveryAddress)
BIND(uri(concat(str($base), "employees/", encode_for_uri(?employeeID), "/#this")) AS ?employee)
BIND(uri(concat(str($base), "customers/", encode_for_uri(?customerID), "/#this")) AS ?customer)
BIND(uri(concat(str($base), "shippers/", encode_for_uri(?shipVia), "/#this")) AS ?shipper)
BIND(strdt(?orderDateString, xsd:date) AS ?orderDate)
BIND(strdt(?requiredDateString, xsd:date) AS ?requiredDate)
BIND(strdt(?freightString, xsd:float) AS ?freight)
}