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
42 43 44 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 42 def to_oai_dc OAIDCMapper.new.map_oai_record(self) end |
#to_oai_dcterms ⇒ Object
46 47 48 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 46 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 |
# 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 = ASpaceExport.model(:marc21).from_resource(@jsonmodel_record) remove_xml_declaration(ASpaceExport::serialize(marc)) end end |
#to_oai_mods ⇒ Object
50 51 52 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 50 def to_oai_mods OAIMODSMapper.new.map_oai_record(self) end |
#updated_at ⇒ Object
54 55 56 |
# File 'backend/app/lib/oai/aspace_oai_record.rb', line 54 def updated_at @sequel_record.system_mtime end |