Class: Ddr::Managers::PermanentIdManager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ddr/managers/permanent_id_manager.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

PermanentIdManager is responsible for managing the permanent id for an object.

Defined Under Namespace

Classes: AssignmentJob

Constant Summary collapse

PERMANENT_URL_BASE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"http://id.library.duke.edu/"
TARGET_URL_BASE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"https://repository.lib.duke.edu/id/"
ASSIGN_EVENT_SUMMARY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"Permanent ID assignment"
SOFTWARE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Ezid::Client.version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ PermanentIdManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PermanentIdManager.



22
23
24
# File 'lib/ddr/managers/permanent_id_manager.rb', line 22

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/ddr/managers/permanent_id_manager.rb', line 20

def object
  @object
end

Instance Method Details

#assignObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ddr/managers/permanent_id_manager.rb', line 30

def assign
  raise Ddr::Models::Error, "Permanent ID already assigned." if object.permanent_id
  ActiveSupport::Notifications.instrument(Ddr::Notifications::UPDATE,
                                          pid: object.pid, 
                                          software: SOFTWARE,
                                          summary: ASSIGN_EVENT_SUMMARY
                                          ) do |payload|

    assign!
    payload[:detail] = <<-EOS
Permanent ID:  #{object.permanent_id}
Permanent URL: #{object.permanent_url}
EZID Metadata:
#{record.}
    EOS
  end
end

#assign_laterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/ddr/managers/permanent_id_manager.rb', line 26

def assign_later
  Resque.enqueue(AssignmentJob, object.pid)
end

#default_metadataObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
61
62
# File 'lib/ddr/managers/permanent_id_manager.rb', line 58

def 
  { profile: "dc", 
    export: "no" 
  }
end

#recordObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



64
65
66
67
68
69
# File 'lib/ddr/managers/permanent_id_manager.rb', line 64

def record
  return @record if @record
  if object.permanent_id
    @record = Ezid::Identifier.find(object.permanent_id.to_s)
  end
end