forked from adam-vessey/islandora_batch
-
Notifications
You must be signed in to change notification settings - Fork 35
/
islandora_batch.install
369 lines (353 loc) · 9.74 KB
/
islandora_batch.install
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php
/**
* @file
* Installation hooks.
*/
/**
* Implements hook_schema().
*/
function islandora_batch_schema() {
$schema = array();
$schema['islandora_batch_queue'] = array(
'description' => 'Holds the queue of object entries being batch ingested.',
'fields' => array(
'id' => array(
'description' => 'An identifier which was allocated for this object.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'parent' => array(
'description' => 'If applicable, the identifier (allocated) for the ' .
'parent object.',
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
),
'data' => array(
'description' => 'A serialized object to be processed later.',
'type' => 'blob',
'size' => 'big',
),
'bid' => array(
'description' => 'ID of this object, in the batch context.',
'type' => 'serial',
'size' => 'big',
'not null' => TRUE,
),
'sid' => array(
'description' => 'ID of the set to which this object belongs.',
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
),
),
'primary key' => array('id'),
'indexes' => array(
'parent_index' => array('parent'),
'sid' => array('sid'),
),
'unique keys' => array(
'bid' => array('bid'),
),
'foreign keys' => array(
'parent_entry' => array(
'table' => 'islandora_batch_queue',
'fields' => array(
'parent' => 'id',
),
),
'set' => array(
'table' => 'islandora_batch_set',
'fields' => array(
'sid' => 'id',
),
),
),
);
$schema['islandora_batch_state'] = array(
'description' => 'Holds the state of the objects in the queue.',
'fields' => array(
'id' => array(
'description' => 'The identifier whose state we are storing.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'state' => array(
'description' => 'The state of the object.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'unsigned' => FALSE,
),
),
'primary key' => array('id'),
'foreign keys' => array(
'associated_entry' => array(
'table' => 'islandora_batch_queue',
'fields' => array(
'id' => 'id',
),
),
),
);
$schema['islandora_batch_resources'] = array(
'description' => 'Tracks resource usage.',
'fields' => array(
'n' => array(
'description' => 'A numeric ID to use in the key.',
'type' => 'serial',
'not null' => TRUE,
),
'id' => array(
'description' => 'The object which will use or have used this resource.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'type' => array(
'description' => 'The type of resource. Directories vs files vs whatever.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 64,
),
'resource' => array(
'description' => 'Indicate how to find the resource.',
'type' => 'varchar',
'length' => 4096,
'not null' => TRUE,
),
),
'primary key' => array('n', 'id', 'type'),
'foreign keys' => array(
'associated_object' => array(
'table' => 'islandora_batch_queue',
'fields' => array(
'id' => 'id',
),
),
'associated_state' => array(
'table' => 'islandora_batch_state',
'fields' => array(
'id' => 'id',
),
),
),
);
$schema['islandora_batch_set'] = array(
'description' => 'Facilitate tracking of items in sets.',
'fields' => array(
'id' => array(
'description' => 'ID to track this a set of items being batched.',
'type' => 'serial',
'size' => 'big',
'not null' => TRUE,
),
'uid' => array(
'description' => 'User ID of the user who created this set.',
'type' => 'int',
'size' => 'big',
'not null' => TRUE,
),
'created' => array(
'description' => 'Timestamp of when this set was registered.',
'type' => 'int',
'not null' => TRUE,
),
'completed' => array(
'description' => 'Timestamp of when this set was completed.',
'type' => 'int',
'not null' => FALSE,
),
),
'primary key' => array('id'),
'foreign keys' => array(
'associated user' => array(
'table' => 'users',
'fields' => array(
'uid' => 'uid',
),
),
),
);
$schema['islandora_batch_queue_messages'] = array(
'description' => 'Per-object messages.',
'fields' => array(
'id' => array(
'description' => 'The identifier whose message we are storing.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'message' => array(
'description' => 'The message for the object.',
'type' => 'text',
'not null' => FALSE,
'size' => 'medium',
),
),
'primary key' => array('id'),
'foreign keys' => array(
'associated_entry' => array(
'table' => 'islandora_batch_queue',
'fields' => array(
'id' => 'id',
),
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function islandora_batch_uninstall() {
$variables = array(
'islandora_batch_java',
'islandora_batch_link_when_finished',
'islandora_batch_auto_remove_set',
);
array_walk($variables, 'variable_del');
}
/**
* Adjust columns tracking error state.
*
* Should have been done when introducing the "error" state
* https://github.com/discoverygarden/islandora_batch/pull/3, or
* https://github.com/discoverygarden/islandora_batch/pull/6 (where it actually
* started getting used, due to exceptions breaking things).
*/
function islandora_batch_update_7100() {
db_change_field('islandora_batch_state', 'state', 'state',
array(
'description' => 'The state of the object.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'unsigned' => FALSE,
)
);
}
/**
* Add index on "parent" column so things are faster.
*
* Index the "parent" column in the islandora_batch_queue table, as it is used
* when determining which parent objects are available to be ingested.
*/
function islandora_batch_update_7101() {
db_add_index('islandora_batch_queue', 'parent_index', array('parent'));
}
/**
* Add new table and columns for better set tracking and file management.
*/
function islandora_batch_update_7102() {
db_create_table('islandora_batch_set', array(
'description' => 'Facilitate tracking of items in sets.',
'fields' => array(
'id' => array(
'description' => 'ID to track this a set of items being batched.',
'type' => 'serial',
'size' => 'big',
'not null' => TRUE,
),
'uid' => array(
'description' => 'User ID of the user who created this set.',
'type' => 'int',
'size' => 'big',
'not null' => TRUE,
),
'created' => array(
'description' => 'Timestamp of when this set was registered.',
'type' => 'int',
'not null' => TRUE,
),
),
'primary key' => array('id'),
'foreign keys' => array(
'associated user' => array(
'table' => 'users',
'fields' => array(
'uid' => 'uid',
),
),
),
));
db_add_field('islandora_batch_queue', 'bid', array(
'description' => 'ID of this object, in the batch context.',
'type' => 'serial',
'size' => 'big',
'not null' => TRUE,
), array(
'unique keys' => array(
'bid' => array('bid'),
),
));
db_add_field('islandora_batch_queue', 'sid', array(
'description' => 'ID of the set to which this object belongs.',
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
), array(
'foreign keys' => array(
'set' => array(
'table' => 'islandora_batch_set',
'fields' => array(
'sid' => 'id',
),
),
),
));
}
/**
* Allow batches to record per-object messages.
*/
function islandora_batch_update_7103() {
$schema['islandora_batch_queue_messages'] = array(
'description' => 'Per-object messages.',
'fields' => array(
'id' => array(
'description' => 'The identifier whose message we are storing.',
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
),
'message' => array(
'description' => 'The message for the object.',
'type' => 'text',
'not null' => FALSE,
'size' => 'medium',
),
),
'primary key' => array('id'),
'foreign keys' => array(
'associated_entry' => array(
'table' => 'islandora_batch_queue',
'fields' => array(
'id' => 'id',
),
),
),
);
db_create_table('islandora_batch_queue_messages', $schema['islandora_batch_queue_messages']);
}
/**
* Add column to track set completion.
*/
function islandora_batch_update_7104() {
db_add_field('islandora_batch_set', 'completed', array(
'description' => 'Timestamp of when this set was completed.',
'type' => 'int',
'not null' => FALSE,
));
}
/**
* Deprecates mods_to_dc.xsl
*/
function islandora_batch_update_7105() {
return t('The mods_to_dc.xsl transform file has been moved to the Islandora module as of Islandora 7.x-1.13.
No action is required for most sites, but any custom modules referring to this file should be pointed to its new location in the Islandora module.
This copy of mods_to_dc.xsl will be removed in the next release.');
}