Beispiel #1
0
    public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $offset = null, $classes = null)
    {
        if ($letter == '*' || $letter == '0-9' || $letter == '!*') {
            // text index cannot support special character queries, use the generic implementation for these
            return parent::generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes);
        }
        $gc = $this->graphClause;
        $classes = $classes ? $classes : array('http://www.w3.org/2004/02/skos/core#Concept');
        $values = $this->formatValues('?type', $classes, 'uri');
        $limitandoffset = $this->formatLimitAndOffset($limit, $offset);
        # make text query clause
        $textcond_pref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $lang);
        $textcond_alt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $lang);
        $query = <<<EOQ
SELECT DISTINCT ?s ?label ?alabel
WHERE {
  {$gc} {
    {
      {$textcond_pref}
      BIND(?literal as ?label)
    }
    UNION
    {
      {$textcond_alt}
      BIND(?literal as ?alabel)
      {
        ?s skos:prefLabel ?label .
        FILTER (langMatches(lang(?label), '{$lang}'))
      }
    }
    ?s a ?type .
    FILTER NOT EXISTS { ?s owl:deprecated true }
  } {$values}
}
ORDER BY LCASE(?literal) {$limitandoffset}
EOQ;
        return $query;
    }
Beispiel #2
0
 /**
  * @covers GenericSparql::listConceptGroupContents
  */
 public function testListConceptGroupContentsIncludingDeprecatedConcept()
 {
     $voc = $this->model->getVocabulary('groups');
     $graph = $voc->getGraph();
     $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);
     $actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en');
     $this->assertEquals('http://www.skosmos.skos/groups/ta113', $actual[0]['uri']);
     $this->assertEquals(1, sizeof($actual));
 }