Class: EACModel

Inherits:
ASpaceExport::ExportModel show all
Defined in:
backend/app/exporters/models/eac.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ASpaceExport::ExportModel

#apply_map, inherited, model_for, model_for?

Methods included from ASpaceExport::ExportModelHelpers

#extract_date_string, #extract_note_content, #get_subnotes_by_type

Constructor Details

- (EACModel) initialize(obj, events, related_records, repo)

Returns a new instance of EACModel



62
63
64
65
66
67
# File 'backend/app/exporters/models/eac.rb', line 62

def initialize(obj, events, related_records, repo)
  @json = obj
  @events = events.map {|e| self.class.instance_variable_get(:@eac_event).new(e) }
  @related_records = related_records
  @repo = repo
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(meth)



93
94
95
96
97
98
99
# File 'backend/app/exporters/models/eac.rb', line 93

def method_missing(meth)
  if @json.respond_to?(meth)
    @json.send(meth)
  else
    nil
  end
end

Instance Attribute Details

Returns the value of attribute related_records



4
5
6
# File 'backend/app/exporters/models/eac.rb', line 4

def related_records
  @related_records
end

Class Method Details

+ (Object) from_agent(obj, events, related_records, repo)



70
71
72
# File 'backend/app/exporters/models/eac.rb', line 70

def self.from_agent(obj, events, related_records, repo)
  self.new(obj, events, related_records, repo)
end

Instance Method Details

- (Object) events



75
76
77
# File 'backend/app/exporters/models/eac.rb', line 75

def events
  @events
end

- (Object) maintenanceAgency



80
81
82
83
84
85
86
87
88
89
90
# File 'backend/app/exporters/models/eac.rb', line 80

def maintenanceAgency
  if @ma.nil?
    @ma = OpenStruct.new
    @ma.agencyName = @repo.name
    if @repo.org_code
      @ma.agencyCode = @repo.org_code
    end
  end

  @ma
end

- (Object) name_part_fields

maps name.field => EAC @localType attribute



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'backend/app/exporters/models/eac.rb', line 112

def name_part_fields
  case @json.jsonmodel_type
  when 'agent_person'
    {
      "primary_name" => "surname",
      "title" => nil,
      "prefix" => nil,
      "rest_of_name" => "forename",
      "suffix" => nil,
      "fuller_form" => "fullerForm",
      "number" => nil,
      "qualifier" => nil,
    }
  when 'agent_family'
    {
      "family_name" => 'familyName',
      "prefix" => nil,
      "qualifier" => nil,
    }
  when 'agent_software'
    {
      "software_name" => nil,
      "version" => nil,
      "manufacturer" => nil
    }
  when 'agent_corporate_entity'
    {
      "primary_name" => "primaryPart", 
      "subordinate_name_1" => "secondaryPart", 
      "subordinate_name_2" => "tertiaryPart", 
      "number" => nil,
      "qualifier" => nil
    }
  end
end


102
103
104
105
106
107
108
# File 'backend/app/exporters/models/eac.rb', line 102

def related_agents
  if @json.respond_to?(:related_agents)
    @json.related_agents
  else
    []
  end
end