Skip to content

Commit

Permalink
Released version 3.3.35.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Oct 24, 2022
1 parent fd4bc75 commit 8c4e92f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ author_link = "https://gitlab.com/Daniel-KM"
module_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-BulkImport"
support_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-BulkImport/-/issues"
configurable = true
version = "3.3.34"
version = "3.3.35"
omeka_version_constraint = "^3.1.0"
dependencies = "Log"
82 changes: 80 additions & 2 deletions data/scripts/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
$connection->executeStatement($sql);

// Module resources are not available during upgrade.
// Update mapping files.
// Update importer files.
$qb = $connection->createQueryBuilder();
$qb
->select('bulk_importer.id', 'bulk_importer.reader_config')
Expand Down Expand Up @@ -555,7 +555,7 @@
$connection->executeStatement($sql);
}

if (version_compare($oldVersion, '3.3.34.0', '<')) {
if (version_compare($oldVersion, '3.3.34', '<')) {
require_once __DIR__ . '/upgrade_vocabulary.php';

$messenger = new Messenger();
Expand All @@ -569,3 +569,81 @@
);
$messenger->addSuccess($message);
}

if (version_compare($oldVersion, '3.3.35', '<')) {
$user = $services->get('Omeka\AuthenticationService')->getIdentity();

// The resource "bulk_importers" is not available during upgrade.
require_once dirname(__DIR__, 2) . '/src/Entity/Import.php';
require_once dirname(__DIR__, 2) . '/src/Entity/Importer.php';

$filenames = [
'csv - assets.php',
'ods - assets.php',
'tsv - assets.php',
];
foreach ($filenames as $filename) {
$filepath = dirname(__DIR__) . '/importers/' . $filename;
$data = include $filepath;
$data['owner'] = $user;
$entity = new \BulkImport\Entity\Importer();
foreach ($data as $key => $value) {
$method = 'set' . ucfirst($key);
$entity->$method($value);
}
$entityManager->persist($entity);
}
$entityManager->flush();

// Check configs for new formats.
// Module resources are not available during upgrade.
// Update mapping files.
$replaceIni = [];
$replaceXml = [];
$dataTypes = $services->get('Omeka\DataTypeManager')->getRegisteredNames();
$dataTypes[] = 'customvocab:';
foreach ($dataTypes as $dataType) {
$replaceIni[' ; ' . $dataType] = ' ^^' . $dataType;
$replaceIni['; ' . $dataType] = ' ^^' . $dataType;
$replaceIni[' ;' . $dataType] = ' ^^' . $dataType;
$replaceIni[';' . $dataType] = ' ^^' . $dataType;
$replaceXml[' ; ' . $dataType] = ' ' . $dataType;
$replaceXml['; ' . $dataType] = ' ' . $dataType;
$replaceXml[' ;' . $dataType] = ' ' . $dataType;
$replaceXml[';' . $dataType] = ' ' . $dataType;
}
$qb = $connection->createQueryBuilder();
$qb
->select('bulk_mapping.id', 'bulk_mapping.mapping')
->from('bulk_mapping', 'bulk_mapping')
->orderBy('bulk_mapping.id', 'asc');
$mappingConfigs = $connection->executeQuery($qb)->fetchAllKeyValue();
foreach ($mappingConfigs as $id => $mappingConfig) {
$mappingConfig = substr(trim($mappingConfigs), 0, 1) === '<'
? str_replace(array_keys($replaceXml), array_values($replaceXml), $mappingConfig)
: str_replace(array_keys($replaceIni), array_values($replaceIni), $mappingConfig);
$sql = <<<'SQL'
UPDATE `bulk_importer`
SET
`reader_config` = ?
WHERE
`id` = ?
;
SQL;
$connection->executeStatement($sql, [
$mappingConfig,
$id,
]);
}

$messenger = new Messenger();
$message = new Message(
'It’s now possible to import and update assets and to attach them to resources.' // @translate
);
$messenger->addSuccess($message);

$message = new Message(
'The format of destination metadata has been improved: spaces after "^^", "@" and "§" are no more managed; for multiple datatypes, the ";" was replaced by "^^"; for custom vocab with a label, the label should be wrapped by quotes or double quotes. Check your custom configs if needed.' // @translate
);
$messenger->addWarning($message);
}
8 changes: 4 additions & 4 deletions src/Processor/MetadataTransformTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ protected function operationFillResource(array $params): bool
$list = $this->listDataValues([$sourceTerm => $sourceId], ['valuesuggest'], 'uri', false);

$headers = [
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/96.0',
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/116.0',
'Content-Type' => 'application/xml',
'Accept-Encoding' => 'gzip, deflate',
];
Expand Down Expand Up @@ -3252,7 +3252,7 @@ protected function valueSuggestQueryGeonames(string $value, string $datatype, ar
// Don't use https, or add certificate to omeka config.
$url = 'http://api.geonames.org/searchJSON';
$headers = [
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/96.0',
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/116.0',
'Content-Type' => 'application/json',
'Accept-Encoding' => 'gzip, deflate',
];
Expand Down Expand Up @@ -3386,7 +3386,7 @@ protected function valueSuggestQueryIdRefAuthor(string $value, string $datatype,
];
$url = 'https://www.idref.fr/Sru/Solr';
$headers = [
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/96.0',
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/116.0',
'Content-Type' => 'application/json',
'Accept-Encoding' => 'gzip, deflate',
];
Expand Down Expand Up @@ -3505,7 +3505,7 @@ protected function valueSuggestQueryIdRefRameau(string $value, string $datatype,
];
$url = 'https://www.idref.fr/Sru/Solr';
$headers = [
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/96.0',
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/116.0',
'Content-Type' => 'application/json',
'Accept-Encoding' => 'gzip, deflate',
];
Expand Down

0 comments on commit 8c4e92f

Please sign in to comment.