Module: RightsRestrictionNotes::Implementation

Defined in:
backend/app/model/mixins/rights_restriction_notes.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) process_restriction_notes(json, obj)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'backend/app/model/mixins/rights_restriction_notes.rb', line 46

def self.process_restriction_notes(json, obj)
  obj.rights_restriction_dataset.delete

  restrictions = ASUtils.wrap(json['notes']).each do |note|
    next unless note['jsonmodel_type'] == 'note_multipart' && RESTRICTION_NOTE_TYPES.include?(note['type'])
    next unless note.has_key?('rights_restriction')

    begin_date = note['rights_restriction']['begin'] ? Date.parse(note['rights_restriction']['begin']) : nil
    end_date = note['rights_restriction']['end'] ? Date.parse(note['rights_restriction']['end']) : nil

    restriction = obj.add_rights_restriction(:begin => begin_date,
                                             :end => end_date,
                                             :restriction_note_type => note['type'])

    ASUtils.wrap(note['rights_restriction']['local_access_restriction_type']).each do |restriction_type|
      restriction.add_rights_restriction_type(:restriction_type => restriction_type)
    end
  end
end