PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX schema: <https://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
CONSTRUCT
{
GRAPH ?graph
{
?graph dct:title ?companyName ;
foaf:primaryTopic ?supplier ;
foaf:topic ?contactPoint, ?employee, ?postalAddress .
?supplier a schema:Corporation ;
schema:identifier ?supplierID ;
dct:title ?companyName ;
schema:legalName ?companyName ;
schema:contactPoint ?contactPoint ;
schema:employee ?employee .
?contactPoint a schema:ContactPoint ;
foaf:page ?graph ;
schema:telephone ?phone ;
schema:faxNumber ?fax ;
schema:url ?homePage .
?employee a schema:Person ;
foaf:page ?graph ;
schema:name ?contactName ;
dct:title ?contactName ;
schema:jobTitle ?contactTitle ;
schema:telephone ?phone ;
schema:faxNumber ?fax ;
schema:address ?postalAddress ;
geo:lat ?lat ;
geo:long ?long .
?postalAddress a schema:PostalAddress ;
foaf:page ?graph ;
schema:addressCountry ?country ;
schema:addressLocality ?city ;
schema:postalCode ?postalCode ;
schema:streetAddress ?address ;
schema:addressRegion ?region .
}
}
WHERE
{
?supplier_row <#supplierID> ?supplierID ;
<#companyName> ?companyName ;
<#contactName> ?contactName ;
<#contactTitle> ?contactTitle ;
<#address> ?address ;
<#city> ?city ;
<#postalCode> ?postalCode ;
<#country> ?country ;
<#phone> ?phone .
OPTIONAL {
?supplier_row <#region> ?region
}
OPTIONAL {
?supplier_row <#fax> ?fax
}
OPTIONAL {
?supplier_row <#homePage> ?homePage
}
OPTIONAL {
?supplier_row <#lat> ?lat_string
BIND(xsd:float(?lat_string) AS ?lat)
}
OPTIONAL {
?supplier_row <#long> ?long_string
BIND(xsd:float(?long_string) AS ?long)
}
BIND(uri(concat(str($base), "suppliers/")) AS ?container)
BIND(uri(concat(str(?container), encode_for_uri(?supplierID), "/")) AS ?graph)
BIND(uri(concat(str(?graph), "#this")) AS ?supplier)
BIND(uri(concat(str(?graph), "#contact-point")) AS ?contactPoint)
BIND(uri(concat(str(?graph), "#employee")) AS ?employee)
BIND(uri(concat(str(?graph), "#postal-address")) AS ?postalAddress)
}