Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show deprecated concepts without replacement in change list #1529

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2262,13 +2262,20 @@ private function generateChangeListQuery($prop, $lang, $offset, $limit=200, $sho
$deprecatedVars = '';
if ($showDeprecated) {
$deprecatedVars = '?replacedBy ?deprecated ?replacingLabel';
$deprecatedOptions =
'UNION {'.
'?concept dc:isReplacedBy ?replacedBy ; dc:modified ?date2 .'.
'BIND(COALESCE(?date2, ?date) AS ?date)'.
'OPTIONAL { ?replacedBy skos:prefLabel ?replacingLabel .'.
'FILTER (langMatches(lang(?replacingLabel), \''.$lang.'\')) }}'.
'OPTIONAL { ?concept owl:deprecated ?deprecated . }';
$deprecatedOptions = <<<EOQ
UNION {
?concept owl:deprecated True; dc:modified ?date2 .
BIND(True as ?deprecated)
BIND(COALESCE(?date2, ?date) AS ?date)
OPTIONAL {
?concept dc:isReplacedBy ?replacedBy .
OPTIONAL {
?replacedBy skos:prefLabel ?replacingLabel .
FILTER (langMatches(lang(?replacingLabel), '$lang'))
}
}
}
EOQ;
}

$query = <<<EOQ
Expand Down Expand Up @@ -2312,6 +2319,11 @@ private function transformChangeListResults($result) {
}
}

if (isset($row->deprecated)) {
$concept['deprecated'] = $row->deprecated->getValue();
} else {
$concept['deprecated'] = false;
}
if (isset($row->replacedBy)) {
$concept['replacedBy'] = $row->replacedBy->getURI();
}
Expand Down
9 changes: 7 additions & 2 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,13 @@ public function testQueryCreatedListWithDeprecated()
foreach($actual as $concept) {
array_push($order, $concept['prefLabel']);
}
$this->assertEquals(4, sizeof($actual));
$this->assertEquals(array('Fourth date', 'Hurr Durr', 'Second date', 'A date'), $order);
$this->assertEquals(5, sizeof($actual));
$this->assertEquals(array('No replacement', 'Fourth date', 'Hurr Durr', 'Second date', 'A date'), $order);

// check that deprecated status is correct
$this->assertTrue($actual[0]['deprecated']); // 'No replacement'
$this->assertTrue($actual[1]['deprecated']); // 'Fourth date'
$this->assertFalse($actual[2]['deprecated']); // 'Hurr Durr'
}


Expand Down
6 changes: 6 additions & 0 deletions tests/RestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,11 @@ public function testNewConcepts() {
},
"changeList": [
{
"uri": "http://www.skosmos.skos/changes/d5",
"prefLabel": "No replacement",
"date": "2021-02-04T12:46:33+0000"
},
{
"uri": "http://www.skosmos.skos/changes/d4",
"prefLabel": "Fourth date",
"date": "2021-01-03T12:46:33+0000",
Expand Down Expand Up @@ -867,6 +872,7 @@ public function testDeprecatedChanges() {
"date": { "@id":"http://purl.org/dc/terms/date","@type":"http://www.w3.org/2001/XMLSchema#dateTime" }
},
"changeList": [
{ "date": "2021-02-04T12:46:33+0000", "prefLabel": "No replacement", "uri": "http://www.skosmos.skos/changes/d5" },
{ "date": "2021-01-03T12:46:30+0000", "prefLabel": "A date", "uri": "http://www.skosmos.skos/changes/d1" },
{ "date": "2021-01-03T12:46:33+0000", "prefLabel": "Fourth date", "replacedBy": "http://www.skosmos.skos/changes/d3", "replacingLabel": "Hurr Durr", "uri": "http://www.skosmos.skos/changes/d4" },
{ "date": "2021-01-03T12:46:32+0000", "prefLabel": "Hurr Durr", "uri": "http://www.skosmos.skos/changes/d3" },
Expand Down
4 changes: 2 additions & 2 deletions tests/VocabularyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ public function testGetTopConcepts() {
public function testGetChangeList() {
$vocab = $this->model->getVocabulary('changes');
$changeList = $vocab->getChangeList('dc:created','en', 0, 5);
$expected = array ('uri' => 'http://www.skosmos.skos/changes/d3', 'prefLabel' => 'Hurr Durr', 'date' => DateTime::__set_state(array('date' => '2010-02-12 10:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')));
$this->assertEquals($expected, $changeList[1]);
$expected = array ('uri' => 'http://www.skosmos.skos/changes/d3', 'prefLabel' => 'Hurr Durr', 'date' => DateTime::__set_state(array('date' => '2010-02-12 10:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')), 'deprecated' => false);
$this->assertEquals($expected, $changeList[2]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/WebControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function testFormatChangeList() {
$changeList = $this->webController->getChangeList($request, 'dc:created');
$months =$this->webController->formatChangeList($changeList, 'en');

$expected = array ('hurr durr' => array ('uri' => 'http://www.skosmos.skos/changes/d3', 'prefLabel' => 'Hurr Durr', 'date' => DateTime::__set_state(array('date' => '2010-02-12 10:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')), 'datestring' => 'Feb 12, 2010'), 'second date' => array ('uri' => 'http://www.skosmos.skos/changes/d2', 'prefLabel' => 'Second date', 'date' => DateTime::__set_state(array('date' => '2010-02-12 15:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')), 'datestring' => 'Feb 12, 2010'));
$expected = array ('hurr durr' => array ('uri' => 'http://www.skosmos.skos/changes/d3', 'prefLabel' => 'Hurr Durr', 'date' => DateTime::__set_state(array('date' => '2010-02-12 10:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')), 'datestring' => 'Feb 12, 2010', 'deprecated' => false), 'second date' => array ('uri' => 'http://www.skosmos.skos/changes/d2', 'prefLabel' => 'Second date', 'date' => DateTime::__set_state(array('date' => '2010-02-12 15:26:39.000000', 'timezone_type' => 3, 'timezone' => 'UTC')), 'datestring' => 'Feb 12, 2010', 'deprecated' => false));
$this->assertEquals($expected, $months['February 2010']);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/test-vocab-data/changes.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ changes:d4 a skos:Concept ;
dc:created "2011-12-12T09:26:39"^^xsd:dateTime ;
dc:modified "2021-01-03T12:46:33"^^xsd:dateTime ;
skos:prefLabel "Fourth date"@en .

changes:d5 a skos:Concept ;
owl:deprecated true ;
dc:created "2012-12-12T09:26:39"^^xsd:dateTime ;
dc:modified "2021-02-04T12:46:33"^^xsd:dateTime ;
skos:prefLabel "No replacement"@en .
2 changes: 1 addition & 1 deletion view/changes.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<h5 class="versal versal-bold">{{day}}</h5>
{% for concept in concepts %}
<li><a href="{{ concept.uri | link_url(vocab,request.lang,'page', request.contentLang) }}">
{% if concept.replacedBy is defined %}
{% if concept.deprecated %}
<s>{{ concept.prefLabel }}</s>
{% else %}
{{ concept.prefLabel }}
Expand Down
Loading