Module: ASpaceImport

Defined in:
backend/app/converters/lib/utils.rb,
backend/app/converters/lib/xml_dom.rb,
backend/app/converters/lib/xml_sax.rb,
backend/app/converters/lib/parse_queue.rb,
backend/app/converters/lib/record_proxy.rb,
backend/app/converters/lib/csv_converter.rb,
backend/app/converters/lib/jsonmodel_wrap.rb

Defined Under Namespace

Modules: CSVConvert, Utils, XML Classes: RecordBatch, RecordProxy, RecordProxyMgr

Constant Summary collapse

FIELDS_TO_DEDUPE =
[:dates]

Class Method Summary collapse

Class Method Details

.JSONModel(type) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'backend/app/converters/lib/jsonmodel_wrap.rb', line 4

def self.JSONModel(type)
  @models ||= {}
  @models[type] ||= Class.new(JSONModel::JSONModel(type)) do


    # Need to bypass some validation rules for
    # JSON objects created by an import
    def self.validate(hash, raise_errors = true)
      begin
        super(hash)
      # TODO - speed things up by avoiding this another way
      rescue JSONModel::ValidationException => e

        e.errors.reject! {|path, mssg|
                            e.attribute_types &&
                            e.attribute_types.has_key?(path) &&
                            e.attribute_types[path] == 'ArchivesSpaceDynamicEnum'
                          }

        raise e unless e.errors.empty?
      end
    end


    def initialize(*args)
      super

      # Set a pre-save URI to be dereferenced by the backend
      if self.class.method_defined? :uri
        self.uri = self.class.uri_for(ASpaceImport::Utils.mint_id,
                                      :repo_id => "import")
      end
    end

    def key
      @key ||= self.class.record_type
    end

    def key=(val)
      @key = val
    end

  end

  @models[type]
end