Class: ArchivesSpaceOAIRecord
- Inherits:
-
Object
- Object
- ArchivesSpaceOAIRecord
- Defined in:
- backend/app/lib/oai/aspace_oai_record.rb
Instance Attribute Summary collapse
-
#jsonmodel_record ⇒ Object
readonly
Returns the value of attribute jsonmodel_record.
-
#sequel_record ⇒ Object
readonly
Returns the value of attribute sequel_record.
Instance Method Summary collapse
-
#id ⇒ Object
-
#initialize(sequel_record, jsonmodel_record) ⇒ ArchivesSpaceOAIRecord
constructor
A new instance of ArchivesSpaceOAIRecord.
-
#to_oai_dc ⇒ Object
-
#to_oai_dcterms ⇒ Object
-
#to_oai_ead ⇒ Object
-
#to_oai_marc ⇒ Object
-
#to_oai_mods ⇒ Object
-
#updated_at ⇒ Object
Constructor Details
#initialize(sequel_record, jsonmodel_record) ⇒ ArchivesSpaceOAIRecord
Returns a new instance of ArchivesSpaceOAIRecord.
9 10 11 12 13 14 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 9 def initialize(sequel_record, jsonmodel_record) @jsonmodel_record = jsonmodel_record JSONModel::set_publish_flags!(@jsonmodel_record) @sequel_record = sequel_record end |
Instance Attribute Details
#jsonmodel_record ⇒ Object (readonly)
Returns the value of attribute jsonmodel_record
7 8 9 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 7 def jsonmodel_record @jsonmodel_record end |
#sequel_record ⇒ Object (readonly)
Returns the value of attribute sequel_record
7 8 9 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 7 def sequel_record @sequel_record end |
Instance Method Details
#id ⇒ Object
16 17 18 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 16 def id @jsonmodel_record.uri end |
#to_oai_dc ⇒ Object
48 49 50 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 48 def to_oai_dc OAIDCMapper.new.map_oai_record(self) end |
#to_oai_dcterms ⇒ Object
52 53 54 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 52 def to_oai_dcterms OAIDCTermsMapper.new.map_oai_record(self) end |
#to_oai_ead ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 20 def to_oai_ead raise OAI::FormatException.new unless @jsonmodel_record['jsonmodel_type'] == 'resource' RequestContext.open(:repo_id => @sequel_record.repo_id) do ead = ASpaceExport.model(:ead).from_resource(@jsonmodel_record, @sequel_record.tree(:all, mode = :sparse), AppConfig[:oai_ead_options]) record = [] ASpaceExport::stream(ead).each do |chunk| record << chunk end remove_xml_declaration(record.join("")) end end |
#to_oai_marc ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 35 def to_oai_marc RequestContext.open(:repo_id => @sequel_record.repo_id) do marc = if @jsonmodel_record['jsonmodel_type'] == 'resource' ASpaceExport.model(:marc21).from_resource(@jsonmodel_record) elsif @jsonmodel_record['jsonmodel_type'] == 'archival_object' ASpaceExport.model(:marc21).from_archival_object(@jsonmodel_record) else raise OAI::FormatException.new end remove_xml_declaration(ASpaceExport::serialize(marc)) end end |
#to_oai_mods ⇒ Object
56 57 58 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 56 def to_oai_mods OAIMODSMapper.new.map_oai_record(self) end |
#updated_at ⇒ Object
60 61 62 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 60 def updated_at @sequel_record.system_mtime end |