Class: AuditJob
- Inherits:
-
Object
- Object
- AuditJob
- Defined in:
- lib/sufia/jobs/audit_job.rb
Overview
Copyright © 2012 The Pennsylvania State University
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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.
-
#generic_file_id ⇒ Object
Returns the value of attribute generic_file_id.
-
#version_id ⇒ Object
Returns the value of attribute version_id.
Instance Method Summary collapse
-
#initialize(generic_file_id, datastream_id, version_id) ⇒ AuditJob
constructor
A new instance of AuditJob.
- #queue_name ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(generic_file_id, datastream_id, version_id) ⇒ AuditJob
Returns a new instance of AuditJob.
25 26 27 28 29 |
# File 'lib/sufia/jobs/audit_job.rb', line 25 def initialize(generic_file_id, datastream_id, version_id) self.generic_file_id = generic_file_id self.datastream_id = datastream_id self.version_id = version_id end |
Instance Attribute Details
#datastream_id ⇒ Object
Returns the value of attribute datastream_id.
23 24 25 |
# File 'lib/sufia/jobs/audit_job.rb', line 23 def datastream_id @datastream_id end |
#generic_file_id ⇒ Object
Returns the value of attribute generic_file_id.
23 24 25 |
# File 'lib/sufia/jobs/audit_job.rb', line 23 def generic_file_id @generic_file_id end |
#version_id ⇒ Object
Returns the value of attribute version_id.
23 24 25 |
# File 'lib/sufia/jobs/audit_job.rb', line 23 def version_id @version_id end |
Instance Method Details
#queue_name ⇒ Object
16 17 18 |
# File 'lib/sufia/jobs/audit_job.rb', line 16 def queue_name :audit end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sufia/jobs/audit_job.rb', line 31 def run generic_file = GenericFile.find(generic_file_id) #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 = GenericFile.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: #{generic_file_id} dsid: #{datastream_id}" end else logger.warn "No generic file for data stream audit!!!!! pid: #{generic_file_id} dsid: #{datastream_id}" end end |