Skip to content

Commit 8f71880

Browse files
add csv import
1 parent b1f8c4d commit 8f71880

241 files changed

Lines changed: 33170 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/CSVImport/LICENSE.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

modules/CSVImport/Module.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
namespace CSVImport;
3+
4+
use Omeka\Module\AbstractModule;
5+
use Laminas\ModuleManager\ModuleManager;
6+
use Laminas\ServiceManager\ServiceLocatorInterface;
7+
8+
class Module extends AbstractModule
9+
{
10+
public function init(ModuleManager $moduleManager)
11+
{
12+
require_once __DIR__ . '/vendor/autoload.php';
13+
}
14+
15+
public function getConfig()
16+
{
17+
return include __DIR__ . '/config/module.config.php';
18+
}
19+
20+
public function install(ServiceLocatorInterface $serviceLocator)
21+
{
22+
$connection = $serviceLocator->get('Omeka\Connection');
23+
$sql = <<<'SQL'
24+
CREATE TABLE csvimport_import (
25+
id INT AUTO_INCREMENT NOT NULL,
26+
job_id INT NOT NULL,
27+
undo_job_id INT DEFAULT NULL,
28+
comment VARCHAR(255) DEFAULT NULL,
29+
resource_type VARCHAR(255) NOT NULL,
30+
has_err TINYINT(1) NOT NULL,
31+
stats LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)',
32+
UNIQUE INDEX UNIQ_17B50881BE04EA9 (job_id),
33+
UNIQUE INDEX UNIQ_17B508814C276F75 (undo_job_id),
34+
PRIMARY KEY(id)
35+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
36+
CREATE TABLE csvimport_entity (
37+
id INT AUTO_INCREMENT NOT NULL,
38+
job_id INT NOT NULL,
39+
entity_id INT NOT NULL,
40+
resource_type VARCHAR(255) NOT NULL,
41+
INDEX IDX_84D382F4BE04EA9 (job_id),
42+
PRIMARY KEY(id)
43+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
44+
ALTER TABLE csvimport_import ADD CONSTRAINT FK_17B50881BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
45+
ALTER TABLE csvimport_import ADD CONSTRAINT FK_17B508814C276F75 FOREIGN KEY (undo_job_id) REFERENCES job (id);
46+
ALTER TABLE csvimport_entity ADD CONSTRAINT FK_84D382F4BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
47+
SQL;
48+
$sqls = array_filter(array_map('trim', explode(';', $sql)));
49+
foreach ($sqls as $sql) {
50+
$connection->exec($sql);
51+
}
52+
}
53+
54+
public function uninstall(ServiceLocatorInterface $serviceLocator)
55+
{
56+
$connection = $serviceLocator->get('Omeka\Connection');
57+
$sql = <<<'SQL'
58+
ALTER TABLE csvimport_entity DROP FOREIGN KEY FK_84D382F4BE04EA9;
59+
ALTER TABLE csvimport_import DROP FOREIGN KEY FK_17B508814C276F75;
60+
ALTER TABLE csvimport_import DROP FOREIGN KEY FK_17B50881BE04EA9;
61+
DROP TABLE IF EXISTS csvimport_entity;
62+
DROP TABLE IF EXISTS csvimport_import;
63+
SQL;
64+
$sqls = array_filter(array_map('trim', explode(';', $sql)));
65+
foreach ($sqls as $sql) {
66+
$connection->exec($sql);
67+
}
68+
// User settings are not removed here: they belong to the user.
69+
}
70+
71+
public function upgrade($oldVersion, $newVersion, ServiceLocatorInterface $serviceLocator)
72+
{
73+
if (version_compare($oldVersion, '1.1.1-rc.1', '<')) {
74+
$connection = $serviceLocator->get('Omeka\Connection');
75+
$sql = <<<'SQL'
76+
ALTER TABLE csvimport_import ADD stats LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)';
77+
UPDATE csvimport_import SET stats = CONCAT('{"processed":{"', resource_type, '":', added_count, '}}');
78+
ALTER TABLE csvimport_import DROP added_count;
79+
SQL;
80+
$sqls = array_filter(array_map('trim', explode(';', $sql)));
81+
foreach ($sqls as $sql) {
82+
$connection->exec($sql);
83+
}
84+
}
85+
}
86+
}

modules/CSVImport/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
CSV Import (module for Omeka S)
2+
===============================
3+
4+
[CSV Import] is a module for [Omeka S] and will allow users to import Entities from a simple CSV (comma separated value) file, and then map the CSV column data to Entity. Each row in the file represents metadata for a single Entity.
5+
6+
Furthermore, it’s possible to import directly files in formats [TSV] (tab separated value), a simpler and more efficient format, and [ODS] (OpenDocument Spreadsheet, the ISO standard office format for spreadsheets, managed by [LibreOffice] and a lot of other tools) directly.
7+
8+
Most often, the import will create new Omeka S items. It is also possible to import item sets, media and users, and other modules can add other import types. It’s possible to import mixed resources in one file too.
9+
10+
See the [Omeka S user manual](http://omeka.org/s/docs/user-manual/modules/csvimport/) for user documentation.
11+
12+
Installation
13+
------------
14+
15+
See general end user documentation for [Installing a module](http://omeka.org/s/docs/user-manual/modules/#installing-modules).
16+
17+
To install CSV Import from the source, go to the root of the module, and run `composer install`. Users
18+
using the pre-packaged downloads from the Releases page or the omeka.org module directory don't need
19+
to worry about this step.
20+
21+
To be able to import `ods`, the php extensions `zip` and `xml` should be installed (default in most cases).
22+
23+
Warning
24+
-------
25+
26+
Use it at your own risk.
27+
28+
It’s always recommended to backup your files and your databases and to check your archives regularly so you can roll back if needed.
29+
30+
Troubleshooting
31+
---------------
32+
33+
See online issues on the [Omeka forum] and the [module issues] page on GitHub.
34+
35+
License
36+
-------
37+
38+
The Corporation for Digital Scholarship distributes the Omeka source code under the GNU General Public License, version 3 (GPLv3). The full text
39+
of this license is given in the license file.
40+
41+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
42+
43+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
44+
45+
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46+
47+
Contact
48+
-------
49+
50+
Current maintainers:
51+
52+
* Omeka Team
53+
* Daniel Berthereau (see [Daniel-KM] on GitHub)
54+
55+
Copyright
56+
---------
57+
* CSVImport is Copyright © 2015-present Corporation for Digital Scholarship, Vienna, Virginia, USA http://digitalscholar.org
58+
59+
The Omeka name is a registered trademark of the Corporation for Digital Scholarship.
60+
61+
Third-party copyright in this distribution is noted where applicable.
62+
63+
All rights not expressly granted are reserved.
64+
65+
* Copyright Daniel Berthereau, 2017-2019
66+
67+
[CSV Import]: https://github.com/Omeka-s-modules/CSVImport
68+
[Omeka S]: https://omeka.org/s
69+
[TSV]: https://en.wikipedia.org/wiki/Tab-separated_values
70+
[ODS]: http://opendocumentformat.org/aboutODF
71+
[LibreOffice]: https://www.libreoffice.org
72+
[Omeka forum]: https://forum.omeka.org/c/omeka-s/modules
73+
[module issues]: https://github.com/omeka-s-modules/CSVImport/issues
74+
[GNU/GPL v3]: https://www.gnu.org/licenses/gpl-3.0.html
75+
[Daniel-KM]: https://github.com/Daniel-KM "Daniel Berthereau"
76+

0 commit comments

Comments
 (0)