acurley/tracksys — Issue #20: Provide facility to reindex all objects based on IndexingScenario
Author: acurley
Created: 2012-02-25 18:34:32+00:00
State: open
Labels: Digital Library, User Interface, Workflow

Below is some sample code to facilitate these transactions. Note that in upgraded DB, we should be able to avoide querying Units to get to ingests MasterFiles; hopefully in the future each MasterFile will carry it's own date_ingested_to_dl datetime stamp.

```
# Reindex all master_files transformed by holsingerTransformation
include ActiveMessaging::MessageSender
mfs = []
units = Unit.find(:all, :conditions => 'indexing_scenario_id = 2 AND date_dl_deliverables_ready is not null'); nil
units.each {|u| u.master_files.each {|mf| mfs << mf}}; nil
mfs.each {|mf|
message = ActiveSupport::JSON.encode( { :object_class => 'MasterFile', :object_id => "#{mf.id}", :type => 'update'})
Object.publish :ingest_solr_doc, message
}; nil

# Reindex all master_files transformed by defaultModsTransformation
include ActiveMessaging::MessageSender
mfs = []
units = Unit.find(:all, :conditions => 'indexing_scenario_id = 1 AND date_dl_deliverables_ready is not null'); nil
units.each {|u| u.master_files.each {|mf| mfs << mf}}; nil
mfs.each {|mf|
message = ActiveSupport::JSON.encode( { :object_class => 'MasterFile', :object_id => "#{mf.id}", :type => 'update'})
Object.publish :ingest_solr_doc, message
}; nil
```