-
Notifications
You must be signed in to change notification settings - Fork 2
/
Module.php
executable file
·95 lines (87 loc) · 3.59 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace OaiPmhHarvester;
use Omeka\Module\AbstractModule;
use Omeka\Entity\Job;
use Zend\ServiceManager\ServiceLocatorInterface;
class Module extends AbstractModule
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function install(ServiceLocatorInterface $serviceLocator)
{
$connection = $serviceLocator->get('Omeka\Connection');
/* Harvested records/items.
id: primary key
harvest_id: the corresponding set id in `oaipmh_harvester_harvests`
item_id: the corresponding item id in `items`
identifier: the OAI-PMH record identifier (unique identifier)
datestamp: the OAI-PMH record datestamp
*/
/*
$sql = "
CREATE TABLE IF NOT EXISTS `oaipmh_harvester_records` (
`id` int unsigned NOT NULL auto_increment,
`harvest_id` int unsigned NOT NULL,
`item_id` int unsigned default NULL,
`identifier` text NOT NULL,
`datestamp` tinytext NOT NULL,
PRIMARY KEY (`id`),
KEY `identifier_idx` (identifier(255)),
UNIQUE KEY `item_id_idx` (item_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$connection->exec($sql);
*/
$sql = "
CREATE TABLE oai_pmh_harvester_harvest_job (
id INT AUTO_INCREMENT NOT NULL,
job_id INT NOT NULL,
undo_job_id INT DEFAULT NULL,
comment VARCHAR(255) DEFAULT NULL,
has_err TINYINT(1) NOT NULL DEFAULT 0,
collection_id int unsigned default NULL,
base_url text NOT NULL,
metadata_prefix tinytext NOT NULL,
set_spec text,
set_name text,
set_description text,
initiated datetime default NULL,
completed datetime default NULL,
start_from datetime default NULL,
resumption_token text,
resource_type text,
UNIQUE INDEX UNIQ_17B50881BE04EA9 (job_id),
UNIQUE INDEX UNIQ_17B508814C276F75 (undo_job_id),
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE oai_pmh_harvester_entity (
id INT AUTO_INCREMENT NOT NULL,
job_id INT NOT NULL,
entity_id INT NOT NULL,
resource_type text,
INDEX IDX_84D382F4BE04EA9 (job_id),
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
";
$connection->exec($sql);
/*
ALTER TABLE oai_pmh_harvester_harvest_job ADD CONSTRAINT FK_17B50881BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
ALTER TABLE oai_pmh_harvester_harvest_job ADD CONSTRAINT FK_17B508814C276F75 FOREIGN KEY (undo_job_id) REFERENCES job (id);
ALTER TABLE oai_pmh_harvester_harvest_entity ADD CONSTRAINT FK_84D382F4BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
*/
}
public function uninstall(ServiceLocatorInterface $serviceLocator)
{
$connection = $serviceLocator->get('Omeka\Connection');
// drop the tables
/*
$sql = "DROP TABLE IF EXISTS `oaipmh_harvester_harvests`;";
$connection->exec($sql);
$sql = "DROP TABLE IF EXISTS `oaipmh_harvester_records`;";
$connection->exec($sql);
*/
$sql = "DROP TABLE IF EXISTS `oai_pmh_harvester_harvest_job`;";
$connection->exec($sql);
$sql = "DROP TABLE IF EXISTS `oai_pmh_harvester_entity`;";
$connection->exec($sql);
}
}