-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbc_islandora_ingest.drush.inc
72 lines (66 loc) · 2.76 KB
/
bc_islandora_ingest.drush.inc
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
<?php
/**
* @file
* Drush command definition for bc_islandora_ingest_objects.
*/
require_once 'includes/bc_islandora.drush_ingest_methods.inc';
/**
* Implements hook_drush_command().
*/
function bc_islandora_ingest_drush_command() {
return array(
'bc_islandora_ingest_objects' => array(
'description' => 'Ingests objects.',
'arguments' => array(
'query_file' => 'A csv file containing information about the objects to be ingested.',
),
'options' => array(
'type' => 'The type of objects to ingest.',
'year' => 'Specific year from which to ingest objects.',
'month' => 'Month from which to ingest objects.',
'generate-csv' => 'Whether to generate a csv file for use in newspaper ingest.',
'identifier' => 'The identifier of the collection to ingest.',
),
'examples' => array(
'drush -u 1 --uri=http://localhost bciio /path/to/pages.csv',
'drush -u 1 bciio --type=newspaper --year=1991 /home/vagrant/bulletin-subset',
'drush -u 1 bciio --type=newspaper /home/vagrant/bulletin-subset/1991pages.csv',
'drush -u 1 bciio --type=book --year=1985 /home/vagrant/yearbook/yearbook.csv',
'drush -u 1 bciio --type=student_publication /home/vagrant/student-pubs',
'drush -u 1 bciio --type=student_publication --identifier=BC12-04 /home/vagrant/student-pubs',
'drush -u 1 bciio --type=manuscript /home/vagrant/manuscripts/metadata.csv',
'drush -u 1 bciio --type=manuscript --identifier=BC13-58_71Q-Daly1972 /home/vagrant/manuscripts/metadata.csv',
'drush -u 1 bciio --type=rgBC15 /mnt/barnard.collections/RG15-Alumnae_Scrapbooks/metadata.csv',
'drush -u 1 bciio --type=rgBC1108 /mnt/barnard.collections/RG11-08-Alumnae_Magazine/metadata.csv',
'drush -u 1 bciio --type=rgBC1358_audio /mnt/barnard.collections/RG1358-SFAudio/metadata.csv',
),
'aliases' => array('bciio'),
// We can pass in users id on the command line using drush -u.
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
),
);
}
/**
* Ingests objects using the appropriate ingest method and options.
*/
function drush_bc_islandora_ingest_objects($query_file) {
if ($type = drush_get_option('type')) {
$function = "_bc_islandora_drush_ingest_{$type}";
}
else {
drush_log(dt("Please specify type of object to ingest."), 'error');
return;
}
$options = array(
'year' => drush_get_option('year'),
'month' => drush_get_option('month'),
'generate-csv' => drush_get_option('generate-csv'),
'identifier' => drush_get_option('identifier'),
);
if (function_exists($function)) {
$function($query_file, $options);
}
else {
drush_log(dt("Didn't get ingest method at type = @type", array('@type' => $type)), 'error');
}
}