Class: AgentSoftware
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- AgentSoftware
- Includes:
- ASModel, AgentManager::Mixin, AutoGenerator, ExternalDocuments, Notes, Publishable, RecordableCataloging
- Defined in:
- backend/app/model/agent_software.rb
Constant Summary
Constants included from JSONModel
JSONModel::REFERENCE_KEY_REGEX
Class Method Summary collapse
-
.archivesspace_record ⇒ Object
-
.ensure_correctly_versioned_archivesspace_record ⇒ Object
Create the agent record that represents the system itself, or update it if it exists but the build version has changed.
-
.system_role ⇒ Object
Instance Method Summary collapse
Methods included from AutoGenerator
Methods included from Publishable
Methods included from Notes
included, #persistent_id_context, #update_from_json
Methods included from RecordableCataloging
Methods included from AgentManager::Mixin
#before_save, included, #linked_agent_roles, #update_from_json, #validate
Methods included from ExternalDocuments
Methods included from ASModel
all_models, included, update_publish_flag, update_suppressed_flag
Methods included from JSONModel
JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository
Class Method Details
.archivesspace_record ⇒ Object
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_record ⇒ Object
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_role ⇒ Object
35 36 37 |
# File 'backend/app/model/agent_software.rb', line 35 def self.system_role "archivesspace_agent" end |
Instance Method Details
#delete ⇒ Object
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 |