Class: AuditJob
- Inherits:
-
ActiveFedoraPidBasedJob
- Object
- ActiveFedoraPidBasedJob
- AuditJob
- Defined in:
- lib/sufia/models/jobs/audit_job.rb
Constant Summary collapse
- PASS =
'Passing Audit Run'
- FAIL =
'Failing Audit Run'
Instance Attribute Summary collapse
-
#datastream_id ⇒ Object
Returns the value of attribute datastream_id.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#version_id ⇒ Object
Returns the value of attribute version_id.
Instance Method Summary collapse
-
#initialize(pid, datastream_id, version_id) ⇒ AuditJob
constructor
A new instance of AuditJob.
- #queue_name ⇒ Object
- #run ⇒ Object
Methods inherited from ActiveFedoraPidBasedJob
Constructor Details
#initialize(pid, datastream_id, version_id) ⇒ AuditJob
Returns a new instance of AuditJob.
11 12 13 14 15 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 11 def initialize(pid, datastream_id, version_id) super(pid) self.datastream_id = datastream_id self.version_id = version_id end |
Instance Attribute Details
#datastream_id ⇒ Object
Returns the value of attribute datastream_id.
9 10 11 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 9 def datastream_id @datastream_id end |
#pid ⇒ Object
Returns the value of attribute pid.
9 10 11 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 9 def pid @pid end |
#version_id ⇒ Object
Returns the value of attribute version_id.
9 10 11 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 9 def version_id @version_id end |
Instance Method Details
#queue_name ⇒ Object
2 3 4 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 2 def queue_name :audit end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sufia/models/jobs/audit_job.rb', line 17 def run #logger.info "GF is #{generic_file.pid}" if generic_file datastream = generic_file.datastreams[datastream_id] #logger.info "DS is #{datastream.inspect}" if datastream #logger.info "Datastream for audit = #{datastream.inspect}" version = datastream.versions.select { |v| v.versionID == version_id}.first log = run_audit(version) # look up the user for sending the message to login = generic_file.depositor #logger.info "User login is #{login}"` #logger.info "All users = #{User.all}" if login user = User.find_by_user_key(login) logger.warn "User '#{login}' not found" unless user #logger.info "ZZZ user = #{user.inspect}" job_user = User.audituser() #send the user a message about the failing audit unless (log.pass == 1) = "The audit run at #{log.created_at} for #{log.pid}:#{log.dsid}:#{log.version} was #{log.pass == 1 ? 'passing' : 'failing'}." subject = (log.pass == 1 ? PASS : FAIL) job_user.(user, , subject) end end else logger.warn "No datastream for audit!!!!! pid: #{pid} dsid: #{datastream_id}" end else logger.warn "No generic file for data stream audit!!!!! pid: #{pid} dsid: #{datastream_id}" end end |