MDNodaHelpers/src/NodaImportLogger.php

123 lines
4.6 KiB
PHP

<?PHP
/**
* Contains class NodaImportLogger for logging the mapping between entered term names
* and their resulting IDs.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Contains class NodaImportLogger for logging the mapping between entered term names
* and their resulting IDs.
*/
final class NodaImportLogger {
/**
* Logs link of a person with an institution.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $instance Instance in which the import was run.
* @param integer $institution_id ID of the importing institution.
* @param integer $persinst_id Resulting actor ID.
* @param string $name Name of the persinst to search for.
* @param string $birthYear Year of birth. Optional.
* @param string $deathYear Year of death. Optional.
*
* @return void
*/
public static function logImportForPersinstByInstitution(MDMysqli $mysqli_noda, string $instance, int $institution_id, int $persinst_id, string $name, string $birthYear = "", string $deathYear = ""):void {
$loggedName = $name . $birthYear . $deathYear;
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `persinst_logged_imports`
(`instance`, `institution_id`, `input_string`, `persinst_id`)
VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $loggedName, $persinst_id);
$logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close();
}
/**
* Logs link of a place with an institution.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $instance Instance in which the import was run.
* @param integer $institution_id ID of the importing institution.
* @param integer $ort_id Resulting place ID.
* @param string $name Name of the place to search for.
*
* @return void
*/
public static function logImportForPlaceByInstitution(MDMysqli $mysqli_noda, string $instance, int $institution_id, int $ort_id, string $name):void {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `orte_logged_imports`
(`instance`, `institution_id`, `input_string`, `ort_id`)
VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $ort_id);
$logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close();
}
/**
* Logs link of a time with an institution.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $instance Instance in which the import was run.
* @param integer $institution_id ID of the importing institution.
* @param integer $zeit_id Resulting time ID.
* @param string $name Name of the time to search for.
*
* @return void
*/
public static function logImportForTimeByInstitution(MDMysqli $mysqli_noda, string $instance, int $institution_id, int $zeit_id, string $name):void {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `zeiten_logged_imports`
(`instance`, `institution_id`, `input_string`, `zeit_id`)
VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $zeit_id);
$logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close();
}
/**
* Logs link of a tag with an institution.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $instance Instance in which the import was run.
* @param integer $institution_id ID of the importing institution.
* @param integer $tag_id Resulting tag ID.
* @param string $name Name of the tag to search for.
*
* @return void
*/
public static function logImportForTagByInstitution(MDMysqli $mysqli_noda, string $instance, int $institution_id, int $tag_id, string $name):void {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `tag_logged_imports`
(`instance`, `institution_id`, `input_string`, `tag_id`)
VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $tag_id);
$logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close();
}
}