Hello ruote-list, I'm trying to create an audit trail for each process launched.
Without going into details, I have to provide a complete map of the
process (i.e. all the possible paths), the actual path taken (time and
order) and the value added/modified/deleted from the workitem by each
participant.
My idea so far is to use a msg_launch observer, add the interpreted
structure of the process (msg['tree']) within the storage itself and
secondly, compare the applied_workitem with the current workitem and
save any participant's modification back in this structure using a
msg_receive observer (i.e. identifing the actual path taken by the
process and any change). Finally, the structure would be stored in it's
real/final database using a msg_terminated observer.
The only problem I face so far is putting my hand on the
applied_workitem from within the receiver observer. I'm pretty sure it's
easy but I fail miserably...
I tried the Receiver Mixin, Ruote class directly (e.g.
Ruote::Exp::FlowExpression::fetch(@context, msg['fei'])) and poking
around the storage but just can't put my hands on it. It seems like
whenever my msg_receive observer capture the workitem, the
applied_workitem is save in the previous fei expression (e.g. 0_0_0 ->
0_0 or 0_0_1 -> 0_0_0).
Here's my code so far.
````
def on_msg_launch(msg)
doc = {
'type' => 'audit_trail',
'_id' => msg['wfid'],
'trail' => msg['tree']
}
@context.storage.put(doc)
end
def on_msg_receive(msg)
return unless accept?(msg)
doc = @context.storage.get('audit_trail', msg['wfid'])
# workitem = msg['workitem']
# applied_workitem = ??applied_workitem??
diff = recursive_diff(applied_workitem, workitem)
# put the diff at the proper location within the trail struct (i.e.
based on expid)
doc = {
'type' => 'audit_trail',
'_id' => msg['wfid'],
'trail' => doc['tree']
}
@context.storage.put(doc)
end
def on_msg_terminated(msg)
doc = @context.storage.get('audit_trail', msg['wfid'])
if doc
trail = {
'id' => msg['wfid'],
'name' => msg['wf_name'],
'version' => msg['wf_revision'],
'at' => msg['wf_launched_at'],
'trail' => doc['trail']
}
#db.save(trail)
@context.storage.delete(doc)
end
end
````
Any idea?
Also, any advice? Is there a better way of doing this is or does it
sounds good? Any help would be appreciated.
p.s. I hope I'll be able to extract this to a gem.
--
Danny Fullerton
Founder
Mantor Organization
signature.asc
Description: OpenPGP digital signature
