From 552cab2ea7267f3ce9fd5baa2f23a6b758b82201 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Wed, 12 Jul 2017 23:47:33 +1200 Subject: [PATCH 1/9] Add options to query Jena Text endpoints with a collation function --- config.inc.dist | 3 +++ model/GlobalConfig.php | 9 +++++++- model/sparql/JenaTextSparql.php | 19 +++++++++++++++- tests/GlobalConfigTest.php | 8 +++++++ tests/JenaTextSparqlTest.php | 25 +++++++++++++++++++++ tests/jenatestconfig.inc | 1 + tests/test-vocab-data/collation.ttl | 34 +++++++++++++++++++++++++++++ tests/testvocabularies.ttl | 8 +++++++ 8 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 tests/test-vocab-data/collation.ttl diff --git a/config.inc.dist b/config.inc.dist index d9c08bea1..d792b8ea8 100644 --- a/config.inc.dist +++ b/config.inc.dist @@ -66,3 +66,6 @@ define("UI_HONEYPOT_ENABLED", TRUE); // default time a user must wait before submitting a form define("UI_HONEYPOT_TIME", 5); + +// whether to enable collation in sparql queries +define("SPARQL_COLLATION_ENABLED", FALSE); diff --git a/model/GlobalConfig.php b/model/GlobalConfig.php index 4080e94fe..e1bce9d5d 100644 --- a/model/GlobalConfig.php +++ b/model/GlobalConfig.php @@ -239,5 +239,12 @@ public function getHoneypotTime() { return $this->getConstant('UI_HONEYPOT_TIME', 5); } - + + /** + * @return boolean + */ + public function getCollationEnabled() + { + return $this->getConstant('SPARQL_COLLATION_ENABLED', FALSE); + } } diff --git a/model/sparql/JenaTextSparql.php b/model/sparql/JenaTextSparql.php index 79e7cfb31..913b7dd72 100644 --- a/model/sparql/JenaTextSparql.php +++ b/model/sparql/JenaTextSparql.php @@ -2,6 +2,7 @@ /* Register text: namespace needed for jena-text queries */ EasyRdf_Namespace::set('text', 'http://jena.apache.org/text#'); // @codeCoverageIgnore +EasyRdf_Namespace::set('arq', 'http://jena.apache.org/ARQ/function#'); // @codeCoverageIgnore /** * Provides functions tailored to the JenaTextSparql extensions for the Fuseki SPARQL index. @@ -73,6 +74,21 @@ protected function generateConceptSearchQueryCondition($term, $searchLang) return $textcond; } + /** + * Generates sparql query clauses used for ordering by an expression. Uses a special collation function + * if configuration for it is enabled. + * @param string $expression the expression used for ordering the results + * @param string $lang language + * @return string sparql order by clause + */ + private function formatOrderBy($expression, $lang) { + if(!$this->model->getConfig()->getCollationEnabled()) { + return $expression; + } + $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang); + return $orderby; + } + /** * Generates the jena-text-specific sparql query used for rendering the alphabetical index. * @param string $letter the letter (or special class) to search for @@ -99,6 +115,7 @@ public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $of $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $lang); $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $lang); + $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang); $query = <<config->getVocabularyConfigFile(); $this->assertEquals('tests/testvocabularies.ttl', $actual); } + + /** + * @covers GlobalConfig::getCollationEnabled + */ + public function testGetCollationEnabled() { + $actual = $this->config->getCollationEnabled(); + $this->assertFalse($actual); + } } diff --git a/tests/JenaTextSparqlTest.php b/tests/JenaTextSparqlTest.php index f2cc8790c..85305bec2 100644 --- a/tests/JenaTextSparqlTest.php +++ b/tests/JenaTextSparqlTest.php @@ -174,4 +174,29 @@ public function testQueryConceptsDefaultGraph() $this->assertEquals('Bass', $actual[0]['prefLabel']); } + /** + * @covers JenaTextSparql::formatOrderBy + */ + public function testQueryConceptsAlphabeticalOrderBy() { + $vocab = $this->model->getVocabulary('collation'); + $graph = $vocab->getGraph(); + $sparql = new JenaTextSparql('http://localhost:3030/ds/sparql', $graph, $this->model); + $actual = $sparql->queryConceptsAlphabetical('t', 'fi'); + $expected = array ( + 0 => array ( + 'uri' => 'http://www.skosmos.skos/collation/val1', + 'localname' => 'val1', + 'prefLabel' => 'tšekin kieli', + 'lang' => 'fi', + ), + 1 => array ( + 'uri' => 'http://www.skosmos.skos/collation/val2', + 'localname' => 'val2', + 'prefLabel' => 'töyhtöhyyppä', + 'lang' => 'fi', + ) + ); + $this->assertEquals($expected, $actual); + } + } diff --git a/tests/jenatestconfig.inc b/tests/jenatestconfig.inc index df8d10f8f..3123c6dee 100644 --- a/tests/jenatestconfig.inc +++ b/tests/jenatestconfig.inc @@ -2,3 +2,4 @@ define("VOCABULARIES_FILE", "tests/testvocabularies.ttl"); define("DEFAULT_SPARQL_DIALECT", "JenaText"); +define("SPARQL_COLLATION_ENABLED", TRUE); diff --git a/tests/test-vocab-data/collation.ttl b/tests/test-vocab-data/collation.ttl new file mode 100644 index 000000000..6fb24d54e --- /dev/null +++ b/tests/test-vocab-data/collation.ttl @@ -0,0 +1,34 @@ +@prefix dc: . +@prefix dc11: . +@prefix dct: . +@prefix collation: . +@prefix meta: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix skos: . +@prefix skosmos: . +@prefix xml: . +@prefix xsd: . +@prefix mads: . + +skos:prefLabel a rdf:Property ; + rdfs:label "preferred label"@en . + +skos:altLabel a rdf:Property ; + rdfs:label "alternative label"@en . + +skos:scopeNote a rdf:Property ; + rdfs:label "scope note"@en . + +skos:broader a rdf:Property ; + rdfs:label "has broader"@en . + +skos:narrower a rdf:Property ; + rdfs:label "has narrower"@en . + +collation:val1 a skos:Concept ; + skos:prefLabel "tšekin kieli"@fi . + +collation:val2 a skos:Concept ; + skos:prefLabel "töyhtöhyyppä"@fi . diff --git a/tests/testvocabularies.ttl b/tests/testvocabularies.ttl index 8704c52ca..7c77820bc 100644 --- a/tests/testvocabularies.ttl +++ b/tests/testvocabularies.ttl @@ -143,6 +143,14 @@ skosmos:sparqlGraph ; skosmos:sparqlDialect "JenaText" . +:collation a skosmos:Vocabulary, void:Dataset ; + dc11:title "A vocabulary for test SPARQL with collation"@en ; + dc:subject :cat_general ; + void:uriSpace "http://www.skosmos.skos/collation/"; + void:sparqlEndpoint ; + skosmos:language "fi"; + skosmos:sparqlGraph . + dc:format "application/rdf+xml" . From d3fae459ec8b40f26653b1771d54711f1be3db33 Mon Sep 17 00:00:00 2001 From: Thomas Francart Date: Fri, 17 Nov 2017 11:22:14 +0100 Subject: [PATCH 2/9] Update light.twig Fix #639 --- view/light.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/light.twig b/view/light.twig index 757817476..d9c7e0946 100644 --- a/view/light.twig +++ b/view/light.twig @@ -93,7 +93,7 @@ From 7770147999c519c83364b5dd629d7192d395d80c Mon Sep 17 00:00:00 2001 From: Thomas Francart Date: Fri, 17 Nov 2017 14:59:46 +0100 Subject: [PATCH 3/9] Use elseif --- view/light.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/light.twig b/view/light.twig index d9c7e0946..c24386b06 100644 --- a/view/light.twig +++ b/view/light.twig @@ -93,7 +93,7 @@ From be0b368c00333be0fa8e6b1cf814ecd24ef3af13 Mon Sep 17 00:00:00 2001 From: Henri Ylikotila Date: Mon, 20 Nov 2017 13:07:06 +0200 Subject: [PATCH 4/9] updating the translation po-file metadata --- resource/translations/skosmos_fi.po | 7 ++----- resource/translations/skosmos_sv.po | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/resource/translations/skosmos_fi.po b/resource/translations/skosmos_fi.po index 009718538..3fba06b60 100644 --- a/resource/translations/skosmos_fi.po +++ b/resource/translations/skosmos_fi.po @@ -1,14 +1,11 @@ -# Finnish translation of ONKI Light -# Copyright SeCo 2012 (C) -# msgid "" msgstr "" -"Project-Id-Version: ONKI Light\n" +"Project-Id-Version: Skosmos\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-01-16 10:23+0200\n" "PO-Revision-Date: \n" "Last-Translator: Henri Ylikotila \n" -"Language-Team: ONKI Team \n" +"Language-Team: Finto Team \n" "Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/resource/translations/skosmos_sv.po b/resource/translations/skosmos_sv.po index e42684ddc..e62e23f3a 100644 --- a/resource/translations/skosmos_sv.po +++ b/resource/translations/skosmos_sv.po @@ -1,14 +1,11 @@ -# Finnish translation of ONKI Light -# Copyright SeCo 2012 (C) -# msgid "" msgstr "" -"Project-Id-Version: ONKI Light\n" +"Project-Id-Version: Skosmos\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-01-16 10:24+0200\n" "PO-Revision-Date: \n" "Last-Translator: Henri Ylikotila \n" -"Language-Team: ONKI Team \n" +"Language-Team: Finto Team \n" "Language: sv\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" From f242456be9e8ab36fa7ab550204ccb279b5837ea Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Tue, 21 Nov 2017 14:16:06 +0200 Subject: [PATCH 5/9] Use runTestsInSeparateProcess decorator to avoid mixing up state between tests --- tests/JenaTextSparqlTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/JenaTextSparqlTest.php b/tests/JenaTextSparqlTest.php index 85305bec2..6d222295d 100644 --- a/tests/JenaTextSparqlTest.php +++ b/tests/JenaTextSparqlTest.php @@ -1,5 +1,9 @@ Date: Tue, 21 Nov 2017 15:16:07 +0200 Subject: [PATCH 6/9] remove redundant require_once --- tests/VocabularyCategoryTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/VocabularyCategoryTest.php b/tests/VocabularyCategoryTest.php index 0275ff1d8..541aa9c80 100644 --- a/tests/VocabularyCategoryTest.php +++ b/tests/VocabularyCategoryTest.php @@ -6,7 +6,6 @@ class VocabularyCategoryTest extends PHPUnit_Framework_TestCase private $mockres; protected function setUp() { - require_once 'testconfig.inc'; putenv("LC_ALL=en_GB.utf8"); setlocale(LC_ALL, 'en_GB.utf8'); $this->model = new Model(new GlobalConfig('/../tests/testconfig.inc')); From e05f89c85268bd176b25bc19b80ae972afc8c9a7 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Tue, 21 Nov 2017 15:16:23 +0200 Subject: [PATCH 7/9] enable process isolation globally in phpunit.xml instead of in a specific test (which didn't seem to have the desired effect) --- phpunit.xml | 2 +- tests/JenaTextSparqlTest.php | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 4a6caabee..227dc0348 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,4 +1,4 @@ - + diff --git a/tests/JenaTextSparqlTest.php b/tests/JenaTextSparqlTest.php index 6d222295d..85305bec2 100644 --- a/tests/JenaTextSparqlTest.php +++ b/tests/JenaTextSparqlTest.php @@ -1,9 +1,5 @@ Date: Tue, 21 Nov 2017 16:06:59 +0200 Subject: [PATCH 8/9] Updated German translations by @hauschke. See also PR #662 --- .../translations/de/LC_MESSAGES/skosmos.mo | Bin 10881 -> 11458 bytes resource/translations/skosmos_de.po | 33 +++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/resource/translations/de/LC_MESSAGES/skosmos.mo b/resource/translations/de/LC_MESSAGES/skosmos.mo index 773e3e1b75661285f8d55d680e160a933fa449dd..4ccf14eba1e5c5a63876690847dd668538987321 100644 GIT binary patch delta 4309 zcmZA332;>P0mt!wAdx@-F<3;dynq1=>|%h>5&=1b+;T_?rA;@Rmt?~p;q5Mj0Irml zVnL{+P^ugP9t0^fnpRM;RWcoiL2c*T3;Mo;2 z{uc|e>#fG{XZrDzkHb;t$M|Nf2%!y1l56dEWwwo zS5fulakJ{_g?C~Ra>`7^;W!5aCc_9RsAmW94ty5Xk>8?vdLDD}686M*QP=++HNt;k zKkQ0tIzIr_ff1i8VHzua1bx-X8Zui5TzL$$m6cIICd9p->Mfok9sYRx)OJ$=)j zzliGKRaC{Fpl0YAYKD4$!@sW>RZl5u2_~RsXd!Z`sYczG%Gkno)EXW^y+&tHH(tU4 z_=!EA&s}P0DC)X$%vOwAnrhTY*PsTp+3xQ^4QM}V08gW4EYnUw7rtf>oJVHe{26t_ zKT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JKrV%|JY=el}_?IZz!~jvCl@ z?2SiJ_qmHhxxabHjz*Bu#kZPAVIt*Os43ot8tHD-_u&j`)n7&3;1TNj;I6(8Pz=6G zc?7B>tE_vm8RfI68M=TjU3i-v-QZ8`iygc9R_%Dy`3f9}>rgj5iyF~&)T4Wh`fda; zEzL0r^%|xkr_5*!!UgDu6G=W9rsuD%577;@=^1MqcL=k}`XLQ$yix@($4=Dj-_5&$c)1P6Ey#W63&_N;G5j zB#*FUy#KWV@8-5vpuVJOWF+~3csJkpc}A4_+hbF#nnG<_3vYS%eBXObaOecGY zwhU54UQ^+J+hEFiWaCMRJvSAf-QNtQu!yh(%p{^Mj+A=$d<*A8_LFRRzBL*3?6qZ* zV$zh%BDG`$d43yW3yX1r?jP{{S@u67TZq2bONkcHWU_z^CtCS+MB6kU-nZfn_G4{% z9yX9oWCP)wWmc0{h~5m=q1i#48oySwwv|My{rSy7VJqoD-Xl9nBqI*_?!J=smPX}UL)a?+gmKb!x46spO)pKElB^-`lN1t9 zv~48mWDIFVMw3p&#Fsg8=jF|wo>x-gSrVEM==rhrmwurYGv+w*%FWEY)N*Heq33e= zw}I|+5$)U$Bg#S&Q+g&RMkn@9?VIc_YTquZq^u}6I!(X5$|_2VoW+jfL9-o&WzOOP zXRmyxXKVZEfqpaHk0XEecNV+vL>=;rcGpEa+&yDrJnLiP{es4wZgkE+-MFyKeJr*i ZWUymV#Vj+?S?(zGoQhl4+`XVj@_!*xWI_M{ diff --git a/resource/translations/skosmos_de.po b/resource/translations/skosmos_de.po index 6478ad752..0b50ac218 100644 --- a/resource/translations/skosmos_de.po +++ b/resource/translations/skosmos_de.po @@ -1,5 +1,6 @@ # # Translators: +# CH_ , 2017 # Joachim Neubert , 2015-2016 # osma , 2015,2017 msgid "" @@ -7,8 +8,8 @@ msgstr "" "Project-Id-Version: Skosmos\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-01-16 10:26+0200\n" -"PO-Revision-Date: 2017-05-30 07:43+0000\n" -"Last-Translator: osma \n" +"PO-Revision-Date: 2017-11-21 13:54+0000\n" +"Last-Translator: CH_ \n" "Language-Team: German (http://www.transifex.com/national-library-of-finland/skosmos/language/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -164,7 +165,7 @@ msgstr "Feedback" #: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:64 msgid "Feedback has been sent!" -msgstr "Ihr Feedback wurde versended!" +msgstr "Ihr Feedback wurde versendet!" #: /tmp/cache/587c83c09abaa/d1/d13f81e53ff33f31fff259d66f8ddbf7cfc39d25c6219ff727553feca6d87d37.php:35 msgid "Group index" @@ -218,7 +219,7 @@ msgstr "Keine Ergebnisse" #: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:103 #: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:111 msgid "Not to a specific vocabulary" -msgstr "Nicht in einem speziellen Vokabular" +msgstr "Nicht zu einem speziellen Vokabular" #: /tmp/cache/587c83c09abaa/9a/9a6d69d72b35f38585477d2f25d50cacf270791aa84e4d523f237566dd428822.php:233 msgid "Search" @@ -242,7 +243,7 @@ msgstr "Sende Feedback" #: /tmp/cache/587c83c09abaa/f2/f29f57cf31b29541d6f810d43d1f7a07e79cfddcf23678f04612a410c0f0607b.php:51 msgid "Show all breadcrumb paths" -msgstr "Zeige alle Brotkrümel Pfade" +msgstr "Zeige alle Brotkrümel-Pfade" #: /tmp/cache/587c83c09abaa/58/58e9c1cebb82d52daf56fab57cd7b86ed47b1d8a86a915177156746eef73248e.php:72 msgid "Skosmos version %version%" @@ -254,15 +255,15 @@ msgstr "Suche absenden" #: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:68 msgid "Thank you for your feedback" -msgstr "Danke für Ihr Feedback" +msgstr "Danke für Ihr Feedback. Wir versuchen, so schnell wie möglich zu antworten." #: /tmp/cache/587c83c09abaa/8a/8aeec9eddcf0848575d119210eda5a849c129c96ea86195b4448536a02a47817.php:129 msgid "The search provided no results." -msgstr "Die Suche ergab keine Ergebnisse" +msgstr "Die Suche ergab keine Ergebnisse." #: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:48 msgid "There is no term for this concept in this language" -msgstr "" +msgstr "In dieser Sprache gibt es keinen Begriff für dieses concept." #: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:173 #: /tmp/cache/587c83c09abaa/f2/f29f57cf31b29541d6f810d43d1f7a07e79cfddcf23678f04612a410c0f0607b.php:47 @@ -311,7 +312,7 @@ msgstr "Ersteller" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:45 msgid "dc:date" -msgstr "Päiväys" +msgstr "Datum" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:47 msgid "dc:description" @@ -375,11 +376,11 @@ msgstr "Quelle" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:77 msgid "dc:source_help" -msgstr "" +msgstr "Quelle für die Beschreibung dieses concepts." #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:79 msgid "dc:spatial" -msgstr "" +msgstr "Räumliche Abdeckung" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:81 msgid "dc:subject" @@ -387,7 +388,7 @@ msgstr "Bezug" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:83 msgid "dc:temporal" -msgstr "" +msgstr "Zeitliche Abdeckung" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:85 msgid "dc:title" @@ -395,7 +396,7 @@ msgstr "Titel" #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:87 msgid "dc:type" -msgstr "" +msgstr "Typ" #: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:36 #: /tmp/cache/587c83c09abaa/8a/8aeec9eddcf0848575d119210eda5a849c129c96ea86195b4448536a02a47817.php:256 @@ -673,12 +674,12 @@ msgstr "Gehört zur Gruppe" #: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:611 #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:205 msgid "skosmos:memberOfArray" -msgstr "" +msgstr "Gehört zu Array" #: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:609 #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:207 msgid "skosmos:memberOfArray_help" -msgstr "" +msgstr "Array, zu dem das Konzept gehört." #: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:546 #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:203 @@ -687,7 +688,7 @@ msgstr "Gruppe zu der das concept Objekt gehört." #: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:23 msgid "zxx-x-taxon" -msgstr "" +msgstr "Wissenschaftlicher Name" #: /tmp/cache/587c83c13194c/0b/0bbfc29e05e244fa07889ce1678840902f16e5f76560e00137de0cc3bb084b8b.php:168 msgid "About page" From 4b131ad6873c927f1f6acb045db14319df3ea4dc Mon Sep 17 00:00:00 2001 From: Thomas Francart Date: Fri, 24 Nov 2017 09:30:51 +0100 Subject: [PATCH 9/9] Exploding on whitespace _after_ urldecoding the request parameter value Use UNION when building SPARQL search conditions on schemes Added unit test for multiple scheme query use implode --- model/ConceptSearchParameters.php | 2 +- model/sparql/GenericSparql.php | 5 ++- tests/GenericSparqlTest.php | 24 +++++++++++++ tests/test-vocab-data/multiple-schemes.ttl | 42 ++++++++++++++++++++++ tests/testvocabularies.ttl | 11 ++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tests/test-vocab-data/multiple-schemes.ttl diff --git a/model/ConceptSearchParameters.php b/model/ConceptSearchParameters.php index fe58581df..2ea5b8697 100644 --- a/model/ConceptSearchParameters.php +++ b/model/ConceptSearchParameters.php @@ -124,7 +124,7 @@ private function getQueryParam($name) { } private function getQueryParamArray($name) { - return $this->request->getQueryParam($name) ? explode(' ', $this->request->getQueryParam($name)) : null; + return $this->request->getQueryParam($name) ? explode(' ', urldecode($this->request->getQueryParam($name))) : null; } public function getGroupLimit() diff --git a/model/sparql/GenericSparql.php b/model/sparql/GenericSparql.php index 544229b6e..7cd61d449 100644 --- a/model/sparql/GenericSparql.php +++ b/model/sparql/GenericSparql.php @@ -936,11 +936,14 @@ protected function generateConceptSearchQuery($fields, $unique, $params, $showDe $extrafields = $formattedfields['extrafields']; $schemes = $params->getSchemeLimit(); + // limit the search to only requested concept schemes $schemecond = ''; if (!empty($schemes)) { + $conditions = array(); foreach($schemes as $scheme) { - $schemecond .= "?s skos:inScheme <$scheme> . "; + $conditions[] = "{?s skos:inScheme <$scheme>}"; } + $schemecond = '{'.implode(" UNION ",$conditions).'}'; } $filterDeprecated=""; //show or hide deprecated concepts diff --git a/tests/GenericSparqlTest.php b/tests/GenericSparqlTest.php index 7afc2065e..d1b86aeae 100644 --- a/tests/GenericSparqlTest.php +++ b/tests/GenericSparqlTest.php @@ -374,6 +374,30 @@ public function testQueryConceptsMultipleVocabs() $this->assertEquals('http://www.skosmos.skos/test/ta112', $actual[1]['uri']); } + /** + * @covers GenericSparql::queryConcepts + * @covers GenericSparql::generateConceptSearchQueryCondition + * @covers GenericSparql::generateConceptSearchQueryInner + * @covers GenericSparql::generateConceptSearchQuery + * @covers GenericSparql::formatFilterGraph + * @covers GenericSparql::transformConceptSearchResults + * @covers GenericSparql::transformConceptSearchResult + * @covers GenericSparql::shortenUri + */ + public function testQueryConceptsMultipleSchemes() + { + $voc = $this->model->getVocabulary('multiple-schemes'); + // returns 3 concepts without the scheme limit, and only 2 with the scheme limit below + $this->params->method('getSearchTerm')->will($this->returnValue('concept*')); + $this->params->method('getSchemeLimit')->will($this->returnValue(array('http://www.skosmos.skos/multiple-schemes/cs1', 'http://www.skosmos.skos/multiple-schemes/cs2'))); + $sparql = new GenericSparql('http://localhost:3030/ds/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model); + $actual = $sparql->queryConcepts(array($voc), null, null, $this->params); + $this->assertEquals(2, sizeof($actual)); + $this->assertEquals('http://www.skosmos.skos/multiple-schemes/c1-in-cs1', $actual[0]['uri']); + $this->assertEquals('http://www.skosmos.skos/multiple-schemes/c2-in-cs2', $actual[1]['uri']); + } + + /** * @covers GenericSparql::queryConcepts * @covers GenericSparql::generateConceptSearchQueryCondition diff --git a/tests/test-vocab-data/multiple-schemes.ttl b/tests/test-vocab-data/multiple-schemes.ttl new file mode 100644 index 000000000..bfb10f9d4 --- /dev/null +++ b/tests/test-vocab-data/multiple-schemes.ttl @@ -0,0 +1,42 @@ +@prefix dc: . +@prefix dc11: . +@prefix dct: . +@prefix multiple-schemes: . +@prefix meta: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix skos: . +@prefix skosmos: . +@prefix xml: . +@prefix xsd: . +@prefix mads: . + +# 3 concept schemes with one concept in each + +multiple-schemes:c1-in-cs1 a skos:Concept ; + skos:inScheme multiple-schemes:cs1; + skos:topConceptOf multiple-schemes:cs1; + skos:prefLabel "concept 1"@en. + +multiple-schemes:c2-in-cs2 a skos:Concept ; + skos:inScheme multiple-schemes:cs2; + skos:topConceptOf multiple-schemes:cs2; + skos:prefLabel "concept 2"@en. + +multiple-schemes:c3-in-cs3 a skos:Concept ; + skos:inScheme multiple-schemes:cs3; + skos:topConceptOf multiple-schemes:cs3; + skos:prefLabel "concept 3"@en. + +multiple-schemes:cs1 a skos:ConceptScheme ; + rdfs:label "Concept Scheme 1"@en ; + skos:hasTopConcept multiple-schemes:c1 . + +multiple-schemes:cs2 a skos:ConceptScheme ; + rdfs:label "Concept Scheme 2"@en ; + skos:hasTopConcept multiple-schemes:c2 . + +multiple-schemes:cs3 a skos:ConceptScheme ; + rdfs:label "Concept Scheme 3"@en ; + skos:hasTopConcept multiple-schemes:c3 . \ No newline at end of file diff --git a/tests/testvocabularies.ttl b/tests/testvocabularies.ttl index 8e907f5d7..27302227f 100644 --- a/tests/testvocabularies.ttl +++ b/tests/testvocabularies.ttl @@ -35,6 +35,17 @@ "Testi lyhyt"@fi; skosmos:sparqlGraph . +:multiple-schemes a skosmos:Vocabulary, void:Dataset ; + skos:prefLabel "Mutiple Schemes vocabulary"@en ; + dc:title "Mutiple Schemes vocabulary"@en ; + dc:type mdrtype:ONTOLOGY ; + void:sparqlEndpoint ; + void:uriSpace "http://www.skosmos.skos/multiple-schemes/"; + skosmos:defaultLanguage "en"; + skosmos:language "en"; + skosmos:showTopConcepts "true"; + skosmos:sparqlGraph . + :testdiff a skosmos:Vocabulary, void:Dataset ; dc11:title "Test ontology 2"@en ; dc:subject :cat_general ;