Exemplo n.º 1
0
    public function getSubject($graph, $property, $object)
    {
        $query = <<<END
SELECT ?subject FROM <{$graph}> WHERE {
\t?subject <{$property}> <{$object}>
}
END;
        $fields = array();
        $fields['default-graph-uri'] = '';
        $fields['format'] = 'application/sparql-results+json';
        $fields['debug'] = 'on';
        $fields['query'] = $query;
        $json = CurlRequest::curlPostContents($this->endpoint, $fields);
        $result = RDFQueryHelper::parseSPARQLResult($json);
        $subject = RDFQueryHelper::parseEntity($result, 'subject');
        return $subject;
    }
Exemplo n.º 2
0
    public function getTransitiveSupClass($graph, $pathType, $term, $supClass)
    {
        $query = <<<END
PREFIX rdf: <{$this->prefixNS['rdf']}>
PREFIX rdfs: <{$this->prefixNS['rdfs']}>
PREFIX owl: <{$this->prefixNS['owl']}>
SELECT ?path ?link ?label FROM <{$graph}> WHERE {
\t{
\t\tSELECT ?s ?o ?label WHERE {
\t\t\t{
\t\t\t\t?s rdfs:subClassOf ?o .
\t\t\t\tFILTER (isURI(?o)).
\t\t\t\tOPTIONAL {?o rdfs:label ?label}
\t\t\t} UNION {
\t\t\t\t?s owl:equivalentClass ?s1 .
\t\t\t\t?s1 owl:intersectionOf ?s2 .
\t\t\t\t?s2 rdf:first ?o  .
\t\t\t\tFILTER (isURI(?o))
\t\t\t\tOPTIONAL {?o rdfs:label ?label}
\t\t\t}
\t\t}
\t}
\tOPTION (TRANSITIVE, t_in(?s), t_out(?o), t_step (?s) as ?link, t_step ('path_id') as ?path).
\tFILTER (isIRI(?o)).
\tFILTER (?s= <{$term}>)
}
END;
        $fields = array();
        $fields['default-graph-uri'] = '';
        $fields['format'] = 'application/sparql-results+json';
        $fields['debug'] = 'on';
        $fields['query'] = $query;
        $json = CurlRequest::curlPostContents($this->endpoint, $fields);
        $result = RDFQueryHelper::parseSPARQLResult($json);
        $transitivePath = RDFQueryHelper::parseTransitivePath($result, $pathType, $supClass);
        return $transitivePath;
    }