Exemple #1
0
    public function insertAxiom($graph, $subject, $property, $axioms)
    {
        $query = <<<END
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX ro: <http://www.obofoundry.org/ro/ro.owl#>
INSERT IN <{$graph}> {

END;
        foreach ($axioms as $axiom) {
            $object = RDFQueryHelper::parseManchesterData($axiom);
            $query .= <<<END
\t<{$subject}> <{$property}> {$object} .

END;
        }
        $query .= '}';
        $fields = array();
        $fields['default-graph-uri'] = '';
        $fields['format'] = 'application/sparql-results+json';
        $fields['debug'] = 'on';
        $fields['query'] = $query;
        $json = CurlRequest::curlPostContents($this->endpoint, $fields);
    }
Exemple #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;
    }