forked from oclservice/oclsdora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oclsdora.drush.inc
47 lines (44 loc) · 1.27 KB
/
oclsdora.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
<?php
/**
* @file
* Holds Drush commands for OCLS.
*/
/**
* Implements hook_drush_command().
*/
function oclsdora_drush_command() {
$commands = array();
$commands['oclsdora-add-missing-model'] = array(
'aliases' => array(
'oamm',
),
'drupal dependencies' => array(
'islandora',
'islandora_solr',
),
);
return $commands;
}
/**
* Drush command callback for oclsdora-add-missing-model.
*/
function drush_oclsdora_add_missing_model() {
$model_field = variable_get('islandora_solr_content_model_field', 'RELS_EXT_hasModel_uri_ms');
$qp = new IslandoraSolrQueryProcessor();
$qp->buildQuery(format_string('-!model_field:*', array('!model_field' => $model_field)));
$qp->solrParams['fl'] = 'PID';
$qp->solrParams['fq'] = array();
$qp->solrLimit = 10000000;
$qp->executeQuery(FALSE);
$processed = 0;
foreach ($qp->islandoraSolrResult['response']['objects'] as $solr_doc) {
$object = islandora_object_load($solr_doc['PID']);
$object->models = 'islandora:sp_pdf';
$processed = $processed + 1;
drush_log(dt('@processed/@total Updated the content model for @pid.', array(
'@processed' => $processed,
'@total' => $qp->islandoraSolrResult['response']['numFound'],
'@pid' => $solr_doc['PID'],
)));
}
}