Skip to content

Commit

Permalink
bug fix: #74 fix rebuild zoom records and imports setting of oai date…
Browse files Browse the repository at this point in the history
…stamp by creating new method with appropriate logic\nand calling it where appropriate\n[#74 tagged:committed state:resolved responsible:walter]
  • Loading branch information
Walter McGinnis committed Oct 5, 2008
1 parent b2de289 commit a058247
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/search/oai_record.rxml
Expand Up @@ -6,7 +6,7 @@ xml.tag!("OAI-PMH", "xmlns:xsi".to_sym => "http://www.w3.org/2001/XMLSchema-inst
xml.record do
xml.header do
oai_dc_xml_oai_identifier(xml,item)
xml.datestamp(item.updated_at.utc.xmlschema)
oai_dc_xml_oai_datestamp(xml, item)
oai_dc_xml_oai_set_specs(xml,item)
end
xml.metadata do
Expand Down
2 changes: 1 addition & 1 deletion lib/importer_zoom.rb
Expand Up @@ -24,7 +24,7 @@ def importer_oai_record_xml(options = { })
xml.record do
xml.header do
oai_dc_xml_oai_identifier(xml,item)
xml.datestamp(Time.now.utc.xmlschema)
oai_dc_xml_oai_datestamp(xml, item)
oai_dc_xml_oai_set_specs(xml,item)
end
xml.metadata do
Expand Down
19 changes: 19 additions & 0 deletions lib/oai_dc_helpers.rb
Expand Up @@ -30,6 +30,25 @@ def oai_dc_xml_oai_identifier(xml, item)
xml.identifier("#{ZoomDb.zoom_id_stub}#{item.basket.urlified_name}:#{item.class.name}:#{item.id}")
end

# Walter McGinnis, 2008-10-05
# adding better logic for determining last time the item was changed
# we want the datestamp to reflect the most recent change to the item
# that can be either when it is created/edited
# or when a relationship has been added
def oai_dc_xml_oai_datestamp(xml, item)
if item.content_item_relations.count == 0
xml.datestamp(item.updated_at.utc.xmlschema)
elsif item.class.name != 'Topic'
xml.datestamp(item.content_item_relations.last.updated_at.utc.xmlschema)
else
# topics can be on either side of the content_item_relation join model
# so to get all possible relations, you have to combine them
all_relations = item.content_item_relations + item.child_content_item_relations
all_relations.sort! { |a,b| a.updated_at <=> b.updated_at }
xml.datestamp(all_relations.last.updated_at.utc.xmlschema)
end
end

# Walter McGinnis, 2008-06-16
# adding oai pmh set support
# assumes public zoom_db
Expand Down

0 comments on commit a058247

Please sign in to comment.