Class: Dor::ArchiveCriteria

Inherits:
Struct
  • Object
show all
Defined in:
lib/dor/workflow_archiver.rb

Overview

Holds the paramaters about the workflow rows that need to be deleted

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#datastreamObject

Returns the value of attribute datastream

Returns:

  • (Object)

    the current value of datastream



8
9
10
# File 'lib/dor/workflow_archiver.rb', line 8

def datastream
  @datastream
end

#druidObject

Returns the value of attribute druid

Returns:

  • (Object)

    the current value of druid



8
9
10
# File 'lib/dor/workflow_archiver.rb', line 8

def druid
  @druid
end

#repositoryObject

Returns the value of attribute repository

Returns:

  • (Object)

    the current value of repository



8
9
10
# File 'lib/dor/workflow_archiver.rb', line 8

def repository
  @repository
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



8
9
10
# File 'lib/dor/workflow_archiver.rb', line 8

def version
  @version
end

Instance Method Details

#set_current_version(dor_conn) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/dor/workflow_archiver.rb', line 28

def set_current_version(dor_conn)
  response = dor_conn.get "/v1/objects/#{druid}/versions/current"
  self.version = response.body
rescue Faraday::Error::ClientError => ise
  raise unless ise.inspect =~ /Unable to find.*in fedora/
  LyberCore::Log.warn ise.inspect.to_s
  LyberCore::Log.warn "Moving workflow rows with version set to '1'"
  self.version = '1'
end

#setup_from_query(row_hash, dor_conn) ⇒ Object

Parameters:



10
11
12
13
14
15
16
# File 'lib/dor/workflow_archiver.rb', line 10

def setup_from_query(row_hash, dor_conn)
  self.repository = row_hash[:repository]
  self.druid = row_hash[:druid]
  self.datastream = row_hash[:datastream]
  set_current_version(dor_conn)
  self
end

#to_bind_hashHash

Removes version from list of members, then picks out non nil members and builds a hash of column_name => column_value

Returns:

  • (Hash)

    Maps column names (in ALL caps) to non-nil column values



20
21
22
23
24
25
26
# File 'lib/dor/workflow_archiver.rb', line 20

def to_bind_hash
  h = {}
  members.reject { |mem| mem =~ /version/ }.each do |m|
    h[m] = send(m) if send(m)
  end
  h
end