PREFIX foaf:
PREFIX dct:
PREFIX schema:
PREFIX xsd:
PREFIX geo:
CONSTRUCT
{
GRAPH ?graph
{
?graph dct:title ?companyName ;
foaf:primaryTopic ?customer ;
foaf:topic ?contactPoint, ?employee, ?postalAddress .
?customer a schema:Corporation ;
schema:identifier ?customerID ;
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 .
?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
{
?customer_row <#customerID> ?customerID ;
<#companyName> ?companyName ;
<#contactName> ?contactName ;
<#contactTitle> ?contactTitle ;
<#address> ?address ;
<#city> ?city ;
<#postalCode> ?postalCode ;
<#country> ?country ;
<#phone> ?phone .
OPTIONAL {
?customer_row <#region> ?region
}
OPTIONAL {
?customer_row <#fax> ?fax
}
OPTIONAL {
?customer_row <#lat> ?lat_string
BIND(xsd:float(?lat_string) AS ?lat)
}
OPTIONAL {
?customer_row <#long> ?long_string
BIND(xsd:float(?long_string) AS ?long)
}
BIND(uri(concat(str($base), "customers/")) AS ?container)
BIND(uri(concat(str(?container), encode_for_uri(?customerID), "/")) AS ?graph)
BIND(uri(concat(str(?graph), "#this")) AS ?customer)
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)
}