--- a/server/src/app/Models/GeoResource.php Mon Jun 06 01:10:25 2016 +0200
+++ b/server/src/app/Models/GeoResource.php Tue Jun 07 01:09:58 2016 +0200
@@ -14,20 +14,20 @@
parent::__construct($uri, $graph);
}
- private $refLoc = false;
+ private $refLocs = null;
private $notes = null;
public function clearMemoizationCache() {
- $this->refLoc = false;
+ $this->refLocs = null;
$this->notes = null;
}
- public function getRefLoc() {
- if($this->refLoc === false) {
- $refLoc = $this->getResource("<http://www.w3.org/2002/07/owl#sameAs>");
- $this->refLoc = is_null($refLoc)?null:$refLoc->getUri();
+ public function getRefLocs() {
+ if(is_null($this->refLocs)) {
+ $refLocs = $this->allResources("<http://www.w3.org/2002/07/owl#sameAs>");
+ $this->refLocs = array_map(function($refLoc) { return $refLoc->getUri();}, $refLocs);
}
- return $this->refLoc;
+ return $this->refLocs;
}
public function getNotes() {
@@ -43,7 +43,7 @@
$this->getNotes()
);
return [
- 'ref-loc' => $this->getRefLoc(),
+ 'ref-locs' => $this->getRefLocs(),
'notes' => $notes
];
}
--- a/server/src/tests/Models/GeoResourceTest.php Mon Jun 06 01:10:25 2016 +0200
+++ b/server/src/tests/Models/GeoResourceTest.php Tue Jun 07 01:09:58 2016 +0200
@@ -115,6 +115,34 @@
<http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
] .
EOT
+ ,
+ "LOC3" => <<<EOT
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+ @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+ @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
+
+ <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ;
+ <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
+ <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
+ <http://purl.org/dc/terms/extent> "PT48M26S" ;
+ <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
+ <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
+ <http://purl.org/dc/elements/1.1/description> "Enregistrement issu du Corpus de Français Parlé Parisien des années 2000 (CFPP2000)"@fr , "Quartier(s) concerné(s) : Paris 3e, et 20e (pour l'âge adulte); Anonymisation : Noalig TANGUY;"@fr ;
+ <http://purl.org/dc/elements/1.1/identifier> "ark:/87895/1.17-375004" , "%2\$scrdo-CFPP2000_35_SOUNDid" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35" , "Cote producteur: [03-01] Ozgur_Kilic_H_32_alii_3e"@fr , "ark:/87895/1.17-372593" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35_SOUND" ;
+ <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
+ <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>;
+ <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ;
+ <http://purl.org/dc/terms/available> "2013-10-12"^^<http://purl.org/dc/terms/W3CDTF> ;
+ <http://purl.org/dc/terms/spatial> [
+ a <http://www.europeana.eu/schemas/edm/Place> ;
+ owl:sameAs <http://sws.geonames.org/6618626/> ;
+ owl:sameAs <http://fr.dbpedia.org/resource/Gramazie> ;
+ <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
+ ] .
+EOT
];
public function setUp() {
@@ -151,18 +179,30 @@
public function testGetRefLoc() {
$geoResource = $this->getGeoResource("LOC1");
- $refLoc = $geoResource->getRefLoc();
+ $refLoc = $geoResource->getRefLocs();
- $this->assertEquals('http://sws.geonames.org/6618626/', $refLoc);
+ $this->assertEquals(['http://sws.geonames.org/6618626/'], $refLoc);
}
public function testGetRefLocNull() {
$geoResource = $this->getGeoResource("LOC2");
- $refLoc = $geoResource->getRefLoc();
+ $refLoc = $geoResource->getRefLocs();
+
+ $this->assertEmpty($refLoc);
+
+ }
- $this->assertNull($refLoc);
+ public function testGetRefLocMultiple() {
+ $geoResource = $this->getGeoResource("LOC3");
+
+ $refLocs = $geoResource->getRefLocs();
+
+ $this->assertTrue(is_array($refLocs));
+ $this->assertCount(2,$refLocs);
+ $this->assertEquals(['http://sws.geonames.org/6618626/', 'http://fr.dbpedia.org/resource/Gramazie'], $refLocs);
+
}
@@ -184,8 +224,8 @@
$json = $geoResource->jsonSerialize();
- $this->assertEquals(["ref-loc", "notes"], array_keys($json));
- $this->assertEquals("http://sws.geonames.org/6618626/", $json['ref-loc']);
+ $this->assertEquals(["ref-locs", "notes"], array_keys($json));
+ $this->assertEquals(["http://sws.geonames.org/6618626/"], $json['ref-locs']);
$notes = $json['notes'];
$this->assertTrue(is_array($notes));
@@ -199,7 +239,17 @@
$json = $geoResource->jsonSerialize();
- $this->assertNull($json['ref-loc']);
+ $this->assertEmpty($json['ref-locs']);
+
+ }
+
+ public function testJsonSerializeMultipleRefLocs() {
+ $geoResource = $this->getGeoResource("LOC3");
+
+ $json = $geoResource->jsonSerialize();
+
+ $this->assertEquals(["ref-locs", "notes"], array_keys($json));
+ $this->assertEquals(["http://sws.geonames.org/6618626/", "http://fr.dbpedia.org/resource/Gramazie"], $json['ref-locs']);
}