Add functions for loading only norm data links from Wikidata for places

+ actors
This commit is contained in:
Joshua Ramon Enslin 2024-10-03 16:36:30 +02:00
parent cd49f194f2
commit 06f13c1a71
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -170,6 +170,9 @@ final class NodaWikidataFetcher {
if ($data === null) {
throw new MDhttpFailedException("Failed fetching from Wikidata. Try again later.");
}
if (empty($data['entities'][$wikidata_id])) {
throw new MDhttpFailedException("Failed fetching from Wikidata. Try again later.");
}
return $data['entities'][$wikidata_id];
}
@ -1096,6 +1099,44 @@ final class NodaWikidataFetcher {
}
/**
* Function for retrieving information.
*
* @param string $wikidata_id Wikidata ID.
* @param integer $persinst_id Actor ID.
* @param string $erfasst_von User name who's currently editing.
*
* @return void
*/
public function retrievePersinstNormDataLinksFromWikidataID(string $wikidata_id, int $persinst_id, string $erfasst_von) {
self::validateWikidataId($wikidata_id);
$data = self::_getWikidataEntity($wikidata_id);
if (!empty($nodaLinks = $this->_getNodaLinksFromWikidataResult('persinst', $wikidata_id, $data))) {
NodaBatchInserter::linkNodaForPersinst($this->_mysqli_noda, $persinst_id, $nodaLinks, $erfasst_von);
}
}
/**
* Retrieves only norm data links from Wikidata.
*
* @param string $wikidata_id Wikidata Q-ID.
* @param integer $onum Place ID.
* @param string $erfasst_von User name of the current user.
*
* @return void
*/
public function retrievePlaceNormDataLinksFromWikidataID(string $wikidata_id, int $onum, string $erfasst_von) {
self::validateWikidataId($wikidata_id);
$data = self::_getWikidataEntity($wikidata_id);
if (!empty($nodaLinks = $this->_getNodaLinksFromWikidataResult('place', $wikidata_id, $data))) {
NodaBatchInserter::linkNodaForPlace($this->_mysqli_noda, $onum, $nodaLinks, $erfasst_von);
}
}
/**
* Function for fetching translations from Wikipedia, based on Wikidata information.
*