lib/active_fedora/base.rb in active-fedora-3.1.0.pre9 vs lib/active_fedora/base.rb in active-fedora-3.1.0.pre10
- old
+ new
@@ -832,10 +832,11 @@
def to_solr(solr_doc = Hash.new, opts={})
unless opts[:model_only]
solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => pid, ActiveFedora::SolrService.solr_name(:system_create, :date) => self.create_date, ActiveFedora::SolrService.solr_name(:system_modified, :date) => self.modified_date, ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol) => self.class.inspect)
end
datastreams.each_value do |ds|
+ ds.ensure_xml_loaded if ds.respond_to? :ensure_xml_loaded ### Can't put this in the model because it's often implemented in Solrizer::XML::TerminologyBasedSolrizer
solr_doc = ds.to_solr(solr_doc) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ds.kind_of?(ActiveFedora::NokogiriDatastream) || ( ds.kind_of?(ActiveFedora::RelsExtDatastream) && !opts[:model_only] )
end
begin
#logger.info("PID: '#{pid}' solr_doc put into solr: #{solr_doc.inspect}")
rescue
@@ -864,11 +865,11 @@
raise "Object #{pid} not found in solr" if result.nil?
solr_doc = result.hits.first
#double check pid and id in record match
raise "Object #{pid} not found in Solr" unless !result.nil? && !solr_doc.nil? && pid == solr_doc[SOLR_DOCUMENT_ID]
else
- raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
- end
+ raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
+ end
create_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)]
modified_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date)]
obj = self.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
#set by default to load any dependent relationship objects from solr as well