Class: AuditRecord

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
models/auditrecord.rb

Overview

Records information about an action that was taken and should be recorded Tracks action type, user who took the action, and up to 2 linked objects to the action. Can also store a blob and a detail string.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from DataMapper::Resource

#make_dirty

Class Method Details

+ (Integer) actor(repository = nil)

Returns ID of User who caused the event

Returns:

  • (Integer)

    ID of User who caused the event



20
# File 'models/auditrecord.rb', line 20

property :actor,			Integer

+ (String) blob(repository = nil)

Returns JSON Blob containing additional even information

Returns:

  • (String)

    JSON Blob containing additional even information



22
# File 'models/auditrecord.rb', line 22

property :blob,				Text, :length => 1024*8

+ (DateTime) created_at(repository = nil)

Returns Date/Time AuditRecord created (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord created (DM Handled)



16
# File 'models/auditrecord.rb', line 16

property :created_at, 		DateTime

+ (String) details_txt(repository = nil)

Returns Text of additional event details

Returns:

  • (String)

    Text of additional event details



23
# File 'models/auditrecord.rb', line 23

property :details_txt,		Text, :length => 1024*8

+ (DateTime) event_at(repository = nil)

Returns Date/Time the event triggering audit occurred

Returns:

  • (DateTime)

    Date/Time the event triggering audit occurred



19
# File 'models/auditrecord.rb', line 19

property :event_at,			DateTime

+ (EVENT_TYPE) event_type(repository = nil)

Returns Type of AuditRecord

Returns:



18
# File 'models/auditrecord.rb', line 18

property :event_type,		Integer

+ (Boolean) flagged(repository = nil)

Returns True if flagged as issue/for further review

Returns:

  • (Boolean)

    True if flagged as issue/for further review



33
# File 'models/auditrecord.rb', line 33

property :flagged,			Boolean, :default => false

+ (Object) getAppAudits(aid)



97
98
99
100
101
102
103
104
105
106
# File 'models/auditrecord.rb', line 97

def self.getAppAudits(aid)
	appAudits = all(:target_a_type => LINK_TYPE::APPLICATION, :target_a => aid.to_s)
	tests = Application.get(aid).tests
	testAudits = Array.new
	tests.each do |t|
		testAudits << {:tid => t.id, :testName => t.name, :audits => all(:target_a_type => LINK_TYPE::TEST, target_a => t.id.to_s)}
	end

	return {:app => appAudits, :tests => testAudits}
end

+ (Integer) id(repository = nil)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



14
# File 'models/auditrecord.rb', line 14

property :id,				Serial

+ (Object) review_notes(repository = nil)

Deprecated.

@return [String] Text body of review notes



34
# File 'models/auditrecord.rb', line 34

property :review_notes,		Text

+ (Boolean) reviewed(repository = nil)

Returns True if AuditRecord has been reviewed and marked as ok

Returns:

  • (Boolean)

    True if AuditRecord has been reviewed and marked as ok



30
# File 'models/auditrecord.rb', line 30

property :reviewed,			Boolean, :default => false

+ (DateTime) reviewed_at(repository = nil)

Returns Date/Time AuditRecord was reviewed

Returns:

  • (DateTime)

    Date/Time AuditRecord was reviewed



31
# File 'models/auditrecord.rb', line 31

property :reviewed_at,		DateTime

+ (Integer) reviewed_by(repository = nil)

Returns ID of User who reviewed AuditRecord

Returns:

  • (Integer)

    ID of User who reviewed AuditRecord



32
# File 'models/auditrecord.rb', line 32

property :reviewed_by,		Integer

+ (String) target_a(repository = nil)

Returns ID of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of first linked object relating to this AuditRecord. See AuditRecord Overview.



26
# File 'models/auditrecord.rb', line 26

property :target_a,			String

+ (LINK_TYPE) target_a_type(repository = nil)

Returns Type of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of first linked object relating to this AuditRecord. See AuditRecord Overview.



25
# File 'models/auditrecord.rb', line 25

property :target_a_type,	Integer

+ (String) target_b(repository = nil)

Returns ID of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of second linked object relating to this AuditRecord. See AuditRecord Overview.



28
# File 'models/auditrecord.rb', line 28

property :target_b,			String

+ (LINK_TYPE) target_b_type(repository = nil)

Returns Type of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of second linked object relating to this AuditRecord. See AuditRecord Overview.



27
# File 'models/auditrecord.rb', line 27

property :target_b_type,	Integer

+ (DateTime) updated_at(repository = nil)

Returns Date/Time AuditRecord last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord last updated (DM Handled)



17
# File 'models/auditrecord.rb', line 17

property :updated_at, 		DateTime

Instance Method Details

- (Integer) actor

Returns ID of User who caused the event

Returns:

  • (Integer)

    ID of User who caused the event



20
# File 'models/auditrecord.rb', line 20

property :actor,			Integer

- (Integer) actor=(value)

Returns ID of User who caused the event

Returns:

  • (Integer)

    ID of User who caused the event



20
# File 'models/auditrecord.rb', line 20

property :actor,			Integer

- (Object) actorName



44
45
46
47
48
49
50
51
# File 'models/auditrecord.rb', line 44

def actorName
	u = User.get(self.actor)
	if(u.nil?)
		return "UNK"
	else
		return u.name
	end
end

- (String) auditString

Generate a string representing the action this AuditRecord recorded. Strings should not include the actor, just the action done.

Returns:

  • (String)

    the String representing that event type



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'models/auditrecord.rb', line 57

def auditString
	if(!self.blob.nil?)
		blobData = JSON.parse(self.blob, {:symbolize_names => true})
	end

	return case self.event_type
	when EVENT_TYPE::PROV_PASS_REQUEST then "Provisional Pass requested"
	when EVENT_TYPE::PROV_PASS_APPROVE then "Provisional Pass approved"
	when EVENT_TYPE::PROV_PASS_DENY then "Provisional Pass denied"
	when EVENT_TYPE::PROV_PASS_REQCANCEL then "Provisional Pass request cancelled"
	when EVENT_TYPE::ADMIN_OVERRIDE_PRIVATE_APP then "Private app view restrictions overridden"
	when EVENT_TYPE::ADMIN_OVERRIDE_PRIVATE_TEST then "Private test view restrictions overridden"
	when EVENT_TYPE::APP_CREATE then "App created"
	when EVENT_TYPE::APP_RENAME then "App renamed <b>#{Rack::Utils::escape_html(blobData[:fromName])}</b> to <b>#{Rack::Utils::escape_html(blobData[:toName])}</b>"
	when EVENT_TYPE::APP_LINK then "App linked to EID #{Rack::Utils::escape_html(self.target_b)} (#{Rack::Utils::escape_html(self.details_txt)})"
	when EVENT_TYPE::APP_UNLINK then "App unlinked from EID #{Rack::Utils::escape_html(self.target_b)}"
	when EVENT_TYPE::APP_MADE_GLOBAL then "App marked <b>global</b>"
	when EVENT_TYPE::APP_MADE_NOTGLOBAL then "App marked <b>not global</b>"
	when EVENT_TYPE::APP_MADE_PRIVATE then "App marked <b>private</b>"
	when EVENT_TYPE::APP_MADE_NOTPRIVATE then "App marked <b>not private</b>"
	when EVENT_TYPE::APP_RTCHANGE then "Changed app RecordType <b>#{Rack::Utils::escape_html(blobData[:fromName])}</b> to <b>#{Rack::Utils::escape_html(blobData[:toName])}</b>"
	when EVENT_TYPE::APP_GEO_SET then "Set app geo to <b>#{geoToString(blobData[:geoId])}</b>"
	when EVENT_TYPE::APP_DELETE then "App deleted"
	when EVENT_TYPE::APP_FLAG_ADD then "App flagged with <b>#{Rack::Utils::escape_html(blobData[:flagName])}</b>"
	when EVENT_TYPE::APP_FLAG_REM then "App flag <b>#{Rack::Utils::escape_html(blobData[:flagName])}</b> removed"
	when EVENT_TYPE::APP_OWNER_ASSIGN then "App owner set to <b>#{Rack::Utils::escape_html(blobData[:userName])}</b>"
	when EVENT_TYPE::TEST_CREATE then "Test created"
	when EVENT_TYPE::TEST_RENAME then "Test renamed <b>#{Rack::Utils::escape_html(blobData[:fromName])}</b> to <b>#{Rack::Utils::escape_html(blobData[:toName])}</b>"
	when EVENT_TYPE::TEST_REVIEWER_UNASSIGNED then "Reviewer (<b>#{Rack::Utils::escape_html(blobData[:userName])}</b>) unassigned"
	when EVENT_TYPE::TEST_REVIEWER_ASSIGNED then "Reviewer (<b>#{Rack::Utils::escape_html(blobData[:userName])}</b>) assigned"
	when EVENT_TYPE::TEST_INPROG then "Test in progress"
	when EVENT_TYPE::TEST_PASS_REQ_APPROVAL then "Test passed pending approval"
	when EVENT_TYPE::TEST_PASS then "<b>Test passed</b> and closed"
	when EVENT_TYPE::TEST_FAIL_REQ_APPROVAL then "Test failed pending approval"
	when EVENT_TYPE::TEST_FAIL then "<b>Test failed</b> and closed"
	when EVENT_TYPE::TEST_DELETE then "Test deleted"
	else "UNK"
	end
end

- (String) blob

Returns JSON Blob containing additional even information

Returns:

  • (String)

    JSON Blob containing additional even information



22
# File 'models/auditrecord.rb', line 22

property :blob,				Text, :length => 1024*8

- (String) blob=(value)

Returns JSON Blob containing additional even information

Returns:

  • (String)

    JSON Blob containing additional even information



22
# File 'models/auditrecord.rb', line 22

property :blob,				Text, :length => 1024*8

- (Object) blobObj



36
37
38
39
40
41
42
# File 'models/auditrecord.rb', line 36

def blobObj
	if(!self.blob.nil?)
		return JSON.parse(self.blob, {:symbolize_names => true})
	else
		return nil
	end
end

- (DateTime) created_at

Returns Date/Time AuditRecord created (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord created (DM Handled)



16
# File 'models/auditrecord.rb', line 16

property :created_at, 		DateTime

- (DateTime) created_at=(value)

Returns Date/Time AuditRecord created (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord created (DM Handled)



16
# File 'models/auditrecord.rb', line 16

property :created_at, 		DateTime

- (String) details_txt

Returns Text of additional event details

Returns:

  • (String)

    Text of additional event details



23
# File 'models/auditrecord.rb', line 23

property :details_txt,		Text, :length => 1024*8

- (String) details_txt=(value)

Returns Text of additional event details

Returns:

  • (String)

    Text of additional event details



23
# File 'models/auditrecord.rb', line 23

property :details_txt,		Text, :length => 1024*8

- (DateTime) event_at

Returns Date/Time the event triggering audit occurred

Returns:

  • (DateTime)

    Date/Time the event triggering audit occurred



19
# File 'models/auditrecord.rb', line 19

property :event_at,			DateTime

- (DateTime) event_at=(value)

Returns Date/Time the event triggering audit occurred

Returns:

  • (DateTime)

    Date/Time the event triggering audit occurred



19
# File 'models/auditrecord.rb', line 19

property :event_at,			DateTime

- (EVENT_TYPE) event_type

Returns Type of AuditRecord

Returns:



18
# File 'models/auditrecord.rb', line 18

property :event_type,		Integer

- (EVENT_TYPE) event_type=(value)

Returns Type of AuditRecord

Returns:



18
# File 'models/auditrecord.rb', line 18

property :event_type,		Integer

- (Boolean) flagged

Returns True if flagged as issue/for further review

Returns:

  • (Boolean)

    True if flagged as issue/for further review



33
# File 'models/auditrecord.rb', line 33

property :flagged,			Boolean, :default => false

- (Boolean) flagged=(value)

Returns True if flagged as issue/for further review

Returns:

  • (Boolean)

    True if flagged as issue/for further review



33
# File 'models/auditrecord.rb', line 33

property :flagged,			Boolean, :default => false

- (Integer) id

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



14
# File 'models/auditrecord.rb', line 14

property :id,				Serial

- (Integer) id=(value)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



14
# File 'models/auditrecord.rb', line 14

property :id,				Serial

- (Object) review_notes

Deprecated.

@return [String] Text body of review notes



34
# File 'models/auditrecord.rb', line 34

property :review_notes,		Text

- (Object) review_notes=(value)

Deprecated.

@return [String] Text body of review notes



34
# File 'models/auditrecord.rb', line 34

property :review_notes,		Text

- (Boolean) reviewed

Returns True if AuditRecord has been reviewed and marked as ok

Returns:

  • (Boolean)

    True if AuditRecord has been reviewed and marked as ok



30
# File 'models/auditrecord.rb', line 30

property :reviewed,			Boolean, :default => false

- (Boolean) reviewed=(value)

Returns True if AuditRecord has been reviewed and marked as ok

Returns:

  • (Boolean)

    True if AuditRecord has been reviewed and marked as ok



30
# File 'models/auditrecord.rb', line 30

property :reviewed,			Boolean, :default => false

- (DateTime) reviewed_at

Returns Date/Time AuditRecord was reviewed

Returns:

  • (DateTime)

    Date/Time AuditRecord was reviewed



31
# File 'models/auditrecord.rb', line 31

property :reviewed_at,		DateTime

- (DateTime) reviewed_at=(value)

Returns Date/Time AuditRecord was reviewed

Returns:

  • (DateTime)

    Date/Time AuditRecord was reviewed



31
# File 'models/auditrecord.rb', line 31

property :reviewed_at,		DateTime

- (Integer) reviewed_by

Returns ID of User who reviewed AuditRecord

Returns:

  • (Integer)

    ID of User who reviewed AuditRecord



32
# File 'models/auditrecord.rb', line 32

property :reviewed_by,		Integer

- (Integer) reviewed_by=(value)

Returns ID of User who reviewed AuditRecord

Returns:

  • (Integer)

    ID of User who reviewed AuditRecord



32
# File 'models/auditrecord.rb', line 32

property :reviewed_by,		Integer

- (String) target_a

Returns ID of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of first linked object relating to this AuditRecord. See AuditRecord Overview.



26
# File 'models/auditrecord.rb', line 26

property :target_a,			String

- (String) target_a=(value)

Returns ID of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of first linked object relating to this AuditRecord. See AuditRecord Overview.



26
# File 'models/auditrecord.rb', line 26

property :target_a,			String

- (LINK_TYPE) target_a_type

Returns Type of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of first linked object relating to this AuditRecord. See AuditRecord Overview.



25
# File 'models/auditrecord.rb', line 25

property :target_a_type,	Integer

- (LINK_TYPE) target_a_type=(value)

Returns Type of first linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of first linked object relating to this AuditRecord. See AuditRecord Overview.



25
# File 'models/auditrecord.rb', line 25

property :target_a_type,	Integer

- (String) target_b

Returns ID of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of second linked object relating to this AuditRecord. See AuditRecord Overview.



28
# File 'models/auditrecord.rb', line 28

property :target_b,			String

- (String) target_b=(value)

Returns ID of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (String)

    ID of second linked object relating to this AuditRecord. See AuditRecord Overview.



28
# File 'models/auditrecord.rb', line 28

property :target_b,			String

- (LINK_TYPE) target_b_type

Returns Type of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of second linked object relating to this AuditRecord. See AuditRecord Overview.



27
# File 'models/auditrecord.rb', line 27

property :target_b_type,	Integer

- (LINK_TYPE) target_b_type=(value)

Returns Type of second linked object relating to this AuditRecord. See AuditRecord Overview.

Returns:

  • (LINK_TYPE)

    Type of second linked object relating to this AuditRecord. See AuditRecord Overview.



27
# File 'models/auditrecord.rb', line 27

property :target_b_type,	Integer

- (DateTime) updated_at

Returns Date/Time AuditRecord last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord last updated (DM Handled)



17
# File 'models/auditrecord.rb', line 17

property :updated_at, 		DateTime

- (DateTime) updated_at=(value)

Returns Date/Time AuditRecord last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time AuditRecord last updated (DM Handled)



17
# File 'models/auditrecord.rb', line 17

property :updated_at, 		DateTime