-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathislandora_entity_bridge.drush.inc
59 lines (49 loc) · 1.76 KB
/
islandora_entity_bridge.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
<?php
/**
* Implements hook_drush_command().
*/
function islandora_entity_bridge_drush_command() {
$items = array();
$items['islandora_entity_bridge_populate_entity_bridge'] = array(
'aliases' => array('ieb-populate'),
'description' => 'Populate entity bridge',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
);
return $items;
}
/**********
* Populate Entity Bridge Mappings.
*/
function drush_islandora_entity_bridge_populate_entity_bridge() {
$batch = array(
'operations' => array(),
'finished' => 'drush_islandora_entity_bridge_populate_entity_bridge_finished',
'title' => t('Loading entities...'),
'init_message' => t('Preparing to import image datastreams'),
'progress_message' => t('Submitting content...'),
'error_message' => t('Content could not get reimported'),
);
$connection = islandora_get_tuque_connection();
$query = 'SELECT ?object FROM <#ri> WHERE {
?object <dc:identifier> ?identifier ;
} ORDER BY ?object';
$results = $connection->repository->ri->sparqlQuery($query);
foreach ($results as $result) {
$pid = $result['object']['value'];
$batch['operations'][] = array(
'drush_islandora_entity_bridge_populate_entity_bridge_object', array($pid),
);
}
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
drush_backend_batch_process();
}
function drush_islandora_entity_bridge_populate_entity_bridge_object($pid, &$context) {
$context['message'] = t("Populating Fedora PID @pid", array('@pid' => $pid));
$object = islandora_object_load($pid);
islandora_entity_bridge_islandora_object_modified($object);
}
function drush_islandora_entity_bridge_populate_entity_bridge_finished() {
drupal_set_message('Successfully prepopulated entity bridge mapping table.');
}