Class: Event
Constant Summary
Constants included
from JSONModel
JSONModel::REFERENCE_KEY_REGEX
Class Method Summary
collapse
Instance Method Summary
collapse
included
included
Methods included from Agents
included
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
.for_archival_record_merge(target, victims) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'backend/app/model/event.rb', line 107
def self.for_archival_record_merge(target, victims)
user = User[:username => RequestContext.get(:current_username)]
merge_note = ""
victims.each do |victim|
victim_json = victim.class.to_jsonmodel(victim)
if victim_json['identifier']
identifier = Identifiers.format(Identifiers.parse(victim_json['identifier']))
else
identifier = victim_json['digital_object_id']
end
merge_note += (identifier +
" -- " +
victim_json['title'] +
"\n")
end
event = JSONModel(:event).from_hash(
:linked_agents => [{
"role" => "implementer",
"ref" => JSONModel(:agent_person).uri_for(user.agent_record_id)
}],
:event_type => 'component_transfer',
:outcome => 'pass',
:outcome_note => merge_note,
:timestamp => Time.now.utc.iso8601,
:linked_records => [{:ref => target.uri, :role => 'outcome'}]
)
Event.create_from_json(event, :system_generated => true)
end
|
.for_cataloging(agent_uri, record_uri) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'backend/app/model/event.rb', line 91
def self.for_cataloging(agent_uri, record_uri)
event = JSONModel(:event).from_hash(
:linked_agents => [{:ref => agent_uri, :role => 'implementer'}],
:event_type => 'cataloged',
:timestamp => Time.now.utc.iso8601,
:linked_records => [{:ref => record_uri, :role => 'outcome'}]
)
RequestContext.in_global_repo do
Event.create_from_json(event, :system_generated => true)
end
end
|
.for_component_transfer(archival_object_uri, source_resource_uri, target_resource_uri) ⇒ Object
Some canned creators for system generated events
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'backend/app/model/event.rb', line 68
def self.for_component_transfer(archival_object_uri, source_resource_uri, target_resource_uri)
user = User[:username => RequestContext.get(:current_username)]
event = JSONModel(:event).from_hash({
"event_type" => "component_transfer",
"timestamp" => Time.now.utc.iso8601,
"linked_records" => [
{"role" => "source", "ref" => source_resource_uri},
{"role" => "outcome", "ref" => target_resource_uri},
{"role" => "transfer", "ref" => archival_object_uri},
],
"linked_agents" => [
{"role" => "implementer", "ref" => JSONModel(:agent_person).uri_for(user.agent_record_id)}
]
})
self.create_from_json(event, :system_generated => true)
end
|
.for_repository_transfer(old_repo, new_repo, record) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'backend/app/model/event.rb', line 142
def self.for_repository_transfer(old_repo, new_repo, record)
event = {
:linked_agents => [
{
"role" => "transmitter",
"ref" => JSONModel(:agent_corporate_entity).uri_for(old_repo.agent_representation_id)
},
{
"role" => "recipient",
"ref" => JSONModel(:agent_corporate_entity).uri_for(new_repo.agent_representation_id)
}
].reject {|l| l['ref'].nil?},
:linked_records => [
{
"role" => "transfer",
"ref" => record.uri
}
],
:event_type => 'custody_transfer',
:timestamp => Time.now.utc.iso8601,
}
Event.create_from_json(JSONModel(:event).from_hash(event), :system_generated => true)
end
|
.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'backend/app/model/event.rb', line 51
def self.sequel_to_jsonmodel(objs, opts = {})
jsons = super
jsons.each do |json|
if json['timestamp']
json['timestamp'] = json['timestamp'].iso8601
end
end
jsons
end
|
Instance Method Details
#has_active_linked_records? ⇒ Boolean
40
41
42
43
44
45
46
47
48
|
# File 'backend/app/model/event.rb', line 40
def has_active_linked_records?
self.related_records(:event_link).each do |linked_record|
if linked_record.values.has_key?(:suppressed) && linked_record[:suppressed] == 0
return true
end
end
return false
end
|