Class: AgentSoftware

Inherits:
Sequel::Model
  • Object
show all
Defined in:
backend/app/model/agent_software.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.archivesspace_recordObject



49
50
51
# File 'backend/app/model/agent_software.rb', line 49

def self.archivesspace_record
  AgentSoftware[:system_role => system_role]
end

.ensure_correctly_versioned_archivesspace_recordObject

Create the agent record that represents the system itself, or update it if it exists but the build version has changed



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'backend/app/model/agent_software.rb', line 56

def self.ensure_correctly_versioned_archivesspace_record
  if AgentSoftware[:system_role => system_role].nil?
    json = JSONModel(:agent_software).from_hash(
              :publish => false,
              :names => [{
                :software_name => 'ArchivesSpace',
                :version => ASConstants.VERSION,
                :source => 'local',
                :rules => 'local',
                :sort_name_auto_generate => true
            }])

    AgentSoftware.create_from_json(json,
                                   :system_generated => true,
                                   :system_role => system_role)
  else
    as_sequel = AgentSoftware[:system_role => system_role]
    if as_sequel.name_software[0].version != ASConstants.VERSION
      as_sequel.name_software[0].version = ASConstants.VERSION
      as_sequel.name_software[0].save
    end
  end
end

.system_roleObject



35
36
37
# File 'backend/app/model/agent_software.rb', line 35

def self.system_role
  "archivesspace_agent"
end

Instance Method Details

#deleteObject



40
41
42
43
44
45
46
# File 'backend/app/model/agent_software.rb', line 40

def delete
  if self.system_role == self.class.system_role
    raise AccessDeniedException.new("Can't delete the system's own agent")
  end

  super
end